/[pcre]/code/tags/pcre-3.2/pgrep.c
ViewVC logotype

Diff of /code/tags/pcre-3.2/pgrep.c

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

revision 3 by nigel, Sat Feb 24 21:38:01 2007 UTC revision 35 by nigel, Sat Feb 24 21:39:05 2007 UTC
# Line 64  pgrep(FILE *in, char *name) Line 64  pgrep(FILE *in, char *name)
64  int rc = 1;  int rc = 1;
65  int linenumber = 0;  int linenumber = 0;
66  int count = 0;  int count = 0;
67  int offsets[2];  int offsets[99];
68  char buffer[BUFSIZ];  char buffer[BUFSIZ];
69    
70  while (fgets(buffer, sizeof(buffer), in) != NULL)  while (fgets(buffer, sizeof(buffer), in) != NULL)
# Line 74  while (fgets(buffer, sizeof(buffer), in) Line 74  while (fgets(buffer, sizeof(buffer), in)
74    if (length > 0 && buffer[length-1] == '\n') buffer[--length] = 0;    if (length > 0 && buffer[length-1] == '\n') buffer[--length] = 0;
75    linenumber++;    linenumber++;
76    
77    match = pcre_exec(pattern, hints, buffer, length, 0, offsets, 2) >= 0;    match = pcre_exec(pattern, hints, buffer, length, 0, 0, offsets, 99) >= 0;
78    if (match && whole_lines && offsets[1] != length) match = FALSE;    if (match && whole_lines && offsets[1] != length) match = FALSE;
79    
80    if (match != invert)    if (match != invert)
# Line 137  int i; Line 137  int i;
137  int rc = 1;  int rc = 1;
138  int options = 0;  int options = 0;
139  int errptr;  int errptr;
140  char *error;  const char *error;
141  BOOL filenames = TRUE;  BOOL filenames = TRUE;
142    
143  /* Process the options */  /* Process the options */
# Line 172  if (i >= argc) return usage(0); Line 172  if (i >= argc) return usage(0);
172    
173  /* Compile the regular expression. */  /* Compile the regular expression. */
174    
175  pattern = pcre_compile(argv[i++], options, &error, &errptr);  pattern = pcre_compile(argv[i++], options, &error, &errptr, NULL);
176  if (pattern == NULL)  if (pattern == NULL)
177    {    {
178    fprintf(stderr, "pgrep: error in regex at offset %d: %s\n", errptr, error);    fprintf(stderr, "pgrep: error in regex at offset %d: %s\n", errptr, error);

Legend:
Removed from v.3  
changed lines
  Added in v.35

  ViewVC Help
Powered by ViewVC 1.1.5