Find a line starting with a prefix in source. Returns pointer to first char * after prefix, or NULL. Handles leading whitespace. */
| 194 | /* Find a line starting with a prefix in source. Returns pointer to first char |
| 195 | * after prefix, or NULL. Handles leading whitespace. */ |
| 196 | static const char *find_line_value(const char *src, int src_len, const char *prefix) { |
| 197 | size_t plen = strlen(prefix); |
| 198 | const char *p = src; |
| 199 | const char *end = src + src_len; |
| 200 | while (p < end) { |
| 201 | /* Skip leading whitespace */ |
| 202 | while (p < end && (*p == ' ' || *p == '\t')) { |
| 203 | p++; |
| 204 | } |
| 205 | if (p + plen <= end && memcmp(p, prefix, plen) == 0) { |
| 206 | return p + plen; |
| 207 | } |
| 208 | /* Skip to next line */ |
| 209 | while (p < end && *p != '\n') { |
| 210 | p++; |
| 211 | } |
| 212 | if (p < end) { |
| 213 | p++; /* skip \n */ |
| 214 | } |
| 215 | } |
| 216 | return NULL; |
| 217 | } |
| 218 | |
| 219 | /* Extract a quoted string value from position. Handles both "..." and '...' |
| 220 | * Returns heap-allocated string, or NULL. */ |
no outgoing calls
no test coverage detected