geoff@utcsstat.UUCP (Geoffrey Collyer) (11/08/83)
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