From 3eedd0b4fe252f38f026ee5338ebe0ab7bec1fb0 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Mon, 5 Mar 2012 14:35:22 -0500 Subject: [PATCH] resolves: bz 799643 --- cscope-15.6-findassign.patch | 164 ++++++++++++++++++++--------------- cscope.spec | 5 +- 2 files changed, 96 insertions(+), 73 deletions(-) diff --git a/cscope-15.6-findassign.patch b/cscope-15.6-findassign.patch index d81e3e6..6d8287d 100644 --- a/cscope-15.6-findassign.patch +++ b/cscope-15.6-findassign.patch @@ -1,6 +1,19 @@ ---- cscope-15.6/src/display.c.orig 2006-09-30 04:13:00.000000000 -0400 -+++ cscope-15.6/src/display.c 2007-05-25 10:15:14.000000000 -0400 -@@ -113,6 +113,7 @@ +diff -up ./src/constants.h.orig ./src/constants.h +--- ./src/constants.h.orig 2012-03-05 14:05:26.468554970 -0500 ++++ ./src/constants.h 2012-03-05 14:04:40.606295032 -0500 +@@ -101,7 +101,7 @@ + #define REGEXP 6 + #define FILENAME 7 + #define INCLUDES 8 +-#define FIELDS 9 ++#define FIELDS 11 + + #if (BSD || V9) && !__NetBSD__ && !__FreeBSD__ + # define TERMINFO 0 /* no terminfo curses */ +diff -up ./src/display.c.orig ./src/display.c +--- ./src/display.c.orig 2012-03-05 14:05:26.479555276 -0500 ++++ ./src/display.c 2012-03-05 14:04:40.605295003 -0500 +@@ -113,6 +113,7 @@ static struct { /* text of input fields {"Find this", "file", findfile}, {"Find", "files #including this file", findinclude}, {"Find all", "function definitions", findallfcns}, /* samuel only */ @@ -8,19 +21,10 @@ }; /* Internal prototypes: */ ---- cscope-15.6/src/global.h.orig 2006-09-30 04:13:00.000000000 -0400 -+++ cscope-15.6/src/global.h 2007-05-25 10:15:14.000000000 -0400 -@@ -327,6 +327,7 @@ - char *findfile(char *dummy); - char *findinclude(char *pattern); - char *findsymbol(char *pattern); -+char *findassign(char *pattern); - char *findregexp(char *egreppat); - char *findstring(char *pattern); - char *inviewpath(char *file); ---- cscope-15.6/src/find.c.orig 2006-09-30 04:13:00.000000000 -0400 -+++ cscope-15.6/src/find.c 2007-05-25 10:15:27.000000000 -0400 -@@ -79,6 +79,8 @@ +diff -up ./src/find.c.orig ./src/find.c +--- ./src/find.c.orig 2012-03-05 14:05:26.475555165 -0500 ++++ ./src/find.c 2012-03-05 14:04:57.661762442 -0500 +@@ -79,6 +79,8 @@ static char *lcasify(char *s); static void findcalledbysub(char *file, BOOL macro); static void findterm(char *pattern); static void putline(FILE *output); @@ -29,7 +33,7 @@ static void putpostingref(POSTING *p, char *pat); static void putref(int seemore, char *file, char *func); static void putsource(int seemore, FILE *output); -@@ -88,6 +90,77 @@ +@@ -88,6 +90,77 @@ static void putsource(int seemore, FILE char * findsymbol(char *pattern) { @@ -52,51 +56,51 @@ + * assignment or not Do this by examining the next character + * or two in blockp */ + char *asgn_char = blockp; -+ int i = 1; /*skip any leading \n*/ ++ unsigned int i = 0; + -+ while(1) { -+ if (asgn_char[i] == blockmark) { -+ /* get the next block when we reach the end of -+ * the current block */ -+ asgn_char = read_block(); -+ i=0; -+ } -+ while (isspace((unsigned char) asgn_char[i])) { -+ /* skip any whitespace or \n */ -+ i++; -+ } -+ /* this next character better be one of the assignment -+ * characters, ie: =, +=, -=, *=, %=, /=, &=, |=, ^=, -+ * ~= if not, then its a notmatched case */ -+ if ((asgn_char[i] != '=') && -+ (asgn_char[i] != '+') && -+ (asgn_char[i] != '-') && -+ (asgn_char[i] != '*') && -+ (asgn_char[i] != '/') && -+ (asgn_char[i] != '%') && -+ (asgn_char[i] != '&') && -+ (asgn_char[i] != '|') && -+ (asgn_char[i] != '^') && -+ (asgn_char[i] != '~')) { -+ return NO; -+ } else { -+ /* if the first found character is = and the -+ * next found character is also =, then this -+ * is not an assignment. likewise if the -+ * first character is not = (i.e. one of the -+ * +,-,*,etc. chars and the next character is -+ * not =, then this is not an assignment */ -+ if ((((asgn_char[i] == '=') -+ && (asgn_char[i+1] == '='))) -+ || ((asgn_char[i] != '=') ++ while (isspace((unsigned char) asgn_char[i])) { ++ /* skip any whitespace or \n */ ++ i++; ++ } ++ if (asgn_char[i] == '\0') { ++ /* get the next block when we reach the end of ++ * the current block */ ++ asgn_char = read_block(); ++ if (asgn_char == NULL) return NO; ++ i=0; ++ } ++ ++ /* this next character better be one of the assignment ++ * characters, ie: =, +=, -=, *=, %=, /=, &=, |=, ^=, ++ * ~= if not, then its a notmatched case */ ++ if ((asgn_char[i] != '=') && ++ (asgn_char[i] != '+') && ++ (asgn_char[i] != '-') && ++ (asgn_char[i] != '*') && ++ (asgn_char[i] != '/') && ++ (asgn_char[i] != '%') && ++ (asgn_char[i] != '&') && ++ (asgn_char[i] != '|') && ++ (asgn_char[i] != '^') && ++ (asgn_char[i] != '~')) { ++ return NO; ++ } else { ++ /* if the first found character is = and the ++ * next found character is also =, then this ++ * is not an assignment. likewise if the ++ * first character is not = (i.e. one of the ++ * +,-,*,etc. chars and the next character is ++ * not =, then this is not an assignment */ ++ if ((((asgn_char[i] == '=') ++ && (asgn_char[i+1] == '='))) ++ || ((asgn_char[i] != '=') + && (asgn_char[i+1] != '='))) { -+ return NO; -+ } -+ /* if we pass all these filters then this is -+ * an assignment */ -+ return YES; -+ } /* else(operator char?) */ -+ } /* while(endless) */ ++ return NO; ++ } ++ /* if we pass all these filters then this is ++ * an assignment */ ++ return YES; ++ } /* else(operator char?) */ +} + + /* The actual routine that does the work for findsymbol() and @@ -107,7 +111,7 @@ char file[PATHLEN + 1]; /* source file name */ char function[PATLEN + 1]; /* function name */ char macro[PATLEN + 1]; /* macro name */ -@@ -249,6 +322,14 @@ +@@ -249,6 +322,14 @@ findsymbol(char *pattern) if (matchrest()) { s = NULL; matched: @@ -122,14 +126,30 @@ /* output the file, function or macro, and source line */ if (strcmp(macro, global) && s != macro) { putref(0, file, macro); ---- cscope-15.6/src/constants.h.orig 2006-09-30 04:13:00.000000000 -0400 -+++ cscope-15.6/src/constants.h 2007-05-25 10:15:14.000000000 -0400 -@@ -101,7 +101,7 @@ - #define REGEXP 6 - #define FILENAME 7 - #define INCLUDES 8 --#define FIELDS 9 -+#define FIELDS 11 - - #if (BSD || V9) && !__NetBSD__ && !__FreeBSD__ - # define TERMINFO 0 /* no terminfo curses */ +@@ -260,11 +341,12 @@ findsymbol(char *pattern) + else { + putref(0, file, global); + } +- if (blockp == NULL) { +- return NULL; +- } + } + notmatched: ++ if (blockp == NULL) { ++ return NULL; ++ } ++ fcndef = NO; + cp = blockp; + } + } +diff -up ./src/global.h.orig ./src/global.h +--- ./src/global.h.orig 2012-03-05 14:05:26.471555052 -0500 ++++ ./src/global.h 2012-03-05 14:04:40.605295003 -0500 +@@ -343,6 +343,7 @@ char *finddef(char *pattern); + char *findfile(char *dummy); + char *findinclude(char *pattern); + char *findsymbol(char *pattern); ++char *findassign(char *pattern); + char *findregexp(char *egreppat); + char *findstring(char *pattern); + char *inviewpath(char *file); diff --git a/cscope.spec b/cscope.spec index fb72ac4..dad98cb 100644 --- a/cscope.spec +++ b/cscope.spec @@ -1,7 +1,7 @@ Summary: C source code tree search and browse tool Name: cscope Version: 15.7a -Release: 8%{?dist} +Release: 9%{?dist} Source0: http://unc.dl.sourceforge.net/sourceforge/cscope/cscope-15.7a.tar.bz2 URL: http://cscope.sourceforge.net License: BSD and GPLv2+ @@ -93,6 +93,9 @@ rm -f %{emacs_lisp_path}/xcscope.el rm -f %{vim_plugin_path}/cctree.vim %changelog +* Mon Mar 05 2012 Neil Horman 15.7a-9 +- Fixed a segfault in the symbol assignment search (bz 799643) + * Fri Jan 13 2012 Fedora Release Engineering - 15.7a-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild