From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Description of problem:
I wanted to find out how to spell accelerate. So, I typed 'look
accel' and got no answers. I then looked for 'acce', 'acc', 'ac', and
'a'. Only 'a' returned any answers, and it returned a list of all
words starting with a capital A only.
I tried this on a RedHat AS-3 system, and it worked as expected.
I downloaded the srpm for util-linux-2.12a-19, and added some
debugging statements to look.c, lines 341 and 386, to print what the
strncasecmp and strncmp were seeing and reporting.
It appears the problem is that strncasecmp is expecting the
/usr/share/dict/words file to be sorted ignoring case, while the
strncmp is expecting the file to not be sorted ignoring case. As the
file is sorted not ignoring case, strncasecmp is going to lose every time.
As a test, I typed 'look accel /usr/share/dict/words', and it worked
perfectly. This is the only way I could see to turn off
The solution is going to be complicated.
Step 1: sort /usr/share/dict/words while ignoring case.
Step 2: use strncasecmp to find the words.
Step 3: if the user wants case sensitivity, filter out words that fail
strncmp when printing the results.
Oh, and add a command line option that lets you turn off case
insensitivity, which defaults to on (-f).
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Type: look accel
2. Type: look accel /usr/share/dict/words
3. Type: look a
Actual Results: 'look accel' returns nothing.
'look accel /usr/share/dict/words' returns the correct results.
'look a' returns only words starting with 'A'.
Expected Results: 'look accel' should have reported words starting
with 'accel', upper or lower case.
'look a' should have reported all words starting with 'a', upper or
The dict/words must be "sort --case-ignore". Fixed in words-3.0-2.2.
That's great, but did you add code to let you 'look' case-sensitively?
Just re-sorting the dict/words file will fix one problem and cause another.
I don't think so. The original order of dict/words __was__ case-insensitive in
The problem with sort have been stared during update to moby dictionary
(http://www.dcs.shef.ac.uk/research/ilash/Moby/) and someone added to .spec file:
sort [1-9]*.??? | uniq | grep -E "^[[:alnum:]'&!,./-]+$" > moby
* Fri Nov 05 2004 Adrian Havill <firstname.lastname@example.org> 3.0-4
- replace word list with much better Moby Project words list (#61395)
BTW, GA release of FC-3 was 8 Nov 2004. IMHO it's regression... (and I'm sure
that it's regression problem for RHEL3).
After updating to words.noarch 0:3.0-2.2 and util-linux.i386 0:2.12a-23
look accel now works, but look accel /usr/share/dict/words does not. looking at
the man page for look it seems both should function the same.
look -f accel /usr/share/dict/words does work correctly. -f seems to be assumed
when using the default file (/usr/share/dict/words) so maybe this is a non issue.
I did look at the code when I posted this, and it's doing a binary search on the
word file, using strncmp or strncasecmp.
If the word list is sorted case-insensitively, strncasecmp will work and strncmp
will not. If case-sensitively, then strncmp will work and strncasecmp will not.
In both cases, there are some command line options to 'look' that will not work
There are two solutions:
1) remove the command line options that will not work right
2) fix the code of those command line options
As the principle of backwards-compatiblity says that '1' is not a good idea, I
suggest '2' would be the course of action to take.
The change that will need to be made is in the initial bug report.
As someone at some future date may change the sort order of the word file
(again) or they might have an older version of the rpm, it would be nice to have
'look' work with either order. Add 'step 0: determine order of list and change
strncasecmp to strncmp if the word file order is sorted case-sensitively' to the
Oh, and changing the order of the word file is going to mess up older versions
of look. Have fun managing the change. :-)
There is harcoded default options for the default file dict/words. That's right.
If you want to use some other file (=you call "look word /path/file") you have
to care about order vs. options.
I think correct long term solution should be keep in directory with words file
with information about:
- order of list (case-sensitive/case-insensitive)
- used locales durring sort