Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!pacbell!att!occrsh!uokmax!rmtodd From: rmtodd@uokmax.UUCP (Richard Michael Todd) Newsgroups: news.software.b Subject: Re: C News on a Mac IIx Summary: SVR2 stdio has got some serious weirdnesses.... Message-ID: <3429@uokmax.UUCP> Date: 26 Jun 89 01:12:40 GMT References: <3398@uokmax.UUCP> <1989Jun24.210627.25374@utzoo.uucp> Reply-To: rmtodd@uokmax.UUCP (Richard Michael Todd) Organization: University of Oklahoma, ECN Lines: 103 In article <1989Jun24.210627.25374@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: [Re: stdio not working correctly on A/UX] >Argh. I was afraid of that. If you can figure out what's going on and find >a test that will spot the incompatibility, we'd love to hear about it. (Geoff >tried fairly hard to do this for SunOS 4.0 but couldn't, admittedly under a >severe time constraint.) Replacing *part* of a library is always fraught >with potential portability problems. Well, I think I've figured out some of what's going on. Appended to the end of this posting is a script showing a short program which reproduces the bug, along with some looking inside the program with sdb. Note especially the place where the new fwrite is called by _doprnt (well, actually _dowrite called by _doprnt), and at that point fp->_cnt is negative. I'd love to hear someone with SVR2 library source explain why that happens.... >> Australian readnews won't even compile. Since anyone in his right >>mind is using rn anyway, I haven't spent too much time looking into this... Well, for starters, the program makes references to "struct sgttyb", which is no more for us USG-using folks. Looking more closely at readnews.c (especially page()), shows that this program doesn't really have code to handle USG termio, just comments showing where such code might be if it were there, which it isn't. >> The C News distribution contains versions of queuelen for HDB and for >>old w/subdirectory versions of UUCP. Alas, A/UX uses old UUCP without >>subdirectories (*despite* what the uucico(1) man page says!), so minor >>hacking here is required. If anyone is interested, I can post the hacked >>version. Okay, here's the queuelen script for A/UX, followed by the typescript (showing the stdio bugs) I mentioned earlier --------------------queuelen----------------------------------------------- #! /bin/sh # Find size of current queue of news outbound to $1. Old-uucp version. # =()<. ${NEWSCONFIG-@@}>()= . ${NEWSCONFIG-/usr/lib/news/bin/config} PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH umask $NEWSUMASK cd /usr/spool/uucp case "$1" in ?|??|???|????|?????|??????|???????) site="$1" ;; *) site=`expr "$1" : '^\(.......\).*'` esac ls | egrep "^C\.$site......\$" | wc | awk '{print $1}' --------------------typescript-------------------------------------- Script started on Sun Jun 25 00:51:51 1989 1 servalan ~/cnews/libstdio % cat test1.c #include main() { char buf[512]; while (1) { fgets(buf, 511, stdin); fprintf(stderr,"line = <%s>\n", buf); } fwrite(buf,strlen(buf),1,stderr); /* gratuitous fwrite call above there to force new fwrite to be linked in */ } 2 servalan ~/cnews/libstdio % cc -o test1 -g test1.c ../libcnews.a "test1.c", line 8: warning: statement not reached 3 servalan ~/cnews/libstdio % test1 llllllllllll line = <> sfsfsfsfsf line = <> 4 servalan ~/cnews/libstdio % sdb test1 Warning: `filbuf.c' not found Warning: `fprintf.c' not found Warning: `doprnt.c' not found Warning: `ecvt.c' not found Warning: `flsbuf.c' not found Warning: `isatty.c' not found Warning: `malloc.c' not found No core image *fwrite:b fwrite:70 b *r test1 llllllllll Breakpoint at fwrite:70: { *s fwrite:71: register unsigned bytes = count * size; *t fwrite(ptr=llllllllll^J,size=1,count=11,fp=0x4008b0) [rdwr.c:71] _dowrite(p=llllllllll^J,n=11,iop=0x4008b0,ptrptr=0x1ffffb0c) [doprnt.c:88] _doprnt(format=line = <%s>^J,args=,iop=0x4008b0) [doprnt.c:747] fprintf(iop=0x4008b0,format=line = <%s>^J,va_alist=536869700) [fprintf.c:40] main(1,536870232,536870240) [test1.c:6] *fp[0]/ fp[0]._cnt/ -8 fp[0]._ptr/ 0x400e68 fp[0]._base/ 0x400e60 fp[0]._flag/ ^F fp[0]._file/ ^B *q 5 servalan ~/cnews/libstdio % exit script done on Sun Jun 25 00:54:03 1989