fix preprocessing
This commit is contained in:
parent
1293d3a49b
commit
12db365ec2
34
src/parse.c
34
src/parse.c
@ -26,12 +26,6 @@
|
||||
|
||||
#include "parse.h"
|
||||
|
||||
/* Variable indicating whether config.emk exists
|
||||
* 1 means config.emk exists
|
||||
* 0 means config.emk does not exist
|
||||
*/
|
||||
int emkConfigExists;
|
||||
|
||||
struct emkfileData {
|
||||
char cc;
|
||||
char prefix;
|
||||
@ -61,15 +55,10 @@ char checkForFiles() {
|
||||
|
||||
emkconfig = fopen(EMKCONFIG, "r");
|
||||
if (emkconfig == NULL) {
|
||||
printf(COL_YELLOW "WRN" COL_RESET " | config.emk does not exist\n");
|
||||
printf(COL_YELLOW "WRN" COL_RESET " | it is highly recommended to\n");
|
||||
printf(COL_YELLOW "WRN" COL_RESET " | use a config.emk file, rather\n");
|
||||
printf(COL_YELLOW "WRN" COL_RESET " | than embedding settings directly\n");
|
||||
printf(COL_YELLOW "WRN" COL_RESET " | within the emkfile.\n");
|
||||
int emkConfigExists = 0;
|
||||
printf(COL_RED "ERR" COL_RESET " | config.emk does not exist\n");
|
||||
return 1;
|
||||
} else if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
printf(COL_BLUE "INF" COL_RESET " | using config.emk at %s/config.emk\n", cwd);
|
||||
int emkConfigExists = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,10 +82,8 @@ char includeConfig() {
|
||||
FILE *emkconfig, *emkfile, *emkfile_new;
|
||||
char filename[100], contents;
|
||||
|
||||
if (emkConfigExists == 1) {
|
||||
printf(COL_BLUE "INF" COL_RESET " | parsing config.emk\n");
|
||||
emkconfig = fopen(EMKCONFIG, "r");
|
||||
}
|
||||
printf(COL_BLUE "INF" COL_RESET " | parsing config.emk\n");
|
||||
emkconfig = fopen(EMKCONFIG, "r");
|
||||
printf(COL_BLUE "INF" COL_RESET " | parsing emkfile\n");
|
||||
emkfile = fopen(EMKFILE, "r");
|
||||
|
||||
@ -105,14 +92,13 @@ char includeConfig() {
|
||||
|
||||
printf(COL_BLUE "INF" COL_RESET " | running preprocessing tasks...\n");
|
||||
/* write emkconfig to new emkfile */
|
||||
if (emkConfigExists == 1) {
|
||||
contents = fgetc(emkconfig);
|
||||
while (contents != EOF) {
|
||||
fputc(contents, emkfile_new);
|
||||
contents = fgetc(emkconfig);
|
||||
while (contents != EOF) {
|
||||
fputc(contents, emkfile_new);
|
||||
contents = fgetc(emkconfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* write emkfile to new emkfile */
|
||||
contents = fgetc(emkfile);
|
||||
while (contents != EOF) {
|
||||
@ -121,9 +107,7 @@ char includeConfig() {
|
||||
}
|
||||
|
||||
printf(COL_BLUE "INF" COL_RESET " | closing files\n");
|
||||
if (emkConfigExists == 1) {
|
||||
fclose(emkconfig);
|
||||
}
|
||||
fclose(emkconfig);
|
||||
fclose(emkfile);
|
||||
fclose(emkfile_new);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user