emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: char-to-string


From: Kenichi Handa
Subject: Re: char-to-string
Date: Fri, 9 Feb 2001 14:33:07 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.0.97 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

ShengHuo ZHU <address@hidden> writes:
> [1  <text/plain (7bit)>]
> (multibyte-string-p (char-to-string ?\200)) returns t, but in Emacs 20
> it returns nil.  This is annoying.  For example, I think programmers
> prefer that (mapconcat 'char-to-string '(?\200 ?\343) "") returns
> "\200\343".  The attached patch fixes this.  Thoughts?

Thank you for the report and patch.  I agree with you.
Especially, there's no reason to have the different behavior
than Emacs 20.

I've just installed the attached change.  
  (string ?\200 ?\343)
should also return a unibyte string.

---
Ken'ichi HANDA
address@hidden

2001-02-09  Kenichi Handa  <address@hidden>

        * charset.c (Fstring): If all arguments are less than 256, return
        a unibyte string.

        * editfns.c (Fchar_to_string): If CHARACTER is less than 256,
        return a unibyte string.

Index: charset.c
===================================================================
RCS file: /cvs/emacs/src/charset.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -c -r1.114 -r1.115
cvs server: conflicting specifications of output style
*** charset.c   2001/02/07 04:24:49     1.114
--- charset.c   2001/02/09 05:32:24     1.115
***************
*** 1619,1630 ****
    unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n);
    unsigned char *p = buf;
    int c;
  
    for (i = 0; i < n; i++)
      {
        CHECK_NUMBER (args[i], 0);
        c = XINT (args[i]);
!       p += CHAR_STRING (c, p);
      }
  
    return make_string_from_bytes (buf, n, p - buf);
--- 1619,1640 ----
    unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n);
    unsigned char *p = buf;
    int c;
+   int multibyte = 0;
  
    for (i = 0; i < n; i++)
      {
        CHECK_NUMBER (args[i], 0);
+       if (!multibyte && !SINGLE_BYTE_CHAR_P (XFASTINT (args[i])))
+       multibyte = 1;
+     }
+ 
+   for (i = 0; i < n; i++)
+     {
        c = XINT (args[i]);
!       if (multibyte)
!       p += CHAR_STRING (c, p);
!       else
!       *p++ += c;
      }
  
    return make_string_from_bytes (buf, n, p - buf);
Index: editfns.c
===================================================================
RCS file: /cvs/emacs/src/editfns.c,v
retrieving revision 1.296
retrieving revision 1.297
diff -u -c -r1.296 -r1.297
cvs server: conflicting specifications of output style
*** editfns.c   2001/02/02 07:53:06     1.296
--- editfns.c   2001/02/09 05:32:46     1.297
***************
*** 167,173 ****
  
    CHECK_NUMBER (character, 0);
  
!   len = CHAR_STRING (XFASTINT (character), str);
    return make_string_from_bytes (str, 1, len);
  }
  
--- 167,175 ----
  
    CHECK_NUMBER (character, 0);
  
!   len = (SINGLE_BYTE_CHAR_P (XFASTINT (character))
!        ? (*str = (unsigned char)(XFASTINT (character)), 1)
!        : char_to_string (XFASTINT (character), str));
    return make_string_from_bytes (str, 1, len);
  }
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]