minor cleanup of verbosity
authorJustin Wind <justin.wind@gmail.com>
Wed, 18 Apr 2012 03:03:47 +0000 (20:03 -0700)
committerJustin Wind <justin.wind@gmail.com>
Wed, 18 Apr 2012 03:03:47 +0000 (20:03 -0700)
as-dcpu16.c

index 2d131d7a40a167c37ee5115543aba21f9f73e8f6..063741d51a8698330c3a8af13d12c33a03114d11 100644 (file)
@@ -597,13 +597,9 @@ int tokenize_line_(char *line, struct instruction_ **next_instr) {
             struct operand_ *new_operand;
             char *y;
 
-            DEBUG_PRINTF("considering operand '%s'\n", x);
-
             /* trim whitespaces */
             x += strspn(x, whitespace);
 
-            DEBUG_PRINTF("considering ftrim operand '%s'\n", x);
-
             if (*x) {
                 for (y = x + strlen(x) - 1; *y; y--) {
                     if (strchr(whitespace, *y)) {
@@ -613,11 +609,11 @@ int tokenize_line_(char *line, struct instruction_ **next_instr) {
             }
             /* nothing left? */
             if (*x == '\0') {
-                fprintf(stderr, "ignoring null operand in line %zu\n", instr->src_line);
-                continue;
+                fprintf(stderr, "null operand encountered\n");
+                return -1;
             }
 
-            DEBUG_PRINTF("found operand '%s'\n", x);
+            DEBUG_PRINTF("tokenized operand '%s'\n", x);
 
             new_operand = malloc(sizeof *new_operand);
             if (new_operand == NULL) {
@@ -644,7 +640,7 @@ int tokenize_line_(char *line, struct instruction_ **next_instr) {
         }
     }
 
-    DEBUG_PRINTF("allocating instruction with room for %zu bytes\n", instr_words_needed);
+    DEBUG_PRINTF("allocating new instruction with room for %zu bytes\n", instr_words_needed);
 
     instr = calloc(1, (instr_words_needed * sizeof *instr->instr_words) + sizeof *instr);
     if (instr == NULL) {
@@ -1092,9 +1088,9 @@ int main(int argc, char *argv[]) {
 
             VERBOSE_PRINTF("assembling '%s'...\n", filename);
             c = parse_stream_(f, filename, instructionps_, labels_, allow_short_labels);
+            fclose(f);
             if (c)
                 break;
-            fclose(f);
         }
     } else {
         VERBOSE_PRINTF("assembling '%s'...\n", "stdin");