]> code.delx.au - gnu-emacs/blobdiff - src/charset.c
(BASE_PURESIZE): Increase to 1140000.
[gnu-emacs] / src / charset.c
index 2c985b14dbc777f0835ee012e56ebbc02210cd11..d7bb13abc399af140914f6c4dccd023e2ae21ee2 100644 (file)
@@ -1,6 +1,8 @@
 /* Basic multilingual character support.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-   Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001
+   Copyright (C) 2001, 2002, 2003, 2004, 2005,
+                 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+     2005, 2006, 2007, 2008
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
 
@@ -8,7 +10,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -335,7 +337,7 @@ split_string (str, len, charset, c1, c2)
   return 0;
 }
 
-/* Return 1 iff character C has valid printable glyph.
+/* Return 1 if character C has valid printable glyph.
    Use the macro CHAR_PRINTABLE_P instead.  */
 int
 char_printable_p (c)
@@ -1100,8 +1102,8 @@ DIMENSION, CHARS, and FINAL-CHAR.  */)
   return CHARSET_SYMBOL (charset);
 }
 
-/* If GENERICP is nonzero, return nonzero iff C is a valid normal or
-   generic character.  If GENERICP is zero, return nonzero iff C is a
+/* If GENERICP is nonzero, return nonzero if C is a valid normal or
+   generic character.  If GENERICP is zero, return nonzero if C is a
    valid normal character.  Do not call this function directly,
    instead use macro CHAR_VALID_P.  */
 int
@@ -1344,6 +1346,10 @@ lisp_string_width (string, precision, nchars, nbytes)
 {
   int len = SCHARS (string);
   int len_byte = SBYTES (string);
+  /* This set multibyte to 0 even if STRING is multibyte when it
+     contains only ascii and eight-bit-graphic, but that's
+     intentional.  */
+  int multibyte = len < len_byte;
   const unsigned char *str = SDATA (string);
   int i = 0, i_byte = 0;
   int width = 0;
@@ -1366,8 +1372,12 @@ lisp_string_width (string, precision, nchars, nbytes)
        }
       else if (dp)
        {
-         int c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+         int c;
 
+         if (multibyte)
+           c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+         else
+           c = str[i_byte], bytes = 1;
          chars = 1;
          val = DISP_CHAR_VECTOR (dp, c);
          if (VECTORP (val))
@@ -1378,7 +1388,10 @@ lisp_string_width (string, precision, nchars, nbytes)
       else
        {
          chars = 1;
-         PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+         if (multibyte)
+           PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+         else
+           bytes = 1;
          thiswidth = ONE_BYTE_CHAR_WIDTH (str[i_byte]);
        }