/[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 66 by nigel, Sat Feb 24 21:40:03 2007 UTC revision 67 by nigel, Sat Feb 24 21:40:13 2007 UTC
# Line 45  static BOOL whole_lines = FALSE; Line 45  static BOOL whole_lines = FALSE;
45    
46  typedef struct option_item {  typedef struct option_item {
47    int one_char;    int one_char;
48    char *long_name;    const char *long_name;
49    char *help_text;    const char *help_text;
50  } option_item;  } option_item;
51    
52  static option_item optionlist[] = {  static option_item optionlist[] = {
# Line 85  recursion support". */ Line 85  recursion support". */
85    
86  typedef DIR directory_type;  typedef DIR directory_type;
87    
88  int  static int
89  isdirectory(char *filename)  isdirectory(char *filename)
90  {  {
91  struct stat statbuf;  struct stat statbuf;
# Line 94  if (stat(filename, &statbuf) < 0) Line 94  if (stat(filename, &statbuf) < 0)
94  return ((statbuf.st_mode & S_IFMT) == S_IFDIR)? '/' : 0;  return ((statbuf.st_mode & S_IFMT) == S_IFDIR)? '/' : 0;
95  }  }
96    
97  directory_type *  static directory_type *
98  opendirectory(char *filename)  opendirectory(char *filename)
99  {  {
100  return opendir(filename);  return opendir(filename);
101  }  }
102    
103  char *  static char *
104  readdirectory(directory_type *dir)  readdirectory(directory_type *dir)
105  {  {
106  for (;;)  for (;;)
# Line 113  for (;;) Line 113  for (;;)
113  return NULL;   /* Keep compiler happy; never executed */  return NULL;   /* Keep compiler happy; never executed */
114  }  }
115    
116  void  static void
117  closedirectory(directory_type *dir)  closedirectory(directory_type *dir)
118  {  {
119  closedir(dir);  closedir(dir);
# Line 320  return rc; Line 320  return rc;
320  *************************************************/  *************************************************/
321    
322  static int  static int
323  grep_or_recurse(char *filename, BOOL recurse, BOOL show_filenames,  grep_or_recurse(char *filename, BOOL dir_recurse, BOOL show_filenames,
324    BOOL only_one_at_top)    BOOL only_one_at_top)
325  {  {
326  int rc = 1;  int rc = 1;
# Line 330  FILE *in; Line 330  FILE *in;
330  /* If the file is a directory and we are recursing, scan each file within it.  /* If the file is a directory and we are recursing, scan each file within it.
331  The scanning code is localized so it can be made system-specific. */  The scanning code is localized so it can be made system-specific. */
332    
333  if ((sep = isdirectory(filename)) != 0 && recurse)  if ((sep = isdirectory(filename)) != 0 && dir_recurse)
334    {    {
335    char buffer[1024];    char buffer[1024];
336    char *nextfile;    char *nextfile;
# Line 347  if ((sep = isdirectory(filename)) != 0 & Line 347  if ((sep = isdirectory(filename)) != 0 &
347      {      {
348      int frc;      int frc;
349      sprintf(buffer, "%.512s%c%.128s", filename, sep, nextfile);      sprintf(buffer, "%.512s%c%.128s", filename, sep, nextfile);
350      frc = grep_or_recurse(buffer, recurse, TRUE, FALSE);      frc = grep_or_recurse(buffer, dir_recurse, TRUE, FALSE);
351      if (frc == 0 && rc == 1) rc = 0;      if (frc == 0 && rc == 1) rc = 0;
352      }      }
353    

Legend:
Removed from v.66  
changed lines
  Added in v.67

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12