Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!lll-tis!elxsi!beatnix!gww From: gww@beatnix.UUCP (Gary Winiger) Newsgroups: comp.bugs.4bsd Subject: lib{F,I,U}77/mkvers hangs if no sccs id string is found. +Fix Message-ID: <730@elxsi.UUCP> Date: 12 Mar 88 20:16:06 GMT Sender: nobody@elxsi.UUCP Reply-To: gww@beatnix.UUCP (Gary Winiger) Organization: ELXSI Super Computers, San Jose Lines: 49 Subject: lib{F,I,U}77/mkvers hangs if no sccs id is found +Fix Index: lib{F,I,U}77/mkvers.c 4.3BSD +Fix Description: Mkvers will hang in an infinite loop if a file being scanned does not contain an sccs ``what'' string but does contain the character '@'. Repeat-By: Create a file with the character '@' in it, but with no ``what'' string. Run mkvers on that file. Fix: There are really two problems to be fixed. First, if a '@' is found by the index(3) call, but the remainder of a ``what'' string is not found, mkvers will continually loop on that '@' character. Advance the pointer ``s''. Second, the end of file condition on stdin is never cleared when a file is read to EOF. Clear the EOF. The attached code solves this problem at Elxsi. Gary.. {ucbvax!sun,lll-lcc!lll-tis,amdahl!altos86,bridge2}!elxsi!gww --------- cut --------- snip --------- :.,$w diff ------------- *** mkvers.c Tue Oct 20 10:33:25 1987 --- newmkvers.c Tue Oct 20 10:35:44 1987 *************** *** 67,72 **** --- 67,74 ---- while(s = index(s, '@')) if (strncmp(s, SCCS_ID, 4) == 0) break; + else + ++s; if (s) { e = index(s, '"'); *************** *** 77,83 **** --- 79,88 ---- } } if (feof(stdin)) + { fprintf(stderr, "%s: no sccs id string\n", *argv); + clearerr(stdin); + } } fprintf(V, "};\n"); fclose(V);