/[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 1216 by zherczeg, Fri Nov 9 13:05:29 2012 UTC revision 1221 by ph10, Sun Nov 11 20:27:03 2012 UTC
# Line 1704  while (ptr < endptr) Line 1704  while (ptr < endptr)
1704            {            {
1705            BOOL printed = FALSE;            BOOL printed = FALSE;
1706            omstr *om;            omstr *om;
1707    
1708            for (om = only_matching; om != NULL; om = om->next)            for (om = only_matching; om != NULL; om = om->next)
1709              {              {
1710              int n = om->groupnum;              int n = om->groupnum;
# Line 1713  while (ptr < endptr) Line 1713  while (ptr < endptr)
1713                int plen = offsets[2*n + 1] - offsets[2*n];                int plen = offsets[2*n + 1] - offsets[2*n];
1714                if (plen > 0)                if (plen > 0)
1715                  {                  {
1716                  if (printed) fprintf(stdout, "%s", om_separator);                  if (printed) fprintf(stdout, "%s", om_separator);
1717                  if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string);                  if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string);
1718                  FWRITE(matchptr + offsets[n*2], 1, plen, stdout);                  FWRITE(matchptr + offsets[n*2], 1, plen, stdout);
1719                  if (do_colour) fprintf(stdout, "%c[00m", 0x1b);                  if (do_colour) fprintf(stdout, "%c[00m", 0x1b);
# Line 1721  while (ptr < endptr) Line 1721  while (ptr < endptr)
1721                  }                  }
1722                }                }
1723              }              }
1724    
1725            if (printed || printname != NULL || number) fprintf(stdout, "\n");            if (printed || printname != NULL || number) fprintf(stdout, "\n");
1726            }            }
1727    
# Line 2261  switch(letter) Line 2261  switch(letter)
2261    case 'L': filenames = FN_NOMATCH_ONLY; break;    case 'L': filenames = FN_NOMATCH_ONLY; break;
2262    case 'M': multiline = TRUE; options |= PCRE_MULTILINE|PCRE_FIRSTLINE; break;    case 'M': multiline = TRUE; options |= PCRE_MULTILINE|PCRE_FIRSTLINE; break;
2263    case 'n': number = TRUE; break;    case 'n': number = TRUE; break;
2264    
2265    case 'o':    case 'o':
2266    only_matching_last = add_number(0, only_matching_last);    only_matching_last = add_number(0, only_matching_last);
2267    if (only_matching == NULL) only_matching = only_matching_last;    if (only_matching == NULL) only_matching = only_matching_last;
2268    break;    break;
2269    
2270    case 'q': quiet = TRUE; break;    case 'q': quiet = TRUE; break;
2271    case 'r': dee_action = dee_RECURSE; break;    case 'r': dee_action = dee_RECURSE; break;
2272    case 's': silent = TRUE; break;    case 's': silent = TRUE; break;
# Line 2652  for (i = 1; i < argc; i++) Line 2652  for (i = 1; i < argc; i++)
2652      {      {
2653      char *s = argv[i] + 1;      char *s = argv[i] + 1;
2654      longop = FALSE;      longop = FALSE;
2655    
2656      while (*s != 0)      while (*s != 0)
2657        {        {
2658        for (op = optionlist; op->one_char != 0; op++)        for (op = optionlist; op->one_char != 0; op++)
# Line 2665  for (i = 1; i < argc; i++) Line 2665  for (i = 1; i < argc; i++)
2665            *s, argv[i]);            *s, argv[i]);
2666          pcregrep_exit(usage(2));          pcregrep_exit(usage(2));
2667          }          }
2668    
2669        option_data = s+1;        option_data = s+1;
2670    
2671        /* Break out if this is the last character in the string; it's handled        /* Break out if this is the last character in the string; it's handled
2672        below like a single multi-char option. */        below like a single multi-char option. */
2673    
2674        if (*option_data == 0) break;        if (*option_data == 0) break;
2675    
2676        /* Check for a single-character option that has data: OP_OP_NUMBER(S)        /* Check for a single-character option that has data: OP_OP_NUMBER(S)
2677        are used for ones that either have a numerical number or defaults, i.e.        are used for ones that either have a numerical number or defaults, i.e.
# Line 2689  for (i = 1; i < argc; i++) Line 2689  for (i = 1; i < argc; i++)
2689    
2690        /* Handle a single-character option with no data, then loop for the        /* Handle a single-character option with no data, then loop for the
2691        next character in the string. */        next character in the string. */
2692    
2693        pcre_options = handle_option(*s++, pcre_options);        pcre_options = handle_option(*s++, pcre_options);
2694        }        }
2695      }      }
2696    
2697    /* At this point we should have op pointing to a matched option. If the type    /* At this point we should have op pointing to a matched option. If the type
2698    is NO_DATA, it means that there is no data, and the option might set    is NO_DATA, it means that there is no data, and the option might set
2699    something in the PCRE options. */    something in the PCRE options. */
# Line 2708  for (i = 1; i < argc; i++) Line 2708  for (i = 1; i < argc; i++)
2708    either has a value or defaults to something. It cannot have data in a    either has a value or defaults to something. It cannot have data in a
2709    separate item. At the moment, the only such options are "colo(u)r",    separate item. At the moment, the only such options are "colo(u)r",
2710    "only-matching", and Jeffrey Friedl's special -S debugging option. */    "only-matching", and Jeffrey Friedl's special -S debugging option. */
2711    
2712    if (*option_data == 0 &&    if (*option_data == 0 &&
2713        (op->type == OP_OP_STRING || op->type == OP_OP_NUMBER ||        (op->type == OP_OP_STRING || op->type == OP_OP_NUMBER ||
2714         op->type == OP_OP_NUMBERS))         op->type == OP_OP_NUMBERS))

Legend:
Removed from v.1216  
changed lines
  Added in v.1221

  ViewVC Help
Powered by ViewVC 1.1.5