| 85 | } |
| 86 | |
| 87 | int cbm_parse_name_status(const char *output, cbm_changed_file_t *out, int max_out) { |
| 88 | if (!output || !out || max_out <= 0) { |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | int count = 0; |
| 93 | const char *line = output; |
| 94 | |
| 95 | while (*line && count < max_out) { |
| 96 | const char *eol = strchr(line, '\n'); |
| 97 | size_t line_len = eol ? (size_t)(eol - line) : strlen(line); |
| 98 | |
| 99 | if (line_len > 0) { |
| 100 | cbm_changed_file_t f; |
| 101 | if (parse_one_name_status(line, line_len, &f)) { |
| 102 | out[count++] = f; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | line = eol ? eol + SKIP_ONE : line + line_len; |
| 107 | } |
| 108 | return count; |
| 109 | } |
| 110 | |
| 111 | /* Parse a single @@ hunk header line and emit a hunk entry if valid. |
| 112 | * Returns true if a hunk was added. */ |
no test coverage detected