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"
|
#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 {
|
struct emkfileData {
|
||||||
char cc;
|
char cc;
|
||||||
char prefix;
|
char prefix;
|
||||||
@ -61,15 +55,10 @@ char checkForFiles() {
|
|||||||
|
|
||||||
emkconfig = fopen(EMKCONFIG, "r");
|
emkconfig = fopen(EMKCONFIG, "r");
|
||||||
if (emkconfig == NULL) {
|
if (emkconfig == NULL) {
|
||||||
printf(COL_YELLOW "WRN" COL_RESET " | config.emk does not exist\n");
|
printf(COL_RED "ERR" COL_RESET " | config.emk does not exist\n");
|
||||||
printf(COL_YELLOW "WRN" COL_RESET " | it is highly recommended to\n");
|
return 1;
|
||||||
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;
|
|
||||||
} else if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
} else if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||||
printf(COL_BLUE "INF" COL_RESET " | using config.emk at %s/config.emk\n", cwd);
|
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;
|
FILE *emkconfig, *emkfile, *emkfile_new;
|
||||||
char filename[100], contents;
|
char filename[100], contents;
|
||||||
|
|
||||||
if (emkConfigExists == 1) {
|
printf(COL_BLUE "INF" COL_RESET " | parsing config.emk\n");
|
||||||
printf(COL_BLUE "INF" COL_RESET " | parsing config.emk\n");
|
emkconfig = fopen(EMKCONFIG, "r");
|
||||||
emkconfig = fopen(EMKCONFIG, "r");
|
|
||||||
}
|
|
||||||
printf(COL_BLUE "INF" COL_RESET " | parsing emkfile\n");
|
printf(COL_BLUE "INF" COL_RESET " | parsing emkfile\n");
|
||||||
emkfile = fopen(EMKFILE, "r");
|
emkfile = fopen(EMKFILE, "r");
|
||||||
|
|
||||||
@ -105,14 +92,13 @@ char includeConfig() {
|
|||||||
|
|
||||||
printf(COL_BLUE "INF" COL_RESET " | running preprocessing tasks...\n");
|
printf(COL_BLUE "INF" COL_RESET " | running preprocessing tasks...\n");
|
||||||
/* write emkconfig to new emkfile */
|
/* write emkconfig to new emkfile */
|
||||||
if (emkConfigExists == 1) {
|
contents = fgetc(emkconfig);
|
||||||
|
while (contents != EOF) {
|
||||||
|
fputc(contents, emkfile_new);
|
||||||
contents = fgetc(emkconfig);
|
contents = fgetc(emkconfig);
|
||||||
while (contents != EOF) {
|
|
||||||
fputc(contents, emkfile_new);
|
|
||||||
contents = fgetc(emkconfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* write emkfile to new emkfile */
|
/* write emkfile to new emkfile */
|
||||||
contents = fgetc(emkfile);
|
contents = fgetc(emkfile);
|
||||||
while (contents != EOF) {
|
while (contents != EOF) {
|
||||||
@ -121,9 +107,7 @@ char includeConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf(COL_BLUE "INF" COL_RESET " | closing files\n");
|
printf(COL_BLUE "INF" COL_RESET " | closing files\n");
|
||||||
if (emkConfigExists == 1) {
|
fclose(emkconfig);
|
||||||
fclose(emkconfig);
|
|
||||||
}
|
|
||||||
fclose(emkfile);
|
fclose(emkfile);
|
||||||
fclose(emkfile_new);
|
fclose(emkfile_new);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user