[SCM] Lisaac compiler branch, master, updated. 2738355d5d2a63aabad9d2f4d7cc0a4670eb44cc

Jeremy Cowgar jeremy at cowgar.com
Wed Jul 29 03:42:39 UTC 2009


The following commit has been merged in the master branch:
commit 2738355d5d2a63aabad9d2f4d7cc0a4670eb44cc
Author: Jeremy Cowgar <jeremy at cowgar.com>
Date:   Tue Jul 28 23:36:36 2009 -0400

    * Added ifdef check for MING32 to unix\system\system_io.li as sys/stdcall.h
      does not exist on Windows. This was preventing many programs from compiling
      on the Windows platform.
    * Added testing directory (including unit_test.li) to new lib2 directory.
    * Applied many previous patches to lib into lib2, including:
      * Added to_string and to_string_in to CHARACTER.
      * Documented a bit better what CHARACTER.is_separator does.
      * Added index_of to ABSTRACT_STRING.
      * Fixed bug in fast_index_of which would cause a "NOT FOUND"
        value to be returned if the character only appeared on the
      * Added is_binary to ABSTRACT_STRING.
      * Fixed bug in is_real_16_16: During the overflow check, it was
        making a decision based on if the number was negative or not,
        however, the number (if negated) was never actually negated
        until the end of the routine. This now causes all current
        unit tests to pass for ABSTRACT_STRING.

diff --git a/lib2/base/character.li b/lib2/base/character.li
index fa9d688..0d0c532 100644
--- a/lib2/base/character.li
+++ b/lib2/base/character.li
@@ -329,7 +329,7 @@ Section Public
   );
   
   - is_separator:BOOLEAN <-
-  // True when character is a separator.
+  // True when character is a separator (' ', '\t', '\n', '\r', '\0', '\f', '\v')?
   (
     (Self= ' ') || {Self = '\t'} || {Self='\n'} ||
     {Self='\r'} || {Self = '\0'} || {Self='\f'} || {Self='\v'}
@@ -371,6 +371,20 @@ Section Public
   // Conversions:
   //
   
+  - to_string:STRING <-
+  // Create a new STRING containing only this character.
+  (
+    STRING.create_filled (Self,1)
+  );
+
+  - to_string_in str:STRING <-
+  // Append this character at the end of 'str'. Thus you
+  // can save memory because no other STRING is allocated
+  // for the job.
+  (
+    str.append_character Self;
+  );
+
   - to_hexadecimal:STRING <-
   // Create a new STRING giving the `code' in hexadecimal.
   // For example :
diff --git a/lib2/string/abstract_string.li b/lib2/string/abstract_string.li
index 7da4b19..07aa6a9 100644
--- a/lib2/string/abstract_string.li
+++ b/lib2/string/abstract_string.li
@@ -263,11 +263,18 @@ Section Public
   // Gives the index of the first occurrence `ch' or
   // 0 if none.
   (+ result:INTEGER;
-    result := 1 + storage.fast_index_of (ch,1) until (count - 1);    
-    ?	{(result != count + 1) ->> {item result = ch}};    
+    result := 1 + storage.fast_index_of (ch,0) until (count - 1);
+    ? {(result != count + 1) ->> {item result = ch}};
     result
   );
   
+  - index_of ch:CHARACTER :INTEGER <-
+  // Gives the index of the first occurrence of 'ch' or
+  // 0 if none.
+  (
+    fast_index_of ch
+  );
+
   - first_index_of c:CHARACTER :INTEGER <-  
   // Index of first occurrence of `c' at index 1 or after index 1.
   (
@@ -564,6 +571,22 @@ Section Public
     result
   );
 
+  - is_binary :BOOLEAN <-
+  ( + result:BOOLEAN;
+    + j:INTEGER;
+
+    (is_empty).if_false {
+      j := lower;
+      { (j > upper) || {! item j.is_binary_digit} }.until_do {
+        j := j + 1;
+      };
+
+      result := j > upper;
+    };
+
+    result
+  );
+
   - to_binary :INTEGER_64 <-
   ( + result:INTEGER_64;
     ? {is_bit};
diff --git a/lib/testing/unit_test.li b/lib2/testing/unit_test.li
similarity index 100%
copy from lib/testing/unit_test.li
copy to lib2/testing/unit_test.li
diff --git a/lib2_os/unix/system/system_io.li b/lib2_os/unix/system/system_io.li
index 8394241..e3e14e7 100644
--- a/lib2_os/unix/system/system_io.li
+++ b/lib2_os/unix/system/system_io.li
@@ -29,7 +29,9 @@ Section Header
   - external := `
 #include <stdio.h>
 #include <stdlib.h>
+#ifndef __MINGW32__
 #include <sys/syscall.h>  
+#endif
 // Hardware 'print_char'
 void print_char(char car)
 {

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list