Thread View: net.bugs
9 messages
9 total messages
Started by USENET administrator
Tue, 18 Mar 1986 20:54
2.10.3 unbatch bug and fix
Author: USENET administrator
Date: Tue, 18 Mar 1986 20:54
Date: Tue, 18 Mar 1986 20:54
20 lines
1138 bytes
1138 bytes
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
Re: 2.10.3 unbatch bug and fix
Author: Carl S. Gutekunst
Date: Thu, 20 Mar 1986 00:59
Date: Thu, 20 Mar 1986 00:59
39 lines
2289 bytes
2289 bytes
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
Re: 2.10.3 unbatch bug and fix
Author: ekrell
Date: Thu, 20 Mar 1986 03:22
Date: Thu, 20 Mar 1986 03:22
14 lines
1239 bytes
1239 bytes
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 !
Re: 2.10.3 unbatch bug and fix
Author: Guy Harris
Date: Thu, 20 Mar 1986 18:45
Date: Thu, 20 Mar 1986 18:45
53 lines
2594 bytes
2594 bytes
> 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)
Re: 2.10.3 unbatch bug and fix
Author: jpn
Date: Thu, 20 Mar 1986 20:32
Date: Thu, 20 Mar 1986 20:32
14 lines
1239 bytes
1239 bytes
>>(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
Re: 2.10.3 unbatch bug and fix
Author: Sam McCall - Hacker In Residency
Date: Fri, 21 Mar 1986 04:51
Date: Fri, 21 Mar 1986 04:51
31 lines
1680 bytes
1680 bytes
>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
Re: 2.10.3 unbatch bug and fix
Author: Daniel R. Levy
Date: Fri, 21 Mar 1986 18:25
Date: Fri, 21 Mar 1986 18:25
34 lines
1885 bytes
1885 bytes
<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
Re: 2.10.3 unbatch bug and fix
Author: Daniel R. Levy
Date: Fri, 21 Mar 1986 19:10
Date: Fri, 21 Mar 1986 19:10
40 lines
2549 bytes
2549 bytes
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
Re: 2.10.3 unbatch bug and fix
Author: Doug Gwyn
Date: Sun, 23 Mar 1986 09:11
Date: Sun, 23 Mar 1986 09:11
5 lines
871 bytes
871 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads