From 728bee7ff3672e7f658912179cd77d5dc4842e86 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Dec 2006 01:50:04 +0000 Subject: r20179: Sync up with Samba4 - remove blank lines at the end parsing a file. Jeremy. (This used to be commit ea8215935e5f3952a4480c1f7dafafa9458f66a9) --- source3/lib/util_file.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 1e0d880e83..03246cad8e 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -285,9 +285,6 @@ static char **file_lines_parse(char *p, size_t size, int *numlines) return NULL; } memset(ret, 0, sizeof(ret[0])*(i+2)); - if (numlines) { - *numlines = i; - } ret[0] = p; for (s = p, i=0; s < p+size; s++) { @@ -301,6 +298,15 @@ static char **file_lines_parse(char *p, size_t size, int *numlines) } } + /* remove any blank lines at the end */ + while (i > 0 && ret[i-1][0] == 0) { + i--; + } + + if (numlines) { + *numlines = i; + } + return ret; } -- cgit