/[pcre]/code/trunk/pcregrep.c
ViewVC logotype

Diff of /code/trunk/pcregrep.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 421 by ph10, Fri Aug 14 15:43:27 2009 UTC revision 422 by ph10, Fri Aug 14 16:42:55 2009 UTC
# Line 210  static option_item optionlist[] = { Line 210  static option_item optionlist[] = {
210    { OP_OP_STRING, N_COLOUR, &colour_option,    "colour=option", "matched text colour option" },    { OP_OP_STRING, N_COLOUR, &colour_option,    "colour=option", "matched text colour option" },
211    { OP_STRING,    'D',      &DEE_option,       "devices=action","how to handle devices, FIFOs, and sockets" },    { OP_STRING,    'D',      &DEE_option,       "devices=action","how to handle devices, FIFOs, and sockets" },
212    { OP_STRING,    'd',      &dee_option,       "directories=action", "how to handle directories" },    { OP_STRING,    'd',      &dee_option,       "directories=action", "how to handle directories" },
213    { OP_PATLIST,   'e',      NULL,              "regex(p)",      "specify pattern (may be used more than once)" },    { OP_PATLIST,   'e',      NULL,              "regex(p)=pattern", "specify pattern (may be used more than once)" },
214    { OP_NODATA,    'F',      NULL,              "fixed-strings", "patterns are sets of newline-separated strings" },    { OP_NODATA,    'F',      NULL,              "fixed-strings", "patterns are sets of newline-separated strings" },
215    { OP_STRING,    'f',      &pattern_filename, "file=path",     "read patterns from file" },    { OP_STRING,    'f',      &pattern_filename, "file=path",     "read patterns from file" },
216    { OP_NODATA,    N_FOFFSETS, NULL,            "file-offsets",  "output file offsets, not text" },    { OP_NODATA,    N_FOFFSETS, NULL,            "file-offsets",  "output file offsets, not text" },
# Line 1929  for (i = 1; i < argc; i++) Line 1929  for (i = 1; i < argc; i++)
1929      Some options have variations in the long name spelling: specifically, we      Some options have variations in the long name spelling: specifically, we
1930      allow "regexp" because GNU grep allows it, though I personally go along      allow "regexp" because GNU grep allows it, though I personally go along
1931      with Jeffrey Friedl and Larry Wall in preferring "regex" without the "p".      with Jeffrey Friedl and Larry Wall in preferring "regex" without the "p".
1932      These options are entered in the table as "regex(p)". No option is in both      These options are entered in the table as "regex(p)". Options can be in
1933      these categories, fortunately. */      both these categories. */
1934    
1935      for (op = optionlist; op->one_char != 0; op++)      for (op = optionlist; op->one_char != 0; op++)
1936        {        {
1937        char *opbra = strchr(op->long_name, '(');        char *opbra = strchr(op->long_name, '(');
1938        char *equals = strchr(op->long_name, '=');        char *equals = strchr(op->long_name, '=');
1939        if (opbra == NULL)     /* Not a (p) case */  
1940          /* Handle options with only one spelling of the name */
1941    
1942          if (opbra == NULL)     /* Does not contain '(' */
1943          {          {
1944          if (equals == NULL)  /* Not thing=data case */          if (equals == NULL)  /* Not thing=data case */
1945            {            {
# Line 1958  for (i = 1; i < argc; i++) Line 1961  for (i = 1; i < argc; i++)
1961              }              }
1962            }            }
1963          }          }
1964        else                   /* Special case xxxx(p) */  
1965          /* Handle options with an alternate spelling of the name */
1966    
1967          else
1968          {          {
1969          char buff1[24];          char buff1[24];
1970          char buff2[24];          char buff2[24];
1971    
1972          int baselen = opbra - op->long_name;          int baselen = opbra - op->long_name;
1973            int fulllen = strchr(op->long_name, ')') - op->long_name + 1;
1974            int arglen = (argequals == NULL || equals == NULL)?
1975              (int)strlen(arg) : argequals - arg;
1976    
1977          sprintf(buff1, "%.*s", baselen, op->long_name);          sprintf(buff1, "%.*s", baselen, op->long_name);
1978          sprintf(buff2, "%s%.*s", buff1,          sprintf(buff2, "%s%.*s", buff1, fulllen - baselen - 2, opbra + 1);
1979            (int)strlen(op->long_name) - baselen - 2, opbra + 1);  
1980          if (strcmp(arg, buff1) == 0 || strcmp(arg, buff2) == 0)          if (strncmp(arg, buff1, arglen) == 0 ||
1981               strncmp(arg, buff2, arglen) == 0)
1982              {
1983              if (equals != NULL && argequals != NULL)
1984                {
1985                option_data = argequals;
1986                if (*option_data == '=')
1987                  {
1988                  option_data++;
1989                  longopwasequals = TRUE;
1990                  }
1991                }
1992            break;            break;
1993              }
1994          }          }
1995        }        }
1996    
# Line 1978  for (i = 1; i < argc; i++) Line 2001  for (i = 1; i < argc; i++)
2001        }        }
2002      }      }
2003    
   
2004    /* Jeffrey Friedl's debugging harness uses these additional options which    /* Jeffrey Friedl's debugging harness uses these additional options which
2005    are not in the right form for putting in the option table because they use    are not in the right form for putting in the option table because they use
2006    only one hyphen, yet are more than one character long. By putting them    only one hyphen, yet are more than one character long. By putting them

Legend:
Removed from v.421  
changed lines
  Added in v.422

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12