[net.news.sa] bug in header.c's use of prefix

fred@mot.UUCP (Fred Christiansen) (10/04/85)

i haven't seen anything on this, but forgive this neophyte if there has been.
in header.c is the following fragment:

	if (prefix(hp->path, FULLSYSNAME))
		fprintf(fp, "Path: %s\n", hp->path);
	else
		fprintf(fp, "Path: %s!%s\n", FULLSYSNAME, hp->path);

which evidently tries to figure out whether or not to add the local system's
name to "Path:".  however, it appears to fail in the event that the local
system's name is a left-anchored substring of the feeding system's name.
the following program demonstrates this: -----------------------------------

#include <stdio.h>
#include <ctype.h>

main() {
	if( prefix("motsj1!bjh", "mot") )
		printf("motsj1/mot, true path\n");
	else
		printf("motsj1/mot, false path\n");
	if( prefix("mot!fred", "motsj1") )
		printf("mot/motsj1, true path\n");
	else
		printf("mot/motsj1, false path\n");
	if( prefix("terak!sohail", "mot") )
		printf("terak/mot, true path\n");
	else
		printf("terak/mot, false path\n");
}

prefix(full, pref)			/* pulled straight from funcs.c */
register char *full, *pref;
{
	register char fc, pc;

	do {
		fc = *full++;
		pc = *pref++;
		if (isupper(fc))
			fc = tolower(fc);
		if (isupper(pc))
			pc = tolower(pc);
	} while (fc == pc);
	if (*--pref == 0)
		return 1;
	else
		return 0;
}
-------------------------------------------------
when you run the program, you discover that the first if returns true,
while the next two return false.  in fact, they should all return false in order
to get the desired effect.
	it appears to me that prefix(), given its other uses, is not the
correct routine to use.
	solutions?  or am i missing something?  thanks ya'll for the help.
-- 
<< Generic disclaimer >>
Fred Christiansen ("Canajun, eh?") @ Motorola Microsystems, Tempe, AZ
UUCP:  {seismo!terak, trwrb!flkvax, utzoo!mnetor, ihnp4!btlunix}!mot!fred
ARPA:  oakhill!mot!fred@ut-sally.ARPA             Telephone:  +1 602-438-3472