]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
look: consider blanks as directory characters
authorKarel Zak <kzak@redhat.com>
Wed, 9 Mar 2016 14:51:28 +0000 (15:51 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Mar 2016 14:51:28 +0000 (15:51 +0100)
This change introduces regression, but it seems better than to be
incompatible with "sort -d" if we assume that "sort -d" is the right
way how to prepare files for look(1).

It seems (from man page) that the original goal has been compatibility
with sort -d, but this feature has never been fully implemented.

Addresses: https://github.com/karelzak/util-linux/issues/284
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/look.1
misc-utils/look.c

index e96a4318dcb07a0174b3b7759605dacc719015fa..4de5f0ed7b38019953df44dac1e84d48a8b21817 100644 (file)
@@ -68,12 +68,16 @@ alphabetic characters is ignored.
 Use the alternative dictionary file.
 .TP
 .BR \-d , " \-\-alphanum"
-Use normal dictionary character set and order, i.e. only alphanumeric characters
-are compared.  (This is on by default if no file is specified.)
+Use normal dictionary character set and order, i.e. only blanks and
+alphanumeric characters are compared.  This is on by default if no file is
+specified.
+
+Note that blanks have been added to dictionary character set for
+compatibility with \fBsort \-d\fR command since version 2.28.
 .TP
 .BR \-f , " \-\-ignore\-case"
-Ignore the case of alphabetic characters.  (This is on by default if no file is
-specified.)
+Ignore the case of alphabetic characters.  This is on by default if no file is
+specified.
 .TP
 .BR \-t , " \-\-terminate " \fIcharacter\fR
 Specify a string termination character, i.e. only the characters
@@ -105,10 +109,6 @@ the alternative dictionary
 .SH "SEE ALSO"
 .BR grep (1),
 .BR sort (1)
-.SH COMPATIBILITY
-The original manual page stated that tabs and blank characters participated
-in comparisons when the \fB\-\-alphanum\fR option was specified.  This was
-incorrect, and the current man page matches the historic implementation.
 .SH HISTORY
 The
 .B look
index 96a02c41d7de064973c5cec675171ca05017f6c3..f0cc1d7f1908ba9e87947e79d5bd90d0d690cf81 100644 (file)
@@ -174,7 +174,7 @@ look(char *front, char *back)
        /* Reformat string string to avoid doing it multiple times later. */
        if (dflag) {
                for (readp = writep = string; (ch = *readp++) != 0;) {
-                       if (isalnum(ch))
+                       if (isalnum(ch) || isblank(ch))
                                *(writep++) = ch;
                }
                *writep = '\0';
@@ -333,7 +333,7 @@ compare(char *s2, char *s2end) {
        p = comparbuf;
        i = stringlen;
        while(s2 < s2end && *s2 != '\n' && i) {
-               if (!dflag || isalnum(*s2))
+               if (!dflag || isalnum(*s2) || isblank(*s2))
                {
                        *p++ = *s2;
                        i--;
@@ -361,7 +361,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
 
        fputs(USAGE_OPTIONS, out);
        fputs(_(" -a, --alternative        use the alternative dictionary\n"), out);
-       fputs(_(" -d, --alphanum           compare only alphanumeric characters\n"), out);
+       fputs(_(" -d, --alphanum           compare only blanks and alphanumeric characters\n"), out);
        fputs(_(" -f, --ignore-case        ignore case differences when comparing\n"), out);
        fputs(_(" -t, --terminate <char>   define the string-termination character\n"), out);