Module Name:    src
Committed By:   dholland
Date:           Sun Aug 11 01:49:40 UTC 2013

Modified Files:
        src/usr.bin/tr: str.c

Log Message:
Fix another bug, relating to parsing the [=x=] syntax.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/tr/str.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tr/str.c
diff -u src/usr.bin/tr/str.c:1.27 src/usr.bin/tr/str.c:1.28
--- src/usr.bin/tr/str.c:1.27	Sun Aug 11 01:42:35 2013
+++ src/usr.bin/tr/str.c	Sun Aug 11 01:49:40 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.27 2013/08/11 01:42:35 dholland Exp $	*/
+/*	$NetBSD: str.c,v 1.28 2013/08/11 01:49:40 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)str.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: str.c,v 1.27 2013/08/11 01:42:35 dholland Exp $");
+__RCSID("$NetBSD: str.c,v 1.28 2013/08/11 01:49:40 dholland Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -196,6 +196,7 @@ bracket(STR *s)
 			return 0;
 		s->str += 2;
 		genequiv(s);
+		s->str = p + 2;
 		return 1;
 	default:				/* "[\###*n]" or "[#*n]" */
 		if ((p = strpbrk(s->str + 2, "*]")) == NULL)
@@ -310,16 +311,19 @@ genequiv(STR *s)
 	ch = (unsigned char)s->str[0];
 	if (ch == '\\') {
 		s->equiv[0] = backslash(s);
-		if (*s->str != '=') {
-			errx(1, "Misplaced equivalence equals sign");
-		}
 	} else {
 		s->equiv[0] = ch;
-		if (s->str[1] != '=') {
-			errx(1, "Misplaced equivalence equals sign");
-		}
+		s->str++;
+	}
+	if (s->str[0] != '=') {
+		errx(1, "Misplaced equivalence equals sign");
 	}
-	s->str += 2;
+	s->str++;
+	if (s->str[0] != ']') {
+		errx(1, "Misplaced equivalence right bracket");
+	}
+	s->str++;
+
 	s->cnt = 0;
 	s->state = SET;
 	s->set = s->equiv;

Reply via email to