🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.v7
Article #97

basename(1) bug

#97
From: utzoohenry
Date: Tue, 21 Sep 1982 19:29
14 lines
722 bytes
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.
Technical Details
Message-ID: <bnews.utzoo.2484>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
From: utzoo!henry
Newsgroups: net.bugs.v7
Title: basename(1) bug 
Article-I.D.: utzoo.2484
Posted: Tue Sep 21 19:29:44 1982
Received: Tue Sep 21 19:29:44 1982
Subject: basename(1) bug
Date: Tue, 21 Sep 1982 19:29:44 +0000
Message-ID: <bnews.utzoo.2484>