]> code.delx.au - gnu-emacs/blobdiff - src/fns.c
(temp_output_buffer_setup): Use new type for overlays_(before|after).
[gnu-emacs] / src / fns.c
index 871c6dcb6188a6f4483cb0a3bd9ba6a7c96edc39..04c6d41ebec3f265cc5a53743a59ba17aea65b69 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -1,5 +1,5 @@
 /* Random utility Lisp functions.
-   Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 98, 99, 2000, 2001, 2002
+   Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 98, 99, 2000, 2001, 02, 2003
    Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -26,10 +26,16 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #include <time.h>
 
+#ifndef MAC_OSX
+/* On Mac OS X, defining this conflicts with precompiled headers.  */
+
 /* Note on some machines this defines `vector' as a typedef,
    so make sure we don't use that name in this file.  */
 #undef vector
 #define vector *****
+
+#endif  /* ! MAC_OSX */
+
 #include "lisp.h"
 #include "commands.h"
 #include "charset.h"
@@ -136,6 +142,8 @@ To get the number of bytes, use `string-bytes'. */)
     XSETFASTINT (val, SCHARS (sequence));
   else if (VECTORP (sequence))
     XSETFASTINT (val, XVECTOR (sequence)->size);
+  else if (SUB_CHAR_TABLE_P (sequence))
+    XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS);
   else if (CHAR_TABLE_P (sequence))
     XSETFASTINT (val, MAX_CHAR);
   else if (BOOL_VECTOR_P (sequence))
@@ -1047,16 +1055,15 @@ string_to_multibyte (string)
 {
   unsigned char *buf;
   int nbytes;
-  int i;
 
   if (STRING_MULTIBYTE (string))
     return string;
 
   nbytes = parse_str_to_multibyte (SDATA (string), SBYTES (string));
-  /* If all the chars are ASCII, they won't need any more bytes
-     once converted.  In that case, we can return STRING itself.  */
+  /* If all the chars are ASCII or eight-bit-graphic, they won't need
+     any more bytes once converted.  */
   if (nbytes == SBYTES (string))
-    return string;
+    return make_multibyte_string (SDATA (string), nbytes, nbytes);
 
   buf = (unsigned char *) alloca (nbytes);
   bcopy (SDATA (string), buf, SBYTES (string));
@@ -2503,9 +2510,9 @@ a coding system, or a character code.  */)
 
 DEFUN ("set-char-table-default", Fset_char_table_default,
        Sset_char_table_default, 3, 3, 0,
-       doc: /* Set the default value in CHAR-TABLE for a generic character CHAR to VALUE.
+       doc: /* Set the default value in CHAR-TABLE for generic character CH to VALUE.
 The generic character specifies the group of characters.
-See also the documentation of make-char.  */)
+See also the documentation of `make-char'.  */)
      (char_table, ch, value)
      Lisp_Object char_table, ch, value;
 {
@@ -2627,9 +2634,9 @@ DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table,
    ARG is passed to C_FUNCTION when that is called.  */
 
 void
-map_char_table (c_function, function, subtable, arg, depth, indices)
+map_char_table (c_function, function, table, subtable, arg, depth, indices)
      void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
-     Lisp_Object function, subtable, arg, *indices;
+     Lisp_Object function, table, subtable, arg, *indices;
      int depth;
 {
   int i, to;
@@ -2639,7 +2646,11 @@ map_char_table (c_function, function, subtable, arg, depth, indices)
       /* At first, handle ASCII and 8-bit European characters.  */
       for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++)
        {
-         Lisp_Object elt = XCHAR_TABLE (subtable)->contents[i];
+         Lisp_Object elt= XCHAR_TABLE (subtable)->contents[i];
+         if (NILP (elt))
+           elt = XCHAR_TABLE (subtable)->defalt;
+         if (NILP (elt))
+           elt = Faref (subtable, make_number (i));
          if (c_function)
            (*c_function) (arg, make_number (i), elt);
          else
@@ -2680,17 +2691,21 @@ map_char_table (c_function, function, subtable, arg, depth, indices)
        {
          if (depth >= 3)
            error ("Too deep char table");
-         map_char_table (c_function, function, elt, arg, depth + 1, indices);
+         map_char_table (c_function, function, table, elt, arg, depth + 1, indices);
        }
       else
        {
          int c1, c2, c;
 
-         if (NILP (elt))
-           elt = XCHAR_TABLE (subtable)->defalt;
          c1 = depth >= 1 ? XFASTINT (indices[1]) : 0;
          c2 = depth >= 2 ? XFASTINT (indices[2]) : 0;
          c = MAKE_CHAR (charset, c1, c2);
+
+         if (NILP (elt))
+           elt = XCHAR_TABLE (subtable)->defalt;
+         if (NILP  (elt))
+           elt = Faref (table, make_number (c));
+
          if (c_function)
            (*c_function) (arg, make_number (c), elt);
          else
@@ -2699,6 +2714,14 @@ map_char_table (c_function, function, subtable, arg, depth, indices)
     }
 }
 
+static void void_call2 P_ ((Lisp_Object a, Lisp_Object b, Lisp_Object c));
+static void
+void_call2 (a, b, c)
+     Lisp_Object a, b, c;
+{
+  call2 (a, b, c);
+}
+
 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table,
        2, 2, 0,
        doc: /* Call FUNCTION for each (normal and generic) characters in CHAR-TABLE.
@@ -2712,7 +2735,11 @@ The key is always a possible IDX argument to `aref'.  */)
 
   CHECK_CHAR_TABLE (char_table);
 
-  map_char_table ((POINTER_TYPE *) call2, Qnil, char_table, function, 0, indices);
+  /* When Lisp_Object is represented as a union, `call2' cannot directly
+     be passed to map_char_table because it returns a Lisp_Object rather
+     than returning nothing.
+     Casting leads to crashes on some architectures.  -stef  */
+  map_char_table (void_call2, Qnil, char_table, char_table, function, 0, indices);
   return Qnil;
 }
 
@@ -3194,7 +3221,12 @@ When USE-FLOATS is non-nil, floats will be used instead of integers.
 These floats are not multiplied by 100.
 
 If the 5-minute or 15-minute load averages are not available, return a
-shortened list, containing only those averages which are available.  */)
+shortened list, containing only those averages which are available.
+
+An error is thrown if the load average can't be obtained.  In some
+cases making it work would require Emacs being installed setuid or
+setgid so that it can read kernel information, and that usually isn't
+advisable.  */)
      (use_floats)
      Lisp_Object use_floats;
 {
@@ -3448,15 +3480,24 @@ usage: (widget-apply WIDGET PROPERTY &rest ARGS)  */)
 #endif
 
 DEFUN ("langinfo", Flanginfo, Slanginfo, 1, 1, 0,
-       doc: /* Access locale category ITEM, if available.
+       doc: /* Access locale data ITEM, if available.
 
 ITEM may be one of the following:
-`codeset', returning the character set as a string (CODESET);
-`days', returning a 7-element vector of day names (DAY_n);
-`months', returning a 12-element vector of month names (MON_n).
+
+`codeset', returning the character set as a string (locale item CODESET);
+
+`days', returning a 7-element vector of day names (locale items DAY_n);
+
+`months', returning a 12-element vector of month names (locale items MON_n);
+
+`paper', returning a list (WIDTH, HEIGHT) for the default paper size,
+  where the width and height are in mm (locale items PAPER_WIDTH,
+  PAPER_HEIGHT).
 
 If the system can't provide such information through a call to
-nl_langinfo(3), return nil.
+nl_langinfo(3) or if ITEM isn't from the list above, return nil.
+
+See also Info node `(libc)Locales'.
 
 The data read from the system are decoded using `locale-coding-system'.  */)
      (item)
@@ -3485,7 +3526,7 @@ The data read from the system are decoded using `locale-coding-system'.  */)
             it is consistent with CODESET?  If not, what to do?  */
          Faset (v, make_number (i),
                 code_convert_string_norecord (val, Vlocale_coding_system,
-                                              Qnil));
+                                              0));
        }
       return v;
     }
@@ -3503,7 +3544,7 @@ The data read from the system are decoded using `locale-coding-system'.  */)
          str = nl_langinfo (months[i]);
          val = make_unibyte_string (str, strlen (str));
          p->contents[i] =
-           code_convert_string_norecord (val, Vlocale_coding_system, Qnil);
+           code_convert_string_norecord (val, Vlocale_coding_system, 0);
        }
       XSETVECTOR (val, p);
       return val;
@@ -3519,7 +3560,7 @@ The data read from the system are decoded using `locale-coding-system'.  */)
     }
 #endif /* PAPER_WIDTH */
 #endif /* HAVE_LANGINFO_CODESET*/
-    return Qnil;
+  return Qnil;
 }
 \f
 /* base64 encode/decode functions (RFC 2045).
@@ -4707,13 +4748,13 @@ sweep_weak_table (h, remove_entries_p)
                  /* Make sure key and value survive.  */
                  if (!key_known_to_survive_p)
                    {
-                     mark_object (&HASH_KEY (h, i));
+                     mark_object (HASH_KEY (h, i));
                      marked = 1;
                    }
 
                  if (!value_known_to_survive_p)
                    {
-                     mark_object (&HASH_VALUE (h, i));
+                     mark_object (HASH_VALUE (h, i));
                      marked = 1;
                    }
                }