X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Ftextfilter.c;h=90354c2723bfde29b264a1c1346949c90542437d;hb=4e3551a5f617a424143aca227a2ce89cfb7d8640;hp=bcac83882495379fa4452f04d08541d0dd29d93f;hpb=02ba8788a0a15cd76fefc777908738cc27e78e6c;p=picodrive.git diff --git a/tools/textfilter.c b/tools/textfilter.c index bcac838..90354c2 100644 --- a/tools/textfilter.c +++ b/tools/textfilter.c @@ -25,17 +25,19 @@ static int check_defines(const char **defs, int defcount, char *tdef) static void do_counters(char *str) { - static int counters[4] = { 1, 1, 1, 1 }; + static int counter_id = -1, counter; char buff[1024]; - int counter; char *s = str; while ((s = strstr(s, "@@"))) { - if (s[2] < '0' || s[2] > '3') { s++; continue; } + if (s[2] < '0' || s[2] > '9') { s++; continue; } - counter = s[2] - '0'; - snprintf(buff, sizeof(buff), "%i%s", counters[counter]++, s + 3); + if (counter_id != s[2] - '0') { + counter_id = s[2] - '0'; + counter = 1; + } + snprintf(buff, sizeof(buff), "%i%s", counter++, s + 3); strcpy(s, buff); } }