Subject: [clisp-list] new-clx builds bad encoding name

From: Pascal J.Bourguignon <[email-masked]>
Date: Sun Dec 14 09:49:02 2003

While compiling garnet with clisp 2.31 on Darwin,  I get this error:

Loading #P"/local/share/lisp/packages/net/sourceforge/garnet/gadgets/scrolling-menu"
;;    Loading file /local/share/lisp/packages/net/sourceforge/garnet/gadgets/scrolling-menu.lisp ...
Object SCROLLING-MENU-FRAME
Object SCROLLING-MENU-INTERIM-FEEDBACK
Object SCROLLING-MENU-TITLE
Object SCROLLING-MENU-TEXT-LABEL-PROTOTYPE
Object SCROLLING-MENU-ITEM
Object SCROLLING-MENU-ITEM-LIST
Object SCROLLING-MENU-SCROLL-BAR
Object SCROLLING-MENU-SELECTOR
Object SCROLLING-MENU

*** - EXT:MAKE-ENCODING: illegal :CHARSET argument "ISO8859-1"

Indeeed, the exported symbol is ISO-8859-1.

1. Break GG[14]> :bt
<1> #<SYSTEM-FUNCTION EXT:SHOW-STACK>
<2> #<COMPILED-CLOSURE SYSTEM::DEBUG-BACKTRACE>
<3> #<SYSTEM-FUNCTION SYSTEM::READ-EVAL-PRINT>
<4> #<COMPILED-CLOSURE SYSTEM::BREAK-LOOP-2-1>
<5> #<SYSTEM-FUNCTION SYSTEM::SAME-ENV-AS>
<6> #<COMPILED-CLOSURE SYSTEM::BREAK-LOOP-2>
<7> #<SYSTEM-FUNCTION SYSTEM::DRIVER>
<8> #<COMPILED-CLOSURE SYSTEM::BREAK-LOOP>
<9> #<SYSTEM-FUNCTION INVOKE-DEBUGGER>
<10> #<SYSTEM-FUNCTION EXT:MAKE-ENCODING>
<11> #<ADD-ON-SYSTEM-FUNCTION XLIB:MAX-CHAR-ASCENT>
<12> #<COMPILED-CLOSURE GEM::X-MAX-CHARACTER-ASCENT>
<13> #<COMPILED-CLOSURE GEM:MAX-CHARACTER-ASCENT>
<14> #<COMPILED-CLOSURE #:|(CREATE-INSTANCE 'FONT GRAPHIC-QUALITY ...)-10-4|>
<15> #<COMPILED-CLOSURE KR::RE-EVALUATE-FORMULA>
<16> #<COMPILED-CLOSURE KR::G-VALUE-FORMULA-VALUE>
<17> #<COMPILED-CLOSURE KR::GV-VALUE-FN>
<18> #<COMPILED-CLOSURE #:|(CREATE-INSTANCE 'FONT GRAPHIC-QUALITY ...)-10-2|>
<19> #<COMPILED-CLOSURE KR::RE-EVALUATE-FORMULA>
<20> #<COMPILED-CLOSURE KR::G-VALUE-FORMULA-VALUE>
<21> #<COMPILED-CLOSURE KR::VALUE-FN>
<22> #<COMPILED-CLOSURE OPAL:STRING-HEIGHT>

The   error  seems   to  be   coming  via   XLIB:MAX-CHAR-ASCENT  from
clisp/modules/clx/new-clx/clx.f line  1056 to  1081. It looks  like it
builds   the   encoding   name   from   the   registry   of   some   X
font.  Unfortunately, that  registry  is "iso8859"  while the  CHARSET
package exports ISO-8859-1 et al.

I hoped to be able to correct this bug adding this:

    char* new_registry=0;
    char* old_registry=0;
    if((strncmp(names[0],"iso",3)==0)&&(names[0][3]!='-')){
        new_registry=malloc(strlen(names[0])+2);
        sprintf(new_registry,"iso-%s",names[0]+3);
        old_registry=names[0];
        names[0]=new_registry;
    }

at the point marked /***BEFORE***/ and this:

   if(new_registry){
        free(new_registry);
        names[0]=old_registry;
   }

at the point marked /***AFTER***/, but it does not seem to work.

          xatoms[0] = rgstry;
          xatoms[1] = encdng;
          names[0] = NULL;
          names[1] = NULL;
#        if !defined(HAVE_XGETATOMNAMES)
          names[0] = XGetAtomName (dpy, xatoms[0]);
          names[1] = XGetAtomName (dpy, xatoms[1]);
          status = names[0] && names[1];
#        else
          status = XGetAtomNames (dpy, xatoms, 2, names); /* X11R6 */
#        endif
          if (status) {
          /***BEFORE***/
            end_x_call();
            pushSTACK(asciz_to_string (names[0], GLO(misc_encoding)));
            pushSTACK(`"-"`);
            pushSTACK(asciz_to_string (names[1], GLO(misc_encoding)));
            value1 = string_concat(3);
            pushSTACK(`:CHARSET`); pushSTACK(value1);
            pushSTACK(`:OUTPUT-ERROR-ACTION`);
            pushSTACK(fixnum(info->default_char));
            funcall(L(make_encoding), 4);
            pushSTACK(STACK_0); /* obj */
            pushSTACK(`XLIB::ENCODING`);
            pushSTACK(value1);
            funcall (L(set_slot_value), 3);
          /***AFTER***/
          }

-- 
__Pascal_Bourguignon__                              .  *   * . * .* .
http://www.informatimago.com/                        .   *   .   .*
There is no worse tyranny than to force             * .  . /\  ()  . *
a man to pay for what he does not                    . .  / .\   . * .
want merely because you think it                    .*.  / *  \  . .
would be good for him. -- Robert Heinlein             . /*   o \     .
http://www.theadvocates.org/                        *   '''||'''   .
SCO Spam-magnet: [email-masked]                 ******************

---

From: Sam Steingold <[email-masked]>
Date: Sun Dec 14 12:35:01 2003

> * Pascal J.Bourguignon <[email-masked]> [2003-12-14 18:47:59 +0100]:
>
> builds the encoding name from the registry of some X font.
> Unfortunately, that registry is "iso8859" while the CHARSET package
> exports ISO-8859-1 et al.

[6]> (make-encoding :charset "iso8859-1")
#<ENCODING "iso8859-1" :UNIX>

apparently Darwin does not have a good iconv(), so the right way to
handle this problem is to install gnu libiconv and then everything
should work OOTB.

Bruno, should MAKE-ENCODING automatically convert "iso8859-1" to
CHARSET:ISO-8859-1?
Should CHARSET contain ISO8859-1 as a synonym for ISO-8859-1?

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
You think Oedipus had a problem -- Adam was Eve's mother.

---

From: Sam Steingold <[email-masked]>
Date: Sat Dec 20 11:03:04 2003

> exports ISO-8859-1 et al.

please try the appended patch.
thanks.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Failure is not an option. It comes bundled with your Microsoft product.

--- clx.f.~2.10.~	2003-10-31 10:10:45.612776300 -0500
+++ clx.f	2003-12-20 13:49:02.009396800 -0500
@@ -1065,12 +1065,16 @@
           status = XGetAtomNames (dpy, xatoms, 2, names); /* X11R6 */
 #        endif
           if (status) {
+            char* whole = alloca(strlen(names[0])+strlen(names[1])+3);
+            if (!strncasecmp(names[0],"iso",3) && names[0][3] != '-') {
+              strcpy(whole,"ISO-");
+              strcat(whole,names[0]+3);
+            } else strcpy(whole,names[0]);
+            strcat(whole,"-");
+            strcat(whole,names[1]);
             end_x_call();
-            pushSTACK(asciz_to_string (names[0], GLO(misc_encoding)));
-            pushSTACK(`"-"`);
-            pushSTACK(asciz_to_string (names[1], GLO(misc_encoding)));
-            value1 = string_concat(3);
-            pushSTACK(`:CHARSET`); pushSTACK(value1);
+            pushSTACK(`:CHARSET`);
+            pushSTACK(asciz_to_string(whole,GLO(misc_encoding)));
             pushSTACK(`:OUTPUT-ERROR-ACTION`);
             pushSTACK(fixnum(info->default_char));
             funcall(L(make_encoding), 4);
@@ -1078,8 +1082,8 @@
             pushSTACK(`XLIB::ENCODING`);
             pushSTACK(value1);
             funcall (L(set_slot_value), 3);
-          }
           begin_x_call();
+          }
           if (names[0])
             XFree (names[0]);
           if (names[1])