Commit 76f8010e by Doug Evans

scan-types.sh: Fix program's name in error message.

* scan-types.sh: Fix program's name in error message.
Rename dummy.c to avoid collisions in parallel makes.

From-SVN: r7062
parent db7f1e43
...@@ -13,7 +13,7 @@ SED=sed ...@@ -13,7 +13,7 @@ SED=sed
# It works by a dummy program through the C pre-processor, and then # It works by a dummy program through the C pre-processor, and then
# using sed to search for typedefs in the output. # using sed to search for typedefs in the output.
cat >dummy.c <<!EOF! cat >st-dummy.c <<!EOF!
#include <sys/types.h> #include <sys/types.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -30,21 +30,21 @@ typedef va_list XXXva_list; ...@@ -30,21 +30,21 @@ typedef va_list XXXva_list;
#endif #endif
!EOF! !EOF!
if ${CPP} dummy.c >TMP ; then true if ${CPP} st-dummy.c >TMP ; then true
else else
echo "gen-params: could not invoke ${CPP} on dummy.c" 1>&2 ; exit 1 echo "scan-types: could not invoke ${CPP} on st-dummy.c" 1>&2 ; exit 1
fi fi
tr ' ' ' ' <TMP >dummy.out tr ' ' ' ' <TMP >st-dummy.out
for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t size_t ssize_t time_t uid_t va_list int32_t uint_32_t ; do for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t size_t ssize_t time_t uid_t va_list int32_t uint_32_t ; do
IMPORTED=`eval 'echo $'"$TYPE"` IMPORTED=`eval 'echo $'"$TYPE"`
if [ -n "${IMPORTED}" ] ; then if [ -n "${IMPORTED}" ] ; then
eval "$TYPE='$IMPORTED" eval "$TYPE='$IMPORTED"
else else
# Search dummy.out for a typedef for $TYPE, and write it out # Search st-dummy.out for a typedef for $TYPE, and write it out
# to TMP in #define syntax. # to TMP in #define syntax.
rm -f TMP rm -f TMP
${SED} -n -e "s|.*typedef *\(.*\) X*$TYPE *;.*|\1|w TMP" <dummy.out>/dev/null ${SED} -n -e "s|.*typedef *\(.*\) X*$TYPE *;.*|\1|w TMP" <st-dummy.out>/dev/null
# Now select the first definition. # Now select the first definition.
if [ -s TMP ]; then if [ -s TMP ]; then
# VALUE is now the typedef'd definition of $TYPE. # VALUE is now the typedef'd definition of $TYPE.
...@@ -54,7 +54,7 @@ for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t size_t s ...@@ -54,7 +54,7 @@ for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t size_t s
if echo $VALUE | grep " " >/dev/null ; then true if echo $VALUE | grep " " >/dev/null ; then true
else else
rm -f TMP rm -f TMP
${SED} -n -e "s|.*typedef[ ][ ]*\(.*[^a-zA-Z0-9_]\)${VALUE}[ ]*;.*|\1|w TMP" <dummy.out>/dev/null ${SED} -n -e "s|.*typedef[ ][ ]*\(.*[^a-zA-Z0-9_]\)${VALUE}[ ]*;.*|\1|w TMP" <st-dummy.out>/dev/null
if [ -s TMP ]; then if [ -s TMP ]; then
eval "VALUE='`${SED} -e '2,$d' -e 's|[ ]*$||' <TMP`'" eval "VALUE='`${SED} -e '2,$d' -e 's|[ ]*$||' <TMP`'"
fi fi
...@@ -100,15 +100,15 @@ else ...@@ -100,15 +100,15 @@ else
else else
# check $tmp doesn't conflict with <unistd.h> # check $tmp doesn't conflict with <unistd.h>
echo "#include <unistd.h> echo "#include <unistd.h>
extern $tmp read();" >dummy.c extern $tmp read();" >st-dummy.c
${CC} -c dummy.c >/dev/null 2>&1 || tmp=int ${CC} -c st-dummy.c >/dev/null 2>&1 || tmp=int
fi fi
echo "#define ${macro_prefix}ssize_t $tmp /* default */" echo "#define ${macro_prefix}ssize_t $tmp /* default */"
fi fi
# va_list can cause problems (e.g. some systems have va_list as a struct). # va_list can cause problems (e.g. some systems have va_list as a struct).
# Check to see if ${va_list-char*} really is compatible with stdarg.h. # Check to see if ${va_list-char*} really is compatible with stdarg.h.
cat >dummy.c <<!EOF! cat >st-dummy.c <<!EOF!
#define X_va_list ${va_list-char* /* default */} #define X_va_list ${va_list-char* /* default */}
extern long foo(X_va_list ap); /* Check that X_va_list compiles on its own */ extern long foo(X_va_list ap); /* Check that X_va_list compiles on its own */
#include <stdarg.h> #include <stdarg.h>
...@@ -116,7 +116,7 @@ long foo(X_va_list ap) { return va_arg(ap, long); } ...@@ -116,7 +116,7 @@ long foo(X_va_list ap) { return va_arg(ap, long); }
long bar(int i, ...) long bar(int i, ...)
{ va_list ap; long j; va_start(ap, i); j = foo(ap); va_end(ap); return j; } { va_list ap; long j; va_start(ap, i); j = foo(ap); va_end(ap); return j; }
!EOF! !EOF!
if ${CC} -c dummy.c >/dev/null 2>&1 ; then if ${CC} -c st-dummy.c >/dev/null 2>&1 ; then
# Ok: We have something that works. # Ok: We have something that works.
echo "#define ${macro_prefix}va_list ${va_list-char* /* default */}" echo "#define ${macro_prefix}va_list ${va_list-char* /* default */}"
else else
...@@ -136,4 +136,4 @@ echo "#define initscr32 initscr" ...@@ -136,4 +136,4 @@ echo "#define initscr32 initscr"
echo "#define w32addch waddch" echo "#define w32addch waddch"
echo "#define w32insch winsch" echo "#define w32insch winsch"
rm -f dummy.c dummy.o TMP dummy.out rm -f st-dummy.c st-dummy.o TMP st-dummy.out
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment