Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!nysernic!itsgw!batcomputer!cornell!rochester!pt!ius1.cs.cmu.edu!edw From: edw@ius1.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <1033@ius1.cs.cmu.edu> Date: Tue, 11-Aug-87 10:03:19 EDT Article-I.D.: ius1.1033 Posted: Tue Aug 11 10:03:19 1987 Date-Received: Thu, 13-Aug-87 06:11:30 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <2182@zeus.TEK.COM> Organization: Carnegie-Mellon University, CS/RI Lines: 54 In article <2182@zeus.TEK.COM>, dant@tekla.TEK.COM (Dan Tilque;1893;92-789;LP=A;60HC) writes: > However, I agree that it's bad programming to have this kind of thing: > > case 'a': > a = b + count; > case 'b': > count += 2; > . > . > . > Lint should definitely give warning since it's almost always the case that > what's desired is a break before case 'b':. Also, one of my more frequent > mistakes is leaving breaks out of switches. Lexer I've written do things like that: case '+' : case '-' : case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : while (isdigit(input())); if (*cc != '.') { (void) ungetc(*cc,yyin); *cc = '\0'; return(TINTEGER); } case '.' : /* float num */ while (isdigit(input())); (void) ungetc(*cc,yyin); *cc = '\0'; return(TREAL); break; > > --- > Dan Tilque > dant@tekla.tek.com or dant@tekla.UUCP -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu