int start = 0;
char* ret = malloc(1);
ret[0] = 0;
+ bool skip = false;
for(i = 0; data[i] != 0; i++) {
cbuf[0] = data[i];
if(data[i] == '@') {
}
}
- if(strcmp(op, "include") == 0) {
+ if(strcmp(op, "endif") == 0) {
+ skip = false;
+ } else if(skip) {
+ } else if(strcmp(op, "if") == 0 || strcmp(op, "ifnot") == 0) {
+ bool result = false;
+ if(arg != NULL) {
+ if(mandshurica_strcaseequ(arg, "true")) {
+ result = true;
+ } else if(mandshurica_strcaseequ(arg, "false")) {
+ result = false;
+ }
+ }
+ if(strcmp(op, "ifnot") == 0) result = !result;
+ skip = !result;
+ } else if(strcmp(op, "include") == 0) {
if(arg != NULL) {
FILE* f = fopen(arg, "r");
if(f != NULL) {
free(tmpl);
}
- } else if(!template) {
+ } else if(!template && !skip) {
char* tmp = ret;
ret = mandshurica_strcat(tmp, cbuf);
free(tmp);