[armedbear-cvs] r12323 - trunk/abcl/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Fri Jan 1 19:41:18 UTC 2010
Author: ehuelsmann
Date: Fri Jan 1 14:41:15 2010
New Revision: 12323
Log:
Implement setting of external format on a stream;
only supported on the Java side for now.
Modified:
trunk/abcl/src/org/armedbear/lisp/FileStream.java
trunk/abcl/src/org/armedbear/lisp/Stream.java
Modified: trunk/abcl/src/org/armedbear/lisp/FileStream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/FileStream.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/FileStream.java Fri Jan 1 14:41:15 2010
@@ -151,6 +151,15 @@
return super.typep(typeSpecifier);
}
+ @Override
+ public void setExternalFormat(LispObject format) {
+ super.setExternalFormat(format);
+
+ if (racf != null)
+ // setExternalFormat also called before 'racf' is set up
+ racf.setEncoding(encoding);
+ }
+
public Pathname getPathname()
{
return pathname;
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 Fri Jan 1 14:41:15 2010
@@ -269,12 +269,15 @@
public LispObject getExternalFormat() {
return externalFormat;
}
-
+
public String getEncoding() {
return encoding;
}
-
+
public void setExternalFormat(LispObject format) {
+ // make sure we encode any remaining buffers with the current format
+ finishOutput();
+
if (format == keywordDefault) {
encoding = null;
eolStyle = platformEolStyle;
@@ -282,10 +285,10 @@
externalFormat = format;
return;
}
-
+
LispObject enc;
boolean encIsCp = false;
-
+
if (format instanceof Cons) {
// meaning a non-empty list
enc = format.car();
@@ -294,7 +297,7 @@
enc = getf(format.cdr(), keywordID, null);
}
-
+
LispObject eol = getf(format.cdr(), keywordEolStyle, keywordRAW);
if (eol == keywordCR)
eolStyle = EolStyle.CR;
@@ -304,10 +307,10 @@
eolStyle = EolStyle.CRLF;
else if (eol != keywordRAW)
; //###FIXME: raise an error
-
+
} else
enc = format;
-
+
if (enc.numberp())
encoding = enc.toString();
else if (enc instanceof AbstractString)
More information about the armedbear-cvs
mailing list