A decimal number at *p, bounded by end. false when there is none or it is * out of range. */
| 64 | /* A decimal number at *p, bounded by end. false when there is none or it is |
| 65 | * out of range. */ |
| 66 | static bool df_number(const char **p, const char *end, int *out) { |
| 67 | const char *q = *p; |
| 68 | long value = 0; |
| 69 | while (q < end && *q >= '0' && *q <= '9') { |
| 70 | value = value * DF_DECIMAL + (*q - '0'); |
| 71 | if (value > DF_LINE_MAX) { |
| 72 | return false; |
| 73 | } |
| 74 | q++; |
| 75 | } |
| 76 | if (q == *p) { |
| 77 | return false; |
| 78 | } |
| 79 | *p = q; |
| 80 | *out = (int)value; |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | /* "start[,count]" after a '-' or '+' in a hunk header. No count means 1. */ |
| 85 | static bool df_range(const char **p, const char *end, char sign, int *start, int *count) { |