From 9bfac2505cb2f55162d145de6db694d5ddb77b8a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 22 Dec 2002 19:18:25 +0000 Subject: [PATCH] To remove empty and comment lines from the Jamfile cache sounds like a nice idea, but it fools the line counter and thus makes error and warning messages a quite confusing. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2283 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tools/jam/jcache.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/tools/jam/jcache.c b/src/tools/jam/jcache.c index a311a9c3a5..771178cf4d 100644 --- a/src/tools/jam/jcache.c +++ b/src/tools/jam/jcache.c @@ -372,27 +372,30 @@ read_file(const char *filename, string_list* list) result = !0; while (result && fgets(buffer, sizeof(buffer) - 1, file)) { char* line = buffer; + int len = 0; + char *string = 0; // skip leading white spaces while (*line == ' ' || *line == '\t' || *line == '\n') line++; - // copy the line, if not empty or a comment line - if (*line && *line != '#') { - int len = strlen(line); - char *string = 0; - // make sure, the line ends in a LF - if (line[len - 1] != '\n') { - line[len] = '\n'; - len++; - line[len] = '\0'; - } - // copy it - string = (char*)malloc(len + 1); - if (string) { - strcpy(string, line); - result = push_string(list, string); - } else - result = 0; + // make empty and comment lines simple new-line lines + if (!*line || *line == '#') { + line[0] = '\n'; + line[1] = '\0'; } + len = strlen(line); + // make sure, the line ends in a LF + if (line[len - 1] != '\n') { + line[len] = '\n'; + len++; + line[len] = '\0'; + } + // copy it + string = (char*)malloc(len + 1); + if (string) { + strcpy(string, line); + result = push_string(list, string); + } else + result = 0; } // close the file fclose(file);