The final utility program that is provided is called hexwords, which is used to generate hexadecimal constants from a dictionary of known words. Such numerical constants can be used in source files for a variety of debugging problems, and problems with uninitialised variables are especially relevant since these special numbers will stand out if seen from within a debugger. For example, here are some common (and some not-so-common) 32-bit hexadecimal constants that can be used as debugging aids:
As can be seen above, many decimal digits can be used to represent the letters that they most closely resemble, along with the hexadecimal digits `A' through `F'. This provides a much larger selection of words that can be matched, although the digits `3' and `8' cannot be used due to the lack of any similar-looking letters. The digits and their corresponding letters are given in the following table.
|`0'||O, o or Q
|`1'||I, i or l
|`2'||Z or z
|`4'||q or R
|`5'||S or s
|`7'||J or T
The argument to hexwords must be a valid dictionary filename but if it is omitted then hexwords will use /usr/dict/words as the name of the dictionary file to use. If that cannot be found then hexwords will try /usr/lib/dict/words and /usr/share/dict/words. The dictionary file must be a plain text file that contains one word per line, otherwise few to no words will be matched.
The words that are matched from the dictionary file can be controlled by using the --match option, which sets the type of case-sensitivity to use. A setting of `exact' performs a case-sensitive comparison of all of the words in the dictionary file and the hexadecimal digits, whereas a setting of `any' does not. The `lower' and `upper' settings convert the words in the dictionary file to lower and upper case respectively before performing a case-sensitive comparison. The default case-sensitivity is `exact'.
The minimum and maximum number of letters that are matched are controlled by the --minimum and --maximum options. None of the hexadecimal numbers displayed will have any less or more digits that those specified with these options. The default minimum is `4' digits and the default maximum is `8' digits. Note also that the hexwords command supports the --help and --version options in common with the other mpatrol command line tools.
The hexwords command currently makes use of several UNIX text processing commands in order to extract the words and their hexadecimal equivalents. As a result, the hexwords command is only likely to work on UNIX platforms or on systems which have the necessary commands installed.