1
0
mirror of https://github.com/golang/go synced 2024-11-19 07:14:45 -07:00

cmd/dist: ignore \r in crlf EOL when splitlines()

Fixes build on Windows. Fixes #9234.

Change-Id: Iebf4317e7cc20ba1afea5558553166cd89783316
Reviewed-on: https://go-review.googlesource.com/1421
Reviewed-by: <iant@golang.org>
This commit is contained in:
Shenghou Ma 2014-12-11 23:07:04 -05:00 committed by iant
parent bd8077116e
commit d3072127cc

9
src/cmd/dist/buf.c vendored
View File

@ -239,7 +239,8 @@ vuniq(Vec *v)
}
// splitlines replaces the vector v with the result of splitting
// the input p after each \n.
// the input p after each \n. If there is a \r immediately before
// each \n, it will be removed.
void
splitlines(Vec *v, char *p)
{
@ -249,8 +250,12 @@ splitlines(Vec *v, char *p)
vreset(v);
start = p;
for(i=0; p[i]; i++) {
if(p[i] == '\n') {
if((p[i] == '\r' && p[i+1] == '\n') || p[i] == '\n') {
vaddn(v, start, (p+i+1)-start);
if(p[i] == '\r') {
v->p[v->len-1][(p+i)-start] = '\n';
i++;
}
start = p+i+1;
}
}