news@micropro.UUCP (USENET administrator) (03/18/86)
Yikes! I lost two days of news. Hasn't anyone *used* the 2.10.3 unbatcher? It doesn't work. Here's a diff. (I don't know how to make a context diff, or don't have the utility. Is it PD?) unbatch.c, where < = old and > = new 53,54c53,54 < while (strncmp(buf, "#! rnews ", 9) < || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ --- > while (!strncmp(buf, "#! rnews ", 9) > && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ -- Mojo Morris Jones, MicroPro USENET Administrator {lll-crg,ptsfa,dual,well,pyramid}!micropro!usenet
csg@pyramid.UUCP (Carl S. Gutekunst) (03/20/86)
In article <243@micropro.UUCP> mojo writes: >Yikes! I lost two days of news. Hasn't anyone *used* the 2.10.3 >unbatcher? It doesn't work. > >53,54c53,54 >< while (strncmp(buf, "#! rnews ", 9) >< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ >--- >> while (!strncmp(buf, "#! rnews ", 9) >> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ Which version of 2.10.3? We have 6/6/85, which is missing the second test. I'll bet a nickel that yours is later, and somebody was trying to fix the "article eater" bug without working out their boolean algebra first.... But your fix isn't correct either. Try this: while (strncmp(buf, "#! rnews ", 9) && strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ That is, the body of the loop is executed only when both strncmp functions return non-zero, meaning that the line was neither "#! rnews" nor "! rnews". What your patch will do is execute the body of the loop only when the buffer is simultaneously equal to both strings! All of which is moot, since I'm painfully familiar with at least one article eater, and this kludge will not catch it reliably. (The real "bug repellant" fix requires a complete rewrite of unbatch's inner loop; it's not difficult, so I suppose I really should go back and work it into the code. Being as none of our adjacent sites have the bug, I've gotten lazy. :-)) >(I don't know how to make a context diff, or don't >have the utility. Is it PD?) You get a context diff with the "-c" option on the BSD diff utility. USG sites get to lose, unfortunately.... -- Carl S. Gutekunst {allegra,cmcl2,decwrl,hplabs,topaz,ut-sally}!pyramid!csg Pyramid Technology Corp, Mountain View, CA +1 415 965 7200
ekrell@ucla-cs.UUCP (03/20/86)
In article <243@micropro.UUCP> news@micropro.UUCP (USENET administrator) writes: >< while (strncmp(buf, "#! rnews ", 9) >< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ >--- >> while (!strncmp(buf, "#! rnews ", 9) >> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ Aren't these two the same by De Morgan's law? -- Eduardo Krell UCLA Computer Science Department ekrell@ucla-locus.arpa ..!{sdcrdcf,ihnp4,trwspp,ucbvax}!ucla-cs!ekrell You have the right to express your opinions, but that doesn't mean your opinions are right !
guy@sun.uucp (Guy Harris) (03/20/86)
> In article <243@micropro.UUCP> news@micropro.UUCP (USENET administrator) writes: > >< while (strncmp(buf, "#! rnews ", 9) > >< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ > >--- > >> while (!strncmp(buf, "#! rnews ", 9) > >> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ > > Aren't these two the same by De Morgan's law? No, the second is the complement of the first, by De Morgan's law. Using a bastardized C notation, !(a || b) == (!a && !b), and therefore obviously (a || b) != (!a && !b). However, looking at the code to the 2.10.3 that comes with 4.3BSD beta, the code around there reads while (strncmp(buf, "#! rnews ", 9)) { which means it's skipping over lines which do NOT begin with "#! rnews". The original version, assuming it was a replacement for this line, skips over lines which either don't begin with "#! rnews" or don't begin with "! rnews", i.e. it never stops and skips over all lines. The replacement for it, given the same assumption, skips over lines which both begin with "#! rnews" and begin with "! rnews", i.e. it stops immediately. (If the first and second tests are complements, since the second test is obviously always FALSE the first test is obviously always TRUE.) This is somewhat of an object lesson in Why Not To Treat "strcmp" As A Function Returning A Boolean Value. It takes some effort to remember that "strcmp(a, b)", treated as a Boolean value (i.e., 0/FALSE or non-0/TRUE) is TRUE iff strings "a" and "b" are different. Now, since what we want is to continue as long as the string neither begins with "#! rnews" or "! rnews", we want while (buf doesn't begin with "#! rnews" && buf doesn't begin with "! rnews") { which translates as while (strncmp(buf, "#! rnews", 9) != 0 && strncmp(buf, "! rnews", 8) != 0)) { since string "a" <comparison op> string "b" iff strcmp(string "a", string "b") <comparison op> 0 -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.arpa (yes, really)
jpn@teddy.UUCP (03/20/86)
>>(I don't know how to make a context diff, or don't >>have the utility. Is it PD?) > >You get a context diff with the "-c" option on the BSD diff utility. USG >sites get to lose, unfortunately.... Just another plug... The mod.sources archive has a utility in it called "diffc" which creates context diffs using the standard diff on USG UNIX'es. These context diffs are identical to those generated by BSD "diff -c". I know it works, I wrote it! John P. Nelson, Moderator, mod.sources (decvax!genrad!panda!jpn seismo!harvard!wjh12!panda!jpn) Send source code to panda!sources, requests to panda!sources-request
cccsam@ucdavis.UUCP (Sam McCall - Hacker In Residency) (03/21/86)
>In article <243@micropro.UUCP> news@micropro.UUCP (USENET administrator) writes: > >< while (strncmp(buf, "#! rnews ", 9) > >< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ > >--- > >> while (!strncmp(buf, "#! rnews ", 9) > >> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ > > Aren't these two the same by De Morgan's law? > -- > Eduardo Krell UCLA Computer Science Department > ekrell@ucla-locus.arpa ..!{sdcrdcf,ihnp4,trwspp,ucbvax}!ucla-cs!ekrell > > You have the right to express your opinions, > but that doesn't mean your opinions are right ! nope. (a or b) != (!a and !b), but !(a or b) == (!a and !b). thus, for the two to have been equal, you would have wanted to see while !(strncmp(buf, "#! rnews ", 9) || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ as the first example. -- -sam mccall -unix consultant -computer center -university of california, davis -...{lll-crg,ucbvax}!ucdavis!deneb!cccsam -...ucdavis!deneb!cccsam@ucbvax.berkeley.edu
levy@ttrdc.UUCP (Daniel R. Levy) (03/21/86)
<Oh oh here it comes. Watch out boy, it'll chew you up! \ Oh oh here it comes. The LINE EATER! [Line eater]> In article <9980@ucla-cs.ARPA>, ekrell@ucla-cs.UUCP writes: >In article <243@micropro.UUCP> news@micropro.UUCP (USENET administrator) writes: >>< while (strncmp(buf, "#! rnews ", 9) >>< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ >>--- >>> while (!strncmp(buf, "#! rnews ", 9) >>> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ > >Aren't these two the same by De Morgan's law? >-- > Eduardo Krell UCLA Computer Science Department int A,B; (A || B) == !(!A && !B); /* sez demorgans law */ A 0 1 0 1 \_____ \_____ B 0|0|1| 0|1|0| ----- == ! ----- (Karnaugh map representation) 1|1|1| 1|0|0| ----- ----- -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, vax135}!ttrdc!levy
levy@ttrdc.UUCP (Daniel R. Levy) (03/21/86)
In article <805@ttrdc.UUCP>, levy@ttrdc.UUCP (I) wrote: ><Oh oh here it comes. Watch out boy, it'll chew you up! \ >Oh oh here it comes. The LINE EATER! [Line eater]> >In article <9980@ucla-cs.ARPA>, ekrell@ucla-cs.UUCP writes: >>In article <243@micropro.UUCP> news@micropro.UUCP (USENET administrator) writes: >>>< while (strncmp(buf, "#! rnews ", 9) >>>< || strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ >>>--- >>>> while (!strncmp(buf, "#! rnews ", 9) >>>> && !strncmp(buf, "! rnews ", 8)) { /* kludge for bug */ >> >>Aren't these two the same by De Morgan's law? >>-- >> Eduardo Krell UCLA Computer Science Department >int A,B; > >(A || B) == !(!A && !B); /* sez demorgans law */ > A > 0 1 0 1 > \_____ \_____ >B 0|0|1| 0|1|0| > ----- == ! ----- (Karnaugh map representation) > 1|1|1| 1|0|0| > ----- ----- Sheesh, egg on my face. Not because this logical assertion is untrue (it still holds) but because I just realized that the strncmp clauses above don't make sense! The first will always be true, the second always false. In the first case, there will always be NO MATCH either between buf and "!# rnews " or buf and "! rnews ". NO MATCH means a "boolean" true (nonzero) in strncmp, at least the last time I checked the manual. The OR of two things, at least one of which is guaranteed to be true, is therefore itself guaranteed to be true. Or am I washed up? -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, vax135}!ttrdc!levy
gwyn@brl-smoke.ARPA (Doug Gwyn ) (03/23/86)
In article <9980@ucla-cs.ARPA> ekrell@ucla-cs.UUCP (Eduardo Krell) writes: >Aren't these two the same by De Morgan's law? No, they're complementary. By the way, "if ( !strncmp(...) )" is atrocious style. strncmp() is not a Boolean function.