From: Hans-Bernhard B. <br...@us...> - 2005-08-16 20:05:43
|
Update of /cvsroot/cscope/cscope/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19786/src Modified Files: main.c Log Message: Print number of references found in verbose line mode, before the actual list. Index: main.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/main.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** main.c 8 Jul 2005 11:00:21 -0000 1.37 --- main.c 16 Aug 2005 20:05:35 -0000 1.38 *************** *** 191,195 **** /* NOTREACHED */ } ! (void) strcpy(Pattern, s); goto nextarg; } --- 191,195 ---- /* NOTREACHED */ } ! strcpy(Pattern, s); goto nextarg; } *************** *** 259,263 **** } if (*s == '\0') { ! (void) fprintf(stderr, "%s: -%c option: missing or empty value\n", argv0, c); goto usage; --- 259,263 ---- } if (*s == '\0') { ! fprintf(stderr, "%s: -%c option: missing or empty value\n", argv0, c); goto usage; *************** *** 266,270 **** case 'f': /* alternate cross-reference file */ reffile = s; ! (void) strcpy(path, s); #ifdef SHORT_NAMES_ONLY /* System V has a 14 character limit */ --- 266,270 ---- case 'f': /* alternate cross-reference file */ reffile = s; ! strcpy(path, s); #ifdef SHORT_NAMES_ONLY /* System V has a 14 character limit */ *************** *** 275,281 **** #endif s = path + strlen(path); ! (void) strcpy(s, ".in"); invname = stralloc(path); ! (void) strcpy(s, ".po"); invpost = stralloc(path); break; --- 275,281 ---- #endif s = path + strlen(path); ! strcpy(s, ".in"); invname = stralloc(path); ! strcpy(s, ".po"); invpost = stralloc(path); break; *************** *** 291,295 **** case 'p': /* file path components to display */ if (*s < '0' || *s > '9' ) { ! (void) fprintf(stderr, "%s: -p option: missing or invalid numeric value\n", argv0); goto usage; --- 291,295 ---- case 'p': /* file path components to display */ if (*s < '0' || *s > '9' ) { ! fprintf(stderr, "%s: -p option: missing or invalid numeric value\n", argv0); goto usage; *************** *** 312,320 **** #endif default: ! (void) fprintf(stderr, "%s: unknown option: -%c\n", argv0, *s); usage: ! (void) usage(); ! (void) fprintf(stderr, "Try the -h option for more information.\n"); myexit(1); } --- 312,320 ---- #endif default: ! fprintf(stderr, "%s: unknown option: -%c\n", argv0, *s); usage: ! usage(); ! fprintf(stderr, "Try the -h option for more information.\n"); myexit(1); } *************** *** 351,355 **** orig_umask = umask(S_IRWXG|S_IRWXO); pid = getpid(); ! (void) sprintf(tempdirpv, "%s/cscope.%d", tmpdir, pid); if(mkdir(tempdirpv,S_IRWXU)) { --- 351,355 ---- orig_umask = umask(S_IRWXG|S_IRWXO); pid = getpid(); ! sprintf(tempdirpv, "%s/cscope.%d", tmpdir, pid); if(mkdir(tempdirpv,S_IRWXU)) { *************** *** 359,373 **** umask(orig_umask); ! (void) sprintf(temp1, "%s/cscope.1", tempdirpv, pid); ! (void) sprintf(temp2, "%s/cscope.2", tempdirpv, pid); /* if running in the foreground */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) { /* cleanup on the interrupt and quit signals */ ! (void) signal(SIGINT, myexit); ! (void) signal(SIGQUIT, myexit); } /* cleanup on the hangup signal */ ! (void) signal(SIGHUP, myexit); /* if the database path is relative and it can't be created */ --- 359,373 ---- umask(orig_umask); ! sprintf(temp1, "%s/cscope.1", tempdirpv, pid); ! sprintf(temp2, "%s/cscope.2", tempdirpv, pid); /* if running in the foreground */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) { /* cleanup on the interrupt and quit signals */ ! signal(SIGINT, myexit); ! signal(SIGQUIT, myexit); } /* cleanup on the hangup signal */ ! signal(SIGHUP, myexit); /* if the database path is relative and it can't be created */ *************** *** 380,389 **** * the home directory */ ! (void) sprintf(path, "%s/%s", home, reffile); if (isuptodate == NO || access(path, READ) == 0) { reffile = stralloc(path); ! (void) sprintf(path, "%s/%s", home, invname); invname = stralloc(path); ! (void) sprintf(path, "%s/%s", home, invpost); invpost = stralloc(path); } --- 380,389 ---- * the home directory */ ! sprintf(path, "%s/%s", home, reffile); if (isuptodate == NO || access(path, READ) == 0) { reffile = stralloc(path); ! sprintf(path, "%s/%s", home, invname); invname = stralloc(path); ! sprintf(path, "%s/%s", home, invpost); invpost = stralloc(path); } *************** *** 392,403 **** if (linemode == NO) { ! (void) signal(SIGINT, SIG_IGN); /* ignore interrupts */ ! (void) signal(SIGPIPE, SIG_IGN);/* | command can cause pipe signal */ /* initialize the curses display package */ ! (void) initscr(); /* initialize the screen */ entercurses(); #if TERMINFO ! (void) keypad(stdscr, TRUE); /* enable the keypad */ # ifdef HAVE_FIXKEYPAD fixkeypad(); /* fix for getch() intermittently returning garbage */ --- 392,403 ---- if (linemode == NO) { ! signal(SIGINT, SIG_IGN); /* ignore interrupts */ ! signal(SIGPIPE, SIG_IGN);/* | command can cause pipe signal */ /* initialize the curses display package */ ! initscr(); /* initialize the screen */ entercurses(); #if TERMINFO ! keypad(stdscr, TRUE); /* enable the keypad */ # ifdef HAVE_FIXKEYPAD fixkeypad(); /* fix for getch() intermittently returning garbage */ *************** *** 433,439 **** /* see if there are options in the database */ for (;;) { ! (void) getc(oldrefs); /* skip the blank */ if ((c = getc(oldrefs)) != '-') { ! (void) ungetc(c, oldrefs); break; } --- 433,439 ---- /* see if there are options in the database */ for (;;) { ! getc(oldrefs); /* skip the blank */ if ((c = getc(oldrefs)) != '-') { ! ungetc(c, oldrefs); break; } *************** *** 444,448 **** case 'q': /* quick search */ invertedindex = YES; ! (void) fscanf(oldrefs, "%ld", &totalterms); break; case 'T': /* truncate symbols to 8 characters */ --- 444,448 ---- case 'q': /* quick search */ invertedindex = YES; ! fscanf(oldrefs, "%ld", &totalterms); break; case 'T': /* truncate symbols to 8 characters */ *************** *** 474,478 **** } s = (char *)mymalloc((unsigned) oldnum); ! (void) getc(oldrefs); /* skip the newline */ /* read the strings */ --- 474,478 ---- } s = (char *)mymalloc((unsigned) oldnum); ! getc(oldrefs); /* skip the newline */ /* read the strings */ *************** *** 499,503 **** s = path + 2; /* for "-Ipath" */ if (*s == '\0') { /* if "-I path" */ ! (void) fscanf(names, "%s", path); s = path; } --- 499,503 ---- s = path + 2; /* for "-Ipath" */ if (*s == '\0') { /* if "-I path" */ ! fscanf(names, "%s", path); s = path; } *************** *** 511,515 **** } } ! (void) fclose(names); } } --- 511,515 ---- } } ! fclose(names); } } *************** *** 523,527 **** } } ! (void) fclose(oldrefs); } else { --- 523,527 ---- } } ! fclose(oldrefs); } else { *************** *** 575,591 **** if (*Pattern != '\0') { /* do any optional search */ if (search() == YES) { ! while ((c = getc(refsfound)) != EOF) { ! (void) putchar(c); ! } } } ! if (onesearch == YES) { myexit(0); ! } for (;;) { char buf[PATLEN + 2]; ! (void) printf(">> "); ! (void) fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) { myexit(0); --- 575,596 ---- if (*Pattern != '\0') { /* do any optional search */ if (search() == YES) { ! /* print the total number of lines in ! * verbose mode */ ! if (verbosemode == YES) ! printf("cscope: %d lines\n", ! totallines); ! ! while ((c = getc(refsfound)) != EOF) ! putchar(c); } } ! if (onesearch == YES) myexit(0); ! for (;;) { char buf[PATLEN + 2]; ! printf(">> "); ! fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) { myexit(0); *************** *** 607,615 **** case '9': /* samuel only */ field = *buf - '0'; ! (void) strcpy(Pattern, buf + 1); ! (void) search(); ! (void) printf("cscope: %d lines\n", totallines); while ((c = getc(refsfound)) != EOF) { ! (void) putchar(c); } break; --- 612,620 ---- case '9': /* samuel only */ field = *buf - '0'; ! strcpy(Pattern, buf + 1); ! search(); ! printf("cscope: %d lines\n", totallines); while ((c = getc(refsfound)) != EOF) { ! putchar(c); } break; *************** *** 634,652 **** case 'R': /* rebuild database samuel style */ rebuild(); ! (void) putchar('\n'); break; case 'C': /* clear file names */ freefilelist(); ! (void) putchar('\n'); break; case 'F': /* add a file name */ ! (void) strcpy(path, buf + 1); if (infilelist(path) == NO && (s = inviewpath(path)) != NULL) { addsrcfile(s); } ! (void) putchar('\n'); break; --- 639,657 ---- case 'R': /* rebuild database samuel style */ rebuild(); ! putchar('\n'); break; case 'C': /* clear file names */ freefilelist(); ! putchar('\n'); break; case 'F': /* add a file name */ ! strcpy(path, buf + 1); if (infilelist(path) == NO && (s = inviewpath(path)) != NULL) { addsrcfile(s); } ! putchar('\n'); break; *************** *** 657,661 **** default: ! (void) fprintf(stderr, "cscope: unknown command '%s'\n", buf); break; } --- 662,666 ---- default: ! fprintf(stderr, "cscope: unknown command '%s'\n", buf); break; } *************** *** 671,678 **** if (*Pattern != '\0') { atfield(); /* move to the input field */ ! (void) command(ctrl('Y')); /* search */ } else if (reflines != NULL) { /* read any symbol reference lines file */ ! (void) readrefs(reflines); } display(); /* update the display */ --- 676,683 ---- if (*Pattern != '\0') { atfield(); /* move to the input field */ ! command(ctrl('Y')); /* search */ } else if (reflines != NULL) { /* read any symbol reference lines file */ ! readrefs(reflines); } display(); /* update the display */ *************** *** 715,724 **** char msg[MSGLEN + 1]; ! (void) snprintf(msg, sizeof(msg), "Removed file %s because write failed", file); #else char *msg = mymalloc(50+strlen(file)); ! (void) sprintf(msg, "Removed file %s because write failed", file); #endif --- 720,729 ---- char msg[MSGLEN + 1]; ! snprintf(msg, sizeof(msg), "Removed file %s because write failed", file); #else char *msg = mymalloc(50+strlen(file)); ! sprintf(msg, "Removed file %s because write failed", file); #endif *************** *** 729,733 **** #endif ! (void) unlink(file); myexit(1); /* calls exit(2), which closes files */ } --- 734,738 ---- #endif ! unlink(file); myexit(1); /* calls exit(2), which closes files */ } *************** *** 776,784 **** incurses = YES; #ifndef __MSDOS__ /* HBB 20010313 */ ! (void) nonl(); /* don't translate an output \n to \n\r */ #endif ! (void) cbreak(); /* single character input */ ! (void) noecho(); /* don't echo input characters */ ! (void) clear(); /* clear the screen */ mouseinit(); /* initialize any mouse interface */ drawscrollbar(topline, nextline); --- 781,789 ---- incurses = YES; #ifndef __MSDOS__ /* HBB 20010313 */ ! nonl(); /* don't translate an output \n to \n\r */ #endif ! cbreak(); /* single character input */ ! noecho(); /* don't echo input characters */ ! clear(); /* clear the screen */ mouseinit(); /* initialize any mouse interface */ drawscrollbar(topline, nextline); *************** *** 791,849 **** { /* clear the bottom line */ ! (void) move(LINES - 1, 0); ! (void) clrtoeol(); ! (void) refresh(); /* exit curses and restore the terminal modes */ ! (void) endwin(); incurses = NO; /* restore the mouse */ mousecleanup(); ! (void) fflush(stdout); } - /* normal usage message */ static void usage(void) { ! (void) fprintf(stderr, "Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n"); ! (void) fprintf(stderr, " [-p number] [-P path] [-[0-8] pattern] [source files]\n"); } - /* long usage message */ static void longusage(void) { ! (void) usage(); ! (void) fprintf(stderr, "\n"); ! (void) fprintf(stderr, "-b Build the cross-reference only.\n"); ! (void) fprintf(stderr, "-C Ignore letter case when searching.\n"); ! (void) fprintf(stderr, "-c Use only ASCII characters in the cross-ref file (don't compress).\n"); ! (void) fprintf(stderr, "-d Do not update the cross-reference.\n"); ! (void) fprintf(stderr, "-e Suppress the <Ctrl>-e command prompt between files.\n"); ! (void) fprintf(stderr, "-F symfile Read symbol reference lines from symfile.\n"); ! (void) fprintf(stderr, "-f reffile Use reffile as cross-ref file name instead of %s.\n", REFFILE); ! (void) fprintf(stderr, "-h This help screen.\n"); ! (void) fprintf(stderr, "-I incdir Look in incdir for any #include files.\n"); ! (void) fprintf(stderr, "-i namefile Browse through files listed in namefile, instead of %s\n", NAMEFILE); ! (void) fprintf(stderr, "-k Kernel Mode - don't use %s for #include files.\n", DFLT_INCDIR); ! (void) fprintf(stderr, "-L Do a single search with line-oriented output.\n"); ! (void) fprintf(stderr, "-l Line-oriented interface.\n"); ! (void) fprintf(stderr, "-num pattern Go to input field num (counting from 0) and find pattern.\n"); ! (void) fprintf(stderr, "-P path Prepend path to relative file names in pre-built cross-ref file.\n"); ! (void) fprintf(stderr, "-p n Display the last n file path components.\n"); ! (void) fprintf(stderr, "-q Build an inverted index for quick symbol searching.\n"); ! (void) fprintf(stderr, "-R Recurse directories for files.\n"); ! (void) fprintf(stderr, "-s dir Look in dir for additional source files.\n"); ! (void) fprintf(stderr, "-T Use only the first eight characters to match against C symbols.\n"); ! (void) fprintf(stderr, "-U Check file time stamps.\n"); ! (void) fprintf(stderr, "-u Unconditionally build the cross-reference file.\n"); ! (void) fprintf(stderr, "-v Be more verbose in line mode.\n"); ! (void) fprintf(stderr, "-V Print the version number.\n"); ! (void) fprintf(stderr, "\n"); ! (void) fprintf(stderr, "Please see the manpage for more information.\n"); } --- 796,862 ---- { /* clear the bottom line */ ! move(LINES - 1, 0); ! clrtoeol(); ! refresh(); /* exit curses and restore the terminal modes */ ! endwin(); incurses = NO; /* restore the mouse */ mousecleanup(); ! fflush(stdout); } + /* normal usage message */ static void usage(void) { ! fprintf(stderr, "Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n"); ! fprintf(stderr, " [-p number] [-P path] [-[0-8] pattern] [source files]\n"); } + /* long usage message */ static void longusage(void) { ! usage(); ! fprintf(stderr, "\ ! \n\ ! -b Build the cross-reference only.\n\ ! -C Ignore letter case when searching.\n\ ! -c Use only ASCII characters in the cross-ref file (don't compress).\n\ ! -d Do not update the cross-reference.\n\ ! -e Suppress the <Ctrl>-e command prompt between files.\n\ ! -F symfile Read symbol reference lines from symfile.\n\ ! -f reffile Use reffile as cross-ref file name instead of %s.\n", ! REFFILE); ! fprintf(stderr, "\ ! -h This help screen.\n\ ! -I incdir Look in incdir for any #include files.\n\ ! -i namefile Browse through files listed in namefile, instead of %s\n", ! NAMEFILE); ! fprintf(stderr, "\ ! -k Kernel Mode - don't use %s for #include files.\n", ! DFLT_INCDIR); ! fputs("\ ! -L Do a single search with line-oriented output.\n\ ! -l Line-oriented interface.\n\ ! -num pattern Go to input field num (counting from 0) and find pattern.\n\ ! -P path Prepend path to relative file names in pre-built cross-ref file.\n\ ! -p n Display the last n file path components.\n\ ! -q Build an inverted index for quick symbol searching.\n\ ! -R Recurse directories for files.\n\ ! -s dir Look in dir for additional source files.\n\ ! -T Use only the first eight characters to match against C symbols.\n\ ! -U Check file time stamps.\n\ ! -u Unconditionally build the cross-reference file.\n\ ! -v Be more verbose in line mode.\n\ ! -V Print the version number.\n\ ! \n\ ! Please see the manpage for more information.\n", ! stderr); } *************** *** 860,866 **** /* remove any temporary files */ if (temp1[0] != '\0') { ! (void) unlink(temp1); ! (void) unlink(temp2); ! (void) rmdir(tempdirpv); } /* restore the terminal to its original mode */ --- 873,879 ---- /* remove any temporary files */ if (temp1[0] != '\0') { ! unlink(temp1); ! unlink(temp2); ! rmdir(tempdirpv); } /* restore the terminal to its original mode */ *************** *** 870,874 **** /* dump core for debugging on the quit signal */ if (sig == SIGQUIT) { ! (void) abort(); } /* HBB 20000421: be nice: free allocated data */ --- 883,887 ---- /* dump core for debugging on the quit signal */ if (sig == SIGQUIT) { ! abort(); } /* HBB 20000421: be nice: free allocated data */ |