henry (09/22/82)
The V7 basename(1) has a minor bug: if the first argument is actually a suffix of the second (e.g. "basename c .c"), basename will yield a null string instead of the first argument. The simplest fix is to change the lines while(p1>p2 && p3>argv[2]) if(*--p3 != *--p1) to while(p3>argv[2]) if(p1 <= p2 && *--p3 != *--p1) which aborts the scan if it hits the beginning of the first argument before hitting the beginning of the suffix.
puder (11/13/82)
Correction: that and in the if should be an OR! change this: while(p1>p2 && p3>argv[2]) if(*--p3 != *--p1) to this: while(p3>argv[2]) if(p1 <= p2 || *--p3 != *--p1) NOT this: while(p3>argv[2]) if(p1 <= p2 && *--p3 != *--p1) With the and in there, it will always infinite loop. There is some comment about the algebra of logical statements that I should make here, but I can't seem to phrase it right now. Something about DeMorgan's laws.