/[emacs]/emacs/src/charset.c
ViewVC logotype

Diff of /emacs/src/charset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.129 by raeburn, Mon May 20 08:05:09 2002 UTC revision 1.129.2.1 by miles, Fri Apr 4 06:20:57 2003 UTC
# Line 210  char_to_string_1 (c, str) Line 210  char_to_string_1 (c, str)
210        /* If C still has any modifier bits, just ignore it.  */        /* If C still has any modifier bits, just ignore it.  */
211        c &= ~CHAR_MODIFIER_MASK;        c &= ~CHAR_MODIFIER_MASK;
212      }      }
213      
214    if (SINGLE_BYTE_CHAR_P (c))    if (SINGLE_BYTE_CHAR_P (c))
215      {      {
216        if (ASCII_BYTE_P (c) || c >= 0xA0)        if (ASCII_BYTE_P (c) || c >= 0xA0)
# Line 345  char_printable_p (c) Line 345  char_printable_p (c)
345      return 0;      return 0;
346    else if (c >= MAX_CHAR)    else if (c >= MAX_CHAR)
347      return 0;      return 0;
348      
349    SPLIT_CHAR (c, charset, c1, c2);    SPLIT_CHAR (c, charset, c1, c2);
350    if (! CHARSET_DEFINED_P (charset))    if (! CHARSET_DEFINED_P (charset))
351      return 0;      return 0;
# Line 700  DESCRIPTION (string) is the description Line 700  DESCRIPTION (string) is the description
700        || !STRINGP (vec[7])        || !STRINGP (vec[7])
701        || !STRINGP (vec[8]))        || !STRINGP (vec[8]))
702      error ("Invalid info-vector argument for defining charset %s",      error ("Invalid info-vector argument for defining charset %s",
703             XSTRING (SYMBOL_NAME (charset_symbol))->data);             SDATA (SYMBOL_NAME (charset_symbol)));
704    
705    if (NILP (charset_id))    if (NILP (charset_id))
706      {      {
707        charset_id = get_new_private_charset_id (XINT (vec[0]), XINT (vec[2]));        charset_id = get_new_private_charset_id (XINT (vec[0]), XINT (vec[2]));
708        if (XINT (charset_id) == 0)        if (XINT (charset_id) == 0)
709          error ("There's no room for a new private charset %s",          error ("There's no room for a new private charset %s",
710                 XSTRING (SYMBOL_NAME (charset_symbol))->data);                 SDATA (SYMBOL_NAME (charset_symbol)));
711      }      }
712    
713    update_charset_table (charset_id, vec[0], vec[1], vec[2], vec[3],    update_charset_table (charset_id, vec[0], vec[1], vec[2], vec[3],
# Line 779  CHARSET should be defined by `defined-ch Line 779  CHARSET should be defined by `defined-ch
779    if (XINT (final_char) < '0' || XFASTINT (final_char) > '~')    if (XINT (final_char) < '0' || XFASTINT (final_char) > '~')
780      error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", XINT (chars));      error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", XINT (chars));
781    if ((charset = get_charset_id (charset_symbol)) < 0)    if ((charset = get_charset_id (charset_symbol)) < 0)
782      error ("Invalid charset %s", XSTRING (SYMBOL_NAME (charset_symbol))->data);      error ("Invalid charset %s", SDATA (SYMBOL_NAME (charset_symbol)));
783    
784    ISO_CHARSET_TABLE (dimension, chars, final_char) = charset;    ISO_CHARSET_TABLE (dimension, chars, final_char) = charset;
785    return Qnil;    return Qnil;
# Line 802  CHARSET should be defined by `defined-ch Line 802  CHARSET should be defined by `defined-ch
802    
803  int  int
804  find_charset_in_text (ptr, nchars, nbytes, charsets, table)  find_charset_in_text (ptr, nchars, nbytes, charsets, table)
805       unsigned char *ptr;       const unsigned char *ptr;
806       int nchars, nbytes, *charsets;       int nchars, nbytes, *charsets;
807       Lisp_Object table;       Lisp_Object table;
808  {  {
# Line 810  find_charset_in_text (ptr, nchars, nbyte Line 810  find_charset_in_text (ptr, nchars, nbyte
810      {      {
811        if (charsets && nbytes > 0)        if (charsets && nbytes > 0)
812          {          {
813            unsigned char *endp = ptr + nbytes;            const unsigned char *endp = ptr + nbytes;
814            int maskbits = 0;            int maskbits = 0;
815    
816            while (ptr < endp && maskbits != 7)            while (ptr < endp && maskbits != 7)
817              {              {
818                maskbits |= (*ptr < 0x80 ? 1 : *ptr < 0xA0 ? 2 : 4);                maskbits |= (*ptr < 0x80 ? 1 : *ptr < 0xA0 ? 2 : 4);
819                ptr++;                ptr++;
820              }                      }
821    
822            if (maskbits & 1)            if (maskbits & 1)
823              charsets[CHARSET_ASCII] = 1;              charsets[CHARSET_ASCII] = 1;
# Line 943  only `ascii', `eight-bit-control', and ` Line 943  only `ascii', `eight-bit-control', and `
943    CHECK_STRING (str);    CHECK_STRING (str);
944    
945    bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));    bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));
946    find_charset_in_text (XSTRING (str)->data, XSTRING (str)->size,    find_charset_in_text (SDATA (str), SCHARS (str),
947                          STRING_BYTES (XSTRING (str)), charsets, table);                          SBYTES (str), charsets, table);
948    
949    val = Qnil;    val = Qnil;
950    if (charsets[1])    if (charsets[1])
# Line 1176  The conversion is done based on `nonasci Line 1176  The conversion is done based on `nonasci
1176  }  }
1177    
1178  DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,  DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,
1179         doc: /* Return 1 regardless of the argument CHAR.         doc: /* Return 1 regardless of the argument CHAR.  */)
 This is now an obsolete function.  We keep it just for backward compatibility.  */)  
1180       (ch)       (ch)
1181       Lisp_Object ch;       Lisp_Object ch;
1182  {  {
# Line 1272  strwidth (str, len) Line 1271  strwidth (str, len)
1271    
1272  int  int
1273  c_string_width (str, len, precision, nchars, nbytes)  c_string_width (str, len, precision, nchars, nbytes)
1274       unsigned char *str;       const unsigned char *str;
1275       int precision, *nchars, *nbytes;       int len, precision, *nchars, *nbytes;
1276  {  {
1277    int i = 0, i_byte = 0;    int i = 0, i_byte = 0;
1278    int width = 0;    int width = 0;
# Line 1336  lisp_string_width (string, precision, nc Line 1335  lisp_string_width (string, precision, nc
1335       Lisp_Object string;       Lisp_Object string;
1336       int precision, *nchars, *nbytes;       int precision, *nchars, *nbytes;
1337  {  {
1338    int len = XSTRING (string)->size;    int len = SCHARS (string);
1339    int len_byte = STRING_BYTES (XSTRING (string));    int len_byte = SBYTES (string);
1340    unsigned char *str = XSTRING (string)->data;    const unsigned char *str = SDATA (string);
1341    int i = 0, i_byte = 0;    int i = 0, i_byte = 0;
1342    int width = 0;    int width = 0;
1343    struct Lisp_Char_Table *dp = buffer_display_table ();    struct Lisp_Char_Table *dp = buffer_display_table ();
# Line 1452  DEFUN ("chars-in-region", Fchars_in_regi Line 1451  DEFUN ("chars-in-region", Fchars_in_regi
1451    
1452  int  int
1453  chars_in_text (ptr, nbytes)  chars_in_text (ptr, nbytes)
1454       unsigned char *ptr;       const unsigned char *ptr;
1455       int nbytes;       int nbytes;
1456  {  {
1457    /* current_buffer is null at early stages of Emacs initialization.  */    /* current_buffer is null at early stages of Emacs initialization.  */
# Line 1469  chars_in_text (ptr, nbytes) Line 1468  chars_in_text (ptr, nbytes)
1468    
1469  int  int
1470  multibyte_chars_in_text (ptr, nbytes)  multibyte_chars_in_text (ptr, nbytes)
1471       unsigned char *ptr;       const unsigned char *ptr;
1472       int nbytes;       int nbytes;
1473  {  {
1474    unsigned char *endp;    const unsigned char *endp;
1475    int chars, bytes;    int chars, bytes;
1476    
1477    endp = ptr + nbytes;    endp = ptr + nbytes;
# Line 1494  multibyte_chars_in_text (ptr, nbytes) Line 1493  multibyte_chars_in_text (ptr, nbytes)
1493     0x80..0x9F are represented by 2 bytes in multibyte text.  */     0x80..0x9F are represented by 2 bytes in multibyte text.  */
1494  void  void
1495  parse_str_as_multibyte (str, len, nchars, nbytes)  parse_str_as_multibyte (str, len, nchars, nbytes)
1496       unsigned char *str;       const unsigned char *str;
1497       int len, *nchars, *nbytes;       int len, *nchars, *nbytes;
1498  {  {
1499    unsigned char *endp = str + len;    const unsigned char *endp = str + len;
1500    int n, chars = 0, bytes = 0;    int n, chars = 0, bytes = 0;
1501    
1502    while (str < endp)    while (str < endp)
# Line 1549  str_as_multibyte (str, len, nbytes, ncha Line 1548  str_as_multibyte (str, len, nbytes, ncha
1548          {          {
1549            while (n--)            while (n--)
1550              *to++ = *p++;              *to++ = *p++;
1551          }                  }
1552        else        else
1553          {          {
1554            *to++ = LEADING_CODE_8_BIT_CONTROL;            *to++ = LEADING_CODE_8_BIT_CONTROL;
# Line 1601  str_to_multibyte (str, len, bytes) Line 1600  str_to_multibyte (str, len, bytes)
1600    endp = str + len;    endp = str + len;
1601    safe_bcopy (p, endp - bytes, bytes);    safe_bcopy (p, endp - bytes, bytes);
1602    p = endp - bytes;    p = endp - bytes;
1603    while (p < endp)          while (p < endp)
1604      {      {
1605        if (*p < 0x80 || *p >= 0xA0)        if (*p < 0x80 || *p >= 0xA0)
1606          *to++ = *p++;          *to++ = *p++;
# Line 1625  str_as_unibyte (str, bytes) Line 1624  str_as_unibyte (str, bytes)
1624    
1625    while (p < endp && *p != LEADING_CODE_8_BIT_CONTROL) p++;    while (p < endp && *p != LEADING_CODE_8_BIT_CONTROL) p++;
1626    to = p;    to = p;
1627    while (p < endp)          while (p < endp)
1628      {      {
1629        if (*p == LEADING_CODE_8_BIT_CONTROL)        if (*p == LEADING_CODE_8_BIT_CONTROL)
1630          *to++ = *(p + 1) - 0x20, p += 2;          *to++ = *(p + 1) - 0x20, p += 2;

Legend:
Removed from v.1.129  
changed lines
  Added in v.1.129.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26