]> granicus.if.org Git - nethack/commitdiff
symbol parsing (trunk only)
authornethack.allison <nethack.allison>
Sat, 23 Sep 2006 06:17:47 +0000 (06:17 +0000)
committernethack.allison <nethack.allison>
Sat, 23 Sep 2006 06:17:47 +0000 (06:17 +0000)
Make sure that less than three digits on a symbol
evaluates correctly.

src/options.c

index 687c742c05dd19c0f8449a8697b0f53e811277a6..ee512de55466d42f2febbb5ef9f3cc6c40046128 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)options.c  3.5     2006/09/17      */
+/*     SCCS Id: @(#)options.c  3.5     2006/09/23      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -718,13 +718,13 @@ char *tp;
 
            cp++;
            if (*cp == 'x' || *cp == 'X')
-               for (++cp; (dp = index(hex, *cp)) && (dcount++ < 2); cp++)
+               for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 2); cp++)
                    cval = (int)((cval * 16) + (dp - hex) / 2);
            else if (*cp == 'o' || *cp == 'O')
-               for (++cp; (index("01234567",*cp)) && (dcount++ < 3); cp++)
+               for (++cp; *cp && (index("01234567",*cp)) && (dcount++ < 3); cp++)
                    cval = (cval * 8) + (*cp - '0');
            else
-               for (; (index("0123456789",*cp)) && (dcount++ < 3); cp++)
+               for (; *cp && (index("0123456789",*cp)) && (dcount++ < 3); cp++)
                    cval = (cval * 10) + (*cp - '0');
        }
        else if (*cp == '\\')           /* C-style character escapes */