Show More
@@ -67,12 +67,13 b' int splitlines(const char *a, int len, s' | |||
|
67 | 67 | { |
|
68 | 68 | int g, h, i; |
|
69 | 69 | const char *p, *b = a; |
|
70 | const char * const plast = a + len - 1; | |
|
70 | 71 | struct line *l; |
|
71 | 72 | |
|
72 | 73 | /* count the lines */ |
|
73 | 74 | i = 1; /* extra line for sentinel */ |
|
74 | 75 | for (p = a; p < a + len; p++) |
|
75 |
if (*p == '\n' || p == |
|
|
76 | if (*p == '\n' || p == plast) | |
|
76 | 77 | i++; |
|
77 | 78 | |
|
78 | 79 | *lr = l = (struct line *)malloc(sizeof(struct line) * i); |
@@ -92,7 +93,7 b' int splitlines(const char *a, int len, s' | |||
|
92 | 93 | h ^= g >> 24; |
|
93 | 94 | h ^= g; |
|
94 | 95 | } |
|
95 |
if (*p == '\n' || p == |
|
|
96 | if (*p == '\n' || p == plast) { | |
|
96 | 97 | l->len = p - b + 1; |
|
97 | 98 | l->h = h * l->len; |
|
98 | 99 | l->l = b; |
General Comments 0
You need to be logged in to leave comments.
Login now