Try to be less strict about whitespace in files
This commit is contained in:
parent
b5648963a7
commit
99fc088d3e
|
@ -557,25 +557,28 @@ Object parseEval(const char *input, struct Environment *env)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
int read_file(const char *filename, struct Environment *env) {
|
int readFile(const char *filename, struct Environment *env) {
|
||||||
FILE *input = fopen(filename, "r");
|
FILE *input = fopen(filename, "r");
|
||||||
if(!input) {
|
if(!input) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Object r = numberObject(0);
|
Object r = numberObject(0);
|
||||||
char buf[256];
|
char page[4096] = "";
|
||||||
if(fgets(buf, 256, input)){
|
char line[256];
|
||||||
if(buf[0] != '#' || buf[1] != '!') {
|
if(fgets(line, 256, input)){
|
||||||
r = parseEval(buf, env);
|
if(line[0] != '#' || line[1] != '!') {
|
||||||
printAndClean(&r);
|
strncat(page, line, strlen(line) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(fgets(buf, 256, input)) {
|
while(fgets(line, 256, input)) {
|
||||||
if(buf[0] != ';') {
|
if(line[0] != ';') {
|
||||||
r = parseEval(buf, env);
|
strncat(page, line, strlen(line) - 1);
|
||||||
printAndClean(&r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = parseEval(page, env);
|
||||||
|
printAndClean(&r);
|
||||||
|
|
||||||
fclose(input);
|
fclose(input);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -595,7 +598,7 @@ int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
struct Environment env = defaultEnv();
|
struct Environment env = defaultEnv();
|
||||||
if(argc >= 2) {
|
if(argc >= 2) {
|
||||||
if(read_file(argv[1], &env) != 0) {
|
if(readFile(argv[1], &env) != 0) {
|
||||||
Object r = numberObject(0);
|
Object r = numberObject(0);
|
||||||
for(int i = 1; i < argc; i++) {
|
for(int i = 1; i < argc; i++) {
|
||||||
r = parseEval(argv[i], &env);
|
r = parseEval(argv[i], &env);
|
||||||
|
|
Loading…
Reference in New Issue