Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!uwvax!uwmacc!hobbes!root From: root@hobbes.UUCP Newsgroups: comp.unix.xenix Subject: New bug in uPort: stdio is broken. Message-ID: <202@hobbes.UUCP> Date: Sun, 30-Aug-87 22:01:30 EDT Article-I.D.: hobbes.202 Posted: Sun Aug 30 22:01:30 1987 Date-Received: Tue, 1-Sep-87 01:02:44 EDT References: <593@sugar.UUCP> Reply-To: root@hobbes.UUCP (John Plocher) Followup-To: comp.unix.xenix Organization: U of Wisconsin - Madison Spanish Department Lines: 67 +---- Peter da Silva writes the following in article <593@sugar.UUCP> ---- | [[ concerning a "supposed" bug in Microport SV/AT ]] | The following program will not work with the printf(""); taken out. It | appears that stdio() doesn't come up properly initted. This is a bug. | You should be able to interleaf printf() and putchar() in any order. | | #include | #include | main(ac, av) int ac; char **av; | { | printf(""); /* needed! */ | while(*++av) { | while(**av) { | if(isdigit(**av)) break; | if(isupper(**av)) break; | if(islower(**av)) break; | if(strchr(**av, "-_=+")) break; | ++*av; | } | while(isalnum(**av) || strchr(**av, ".-_=+")) { | putchar(**av); | ++*av; | } | putchar(' '); | } | putchar('\n'); | } +---- Not a bug in stdio - replace the "printf("");" with "strlen("");" and it works, too. The *REAL* bug is that your code is corrupting the stack, specifically the call to strchr(). You have reversed the arguments to the function. From the S5r2 man page string(3C): char *strchr(s, c) char *s; int c; I *hate* it when people blame the OS for their simple programming errors. I used lint to find this one: % lint x.c x.c ============== (37) warning: main() returns random value to invocation environment warning: argument unused in function: (37) ac in main ============== value type used inconsistently strchr llib-lc(424) :: x.c(27) strchr llib-lc(424) :: x.c(30) value type declared inconsistently strchr llib-lc(424) :: x.c(30) function argument ( number ) used inconsistently strchr( arg 1 ) llib-lc(424) :: x.c(27) strchr( arg 2 ) llib-lc(424) :: x.c(27) strchr( arg 1 ) llib-lc(424) :: x.c(30) strchr( arg 2 ) llib-lc(424) :: x.c(30) function returns value which is always ignored putchar FLAME ON: Why don't *you* use it? That's what its for! FLAME OFF! -- John Plocher uwvax!geowhiz!uwspan!plocher plocher%uwspan.UUCP@uwvax.CS.WISC.EDU