From: Dan Faigin, Doug Landauer Date: Thu, 21 Jan 1988 09:21:04 +0000 (+0000) Subject: perl 1.0 patch 1: Portability bugs and one possible SIGSEGV X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=36ce8bec6e5bbc05c8d60ee17f105fc8b751cada;p=p5sagit%2Fp5-mst-13.2.git perl 1.0 patch 1: Portability bugs and one possible SIGSEGV On some systems the Configure script and C compilations get warning messages that may scare some folks unnecessarily. Also, use of the "redo" command if debugging is compiled in overflows a stack on which the trace context is kept. --- diff --git a/Configure b/Configure index 3035f15..66d8a6e 100755 --- a/Configure +++ b/Configure @@ -8,7 +8,7 @@ # and edit it to reflect your system. Some packages may include samples # of config.h for certain machines, so you might look for one of those.) # -# $Header: Configure,v 1.0 87/12/18 15:05:56 root Exp $ +# $Header: Configure,v 1.0.1.1 88/01/21 21:21:47 root Exp $ # # Yes, you may rip this off to use in other distribution packages. # (Note: this Configure script was generated automatically. Rather than @@ -67,10 +67,13 @@ bin='' cc='' contains='' cpp='' +cppminus='' d_charsprf='' d_index='' +d_stdstdio='' d_strctcpy='' d_vfork='' +d_voidsig='' libc='' libnm='' mansrc='' @@ -90,6 +93,7 @@ spitshell='' shsharp='' sharpbang='' startsh='' +stdchar='' voidflags='' defvoidused='' CONFIG='' @@ -110,7 +114,7 @@ rmlist='kit[1-9]isdone kit[1-9][0-9]isdone' trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr" attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200" -attrlist="$attrlist ns32000 ns16000 iAPX286" +attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc" pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib" defvoidused=7 @@ -200,8 +204,8 @@ cat <testcpp.c +#define ABC abc +#define XYZ xyz +ABC.XYZ +EOT +echo 'Maybe "/lib/cpp" will work...' +/lib/cpp testcpp.out 2>&1 +if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Yup, it does." + cpp='/lib/cpp' + cppminus=''; +else + echo 'Nope, maybe "/lib/cpp -" will work...' + /lib/cpp - testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Yup, it does." + cpp='/lib/cpp' + cppminus='-'; + else + echo 'No such luck...maybe "cc -E" will work...' + cc -E testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "It works!" + cpp='cc -E' + cppminus=''; + else + echo 'Nixed again...maybe "cc -E -" will work...' + cc -E - testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Hooray, it works! I was beginning to wonder." + cpp='cc -E' + cppminus='-'; + else + echo 'Nope...maybe "cc -P" will work...' + cc -P testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Yup, that does." + cpp='cc -P' + cppminus=''; + else + echo 'Nope...maybe "cc -P -" will work...' + cc -P - testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Yup, that does." + cpp='cc -P' + cppminus='-'; + else + echo 'Hmm...perhaps you already told me...' + case "$cpp" in + '') ;; + *) $cpp $cppminus testcpp.out 2>&1;; + esac + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Hooray, you did! I was beginning to wonder." + else + echo 'Uh-uh. Time to get fancy...' + echo 'Trying (cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)' + cpp='(cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)' + cppminus=''; + $cpp testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "Eureka!." + else + dflt=blurfl + $echo $n "No dice. I can't find a C preprocessor. Name one: $c" + rp='Name a C preprocessor:' + . myread + cpp="$ans" + $cpp testcpp.out 2>&1 + if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then + echo "OK, that will do." + else + echo "Sorry, I can't get that to work. Go find one." + exit 1 + fi + fi + fi + fi + fi + fi + fi + fi +fi +rm -f testcpp.c testcpp.out + : see if sprintf is declared as int or pointer to char echo " " if $contains 'char.*sprintf' /usr/include/stdio.h >/dev/null 2>&1 ; then @@ -579,6 +671,21 @@ else esac fi +: see if stdio is really std +echo " " +if $contains 'char.*_ptr;' /usr/include/stdio.h >/dev/null 2>&1 ; then + if $contains '_cnt;' /usr/include/stdio.h >/dev/null 2>&1 ; then + echo "Your stdio is pretty std." + d_stdstdio="$define" + else + echo "Your stdio isn't very std." + d_stdstdio="$undef" + fi +else + echo "Your stdio isn't very std." + d_stdstdio="$undef" +fi + : check for structure copying echo " " echo "Checking to see if your C compiler can copy structs..." @@ -611,6 +718,16 @@ else d_vfork="$define" fi +: see if signal is declared as pointer to function returning int or void +echo " " +if $contains 'void.*signal' /usr/include/signal.h >/dev/null 2>&1 ; then + echo "You have void (*signal())() instead of int." + d_voidsig="$define" +else + echo "You have int (*signal())() instead of void." + d_voidsig="$undef" +fi + : check for void type echo " " $cat </dev/null 2>&1 ; then + echo "Your stdio uses unsigned chars." + stdchar="unsigned char" +else + echo "Your stdio uses signed chars." + stdchar="char" +fi + : preserve RCS keywords in files with variable substitution, grrr Log='$Log' Header='$Header' @@ -793,61 +920,9 @@ case "$mansrc" in ;; esac -: see how we invoke the C preprocessor -echo " " -echo "Checking to see how your C preprocessor is invoked..." -cat <<'EOT' >testcpp.c -#define ABC abc -#define XYZ xyz -ABC.XYZ -EOT -echo 'Maybe "cc -E" will work...' -cc -E testcpp.c >testcpp.out 2>&1 -if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then - echo "Yup, it does." - cpp='cc -E' -else - echo 'Nope...maybe "cc -P" will work...' - cc -P testcpp.c >testcpp.out 2>&1 - if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then - echo "Yup, that does." - cpp='cc -P' - else - echo 'Nixed again...maybe "/lib/cpp" will work...' - /lib/cpp testcpp.c >testcpp.out 2>&1 - if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then - echo "Hooray, it works! I was beginning to wonder." - cpp='/lib/cpp' - else - echo 'Hmm...maybe you already told me...' - case "$cpp" in - '') ;; - *) $cpp testcpp.c >testcpp.out 2>&1;; - esac - if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then - echo "Hooray, you did! I was beginning to wonder." - else - dflt=blurfl - $echo $n "Nope. I can't find a C preprocessor. Name one: $c" - rp='Name a C preprocessor:' - . myread - cpp="$ans" - $cpp testcpp.c >testcpp.out 2>&1 - if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then - echo "OK, that will do." - else - echo "Sorry, I can't get that to work. Go find one." - exit 1 - fi - fi - fi - fi -fi -rm -f testcpp.c testcpp.out - : get C preprocessor symbols handy echo " " -echo $attrlist | $tr '[ ]' '[\012]' >Cppsym.know +echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know $cat <Cppsym $startsh case "\$1" in @@ -874,13 +949,13 @@ esac case \$# in 0) exit 1;; esac -echo \$* | $tr '[ ]' '[\012]' | $sed -e 's/\(.*\)/\\ +echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\ #ifdef \1\\ exit 0; _ _ _ _\1\\ \1\\ #endif\\ /' >/tmp/Cppsym\$\$ echo exit 1 >>/tmp/Cppsym\$\$ -$cpp /tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$ +$cpp $cppminus /tmp/Cppsym2\$\$ case "\$list" in true) awk '\$6 != "" {print substr(\$6,2,100)}' config.h #$d_eunice EUNICE /**/ #$d_eunice VMS /**/ +/* CPP: + * This symbol contains the first part of the string which will invoke + * the C preprocessor on the standard input and produce to standard + * output. Typical value of "cc -E" or "/lib/cpp". + */ +/* CPPMINUS: + * This symbol contains the second part of the string which will invoke + * the C preprocessor on the standard input and produce to standard + * output. This symbol will have the value "-" if CPP needs a minus + * to specify standard input, otherwise the value is "". + */ +#define CPP "$cpp" +#define CPPMINUS "$cppminus" + /* CHARSPRINTF: * This symbol is defined if this system declares "char *sprintf()" in * stdio.h. The trend seems to be to declare it as "int sprintf()". It @@ -56,6 +70,12 @@ cat <config.h #$d_index index strchr /* cultural */ #$d_index rindex strrchr /* differences? */ +/* STDSTDIO: + * This symbol is defined if this system has a FILE structure declaring + * _ptr and _cnt in stdio.h. + */ +#$d_stdstdio STDSTDIO /**/ + /* STRUCTCOPY: * This symbol, if defined, indicates that this C compiler knows how * to copy structures. If undefined, you'll need to use a block copy @@ -69,6 +89,20 @@ cat <config.h */ #$d_vfork vfork fork /**/ +/* VOIDSIG: + * This symbol is defined if this system declares "void (*signal())()" in + * signal.h. The old way was to declare it as "int (*signal())()". It + * is up to the package author to declare things correctly based on the + * symbol. + */ +#$d_voidsig VOIDSIG /**/ + +/* STDCHAR: + * This symbol is defined to be the type of char used in stdio.h. + * It has the values "unsigned char" or "char". + */ +#define STDCHAR $stdchar /**/ + /* VOIDFLAGS: * This symbol indicates how much support of the void type is given by this * compiler. What various bits mean: diff --git a/patchlevel.h b/patchlevel.h index 935ec35..110c86f 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -1 +1 @@ -#define PATCHLEVEL 0 +#define PATCHLEVEL 1 diff --git a/perl.h b/perl.h index 3ccff10..ce2d2ab 100644 --- a/perl.h +++ b/perl.h @@ -1,13 +1,15 @@ -/* $Header: perl.h,v 1.0 87/12/18 13:05:38 root Exp $ +/* $Header: perl.h,v 1.0.1.1 88/01/21 21:29:23 root Exp $ * * $Log: perl.h,v $ + * Revision 1.0.1.1 88/01/21 21:29:23 root + * No longer defines STDSTDIO--gets it from config.h now. + * * Revision 1.0 87/12/18 13:05:38 root * Initial revision * */ #define DEBUGGING -#define STDSTDIO /* eventually should be in config.h */ #define VOIDUSED 1 #include "config.h" diff --git a/perly.c b/perly.c index bc32318..641971b 100644 --- a/perly.c +++ b/perly.c @@ -1,6 +1,9 @@ -char rcsid[] = "$Header: perly.c,v 1.0 87/12/18 15:53:31 root Exp $"; +char rcsid[] = "$Header: perly.c,v 1.0.1.1 88/01/21 21:25:57 root Exp $"; /* * $Log: perly.c,v $ + * Revision 1.0.1.1 88/01/21 21:25:57 root + * Now uses CPP and CPPMINUS symbols from config.h. + * * Revision 1.0 87/12/18 15:53:31 root * Initial revision * @@ -118,8 +121,8 @@ register char **env; -e '/^#[ ]*else/b' \ -e '/^#[ ]*endif/b' \ -e 's/^#.*//' \ - %s | /lib/cpp -C %s-", - argv[0], str_get(str)); + %s | %s -C %s%s", + argv[0], CPP, str_get(str), CPPMINUS); rsfp = popen(buf,"r"); } else if (!*argv[0]) diff --git a/str.c b/str.c index 52e83f2..2970879 100644 --- a/str.c +++ b/str.c @@ -1,6 +1,9 @@ -/* $Header: str.c,v 1.0 87/12/18 13:06:22 root Exp $ +/* $Header: str.c,v 1.0.1.1 88/01/21 21:28:39 root Exp $ * * $Log: str.c,v $ + * Revision 1.0.1.1 88/01/21 21:28:39 root + * Suppressed warning messages on signed vs unsigned chars in str_gets(). + * * Revision 1.0 87/12/18 13:06:22 root * Initial revision * @@ -318,8 +321,8 @@ register FILE *fp; register char *bp; /* we're going to steal some values */ register int cnt; /* from the stdio struct and put EVERYTHING */ - register char *ptr; /* in the innermost loop into registers */ - register char newline = record_separator; /* (assuming >= 6 registers) */ + register STDCHAR *ptr; /* in the innermost loop into registers */ + register char newline = record_separator;/* (assuming >= 6 registers) */ int i; int bpx; int obpx;