From: kmhugo Date: Sat, 19 Jan 2002 06:06:16 +0000 (+0000) Subject: Line numbering in lev_comp files X-Git-Tag: MOVE2GIT~3430 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=263b6c06b1228ba09b5983a26d66abf8ef997419;p=nethack Line numbering in lev_comp files This patch allows the digits 0-9 to be used to indicate line numbers in the MAP...ENDMAP arrays of level files. This makes it a wee bit easier to place features. The digits get stripped out before the map is interpreted. --- diff --git a/util/lev_comp.l b/util/lev_comp.l index 9cbf927ff..ea56256ba 100644 --- a/util/lev_comp.l +++ b/util/lev_comp.l @@ -88,7 +88,7 @@ static int map_cnt = 0; map_cnt = 0; return MAP_ID; } -[-|}{+ABCISHKPLWTF\\#. ]*\n { +[-|}{+ABCISHKPLWTF\\#. 0123456789]*\n { line_number++; (void) strncpy(map + map_cnt, yytext, yyleng); map_cnt += yyleng; diff --git a/util/lev_main.c b/util/lev_main.c index bf9aae25d..440d93c0a 100644 --- a/util/lev_main.c +++ b/util/lev_main.c @@ -516,8 +516,13 @@ char *map; int max_hig = 0; char msg[256]; - /* First : find the max width of the map */ + /* First, strip out digits 0-9 (line numbering) */ + for (s1 = s2 = map; *s1; s1++) + if (*s1 < '0' || *s1 > '9') + *s2++ = *s1; + *s2 = '\0'; + /* Second, find the max width of the map */ s1 = map; while (s1 && *s1) { s2 = index(s1, NEWLINE); @@ -532,7 +537,6 @@ char *map; } /* Then parse it now */ - while (map && *map) { tmpmap[max_hig] = (char *) alloc(max_len); s1 = index(map, NEWLINE);