home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.sys5.r3:78 comp.sys.sun.misc:5135 comp.editors:2688 comp.lang.c:16112
- Newsgroups: comp.unix.sys5.r3,comp.sys.sun.misc,comp.editors,comp.lang.c
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!wotan.compaq.com!moxie!sugar!ficc!peter
- From: peter@ferranti.com (peter da silva)
- Subject: compiling SAM with non-ANSI compilers
- Message-ID: <id.N1RU.TAB@ferranti.com>
- Followup-To: comp.unix.sys5.r3,comp.sys.sun.misc
- Organization: Xenix Support, FICC
- Date: Fri, 6 Nov 1992 17:06:50 GMT
- Lines: 90
-
- [If you change the followups, please leave one of the groups I've got followups
- to in the Newsgroups line, as I don't follow the other groups]
-
- OK, I've got SAM, but it's for ANSI compilers only. My System V.3.2 and
- Sun 4.x systems only have K&R compilers. I can get it all to compile
- pretty cleanly with "unproto", but I get a weird memory allocation
- failure in erealloc. It looks like this:
-
- void *erealloc(void *p, unsigned long n)
- {
- p = realloc(p, n);
- if(!p)
- fatal error code
- return p
- }
-
- It barfed when the regular expression code was compiling a character
- class. The character class code calls erealloc() with a null pointer.
- No problem, just create srealloc that special-cases the null pointer:
-
- void *srealloc(void *p, unsigned long n)
- {
- if(p)
- p = realloc(p, n);
- else
- p = malloc(n);
- return p;
- }
-
- Now erealloc is failing on the call to srealloc(), but the stack trace
- says it's in free(). I can't figure out what's going on here. I'm using
- a compiler with 32 bit ints and the standard promotion rules, so I can't
- imagine that it's stack bashing.
-
- Is anyone else so demented as to try this? Has anyone had better success?
-
- For reference, the "ansi cc" I'm using looks like this:
-
- :
- SAMDIR=/usr1/xds/src/sam
- BIN=$SAMDIR/bin
-
- ECHO=:
- CPPARGS="-E"
- for i
- do
- case $i in
- -I*|-D*) CPPARGS="$CPPARGS $i";;
- -v) ECHO=echo
- esac
- done
-
- ARGS=
- MV=
- for i
- do
- case $i in
- -I*|-D*) ;;
- *.c)
- $ECHO "- /lib/cpp $CPPARGS $i"
- if /lib/cpp $CPPARGS $i |
- $BIN/unproto > _$i
- then
- ARGS="$ARGS _$i"
- o="`echo $i | sed 's/\.c$/.o/'`"
- MV="$MV mv _$o $o;"
- else exit 2
- fi
- ;;
- *)
- ARGS="$ARGS $i"
- ;;
- esac
- done
- $ECHO - cc $ARGS
- if cc $ARGS
- then
- if [ "$MV" ]
- then
- $ECHO "-$MV"
- eval $MV
- else true
- fi
- else false
- fi
- --
- % Peter da Silva % 77487-5012 % +1 713 274 5180 %
- true(<<VV$@\\$'&O 9$O%'$LT$&$"V6"$&$<4$?'&$ #I&&?$=$<<@)24 24 scale 3 21 moveto
- {dup 36 eq{pop not}{dup 7 and 4 sub exch 56 and 8 div 4 sub 2 index{rlineto}{
- rmoveto}ifelse}ifelse}forall stroke pop showpage % Har du kramat din varg idag?
-