]> Nishi Git Mirror - dataworks.git/commitdiff
fix
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 5 Jun 2024 03:02:21 +0000 (03:02 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 5 Jun 2024 03:02:21 +0000 (03:02 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@152 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/client.c
Library/exec.c
Library/parser.c

index 3a02d8888748e6d835da2850b714c5dbf58bd0be..18a29697f1424595e4f17bdb397c98478b7bc5b7 100644 (file)
@@ -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 {
index 58099ad7c8da967df92e163ce9112e56f86634f3..30d88a24732c92c0c14ddc29c153ddfbabcbad8a 100644 (file)
 
 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;
index 7f5cade2da32767d94991c3671d541ebdde9d96a..10ba29f348f9a2e7e5e9f6266120cce655224abe 100644 (file)
@@ -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");
        }
 }