]> Chaos Git - vn/vndc.git/commitdiff
Adding lookahead broke jump, firstlines and lastlines. After determining the cause...
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 02:12:16 +0000 (22:12 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 25 Aug 2014 02:12:16 +0000 (22:12 -0400)
bin/vndc.x86_64
buildscripts/build.generic
vndc/include/Data.hpp
vndc/src/Parse.cpp
vndc/src/op_jump.cpp

index 3523bfbc323b93fb6b961b7f5616c6e85221d493..0f8601baf5ce686ea91ffa1fe29276f4e0a69889 100755 (executable)
Binary files a/bin/vndc.x86_64 and b/bin/vndc.x86_64 differ
index 5f636a08d260f74b57469e2494a3a6cad933d61d..821567727352d91b08c94d53841b84121772aa32 100755 (executable)
@@ -11,7 +11,7 @@ SRC=$ROOT/
 LIB=$ROOT/external/lib
 BIN=$ROOT/bin
 
-CXXFLAGS="-DGIT_REV=\"$(git rev-parse HEAD)\""
+CXXFLAGS="-g -DGIT_REV=\"$(git rev-parse HEAD)\""
 
 source buildscripts/mk
 
index 48883a00358614470c460d0041d5d5f95edfd715..add415fe998a4176b12fb9562567b51658a6e4fb 100644 (file)
@@ -34,6 +34,7 @@ class DataContainer {
                bool verbose = false;
                int currentLine = 0;
                bool skip_key_on = false;
+               bool eof = false;
                char* window_name;
                char* next_line = NULL; // Used for voice-detect.
                                        // It's impossible to parse without lookahead.
index a4accd472be64a297e117d16725fa7f49fea687d..3a550bcd6d332492f13c4086cc55c340ea236583 100644 (file)
@@ -142,8 +142,6 @@ void ParseCmd(char* line) {
        }
        else if(!strcmp(tokens[0], "goto"))
                op_goto(tokens[1]);
-       else if(!strcmp(tokens[0], "label")) {}
-               // Nuthin.
        else if(!strcmp(tokens[0], "cleartext"))
                op_cleartext();
 
@@ -224,16 +222,7 @@ void Parse() {
        // Load the next line to this one.
        char* line = GetData()->next_line;
 
-       if(line == NULL) {
-               // We've reached EOF.
-               op_jump(GetData()->main_scr[0], NULL, true);
-       }
-
-       GetData()->next_line = (char*)calloc(sizeof(char), 400);
-       // Load the next line.
-       fgets(GetData()->next_line, 400, GetData()->accessScriptHandle);
-
-       char* line_copy = GetData()->next_line;
+       char* line_copy = line;
 
        while(line_copy[0] == ' ' || line_copy[0] == '\t') {
                line_copy[0] = '\0';
@@ -246,17 +235,22 @@ void Parse() {
                        line_copy[i] = '\0';
        }
 
+       GetData()->next_line = (char*)calloc(sizeof(char), 400);
+       fgets(GetData()->next_line, 400, GetData()->accessScriptHandle);
+
        // Execute the current line.
-       if(strlen(line) != 0) {
-               ParseCmd(line);
+       if(strlen(line_copy) != 0) {
+               ParseCmd(line_copy);
        }
 
        free(line);
 
+       // Load the next line.
+
        // The next line is null, because the file is finished.
-       if(feof(GetData()->accessScriptHandle)) {
-               free(GetData()->next_line);
-               GetData()->next_line = NULL;
+       if(feof(GetData()->accessScriptHandle) && strlen(GetData()->next_line) == 0) {
+               // We've reached EOF. Jump back and return.
+               op_jump(GetData()->main_scr[0], NULL, true);
        }
 
        return;
index a58b4d96af159f91a35cd59d9538a95b12508731..7650ab80b98e21d8d9cc5c5e094d021455e3e285 100644 (file)
@@ -5,13 +5,12 @@
 /*
  * Implements jump vnds function.
  * jump file
- * The parser actually does most of the work. This
- * just kind of gives it a nudge ans says 'reload k'
  */
 
 void op_jump(char* file, int* lineTo, bool isSave) {
        if (GetData()->if_fail != 0)
                return;
+
        memset(GetData()->current_scr, 0, 400);
        if(!isSave)
                snprintf(GetData()->current_scr, 400, "script/%s", file);
@@ -30,6 +29,7 @@ void op_jump(char* file, int* lineTo, bool isSave) {
        GetData()->accessScriptHandle = fopen(GetData()->current_scr, "r");
        if(GetData()->accessScriptHandle == NULL) {
                printf("[error] Failed to open script file %s.\n", GetData()->current_scr);
+               exit(-1);
        }
 
 
@@ -50,16 +50,4 @@ void op_jump(char* file, int* lineTo, bool isSave) {
        // Load the next line.
        fgets(GetData()->next_line, 400, GetData()->accessScriptHandle);
 
-       char* line_copy = GetData()->next_line;
-
-       while(line_copy[0] == ' ' || line_copy[0] == '\t') {
-               line_copy[0] = '\0';
-               line_copy = &line_copy[1];
-       }
-
-       // Remove all '\n' from the buffer line
-       for(int i=0; i < (int)strlen(line_copy); i++) {
-               if (line_copy[i] == '\n')
-                       line_copy[i] = '\0';
-       }
 }