[armedbear-cvs] r12602 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sat Apr 10 21:36:07 UTC 2010


Author: ehuelsmann
Date: Sat Apr 10 17:36:06 2010
New Revision: 12602

Log:
Un-duplicate string reading between FaslReader and LispReader.

Modified:
   trunk/abcl/src/org/armedbear/lisp/FaslReader.java
   trunk/abcl/src/org/armedbear/lisp/LispReader.java
   trunk/abcl/src/org/armedbear/lisp/Stream.java

Modified: trunk/abcl/src/org/armedbear/lisp/FaslReader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/FaslReader.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/FaslReader.java	Sat Apr 10 17:36:06 2010
@@ -46,41 +46,7 @@
         public LispObject execute(Stream stream, char terminator)
 
         {
-            final Readtable rt = FaslReadtable.getInstance();
-            StringBuilder sb = new StringBuilder();
-            try 
-              {
-                while (true) {
-                  int n = stream._readChar();
-                  if (n < 0) {
-                    error(new EndOfFile(stream));
-                    // Not reached.
-                    return null;
-                  }
-                  char c = (char) n;
-                  if (rt.getSyntaxType(c) == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
-                    // Single escape.
-                    n = stream._readChar();
-                    if (n < 0) {
-                      error(new EndOfFile(stream));
-                      // Not reached.
-                      return null;
-                    }
-                    sb.append((char)n);
-                    continue;
-                  }
-                  if (c == terminator)
-                    break;
-                  // Default.
-                  sb.append(c);
-                }
-                return new SimpleString(sb);
-              }
-            catch (java.io.IOException e)
-              {
-                return new SimpleString(sb);
-		//                return null;
-              }
+            return stream.readString(terminator, Stream.faslReadtable);
         }
     };
 

Modified: trunk/abcl/src/org/armedbear/lisp/LispReader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispReader.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispReader.java	Sat Apr 10 17:36:06 2010
@@ -72,42 +72,7 @@
         public LispObject execute(Stream stream, char terminator)
 
         {
-            final LispThread thread = LispThread.currentThread();
-            final Readtable rt = (Readtable) Symbol.CURRENT_READTABLE.symbolValue(thread);
-            StringBuilder sb = new StringBuilder();
-            try 
-              {
-                while (true) {
-                  int n = stream._readChar();
-                  if (n < 0) {
-                    error(new EndOfFile(stream));
-                    // Not reached.
-                    return null;
-                  }
-                  char c = (char) n; // ### BUG: Codepoint conversion
-                  if (rt.getSyntaxType(c) == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
-                    // Single escape.
-                    n = stream._readChar();
-                    if (n < 0) {
-                      error(new EndOfFile(stream));
-                      // Not reached.
-                      return null;
-                    }
-                    sb.append((char)n); // ### BUG: Codepoint conversion
-                    continue;
-                  }
-                  if (c == terminator)
-                    break;
-                  // Default.
-                  sb.append(c);
-                }
-              }
-            catch (java.io.IOException e)
-              {
-                //error(new EndOfFile(stream));
-		return new SimpleString(sb);
-              }
-            return new SimpleString(sb);
+            return stream.readString(terminator, Stream.currentReadtable);
         }
     };
 

Modified: trunk/abcl/src/org/armedbear/lisp/Stream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Stream.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Stream.java	Sat Apr 10 17:36:06 2010
@@ -574,6 +574,46 @@
                                      this));
     }
 
+    public LispObject readString(char terminator, ReadtableAccessor rta)
+    {
+      final LispThread thread = LispThread.currentThread();
+      final Readtable rt = rta.rt(thread);
+      StringBuilder sb = new StringBuilder();
+      try
+      {
+        while (true) {
+          int n = _readChar();
+          if (n < 0) {
+            error(new EndOfFile(this));
+            // Not reached.
+            return null;
+          }
+          char c = (char) n; // ### BUG: Codepoint conversion
+          if (rt.getSyntaxType(c) == Readtable.SYNTAX_TYPE_SINGLE_ESCAPE) {
+            // Single escape.
+            n = _readChar();
+            if (n < 0) {
+              error(new EndOfFile(this));
+              // Not reached.
+              return null;
+            }
+            sb.append((char)n); // ### BUG: Codepoint conversion
+            continue;
+          }
+          if (c == terminator)
+            break;
+          // Default.
+          sb.append(c);
+        }
+      }
+      catch (java.io.IOException e)
+      {
+        //error(new EndOfFile(stream));
+        return new SimpleString(sb);
+      }
+      return new SimpleString(sb);
+    }
+
     public LispObject readList(boolean requireProperList,
                                ReadtableAccessor rta)
     {




More information about the armedbear-cvs mailing list