Return 1 if the "a-b,c-d" range string covers 1-based `line`. */
| 665 | |
| 666 | /* Return 1 if the "a-b,c-d" range string covers 1-based `line`. */ |
| 667 | static int ranges_cover_line(const char *ranges, unsigned int line) { |
| 668 | const char *p = ranges; |
| 669 | while (p && *p) { |
| 670 | unsigned int s = 0, e = 0; |
| 671 | if (sscanf(p, "%u-%u", &s, &e) == 2 && line >= s && line <= e) { |
| 672 | return 1; |
| 673 | } |
| 674 | p = strchr(p, ','); |
| 675 | if (p) { |
| 676 | p++; |
| 677 | } |
| 678 | } |
| 679 | return 0; |
| 680 | } |
| 681 | |
| 682 | /* Total lines covered by every range in the string. */ |
| 683 | static unsigned int ranges_total_span(const char *ranges) { |