Article View: net.bugs.v7
Article #129bugs in look(1): -d is broken, -t undocumented & others
From: Geoffrey Collyer
Date: Tue, 08 Nov 1983 01:15
Date: Tue, 08 Nov 1983 01:15
38 lines
1840 bytes
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
Technical Details
Message-ID:
<1397@utcsstat.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utcsstat!geoffShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcsstat.UUCP Path: arc1-ca.pugleaf.net!utzoo!utcsstat!geoff From: geoff@utcsstat.UUCP (Geoffrey Collyer) Newsgroups: net.bugs.v7,net.bugs.4bsd Subject: bugs in look(1): -d is broken, -t undocumented & others Message-ID: <1397@utcsstat.UUCP> Date: Mon, 7-Nov-83 20:15:42 EST Article-I.D.: utcsstat.1397 Posted: Mon Nov 7 20:15:42 1983 Date-Received: Tue, 8-Nov-83 05:21:58 EST Organization: U. of Toronto, Canada Lines: 38