Skip to content

Commit

Permalink
Only add C files in directory load
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinux authored and jaromil committed Oct 6, 2024
1 parent ead9f64 commit 0d2d9dc
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,24 @@ static int file_load_ftw(const char *pathname,
FILE *fd;
char *content = NULL;
if (type == FTW_F) {
content = file_load(pathname);
if (content == NULL) {
_err("Error: file_load %s",pathname);
return -1;
}
if (full_content == NULL) {
full_content = content;
} else {
full_content = realloc(full_content, strlen(full_content) + strlen(content) + 1);
if (full_content == NULL) {
_err("Error: realloc full_content");
size_t pathlen = strlen(pathname);
if (pathname[pathlen-1] == 'c' &&
pathname[pathlen-2] == '.') {
content = file_load(pathname);
if (content == NULL) {
_err("Error: file_load %s",pathname);
return -1;
}
strcat(full_content, content);
if (full_content == NULL) {
full_content = content;
} else {
full_content = realloc(full_content, strlen(full_content) + strlen(content) + 1);
if (full_content == NULL) {
_err("Error: realloc full_content");
return -1;
}
strcat(full_content, content);
}
}
}
return 0;
Expand Down

0 comments on commit 0d2d9dc

Please sign in to comment.