Deleted Added
full compact
headers-sh.in (220749) headers-sh.in (241818)
1#! /bin/sh
1#! /bin/sh
2# $Id: headers-sh.in,v 1.9 2011/01/06 09:38:25 tom Exp $
2# $Id: headers-sh.in,v 1.11 2011/10/18 23:49:13 tom Exp $
3##############################################################################
4# Copyright (c) 2004-2007,2011 Thomas E. Dickey #
5# #
6# Permission is hereby granted, free of charge, to any person obtaining a #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation #
9# the rights to use, copy, modify, merge, publish, distribute, distribute #
10# with modifications, sublicense, and/or sell copies of the Software, and to #

--- 29 unchanged lines hidden (view full) ---

40# $3 is the source directory
41# $4 is the file to install, editing source/target/etc.
42
43PACKAGE=@PACKAGE@
44PKGNAME=@PACKAGE_PREFIX@
45CONFIGH=@PACKAGE_CONFIG@
46SUB_INC=@SUB_INC@
47
3##############################################################################
4# Copyright (c) 2004-2007,2011 Thomas E. Dickey #
5# #
6# Permission is hereby granted, free of charge, to any person obtaining a #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation #
9# the rights to use, copy, modify, merge, publish, distribute, distribute #
10# with modifications, sublicense, and/or sell copies of the Software, and to #

--- 29 unchanged lines hidden (view full) ---

40# $3 is the source directory
41# $4 is the file to install, editing source/target/etc.
42
43PACKAGE=@PACKAGE@
44PKGNAME=@PACKAGE_PREFIX@
45CONFIGH=@PACKAGE_CONFIG@
46SUB_INC=@SUB_INC@
47
48: ${TMPDIR:=/tmp}
49
48TMPSED=headers.sed
49
50DIGIT=0123456789
51alpha=abcdefghijklmnopqrstuvwxyz
52ALPHA=ABCDEFGHIJKLMNOPQRSTUVWXYZ
53
54alnum=_${DIGIT}${alpha}
55ALNUM=_${DIGIT}${ALPHA}

--- 37 unchanged lines hidden (view full) ---

93 b done
94:next
95 x
96 s/^[^ ][^ ]* //
97 t split
98:done
99EOF
100 # pick up autoconf-style symbols used in the application's headers
50TMPSED=headers.sed
51
52DIGIT=0123456789
53alpha=abcdefghijklmnopqrstuvwxyz
54ALPHA=ABCDEFGHIJKLMNOPQRSTUVWXYZ
55
56alnum=_${DIGIT}${alpha}
57ALNUM=_${DIGIT}${ALPHA}

--- 37 unchanged lines hidden (view full) ---

95 b done
96:next
97 x
98 s/^[^ ][^ ]* //
99 t split
100:done
101EOF
102 # pick up autoconf-style symbols used in the application's headers
101 for i in $REF/*.h
103 for name in $REF/*.h
102 do
104 do
103 sed -e 's/^[ ][ ]*#[ ][ ]*/#/' $i \
105 sed -e 's/^[ ][ ]*#[ ][ ]*/#/' $name \
104 | egrep '^#(if|ifdef|ifndef|elif)' \
105 | sed -f headers.tmp \
106 | sort -u \
107 | egrep '^(HAVE_|NEED_|NO_|ENABLE_|DISABLE_)' \
108 | sed -e 's%^\(.*\)%s/\\<\1\\>/'${PKGNAME}'_\1/g%' >>$TMPSED
109 done
110 rm -f headers.tmp
111
112 # pick up autoconf-defined symbols in the config.h file
113 for name in `
114 egrep '^#define[ ][ ]*['$ALNUM']' $REF/$CONFIGH \
115 | sed \
116 -e 's/^#define[ ][ ]*//' \
117 -e 's/[ ].*//' \
118 | egrep -v "^${PACKAGE}_" \
106 | egrep '^#(if|ifdef|ifndef|elif)' \
107 | sed -f headers.tmp \
108 | sort -u \
109 | egrep '^(HAVE_|NEED_|NO_|ENABLE_|DISABLE_)' \
110 | sed -e 's%^\(.*\)%s/\\<\1\\>/'${PKGNAME}'_\1/g%' >>$TMPSED
111 done
112 rm -f headers.tmp
113
114 # pick up autoconf-defined symbols in the config.h file
115 for name in `
116 egrep '^#define[ ][ ]*['$ALNUM']' $REF/$CONFIGH \
117 | sed \
118 -e 's/^#define[ ][ ]*//' \
119 -e 's/[ ].*//' \
120 | egrep -v "^${PACKAGE}_" \
119 | sort -u \
120 | egrep -v "^${PKGNAME}_"`
121 | sort -u`
121 do
122 echo "s/\\<$name\\>/${PKGNAME}_$name/g" >>$TMPSED
123 done
124
125 if test "$SUB_INC" = yes
126 then
127 echo "s,#include <${pkgname}_,#include <${PACKAGE}/${pkgname}_," >>$TMPSED
128 fi
129
122 do
123 echo "s/\\<$name\\>/${PKGNAME}_$name/g" >>$TMPSED
124 done
125
126 if test "$SUB_INC" = yes
127 then
128 echo "s,#include <${pkgname}_,#include <${PACKAGE}/${pkgname}_," >>$TMPSED
129 fi
130
131 echo '/_FILE_OFFSET_BITS/d' >>$TMPSED
132
130 # reduce the count if possible, since some old sed's limit is 100 lines
131 sort -u $TMPSED >headers.tmp
132 mv headers.tmp $TMPSED
133else
134 PRG=""
135 while test $# != 3
136 do
137 PRG="$PRG $1"; shift
138 done
139
140 DST=$1
141 REF=$2
142 SRC=$3
143
144 SHOW=`basename $SRC`
133 # reduce the count if possible, since some old sed's limit is 100 lines
134 sort -u $TMPSED >headers.tmp
135 mv headers.tmp $TMPSED
136else
137 PRG=""
138 while test $# != 3
139 do
140 PRG="$PRG $1"; shift
141 done
142
143 DST=$1
144 REF=$2
145 SRC=$3
146
147 SHOW=`basename $SRC`
145 TMPSRC=${TMPDIR-/tmp}/${SHOW}$$
148 TMPSRC=$TMPDIR/${SHOW}-text$$
149 TMPEDT=$TMPDIR/${SHOW}-edit$$
150 TMPTMP=$TMPDIR/${SHOW}-temp$$
146
147 echo " ... $SHOW"
148 test -f $REF/$SRC && SRC="$REF/$SRC"
149
150 rm -f $TMPSRC
151
152 echo " ... $SHOW"
153 test -f $REF/$SRC && SRC="$REF/$SRC"
154
155 rm -f $TMPSRC
151 sed -f $TMPSED $SRC > $TMPSRC
156 cat $SRC >$TMPSRC
157
158 tmp1=1
159 while true
160 do
161 tmp2=`expr $tmp1 + 49`
162 if test $tmp1 = 1
163 then
164 sed "${tmp2}q" $TMPSED >$TMPEDT
165 else
166 sed "1,${tmp1}d; ${tmp2}q" $TMPSED >$TMPEDT
167 fi
168 test -s $TMPEDT || break
169 sed -f $TMPEDT $TMPSRC > $TMPTMP
170 mv $TMPTMP $TMPSRC
171 tmp1=$tmp2
172 done
173
152 NAME=`basename $SRC`
153
154 # Just in case someone gzip'd manpages, remove the conflicting copy.
155 test -f $DST/$NAME.gz && rm -f $DST/$NAME.gz
156
157 if test "$SUB_INC" = yes
158 then
159 case $NAME in #(vi

--- 7 unchanged lines hidden (view full) ---

167 ;;
168 *)
169 NAME=$PACKAGE.h
170 ;;
171 esac
172 fi
173
174 eval $PRG $TMPSRC $DST/$NAME
174 NAME=`basename $SRC`
175
176 # Just in case someone gzip'd manpages, remove the conflicting copy.
177 test -f $DST/$NAME.gz && rm -f $DST/$NAME.gz
178
179 if test "$SUB_INC" = yes
180 then
181 case $NAME in #(vi

--- 7 unchanged lines hidden (view full) ---

189 ;;
190 *)
191 NAME=$PACKAGE.h
192 ;;
193 esac
194 fi
195
196 eval $PRG $TMPSRC $DST/$NAME
175 rm -f $TMPSRC
197 rm -f $TMPEDT $TMPTMP $TMPSRC
176fi
177# vile:ts=4 sw=4
198fi
199# vile:ts=4 sw=4