diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-12-09 03:12:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:29:03 -0500 |
commit | 5235e6518cd9d9f5edac9424a4cc43023dd96b7f (patch) | |
tree | 10ecea2fde95f47840075456c79a485e74513478 /source4/lib/util | |
parent | 8b137ba30a19a1af56046fd780daf009f4ffb43f (diff) | |
download | samba-5235e6518cd9d9f5edac9424a4cc43023dd96b7f.tar.gz samba-5235e6518cd9d9f5edac9424a4cc43023dd96b7f.tar.bz2 samba-5235e6518cd9d9f5edac9424a4cc43023dd96b7f.zip |
r20091: remove blank lines at the end of text lines loaded from a file
(This used to be commit afcc797e8a25d99269f67e05fe57e952dd5d65bc)
Diffstat (limited to 'source4/lib/util')
-rw-r--r-- | source4/lib/util/util_file.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source4/lib/util/util_file.c b/source4/lib/util/util_file.c index 5d7ec40b30..887efb9836 100644 --- a/source4/lib/util/util_file.c +++ b/source4/lib/util/util_file.c @@ -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; } |