[cscope/f16] Resolves; bz 799643

Neil Horman nhorman at fedoraproject.org
Mon Mar 5 19:10:16 UTC 2012


commit d8a355cad3f1540a2e3989a3b80a13229cb05434
Author: Neil Horman <nhorman at tuxdriver.com>
Date:   Mon Mar 5 14:09:58 2012 -0500

    Resolves; bz 799643

 cscope-15.6-findassign.patch |  176 +++++++++++++++++++++++++-----------------
 cscope.spec                  |    5 +-
 2 files changed, 108 insertions(+), 73 deletions(-)
---
diff --git a/cscope-15.6-findassign.patch b/cscope-15.6-findassign.patch
index d81e3e6..093ab63 100644
--- a/cscope-15.6-findassign.patch
+++ b/cscope-15.6-findassign.patch
@@ -1,6 +1,31 @@
---- 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 ./doc/Makefile.in.orig ./doc/Makefile.in
+--- ./doc/Makefile.in.orig	2009-04-30 16:03:12.000000000 -0400
++++ ./doc/Makefile.in	2012-03-05 14:04:15.675611788 -0500
+@@ -158,7 +158,7 @@ sbindir = @sbindir@
+ sharedstatedir = @sharedstatedir@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+-man_MANS = cscope.1
++man_MANS = cscope.1 xcscope.1
+ EXTRA_DIST = $(man_MANS)
+ all: all-am
+ 
+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 +33,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 +45,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 +68,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 +123,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 +138,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 d3902be..69d177d 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: 7%{?dist}
+Release: 8%{?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 <nhorman at redhat.com> - 17.7a-8
+- fixed segfault on check_for_assignment (bz 799643)
+
 * Wed Jun 30 2011 Neil Horman <nhorman at redhat.com> - 15.7a-7
 - Added LEXERR token to catch bad parsing before we crash (bz717545)
 


More information about the scm-commits mailing list