[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] vgrind



Here is a patch to vgrind to do the following:

- fix segfault when using vgrind on sparc64/current. Attempted access
  to _start variable segfaults the process. Checked NetBSD and found 
  they had already fixed this problem by renaming the _start variable.
  They also renamed _escaped and I have mimic'ed the behavior. Used 
  the same names to reduce diff size.
- fix many comment typos
- fix typo ':' -> ';' in the RETEST subdir (not built by default), 
  noticed while going through NetBSD's CVS tree. This had prevented
  the retest binary from building.

A quick test shows the output the same as a i386/3.2 machine for a
tested input. Not able to do much more testing than that right now 
though so it would probably not hurt to double check.

Reproducing the segfault should be as simple as:

$ vgrind /usr/src/Makefile		 [any file will do]
Segmentation fault (core dumped)


-b 

Index: usr.bin/vgrind/extern.h
===================================================================
RCS file: /cvs/src/usr.bin/vgrind/extern.h,v
retrieving revision 1.3
diff -u -r1.3 extern.h
--- usr.bin/vgrind/extern.h	16 Feb 2002 21:27:56 -0000	1.3
+++ usr.bin/vgrind/extern.h	19 Feb 2003 05:39:10 -0000
@@ -39,8 +39,8 @@
 
 typedef int boolean;
 
-extern boolean	 _escaped;             /* if last character was an escape */
-extern char    *_start;                /* start of the current string */
+extern boolean	 x_escaped;             /* if last character was an escape */
+extern char    *x_start;                /* start of the current string */
 extern char    *l_acmbeg;              /* string introducing a comment */
 extern char    *l_acmend;              /* string ending a comment */
 extern char    *l_blkbeg;              /* string begining of a block */
Index: usr.bin/vgrind/regexp.c
===================================================================
RCS file: /cvs/src/usr.bin/vgrind/regexp.c,v
retrieving revision 1.4
diff -u -r1.4 regexp.c
--- usr.bin/vgrind/regexp.c	16 Feb 2002 21:27:56 -0000	1.4
+++ usr.bin/vgrind/regexp.c	19 Feb 2003 05:39:10 -0000
@@ -59,8 +59,8 @@
 
 static void	expconv(void);
 
-boolean	 _escaped;	/* true if we are currently _escaped */
-char	*_start;	/* start of string */
+boolean	 x_escaped;	/* true if we are currently x_escaped */
+char	*x_start;	/* start of string */
 boolean	 l_onecase;	/* true if upper and lower equivalent */
 
 #define makelower(c) (isupper((c)) ? tolower((c)) : (c))
@@ -101,14 +101,14 @@
  *	internal format.
  *
  *	Either meta symbols (\a \d or \p) or character strings or
- *	operations ( alternation or perenthesizing ) can be
+ *	operations ( alternation or parenthesizing ) can be
  *	specified.  Each starts with a descriptor byte.  The descriptor
  *	byte has STR set for strings, META set for meta symbols
  *	and OPER set for operations.
  *	The descriptor byte can also have the OPT bit set if the object
  *	defined is optional.  Also ALT can be set to indicate an alternation.
  *
- *	For metasymbols the byte following the descriptor byte identities
+ *	For metasymbols the byte following the descriptor byte identifies
  *	the meta symbol (containing an ascii 'a', 'd', 'p', '|', or '(').  For
  *	strings the byte after the descriptor is a character count for
  *	the string:
@@ -183,7 +183,7 @@
 {
     char *cs;		/* pointer to current symbol in converted exp */
     char c;		/* character being processed */
-    char *acs;		/* pinter to last alternate */
+    char *acs;		/* pointer to last alternate */
     int temp;
 
     /* let the conversion begin */
@@ -269,7 +269,7 @@
 	    OCNT(cs) = ccre - cs;		/* offset to next symbol */
 	    break;
 
-	/* reurn from a recursion */
+	/* return from a recursion */
 	case ')':
 	    if (acs != NIL) {
 		do {
@@ -301,7 +301,7 @@
 	    acs = cs;	/* remember that the pointer is to be filles */
 	    break;
 
-	/* if its not a metasymbol just build a scharacter string */
+	/* if its not a metasymbol just build a character string */
 	default:
 	    if (cs == NIL || (*cs & STR) == 0) {
 		cs = ccre;
@@ -324,11 +324,11 @@
     }
     return;
 }
-/* end of convertre */
+/* end of converter */
 
 
 /*
- *	The following routine recognises an irregular expresion
+ *	The following routine recognises an irregular expression
  *	with the following special characters:
  *
  *		\?	-	means last match was optional
@@ -457,7 +457,7 @@
 			return (ptr);
 		    } else if (ptr != NIL && (*cs & OPT)) {
 
-			/* it was aoptional so no match is ok */
+			/* it was optional so no match is ok */
 			return (ptr);
 		    } else if (ptr != NIL) {
 
@@ -467,9 +467,9 @@
 		    if (!isalnum(*s1) && *s1 != '_')
 			return (NIL);
 		    if (*s1 == '\\')
-			_escaped = _escaped ? FALSE : TRUE;
+			x_escaped = x_escaped ? FALSE : TRUE;
 		    else
-			_escaped = FALSE;
+			x_escaped = FALSE;
 		} while (*s1++);
 		return (NIL);
 
@@ -489,7 +489,7 @@
 			return (ptr);
 		    } else if (ptr != NIL && (*cs & OPT)) {
 
-			/* it was aoptional so no match is ok */
+			/* it was optional so no match is ok */
 			return (ptr);
 		    } else if (ptr != NIL) {
 
@@ -497,15 +497,15 @@
 			return (NIL);
 		    }
 		    if (*s1 == '\\')
-			_escaped = _escaped ? FALSE : TRUE;
+			x_escaped = x_escaped ? FALSE : TRUE;
 		    else
-			_escaped = FALSE;
+			x_escaped = FALSE;
 		} while (*s1++);
 		return (NIL);
 
-	    /* fail if we are currently _escaped */
+	    /* fail if we are currently x_escaped */
 	    case 'e':
-		if (_escaped)
+		if (x_escaped)
 		    return(NIL);
 		cs = MNEXT(cs); 
 		break;
@@ -515,7 +515,7 @@
 		ptr = s;
 		while (*s == ' ' || *s == '\t')
 		    s++;
-		if (s != ptr || s == _start) {
+		if (s != ptr || s == x_start) {
 
 		    /* match, be happy */
 		    matched = 1;
@@ -567,7 +567,7 @@
 
 	    /* check for start of line */
 	    case '^':
-		if (s == _start) {
+		if (s == x_start) {
 
 		    /* match, be happy */
 		    matched = 1;
Index: usr.bin/vgrind/vfontedpr.c
===================================================================
RCS file: /cvs/src/usr.bin/vgrind/vfontedpr.c,v
retrieving revision 1.6
diff -u -r1.6 vfontedpr.c
--- usr.bin/vgrind/vfontedpr.c	16 Feb 2002 21:27:56 -0000	1.6
+++ usr.bin/vgrind/vfontedpr.c	19 Feb 2003 05:39:10 -0000
@@ -1,5 +1,5 @@
 /*	$OpenBSD: vfontedpr.c,v 1.6 2002/02/16 21:27:56 millert Exp $	*/
-/*	$NetBSD: vfontedpr.c,v 1.4 1996/03/21 18:08:30 jtc Exp $	*/
+/*	$NetBSD: vfontedpr.c,v 1.7 1998/12/19 23:41:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -289,7 +289,7 @@
 	incomm = FALSE;
 	instr = FALSE;
 	inchr = FALSE;
-	_escaped = FALSE;
+	x_escaped = FALSE;
 	blklevel = 0;
 	for (psptr=0; psptr<PSMAX; psptr++) {
 	    pstack[psptr][0] = NULL;
@@ -365,8 +365,8 @@
     char *blksptr;			/* end of a lexical block start */
     char *blkeptr;			/* end of a lexical block end */
 
-    _start = os;			/* remember the start for expmatch */
-    _escaped = FALSE;
+    x_start = os;			/* remember the start for expmatch */
+    x_escaped = FALSE;
     if (nokeyw || incomm || instr)
 	goto skip;
     if (isproc(s)) {
@@ -559,14 +559,14 @@
 	if (*start == '\t') {
 	    while (*start == '\t')
 		start++;
-	    i = tabs(_start, start) - margin / 8;
+	    i = tabs(x_start, start) - margin / 8;
 	    printf("\\h'|%dn'", i * 10 + 1 - margin % 8);
 	    continue;
 	}
 
 	if (!nokeyw && !force)
 	    if ((*start == '#' || isidchr(*start)) 
-	    && (start == _start || !isidchr(start[-1]))) {
+	    && (start == x_start || !isidchr(start[-1]))) {
 		i = iskw(start);
 		if (i > 0) {
 		    ps("\\*(+K");
Index: usr.bin/vgrind/vgrindefs.c
===================================================================
RCS file: /cvs/src/usr.bin/vgrind/vgrindefs.c,v
retrieving revision 1.3
diff -u -r1.3 vgrindefs.c
--- usr.bin/vgrind/vgrindefs.c	19 Nov 2001 19:02:17 -0000	1.3
+++ usr.bin/vgrind/vgrindefs.c	19 Feb 2003 05:39:10 -0000
@@ -308,7 +308,7 @@
 }
 
 /*
- * Tdecode does the grung work to decode the
+ * Tdecode does the grunt work to decode the
  * string capability escapes.
  */
 static char *
Index: usr.bin/vgrind/RETEST/retest.c
===================================================================
RCS file: /cvs/src/usr.bin/vgrind/RETEST/retest.c,v
retrieving revision 1.3
diff -u -r1.3 retest.c
--- usr.bin/vgrind/RETEST/retest.c	24 Feb 2002 01:24:24 -0000	1.3
+++ usr.bin/vgrind/RETEST/retest.c	19 Feb 2003 05:39:10 -0000
@@ -44,14 +44,14 @@
 #if 0
 static char sccsid[] = "@(#)retest.c	8.1 (Berkeley) 6/6/93";
 #endif
-static char rcsid[] = "$OpenBSD: retest.c,v 1.3 2002/02/24 01:24:24 pvalchev Exp $":
+static char rcsid[] = "$OpenBSD: retest.c,v 1.3 2002/02/24 01:24:24 pvalchev Exp $";
 #endif /* not lint */
 
 #include <ctype.h>
 
 int l_onecase = 0;
-char * _start;
-char * _escaped;
+char * x_start;
+char * x_escaped;
 char * convexp();
 char * expmatch();
 main()
@@ -98,8 +98,8 @@
 	    if (str[0] == '#')
 		break;
 	    matstr[0] = 0;
-	    _start = str;
-	    _escaped = 0;
+	    x_start = str;
+	    x_escaped = 0;
 	    match = expmatch (str, ireg, matstr);
 	    if (match == 0)
 		printf ("FAILED\n");



Visit your host, monkey.org