Hello,
I believe I have found a bug of lid command.

The range specification of the -F option of lid(1) is not correctly interpreted.

1. Situation of the trouble
---------------------------

% cat frequency.txt
one
two two
three three three
four four four four
% mkid frequency.txt 
% lid -F '2..'
two            frequency.txt            <= It seems 2. It should be >= 2
% lid -F '..2'
one            frequency.txt            <= It seems 1. It should be <= 2

2. Correction of the trouble
----------------------------

o Fixed version

% lid -F '2..'
four           frequency.txt
three          frequency.txt
two            frequency.txt
% lid -F '..2'
one            frequency.txt
two            frequency.txt

Here is the patch.
Thank you for your great tool.

*** lid.c.org   Tue May 17 12:54:08 2011
--- lid.c       Tue May 17 12:51:28 2011
***************
*** 1087,1092 ****
--- 1087,1094 ----
  void
  parse_frequency_arg (char const *arg)
  {
+   int range = 0;
+ 
    if (strnequ (arg, "..", 2))
      frequency_low = 1;
    else
***************
*** 1094,1105 ****
        frequency_low = atoi (arg);
        while (isdigit (*arg))
        arg++;
!       if (strnequ (arg, "..", 2))
!       arg += 2;
      }
    if (*arg)
      frequency_high = atoi (arg);
!   else if (strnequ (&arg[-1], "..", 2))
      frequency_high = USHRT_MAX;
    else
      frequency_high = frequency_low;
--- 1096,1110 ----
        frequency_low = atoi (arg);
        while (isdigit (*arg))
        arg++;
!     }
!   if (strnequ (arg, "..", 2))
!     {
!       range = 1;
!       arg += 2;
      }
    if (*arg)
      frequency_high = atoi (arg);
!   else if (range)
      frequency_high = USHRT_MAX;
    else
      frequency_high = frequency_low;
--
Shigio YAMAGUCHI <shi...@gnu.org>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

_______________________________________________
bug-idutils mailing list
bug-idutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-idutils

Reply via email to