• R/O
  • SSH
  • HTTPS

junnethack: Commit


Commit MetaInfo

Revisión406 (tree)
Tiempo2011-03-14 16:12:55
Autorso-miya

Log Message

UnNetHack SVN版rev.769を適用した。
Simplify parse_symbol()
parse_symbol()を単純に

Cambiar Resumen

Diferencia

--- junnethack/trunk/src/options.c (revision 405)
+++ junnethack/trunk/src/options.c (revision 406)
@@ -22,6 +22,7 @@
2222 #include "tcap.h"
2323 #include <ctype.h>
2424 #endif
25+#include <errno.h>
2526
2627 #define WINTYPELEN 16
2728
@@ -1444,7 +1445,9 @@
14441445 }
14451446
14461447 /** Parse '"dungeon feature":unicode_codepoint' and change symbol in
1447- * UTF8graphics. */
1448+ * UTF8graphics.
1449+ * Valid codepoints are decimal numbers or U+FFFF and 0xFFFF for hexadecimal
1450+ * values. */
14481451 boolean
14491452 parse_symbol(str)
14501453 const char *str;
@@ -1452,7 +1455,7 @@
14521455 char feature[BUFSZ];
14531456 char codepoint[BUFSZ];
14541457 char *ptr, *endptr;
1455- int i, num=0;
1458+ int i, num=0, base;
14561459
14571460 if (!parse_extended_option(str, feature, codepoint)) {
14581461 return FALSE;
@@ -1462,21 +1465,18 @@
14621465 if (!strncmpi(codepoint, "u+", 2) ||
14631466 !strncmpi(codepoint, "0x", 2)) {
14641467 /* hexadecimal */
1465- ptr = &(codepoint[2]);
1466- errno = 0;
1467- num = strtol(ptr, &endptr, 16);
1468- if (errno != 0 || *endptr != 0 || endptr == ptr) {
1469- return FALSE;
1470- }
1468+ ptr = &codepoint[2];
1469+ base = 16;
14711470 } else {
14721471 /* decimal */
14731472 ptr = &codepoint[0];
1474- errno = 0;
1475- num = strtol(ptr, &endptr, 10);
1476- if (errno != 0 || *endptr != 0 || endptr == ptr) {
1477- return FALSE;
1478- }
1473+ base = 10;
14791474 }
1475+ errno = 0;
1476+ num = strtol(ptr, &endptr, base);
1477+ if (errno != 0 || *endptr != 0 || endptr == ptr) {
1478+ return FALSE;
1479+ }
14801480
14811481 /* find dungeon feature */
14821482 for (i=0; i < MAXPCHARS; i++) {
Show on old repository browser