/[global]/global/global/global.c
ViewVC logotype

Diff of /global/global/global.c

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

revision 1.124 by shigio, Thu Nov 17 03:59:40 2005 UTC revision 1.125 by shigio, Sat Nov 19 00:14:09 2005 UTC
# Line 87  int xflag;                             /* [option]             */ Line 87  int xflag;                             /* [option]             */
87  int show_version;  int show_version;
88  int show_help;  int show_help;
89  int show_filter;                        /* undocumented command */  int show_filter;                        /* undocumented command */
90    int nofilter;
91    int nosource;                           /* undocumented command */
92  int debug;  int debug;
93  int devel;  int devel;
94  int fileid;  int fileid;
# Line 107  help(void) Line 109  help(void)
109          exit(0);          exit(0);
110  }  }
111    
112    #define SORT_FILTER     1
113    #define PATH_FILTER     2
114    #define BOTH_FILTER     (SORT_FILTER|PATH_FILTER)
115    #define SHOW_FILTER     128
116    
117  static struct option const long_options[] = {  static struct option const long_options[] = {
118          {"absolute", no_argument, NULL, 'a'},          {"absolute", no_argument, NULL, 'a'},
119          {"completion", no_argument, NULL, 'c'},          {"completion", no_argument, NULL, 'c'},
120          {"regexp", required_argument, NULL, 'e'},          {"regexp", required_argument, NULL, 'e'},
121          {"file", no_argument, NULL, 'f'},          {"file", no_argument, NULL, 'f'},
122          {"local", no_argument, NULL, 'l'},          {"local", no_argument, NULL, 'l'},
123          {"nofilter", no_argument, NULL, 'n'},          {"nofilter", optional_argument, NULL, 'n'},
124          {"grep", no_argument, NULL, 'g'},          {"grep", no_argument, NULL, 'g'},
125          {"basic-regexp", no_argument, NULL, 'G'},          {"basic-regexp", no_argument, NULL, 'G'},
126          {"ignore-case", no_argument, NULL, 'i'},          {"ignore-case", no_argument, NULL, 'i'},
127          {"idutils", optional_argument, NULL, 'I'},          {"idutils", no_argument, NULL, 'I'},
128          {"other", no_argument, NULL, 'o'},          {"other", no_argument, NULL, 'o'},
129          {"print-dbpath", no_argument, NULL, 'p'},          {"print-dbpath", no_argument, NULL, 'p'},
130          {"path", no_argument, NULL, 'P'},          {"path", no_argument, NULL, 'P'},
# Line 137  static struct option const long_options[ Line 144  static struct option const long_options[
144          {"fileid", no_argument, &fileid, 1},          {"fileid", no_argument, &fileid, 1},
145          {"version", no_argument, &show_version, 1},          {"version", no_argument, &show_version, 1},
146          {"help", no_argument, &show_help, 1},          {"help", no_argument, &show_help, 1},
147          {"filter", no_argument, &show_filter, 1},          {"filter", optional_argument, NULL, SHOW_FILTER},
148            {"nosource", no_argument, &nosource, 1},
149          { 0 }          { 0 }
150  };  };
151    
# Line 189  main(int argc, char **argv) Line 197  main(int argc, char **argv)
197                          break;                          break;
198                  case 'n':                  case 'n':
199                          nflag++;                          nflag++;
200                            if (optarg) {
201                                    if (!strcmp(optarg, "sort"))
202                                            nofilter = SORT_FILTER;
203                                    else if (!strcmp(optarg, "path"))
204                                            nofilter = PATH_FILTER;
205                            } else {
206                                    nofilter = BOTH_FILTER;;
207                            }
208                          break;                          break;
209                  case 'g':                  case 'g':
210                          gflag++;                          gflag++;
# Line 241  main(int argc, char **argv) Line 257  main(int argc, char **argv)
257                  case 'x':                  case 'x':
258                          xflag++;                          xflag++;
259                          break;                          break;
260                    case SHOW_FILTER:
261                            if (optarg) {
262                                    if (!strcmp(optarg, "sort"))
263                                            show_filter = SORT_FILTER;
264                                    else if (!strcmp(optarg, "path"))
265                                            show_filter = PATH_FILTER;
266                            } else {
267                                    show_filter = BOTH_FILTER;
268                            }
269                            break;
270                  default:                  default:
271                          usage();                          usage();
272                          break;                          break;
# Line 298  main(int argc, char **argv) Line 324  main(int argc, char **argv)
324                  lflag = 0;                  lflag = 0;
325          if (tflag)          if (tflag)
326                  xflag = 0;                  xflag = 0;
327            if (nflag > 1)
328                    nosource = 1;   /* to keep compatibility */
329          /*          /*
330           * remove leading blanks.           * remove leading blanks.
331           */           */
# Line 487  main(int argc, char **argv) Line 515  main(int argc, char **argv)
515           * print filter.           * print filter.
516           */           */
517          if (show_filter) {          if (show_filter) {
518                  STRBUF  *sb = strbuf_open(0);                  STRBUF  *sb;
519    
520                  makefilter(sb);                  switch (show_filter) {
521                  fprintf(stdout, "%s\n", strbuf_value(sb));                  case SORT_FILTER:
522                  strbuf_close(sb);                          if (!(nofilter & SORT_FILTER))
523                                    fprintf(stdout, "%s\n", strbuf_value(sortfilter));
524                            break;
525                    case PATH_FILTER:
526                            if (!(nofilter & PATH_FILTER))
527                                    fprintf(stdout, "%s\n", strbuf_value(pathfilter));
528                            break;
529                    case BOTH_FILTER:
530                            sb = strbuf_open(0);
531                            makefilter(sb);
532                            fprintf(stdout, "%s\n", strbuf_value(sb));
533                            strbuf_close(sb);
534                            break;
535                    default:
536                            die("internal error in show_filter.");
537                    }
538                  exit(0);                  exit(0);
539          }          }
540          /*          /*
# Line 599  main(int argc, char **argv) Line 642  main(int argc, char **argv)
642  void  void
643  makefilter(STRBUF *sb)  makefilter(STRBUF *sb)
644  {  {
645          if (!nflag) {          int set_sortfilter = 0;
646    
647            if (!(nofilter & SORT_FILTER) && strbuf_getlen(sortfilter)) {
648                  strbuf_puts(sb, strbuf_value(sortfilter));                  strbuf_puts(sb, strbuf_value(sortfilter));
649                  if (strbuf_getlen(sortfilter) && strbuf_getlen(pathfilter))                  set_sortfilter = 1;
650            }
651            if (!(nofilter & PATH_FILTER) && strbuf_getlen(pathfilter)) {
652                    if (set_sortfilter)
653                          strbuf_puts(sb, " | ");                          strbuf_puts(sb, " | ");
654                  strbuf_puts(sb, strbuf_value(pathfilter));                  strbuf_puts(sb, strbuf_value(pathfilter));
655          }          }
# Line 1086  search(const char *pattern, const char * Line 1134  search(const char *pattern, const char *
1134          /*          /*
1135           * search through tag file.           * search through tag file.
1136           */           */
1137          if (nflag > 1)          if (nosource)
1138                  flags |= GTOP_NOSOURCE;                  flags |= GTOP_NOSOURCE;
1139          if (iflag) {          if (iflag) {
1140                  if (!isregex(pattern)) {                  if (!isregex(pattern)) {

Legend:
Removed from v.1.124  
changed lines
  Added in v.1.125

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26