/** @license 2022 Neil Edelman, distributed under the terms of the [MIT License](https://opensource.org/licenses/MIT). Is intended to use . */ #include "../src/kjv.h" #include #include #include /* debug */ static int parse_natural(const char *s, const char *const e, unsigned *const n) { unsigned accum = 0; while(s < e) { unsigned next = accum * 10 + (unsigned)(*s - '0'); if(accum >= next) return errno = ERANGE, 0; accum = next; s++; } *n = accum; return 1; } /*!re2c /**/ re2c:yyfill:enable = 0; re2c:define:YYCTYPE = char; sentinel = "\x00"; newline = "\n"; natural = [1-9][0-9]*; */ int kjv_filename(const char *fn, unsigned *book_no) { const char *YYCURSOR = fn, *YYMARKER, *yyt1, *yyt2, *s0, *s1; assert(fn && book_no); /*!re2c /**/ * { return 0; } @s0 natural @s1 [^.\x00]* ".txt" sentinel { return parse_natural(s0, s1, book_no); } */ }