Re: [PATCH] scanner.c: prefer strchr() over for loop and toupper() in place

2024-01-09 Thread Thiago Macieira
On Wednesday, 3 January 2024 02:48:26 -03 James Tirta Halim wrote: > - u = xstrdup(src); > - for (i = 0; u[i]; i++) > - u[i] = toupper(u[i]); > - u[i] = '\0'; > + dst = u = fail_on_null(malloc(strlen(src) + 1)); This does have the advantage of not writing to

Re: [PATCH] scanner.c: prefer strchr() over for loop and toupper() in place

2024-01-06 Thread Simon Ser
I personally find the current code more readable.

[PATCH] scanner.c: prefer strchr() over for loop and toupper() in place

2024-01-06 Thread James Tirta Halim
uppercase_dup() was copying SRC to DST and converting DST to uppercase. Now it converts to uppercase while copying. find_enumeration() was calling strlen() on the whole string before checking for the '.' character in a loop. Now it uses strchr(). --- src/scanner.c | 19 +++ 1