commit 1c845e0bd5ff897dc5e90f2c24db4ecd81a8f60c from: Russ Cox date: Wed Jan 06 04:38:09 2021 UTC acme, sam, samterm: remove weird switch usage For whatever reason all three of these programs contain switches like: switch(x) { case 1: if(cond) case 2: f(); } Like Duff's device, this is legal C but more obscure than it really needs to be. This commit assumes those are intended as written and simply writes them more clearly. I did consider that maybe they are mistakes, but in the case of sam/regexp.c, my rewrite in this commit matches the acme/regx.c that has been in plan9port since I added acme in 2003. (I didn't bother to dig up the old Plan 9 releases.) Assuming acme/regx.c has been correct for the past two decades, this commit should be correct too. commit - 0a513e65607223d11ba94003256b13ef5779e7e8 commit + 1c845e0bd5ff897dc5e90f2c24db4ecd81a8f60c blob - 81f80300db28d033b22290177f3e00632b679e72 blob + 82a19b0d585516d603c3d3d5c24c48bed0bde46c --- src/cmd/acme/edit.c +++ src/cmd/acme/edit.c @@ -635,9 +635,11 @@ simpleaddr(void) case '.': case '$': case '\'': - if(addr.type!='"') + if(addr.type=='"') + break; + /* fall through */ case '"': - editerror("bad address syntax"); + editerror("bad address syntax"); break; case 'l': case '#': blob - 7176a8271560f0d184460486d709d84bd7f87327 blob + 13bd17e0dd59359a2470829ff3295bce7ff72dae --- src/cmd/sam/cmd.c +++ src/cmd/sam/cmd.c @@ -559,9 +559,11 @@ simpleaddr(void) case '.': case '$': case '\'': - if(addr.type!='"') + if(addr.type=='"') + break; + /* fall through */ case '"': - error(Eaddress); + error(Eaddress); break; case 'l': case '#': blob - 2e369fe161eb0f71028e71e7575081ed96931ab8 blob + 57c639d9cf30ce3a9ab7512a8dd0989790081583 --- src/cmd/sam/regexp.c +++ src/cmd/sam/regexp.c @@ -700,11 +700,11 @@ bexecute(File *f, Posn startp) break; case 1: /* expired; wrap to end */ if(sel.p[0].p1>=0) - case 3: goto Return; list[0][0].inst = list[1][0].inst = 0; p = f->b.nc; goto doloop; + case 3: default: goto Return; } blob - e9fde31c08414ca49a1a4220d2926b9adb81d795 blob + a8e70d0c044da354f7a4b5402521f99cf4ba6eba --- src/cmd/samterm/flayer.c +++ src/cmd/samterm/flayer.c @@ -169,8 +169,8 @@ newvisibilities(int redraw) break; case V(Some, Some): - if(l->f.b==0 && redraw) case V(None, Some): + if(ov == None || (l->f.b==0 && redraw)) flprepare(l); if(l->f.b && redraw){ flrefresh(l, l->entire, 0);