From: nishi Date: Wed, 5 Jun 2024 03:02:21 +0000 (+0000) Subject: fix X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=1c4a7b2cad73a743570bc92fb1725b26b37c65f8;p=dataworks.git fix git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@152 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/client.c b/Client/client.c index 3a02d88..18a2969 100644 --- a/Client/client.c +++ b/Client/client.c @@ -54,7 +54,7 @@ void padleft(int leftpad, const char* str) { free(spaces); } -bool option(const char* str, const char* shortopt, const char* longopt){ +bool option(const char* str, const char* shortopt, const char* longopt) { char* dos_shortopt = __dw_strcat("/", shortopt); char* dos_longopt = __dw_strcat("/", longopt); char* nix_shortopt = __dw_strcat("-", shortopt); @@ -79,7 +79,7 @@ int main(int argc, char** argv) { if(option(argv[i], "V", "version")) { printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); return 0; - } else if(option(argv[i], "C", "create")){ + } else if(option(argv[i], "C", "create")) { create = true; } else if(option(argv[i], "NC", "noclear")) { clear = false; @@ -87,11 +87,11 @@ int main(int argc, char** argv) { banner = false; log = false; clear = false; - } else if(option(argv[i], "NB", "nobanner")){ + } else if(option(argv[i], "NB", "nobanner")) { banner = false; } else if(option(argv[i], "NL", "nolog")) { log = false; - } else if(option(argv[i], "f", "file")){ + } else if(option(argv[i], "f", "file")) { fprog = argv[i + 1]; i++; } else { diff --git a/Library/exec.c b/Library/exec.c index 58099ad..30d88a2 100644 --- a/Library/exec.c +++ b/Library/exec.c @@ -38,12 +38,12 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dolog) { if(node->ident != NULL) { - if(dolog) __dw_print_node(node, true); int i; struct Node* newnode = malloc(sizeof(*newnode)); newnode->ident = NULL; newnode->string = NULL; newnode->nodes = NULL; + newnode->type = 0; newnode->errnum = DW_ERR_SUCCESS; char** fields = malloc(sizeof(*fields)); fields[0] = NULL; @@ -67,7 +67,9 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol return newnode; } if(__dw_strcaseequ(node->ident, "print")) { - if(r->string != NULL) { + if(r->type == 'N') { + printf("%f", r->number); + } else if(r->string != NULL) { printf("%s", r->string); } fflush(stdout); @@ -188,9 +190,14 @@ struct dataworks_db_result* dataworks_database_execute_code(struct dataworks_db* r->error = true; r->errnum = DW_ERR_PARSER_FAIL; } else { + if(dolog) { + __dw_print_node(node, true); + printf("\n"); + } struct Node* ret = parser_process(db, node, dolog); if(ret->errnum == DW_ERR_SUCCESS) { __dw_print_node(ret, true); + printf("\n"); } else { r->error = true; r->errnum = ret->errnum; diff --git a/Library/parser.c b/Library/parser.c index 7f5cade..10ba29f 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -102,11 +102,9 @@ void __dw_print_node(struct Node* node, bool top) { if(node->type == 'N') { printf("%f", node->number); fflush(stdout); - if(top) printf("\n"); } else if(node->string != NULL) { printf("\"%s\"", node->string); fflush(stdout); - if(top) printf("\n"); } else if(node->ident != NULL) { printf("%s(", node->ident); fflush(stdout); @@ -122,6 +120,5 @@ void __dw_print_node(struct Node* node, bool top) { } printf(")"); fflush(stdout); - if(top) printf("\n"); } }