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
This commit is contained in:
+20
-17
@@ -372,27 +372,30 @@ read_file(const char *filename, string_list* list)
|
|||||||
result = !0;
|
result = !0;
|
||||||
while (result && fgets(buffer, sizeof(buffer) - 1, file)) {
|
while (result && fgets(buffer, sizeof(buffer) - 1, file)) {
|
||||||
char* line = buffer;
|
char* line = buffer;
|
||||||
|
int len = 0;
|
||||||
|
char *string = 0;
|
||||||
// skip leading white spaces
|
// skip leading white spaces
|
||||||
while (*line == ' ' || *line == '\t' || *line == '\n')
|
while (*line == ' ' || *line == '\t' || *line == '\n')
|
||||||
line++;
|
line++;
|
||||||
// copy the line, if not empty or a comment line
|
// make empty and comment lines simple new-line lines
|
||||||
if (*line && *line != '#') {
|
if (!*line || *line == '#') {
|
||||||
int len = strlen(line);
|
line[0] = '\n';
|
||||||
char *string = 0;
|
line[1] = '\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;
|
|
||||||
}
|
}
|
||||||
|
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
|
// close the file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user