🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Geoffrey Collyer Tue, 08 Nov 1983 01:15
bugs in look(1): -d is broken, -t undocumented & others
#129
Author: Geoffrey Collyer
Date: Tue, 08 Nov 1983 01:15
38 lines
1840 bytes
The following bugs are present in look on at least V7 and 4.1BSD.

The -d (dictionary order) option does not work as advertised.  It
ignores whitespace during comparison, despite look(1), which says

     d  `Dictionary' order: only letters, digits, tabs and
	blanks participate in comparisons.

The fix is to change, in canon(),

		if (!isalnum(c))
to
		if ((!isascii(c) || !isalnum(c)) &&
		    c != ' ' && c != '\t')

There is an undocumented -t option, identical to that of sort(1).

There are lots of coding botches.  Look uses continue statements
liberally, and returns from main() without a value.  In canon(),
isalnum and isupper are used without testing isascii first.  The fix
for isalnum is given above, the other correction is to change

	if (isupper(c))
		*new += 'a' - 'A';
to
	if (isascii(c) && isupper(c))
		*new = tolower(c);

The new version also uses tolower portably rather than the previous,
less-portable addition of a magic quantity.

Once the above fixes are applied, look may be used to look up the
spelling of a word (in /usr/dict/words) much more rapidly than egrep
can or to search a phonebook.  Look performs a binary search on sorted
text files and so could be used to look for poor passwords in
passwd(1) [strong hint].

Geoff Collyer, U. of Toronto
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