1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-09 20:23:51 +03:00

r20091: remove blank lines at the end of text lines loaded from a file

This commit is contained in:
Andrew Tridgell
2006-12-09 03:12:33 +00:00
committed by Gerald (Jerry) Carter
parent 557bb80089
commit afcc797e8a

View File

@@ -263,7 +263,6 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
talloc_steal(ret, p);
memset(ret, 0, sizeof(ret[0])*(i+2));
if (numlines) *numlines = i;
ret[0] = p;
for (s = p, i=0; s < p+size; s++) {
@@ -275,6 +274,13 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
if (s[0] == '\r') s[0] = 0;
}
/* remove any blank lines at the end */
while (i > 0 && ret[i-1][0] == 0) {
i--;
}
if (numlines) *numlines = i;
return ret;
}