Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYSTEM:AVAILABLE-ENCODINGS symbols strangeness #82

Closed
robert-dodier opened this issue Mar 27, 2018 · 2 comments
Closed

SYSTEM:AVAILABLE-ENCODINGS symbols strangeness #82

robert-dodier opened this issue Mar 27, 2018 · 2 comments

Comments

@robert-dodier
Copy link

I see that SYSTEM:AVAILABLE-ENCODINGS returns a list of symbols which represent the various encodings that are discovered via Charset.availableCharsets. That's great, but the symbols are apparently not interned in the keyword package, so it makes it somewhat confusing to determine whether a given encoding is on the list.

e.g. (member :utf-16 (system:available-encodings)) returns NIL, although looking at the list, you can see that :UTF-16 is there.

Confusingly, (mapcar #'symbol-package (system:available-encodings)) shows that all symbols are in the keyword package, but (find-symbol "UTF-16" :keyword) returns NIL.

I believe the problem is that availableEncodings in src/org/armedbear/lisp/Stream.java says, in part, (at line 399 in the current version)

new Symbol(charset, PACKAGE_KEYWORD)

but I think more appropriate would be

PACKAGE_KEYWORD.intern(charset)

Here is a patch which implements that change, and fixes the bug, from what I can tell.

Index: src/org/armedbear/lisp/Stream.java
===================================================================
--- src/org/armedbear/lisp/Stream.java	(revision 15113)
+++ src/org/armedbear/lisp/Stream.java	(working copy)
@@ -396,7 +396,7 @@
     SortedMap<String, Charset> available = Charset.availableCharsets();
     Set<String> encodings = available.keySet();
     for (String charset : encodings) {
-      result.add(new Symbol(charset, PACKAGE_KEYWORD));
+      result.add (PACKAGE_KEYWORD.intern (charset));
     }
     return result;
   }
@easye
Copy link
Collaborator

easye commented Apr 1, 2018

easye pushed a commit that referenced this issue Apr 1, 2018
@easye
Copy link
Collaborator

easye commented Apr 1, 2018

Merged. Thanks for the patch!

@easye easye closed this as completed Apr 1, 2018
slyrus pushed a commit to slyrus/abcl that referenced this issue Nov 16, 2019
(robert Dodier)

c.f. <armedbear/abcl#82>

git-svn-id: https://abcl.org/svn/trunk/abcl@15114 1c010e3e-69d0-11dd-93a8-456734b0d56f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants