This commit is contained in:
Kelvin Sherlock 2019-09-01 23:48:42 -04:00
parent db84b13884
commit e009f90c4b

View File

@ -39,13 +39,15 @@ This will generate a function (`int match(const char *)`) which is essentially:
```
int match(const char *cp) {
if (!strncasecmp(cp, "abcd", 4)) return (2 << 8) | 4;
if (!strncasecmp(cp, "abc", 3)) return (1 << 8) | 3;
if (!strcasecmp(cp, "abcd")) return (2 << 8) | 4;
if (!strcasecmp(cp, "abc")) return (1 << 8) | 3;
return 0;
}
```
(without the `-c` flag it would be more akin to `memcmp` than `strcmp`)
(without the `-c` flag it would be more akin to `memcmp` than `strcmp`.
Actual matching logic is based on the character count not a terminal character
so embedded `0`s match correctly.)
But hopefully more efficient...