|
From: Hans-Bernhard B. <br...@us...> - 2004-01-08 14:07:26
|
Update of /cvsroot/cscope/cscope/src
In directory sc8-pr-cvs1:/tmp/cvs-serv3072/src
Modified Files:
alloc.c build.c command.c display.c find.c global.h main.c
scanner.l
Log Message:
Fix SF bugs #419510 and 508060.
Index: alloc.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/alloc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** alloc.c 28 Jul 2002 15:40:07 -0000 1.5
--- alloc.c 8 Jan 2004 14:07:20 -0000 1.6
***************
*** 88,93 ****
{
if (p == NULL) {
! (void) fprintf(stderr, "\n%s: out of storage\n", argv0);
! myexit(1);
}
return(p);
--- 88,93 ----
{
if (p == NULL) {
! postfatal("\n%s: out of storage\n", argv0);
! /* NOTREACHED */
}
return(p);
Index: build.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/build.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** build.c 29 Apr 2003 14:13:53 -0000 1.5
--- build.c 8 Jan 2004 14:07:20 -0000 1.6
***************
*** 316,321 ****
/* reopen the old cross-reference file for fast scanning */
if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
! (void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
! myexit(1);
}
/* get the first file name in the old cross-reference */
--- 316,321 ----
/* reopen the old cross-reference file for fast scanning */
if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
! postfatal("cscope: cannot open file %s\n", reffile);
! /* NOTREACHED */
}
/* get the first file name in the old cross-reference */
***************
*** 331,336 ****
/* open the new cross-reference file */
if ((newrefs = myfopen(newreffile, "wb")) == NULL) {
! (void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
! myexit(1);
}
if (invertedindex == YES && (postings = myfopen(temp1, "wb")) == NULL) {
--- 331,336 ----
/* open the new cross-reference file */
if ((newrefs = myfopen(newreffile, "wb")) == NULL) {
! postfatal("cscope: cannot open file %s\n", reffile);
! /* NOTREACHED */
}
if (invertedindex == YES && (postings = myfopen(temp1, "wb")) == NULL) {
***************
*** 493,502 ****
{
if (fscanf(f, "%ld", &traileroffset) != 1) {
! posterr("cscope: cannot read trailer offset from file %s\n", reffile);
! myexit(1);
}
if (fseek(f, traileroffset, SEEK_SET) == -1) {
! posterr("cscope: cannot seek to trailer in file %s\n", reffile);
! myexit(1);
}
}
--- 493,502 ----
{
if (fscanf(f, "%ld", &traileroffset) != 1) {
! postfatal("cscope: cannot read trailer offset from file %s\n", reffile);
! /* NOTREACHED */
}
if (fseek(f, traileroffset, SEEK_SET) == -1) {
! postfatal("cscope: cannot seek to trailer in file %s\n", reffile);
! /* NOTREACHED */
}
}
***************
*** 704,710 ****
if (rename(new, old) == -1) {
(void) myperror("cscope");
! posterr("cscope: cannot rename file %s to file %s\n",
! new, old);
! myexit(1);
}
}
--- 704,710 ----
if (rename(new, old) == -1) {
(void) myperror("cscope");
! postfatal("cscope: cannot rename file %s to file %s\n",
! new, old);
! /* NOTREACHED */
}
}
Index: command.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/command.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** command.c 28 Jul 2002 15:40:07 -0000 1.19
--- command.c 8 Jan 2004 14:07:20 -0000 1.20
***************
*** 110,114 ****
}
entercurses();
! postmsg(""); /* clear any previous message */
totallines = 0;
disprefs = 0;
--- 110,114 ----
}
entercurses();
! clearmsg(); /* clear any previous message */
totallines = 0;
disprefs = 0;
Index: display.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/display.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** display.c 12 Jun 2003 17:11:38 -0000 1.22
--- display.c 8 Jan 2004 14:07:20 -0000 1.23
***************
*** 122,127 ****
if (mdisprefs <= 0) {
! (void) fprintf(stderr, "%s: screen too small\n", argv0);
! myexit(1);
}
--- 122,127 ----
if (mdisprefs <= 0) {
! postfatal("%s: screen too small\n", argv0);
! /* NOTREACHED */
}
***************
*** 397,401 ****
jumpback(int sig)
{
! (void) sig; /* 'use' sig, to avoid warning from compiler */
longjmp(env, 1);
}
--- 397,403 ----
jumpback(int sig)
{
! /* HBB NEW 20031008: try whether reinstating signal handler
! * helps... */
! signal(sig, jumpback);
longjmp(env, 1);
}
***************
*** 619,624 ****
}
else {
! move(MSGLINE, 0);
! clrtoeol();
addstr(msg);
refresh();
--- 621,625 ----
}
else {
! clearmsg();
addstr(msg);
refresh();
***************
*** 627,630 ****
--- 628,642 ----
}
+ /* clearmsg clears the first message line */
+
+ void
+ clearmsg(void)
+ {
+ if (linemode == NO) {
+ move(MSGLINE, 0);
+ clrtoeol();
+ }
+ }
+
/* clearmsg2 clears the second message line */
***************
*** 649,652 ****
--- 661,665 ----
clearmsg2();
addstr(msg);
+ refresh();
}
}
***************
*** 664,670 ****
(void) vfprintf(stderr, msg, ap);
(void) fputc('\n', stderr);
! }
! else
! {
#if HAVE_VSNPRINTF
vsnprintf(errbuf, sizeof(errbuf), msg, ap);
--- 677,681 ----
(void) vfprintf(stderr, msg, ap);
(void) fputc('\n', stderr);
! } else {
#if HAVE_VSNPRINTF
vsnprintf(errbuf, sizeof(errbuf), msg, ap);
***************
*** 676,679 ****
--- 687,714 ----
}
+ /* display a fatal error mesg -- stderr *after* shutting down curses */
+ void
+ postfatal(const char *msg, ...)
+ {
+ va_list ap;
+ char errbuf[MSGLEN];
+
+ va_start(ap, msg);
+ #if HAVE_VSNPRINTF
+ vsnprintf(errbuf, sizeof(errbuf), msg, ap);
+ #else
+ vsprintf(errbuf, msg, ap);
+ #endif
+ /* restore the terminal to its original mode */
+ if (incurses == YES) {
+ exitcurses();
+ }
+
+ /* display fatal error messages */
+ fprintf(stderr,"%s",errbuf);
+
+ /* shut down */
+ myexit(1);
+ }
/* position references found file at specified line */
Index: find.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/find.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** find.c 20 Jun 2002 16:26:29 -0000 1.15
--- find.c 8 Jan 2004 14:07:20 -0000 1.16
***************
*** 792,797 ****
if (*blockp != '\n' || getrefchar() != '\n' ||
(!isdigit(getrefchar()) && fileversion >= 12)) {
! postmsg("Internal error: cannot get source line from database");
! myexit(1);
}
/* until a double newline is found */
--- 792,797 ----
if (*blockp != '\n' || getrefchar() != '\n' ||
(!isdigit(getrefchar()) && fileversion >= 12)) {
! postfatal("Internal error: cannot get source line from database");
! /* NOTREACHED */
}
/* until a double newline is found */
Index: global.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/global.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** global.h 15 Sep 2003 11:02:36 -0000 1.25
--- global.h 8 Jan 2004 14:07:20 -0000 1.26
***************
*** 338,341 ****
--- 338,342 ----
void cannotwrite(char *file);
void cannotopen(char *file);
+ void clearmsg(void);
void clearmsg2(void);
void crossref(char *srcfile);
***************
*** 370,373 ****
--- 371,375 ----
void postmsg2(char *msg);
void posterr(char *msg,...);
+ void postfatal(const char *msg,...);
void putposting(char *term, int type);
void putstring(char *s);
Index: main.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/main.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** main.c 14 Aug 2003 14:36:17 -0000 1.31
--- main.c 8 Jan 2004 14:07:20 -0000 1.32
***************
*** 54,58 ****
/* defaults for unset environment variables */
#define EDITOR "vi"
! #define HOME "/" /* no $HOME --> use root directory */
#define SHELL "sh"
#define LINEFLAG "+%s" /* default: used by vi and emacs */
--- 54,58 ----
/* defaults for unset environment variables */
#define EDITOR "vi"
! #define HOME "/" /* no $HOME --> use root directory */
#define SHELL "sh"
#define LINEFLAG "+%s" /* default: used by vi and emacs */
***************
*** 142,146 ****
/* HBB 20030814: add GNU-style --help and --version
* options */
! if (strequal(argv[0], "--help")
|| strequal(argv[0], "-h")) {
longusage();
--- 142,146 ----
/* HBB 20030814: add GNU-style --help and --version
* options */
! if (strequal(argv[0], "--help")
|| strequal(argv[0], "-h")) {
longusage();
***************
*** 170,175 ****
}
if (strlen(s) > PATLEN) {
! (void) fprintf(stderr, "cscope: pattern too long, cannot be > %d characters\n", PATLEN);
! myexit(1);
}
(void) strcpy(pattern, s);
--- 170,175 ----
}
if (strlen(s) > PATLEN) {
! postfatal("cscope: pattern too long, cannot be > %d characters\n", PATLEN);
! /* NOTREACHED */
}
(void) strcpy(pattern, s);
***************
*** 249,253 ****
reffile = s;
(void) strcpy(path, s);
! #ifdef SHORT_NAMES_ONLY
/* System V has a 14 character limit */
s = mybasename(path);
--- 249,253 ----
reffile = s;
(void) strcpy(path, s);
! #ifdef SHORT_NAMES_ONLY
/* System V has a 14 character limit */
s = mybasename(path);
***************
*** 318,323 ****
if (namefile && strcmp(namefile, "-") == 0 && !buildonly)
{
! fprintf (stderr, "cscope: Must use -b if file list comes from stdin\n");
! myexit(1);
}
--- 318,323 ----
if (namefile && strcmp(namefile, "-") == 0 && !buildonly)
{
! postfatal("cscope: Must use -b if file list comes from stdin\n");
! /* NOTREACHED */
}
***************
*** 382,386 ****
dispinit(); /* initialize display parameters */
setfield(); /* set the initial cursor position */
! postmsg(""); /* clear any build progress message */
display(); /* display the version number and input fields */
}
--- 382,386 ----
dispinit(); /* initialize display parameters */
setfield(); /* set the initial cursor position */
! clearmsg(); /* clear any build progress message */
display(); /* display the version number and input fields */
}
***************
*** 390,400 ****
if (isuptodate == YES) {
if ((oldrefs = vpfopen(reffile, "rb")) == NULL) {
! posterr("cscope: cannot open file %s\n", reffile);
! myexit(1);
}
/* get the crossref file version but skip the current directory */
if (fscanf(oldrefs, "cscope %d %*s", &fileversion) != 1) {
! posterr("cscope: cannot read file version from file %s\n", reffile);
! myexit(1);
}
if (fileversion >= 8) {
--- 390,400 ----
if (isuptodate == YES) {
if ((oldrefs = vpfopen(reffile, "rb")) == NULL) {
! postfatal("cscope: cannot open file %s\n", reffile);
! /* NOTREACHED */
}
/* get the crossref file version but skip the current directory */
if (fscanf(oldrefs, "cscope %d %*s", &fileversion) != 1) {
! postfatal("cscope: cannot read file version from file %s\n", reffile);
! /* NOTREACHED */
}
if (fileversion >= 8) {
***************
*** 434,439 ****
/* get the number of source files */
if (fscanf(oldrefs, "%d", &nsrcfiles) != 1) {
! posterr("cscope: cannot read source file size from file %s\n", reffile);
! myexit(1);
}
/* get the source file list */
--- 434,439 ----
/* get the number of source files */
if (fscanf(oldrefs, "%d", &nsrcfiles) != 1) {
! postfatal("cscope: cannot read source file size from file %s\n", reffile);
! /* NOTREACHED */
}
/* get the source file list */
***************
*** 443,448 ****
/* allocate the string space */
if (fscanf(oldrefs, "%d", &oldnum) != 1) {
! posterr("cscope: cannot read string space size from file %s\n", reffile);
! myexit(1);
}
s = (char *)mymalloc((unsigned) oldnum);
--- 443,448 ----
/* allocate the string space */
if (fscanf(oldrefs, "%d", &oldnum) != 1) {
! postfatal("cscope: cannot read string space size from file %s\n", reffile);
! /* NOTREACHED */
}
s = (char *)mymalloc((unsigned) oldnum);
***************
*** 451,456 ****
/* read the strings */
if (fread(s, oldnum, 1, oldrefs) != 1) {
! posterr("cscope: cannot read source file names from file %s\n", reffile);
! myexit(1);
}
/* change newlines to nulls */
--- 451,456 ----
/* read the strings */
if (fread(s, oldnum, 1, oldrefs) != 1) {
! postfatal("cscope: cannot read source file names from file %s\n", reffile);
! /* NOTREACHED */
}
/* change newlines to nulls */
***************
*** 490,495 ****
for (i = 0; i < nsrcfiles; ++i) {
if (fscanf(oldrefs, "%s", path) != 1) {
! posterr("cscope: cannot read source file name from file %s\n", reffile);
! myexit(1);
}
srcfiles[i] = stralloc(path);
--- 490,495 ----
for (i = 0; i < nsrcfiles; ++i) {
if (fscanf(oldrefs, "%s", path) != 1) {
! postfatal("cscope: cannot read source file name from file %s\n", reffile);
! /* NOTREACHED */
}
srcfiles[i] = stralloc(path);
***************
*** 511,516 ****
makefilelist();
if (nsrcfiles == 0) {
! posterr( "cscope: no source files found\n");
! myexit(1);
}
/* get include directories from the environment */
--- 511,516 ----
makefilelist();
if (nsrcfiles == 0) {
! postfatal("cscope: no source files found\n");
! /* NOTREACHED */
}
/* get include directories from the environment */
***************
*** 533,540 ****
initcompress();
if (linemode == NO || verbosemode == YES) /* display if verbose as well */
! postmsg("Building cross-reference...");
build();
if (linemode == NO )
! postmsg(""); /* clear any build progress message */
if (buildonly == YES) {
myexit(0);
--- 533,540 ----
initcompress();
if (linemode == NO || verbosemode == YES) /* display if verbose as well */
! postmsg("Building cross-reference...");
build();
if (linemode == NO )
! clearmsg(); /* clear any build progress message */
if (buildonly == YES) {
myexit(0);
***************
*** 682,685 ****
--- 682,686 ----
}
+ /* FIXME MTE - should use postfatal here */
void
cannotwrite(char *file)
***************
*** 731,741 ****
if (fscanf(oldrefs, "%d", &i) != 1) {
! posterr("cscope: cannot read list size from file %s\n", reffile);
! myexit(1);
}
while (--i >= 0) {
if (fscanf(oldrefs, "%*s") != 0) {
! posterr("cscope: cannot read list name from file %s\n", reffile);
! myexit(1);
}
}
--- 732,742 ----
if (fscanf(oldrefs, "%d", &i) != 1) {
! postfatal("cscope: cannot read list size from file %s\n", reffile);
! /* NOTREACHED */
}
while (--i >= 0) {
if (fscanf(oldrefs, "%*s") != 0) {
! postfatal("cscope: cannot read list name from file %s\n", reffile);
! /* NOTREACHED */
}
}
Index: scanner.l
===================================================================
RCS file: /cvsroot/cscope/cscope/src/scanner.l,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** scanner.l 26 Jun 2001 13:55:07 -0000 1.6
--- scanner.l 8 Jan 2004 14:07:20 -0000 1.7
***************
*** 104,111 ****
%}
identifier [a-zA-Z_$][a-zA-Z_0-9$]*
number \.?[0-9][.0-9a-fA-FlLuUxX]*
%start SDL
! %a 4000
%o 7000
%%
--- 104,115 ----
%}
+
+ ws [ \t\r\v\f]
+ wsnl [ \t\r\v\f\n]
identifier [a-zA-Z_$][a-zA-Z_0-9$]*
number \.?[0-9][.0-9a-fA-FlLuUxX]*
+
%start SDL
! %a 12000
%o 7000
%%
***************
*** 154,158 ****
}
}
! <SDL>STATE[ \t]+({identifier}|\*) { /* sdl state, treat as function def */
braces = 1;
fcndef = YES;
--- 158,162 ----
}
}
! <SDL>STATE{ws}+({identifier}|\*) { /* sdl state, treat as function def */
braces = 1;
fcndef = YES;
***************
*** 161,165 ****
/* NOTREACHED */
}
! <SDL>ENDSTATE[ \t] { /* end of an sdl state, treat as end of a function */
goto endstate;
/* NOTREACHED */
--- 165,169 ----
/* NOTREACHED */
}
! <SDL>ENDSTATE{ws} { /* end of an sdl state, treat as end of a function */
goto endstate;
/* NOTREACHED */
***************
*** 183,187 ****
/* NOTREACHED */
}
! \#[ \t]*endif/.*\n[ \t\n]*#[ \t]*if {
/* attempt to correct erroneous brace count caused by:
*
--- 187,191 ----
/* NOTREACHED */
}
! \#{ws}*endif/.*\n{wsnl}*#{ws}*if {
/* attempt to correct erroneous brace count caused by:
*
***************
*** 202,206 ****
/* NOTREACHED */
}
! \#[ \t]*ifn?(def)? { /* #if, #ifdef or #ifndef */
elseelif = NO;
if (pseudoelif == YES) {
--- 206,210 ----
/* NOTREACHED */
}
! \#{ws}*ifn?(def)? { /* #if, #ifdef or #ifndef */
elseelif = NO;
if (pseudoelif == YES) {
***************
*** 221,225 ****
/* NOTREACHED */
}
! \#[ \t]*el(se|if) { /* #elif or #else */
elseelif = YES;
elif:
--- 225,229 ----
/* NOTREACHED */
}
! \#{ws}*el(se|if) { /* #elif or #else */
elseelif = YES;
elif:
***************
*** 236,240 ****
/* NOTREACHED */
}
! \#[ \t]*endif { /* #endif */
endif:
if (iflevel > 0) {
--- 240,244 ----
/* NOTREACHED */
}
! \#{ws}*endif { /* #endif */
endif:
if (iflevel > 0) {
***************
*** 335,339 ****
/* NOTREACHED */
}
! \#[ \t]*define[ \t]+{identifier} {
/* preprocessor macro or constant definition */
--- 339,343 ----
/* NOTREACHED */
}
! \#{ws}*define{ws}+{identifier} {
/* preprocessor macro or constant definition */
***************
*** 352,356 ****
/* NOTREACHED */
}
! class[ \t]+{identifier}[ \t\na-zA-Z0-9_():]*\{ { /* class definition */
classdef = YES;
tagdef = 'c';
--- 356,360 ----
/* NOTREACHED */
}
! class{ws}+{identifier}({wsnl}|[a-zA-Z0-9_():])*\{ { /* class definition */
classdef = YES;
tagdef = 'c';
***************
*** 358,367 ****
/* NOTREACHED */
}
! (enum|struct|union)/([ \t\n]+{identifier})[ \t\n]*\{ { /* enum/struct/union definition */
tagdef = *(yytext + first);
goto ident;
/* NOTREACHED */
}
! (enum|struct|union)/[ \t\n]*\{ { /* tag-less e/s/u definition */
tagdef = yytext[first];
if (braces == 0) {
--- 362,371 ----
/* NOTREACHED */
}
! (enum|struct|union)/({wsnl}+{identifier}){wsnl}*\{ { /* enum/struct/union definition */
tagdef = *(yytext + first);
goto ident;
/* NOTREACHED */
}
! (enum|struct|union)/{wsnl}*\{ { /* tag-less e/s/u definition */
tagdef = yytext[first];
if (braces == 0) {
***************
*** 372,376 ****
goto more;
}
! {identifier}/[ \t]*\([ \t\na-zA-Z0-9_*&[\]=,.]*\)[ \t\n()]*[:a-zA-Z_#{] {
/* warning: "if (...)" must not overflow yytext, so the content
--- 376,380 ----
goto more;
}
! {identifier}/{ws}*\(({wsnl}|a-zA-Z0-9_*&[\]=,.])*\)({wsnl}|[()])*[:a-zA-Z_#{] {
/* warning: "if (...)" must not overflow yytext, so the content
***************
*** 390,394 ****
/* NOTREACHED */
}
! {identifier}/[ \t]*\( { /* if a function call */
fcncal: if (fcndef == YES || ppdefine == YES || rules == YES) {
token = FCNCALL;
--- 394,398 ----
/* NOTREACHED */
}
! {identifier}/{ws}*\( { /* if a function call */
fcncal: if (fcndef == YES || ppdefine == YES || rules == YES) {
token = FCNCALL;
***************
*** 403,407 ****
/* NOTREACHED */
}
! {identifier}/[* \t\n]+[a-zA-Z0-9_] { /* typedef name use */
goto ident;
/* NOTREACHED */
--- 407,411 ----
/* NOTREACHED */
}
! {identifier}/([*]|{wsnl})+[a-zA-Z0-9_] { /* typedef name use */
goto ident;
/* NOTREACHED */
***************
*** 565,571 ****
/* NOTREACHED */
}
! ^[ \t\f]+ { /* don't save leading white space */
}
! \#[ \t]*include[ \t]*["<][^"> \t\n]+ { /* #include file */
char *s;
--- 569,575 ----
/* NOTREACHED */
}
! ^{ws}+ { /* don't save leading white space */
}
! \#{ws}*include{ws}*["<][^"> \t\n]+ { /* #include file */
char *s;
***************
*** 583,587 ****
/* NOTREACHED */
}
! \#[ \t]*{identifier} | /* preprocessor keyword */
{number} | /* number */
. { /* punctuation and operators */
--- 587,591 ----
/* NOTREACHED */
}
! \#{ws}*{identifier} | /* preprocessor keyword */
{number} | /* number */
. { /* punctuation and operators */
|