Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/tr avoid undefined behavior.



details:   https://anonhg.NetBSD.org/src/rev/cfd3331c5c71
branches:  trunk
changeset: 789200:cfd3331c5c71
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Aug 11 00:52:17 2013 +0000

description:
avoid undefined behavior.

diffstat:

 usr.bin/tr/str.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r a3f0e41bd510 -r cfd3331c5c71 usr.bin/tr/str.c
--- a/usr.bin/tr/str.c  Sun Aug 11 00:49:15 2013 +0000
+++ b/usr.bin/tr/str.c  Sun Aug 11 00:52:17 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: str.c,v 1.23 2013/08/11 00:39:22 dholland Exp $        */
+/*     $NetBSD: str.c,v 1.24 2013/08/11 00:52:17 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.23 2013/08/11 00:39:22 dholland Exp $");
+__RCSID("$NetBSD: str.c,v 1.24 2013/08/11 00:52:17 dholland Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -277,8 +277,8 @@
        int stopval;
        const char *savestart;
 
-       savestart = s->str;
-       stopval = *++s->str == '\\' ? backslash(s) : *s->str++;
+       savestart = s->str++;
+       stopval = *s->str == '\\' ? backslash(s) : *s->str++;
        if (stopval < (u_char)s->lastch) {
                s->str = savestart;
                return 0;



Home | Main Index | Thread Index | Old Index