Added error messages displaying using source file name and line number
[zilutils.git] / zilasm / string_table.cpp
index a086b8794c31bf29d137c3821f157def2e8a9a68..ed2b6d7c1db0e00b892e3a81a70c721830507524 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * string_table.cpp -- part of ZilUtils/ZilAsm
  *
- * Copyright (C) 2019 Jason Self <j@jxself.org>
+ * Copyright (C) 2019, 2020 Jason Self <j@jxself.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -90,7 +90,14 @@ String_table::encrypt_string (const char *str, ZMemblock * zmb)
        }
       else if (c == ' ')
        {
-         write_one_word_to_string_table (zmb, &w, &numberOfSymbolsInWord, 0);
+                 //if (numberOfSymbolsInWord != 0)
+                 //{
+                        // zmem_putbyte(zmb, (w >> 8) & 255);
+                        // zmem_putbyte(zmb, w & 255);
+                        // numberOfSymbolsInWord = 0;
+                        // w = 0;
+                 //}
+                 write_one_word_to_string_table (zmb, &w, &numberOfSymbolsInWord, 0);
        }
       else
        {
@@ -130,7 +137,14 @@ String_table::encrypt_string (const char *str, ZMemblock * zmb)
       numberOfSymbolsInWord = 0;
       w = 0;
     }
-  zmb->contents[zmb->used_size - 2] |= 0x80;
+  
+  if ((zmb->contents[zmb->used_size - 1] & 31) == 0) // if the last symbol is a space or not filled
+         zmb->contents[zmb->used_size - 2] |= 0x80;     // then we mark this word as the last word
+  else
+  {
+         zmem_putbyte(zmb, 0x80);                       // otherwise we add one more empty word
+         zmem_putbyte(zmb, 0x0);                        // with 15-th bit set
+  }
 
   return zmb;
 }