Deleted Added
sdiff udiff text old ( 220749 ) new ( 241818 )
full compact
1#! /bin/sh
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
48: ${TMPDIR:=/tmp}
49
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
103 for name in $REF/*.h
104 do
105 sed -e 's/^[ ][ ]*#[ ][ ]*/#/' $name \
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}_" \
121 | sort -u`
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
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`
148 TMPSRC=$TMPDIR/${SHOW}-text$$
149 TMPEDT=$TMPDIR/${SHOW}-edit$$
150 TMPTMP=$TMPDIR/${SHOW}-temp$$
151
152 echo " ... $SHOW"
153 test -f $REF/$SRC && SRC="$REF/$SRC"
154
155 rm -f $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
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
197 rm -f $TMPEDT $TMPTMP $TMPSRC
198fi
199# vile:ts=4 sw=4