| 17 | #include <string.h> |
| 18 | |
| 19 | void cbm_parse_range(const char *s, int *out_start, int *out_count) { |
| 20 | *out_start = 0; |
| 21 | *out_count = SKIP_ONE; |
| 22 | |
| 23 | const char *comma = strchr(s, ','); |
| 24 | if (!comma) { |
| 25 | *out_start = (int)strtol(s, NULL, CBM_DECIMAL_BASE); |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | /* Parse start */ |
| 30 | char buf[CBM_SZ_32]; |
| 31 | size_t len = (size_t)(comma - s); |
| 32 | if (len >= sizeof(buf)) { |
| 33 | len = sizeof(buf) - SKIP_ONE; |
| 34 | } |
| 35 | memcpy(buf, s, len); |
| 36 | buf[len] = '\0'; |
| 37 | *out_start = (int)strtol(buf, NULL, CBM_DECIMAL_BASE); |
| 38 | |
| 39 | /* Parse count */ |
| 40 | *out_count = (int)strtol(comma + SKIP_ONE, NULL, CBM_DECIMAL_BASE); |
| 41 | } |
| 42 | |
| 43 | #define HUNK_LINE_BUF 1536 |
| 44 |
no outgoing calls
no test coverage detected