/* 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.
#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"
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))
{
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));
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;
{
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;
/* 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
{
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
}
}
+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.
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;
}
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;
{
#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)
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;
}
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;
}
#endif /* PAPER_WIDTH */
#endif /* HAVE_LANGINFO_CODESET*/
- return Qnil;
+ return Qnil;
}
\f
/* base64 encode/decode functions (RFC 2045).
/* 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;
}
}