From 8d7e498db160f9a366400fc1c55dacbcffaf4196 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 11:17:19 +0000 Subject: converted a couple more functions to use a fd instead of a FILE* added a new utility fn file_lines_slashcont() which is used to handle files that treat a \ followed by a newline as a blank (This used to be commit 384ecd9d66ccd31ee85000c0ca55d413d8f2cc53) --- source3/lib/util_file.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 1ef713b105..f3e2879587 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -473,3 +473,26 @@ void file_lines_free(char **lines) free(lines); } + +/**************************************************************************** +take a lislist of lines and modify them to produce a list where \ continues +a line +****************************************************************************/ +void file_lines_slashcont(char **lines) +{ + int i, j; + + for (i=0; lines[i];) { + int len = strlen(lines[i]); + if (lines[i][len-1] == '\\') { + lines[i][len-1] = ' '; + if (lines[i+1]) { + char *p = &lines[i][len]; + while (p < lines[i+1]) *p++ = ' '; + for (j = i+1; lines[j]; j++) lines[j] = lines[j+1]; + } + } else { + i++; + } + } +} -- cgit