#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <time.h>
/* Note on some machines this defines `vector' as a typedef,
so make sure we don't use that name in this file. */
#include "intervals.h"
#include "frame.h"
#include "window.h"
-#ifdef HAVE_MENUS
+#if defined (HAVE_MENUS) && defined (HAVE_X_WINDOWS)
#include "xterm.h"
#endif
}
DEFUN ("compare-strings", Fcompare_strings,
- Scompare_strings, 2, 7, 0,
+ Scompare_strings, 6, 7, 0,
"Compare the contents of two strings, converting to multibyte if needed.\n\
In string STR1, skip the first START1 characters and stop at END1.\n\
In string STR2, skip the first START2 characters and stop at END2.\n\
+END1 and END2 default to the full lengths of the respective strings.\n\
+\n\
Case is significant in this comparison if IGNORE-CASE is nil.\n\
Unibyte strings are converted to multibyte for comparison.\n\
\n\
CHECK_NUMBER (elt, 0);
if (SINGLE_BYTE_CHAR_P (XINT (elt)))
{
- XSTRING (val)->data[toindex++] = XINT (elt);
- toindex_byte++;
+ XSTRING (val)->data[toindex_byte++] = XINT (elt);
+ toindex++;
}
else
/* If we have any multibyte characters,
DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte,
1, 1, 0,
- "Return the multibyte equivalent of STRING.")
+ "Return the multibyte equivalent of STRING.\n\
+The function `unibyte-char-to-multibyte' is used to convert\n\
+each unibyte character to a multibyte character.")
(string)
Lisp_Object string;
{
+ CHECK_STRING (string, 0);
+
return string_make_multibyte (string);
}
DEFUN ("string-make-unibyte", Fstring_make_unibyte, Sstring_make_unibyte,
1, 1, 0,
- "Return the unibyte equivalent of STRING.")
+ "Return the unibyte equivalent of STRING.\n\
+Multibyte character codes are converted to unibyte\n\
+by using just the low 8 bits.")
(string)
Lisp_Object string;
{
+ CHECK_STRING (string, 0);
+
return string_make_unibyte (string);
}
(string)
Lisp_Object string;
{
+ CHECK_STRING (string, 0);
+
if (STRING_MULTIBYTE (string))
{
string = Fcopy_sequence (string);
(string)
Lisp_Object string;
{
+ CHECK_STRING (string, 0);
+
if (! STRING_MULTIBYTE (string))
{
int nbytes = STRING_BYTES (XSTRING (string));
}
}
\f
-DEFUN ("load-average", Fload_average, Sload_average, 0, 0, 0,
+DEFUN ("load-average", Fload_average, Sload_average, 0, 1, 0,
"Return list of 1 minute, 5 minute and 15 minute load averages.\n\
Each of the three load averages is multiplied by 100,\n\
then converted to integer.\n\
+When USE-FLOATS is non-nil, floats will be used instead of integers.\n\
+These floats are not multiplied by 100.\n\n\
If the 5-minute or 15-minute load averages are not available, return a\n\
shortened list, containing only those averages which are available.")
- ()
+ (use_floats)
+ Lisp_Object use_floats;
{
double load_ave[3];
int loads = getloadavg (load_ave, 3);
- Lisp_Object ret;
+ Lisp_Object ret = Qnil;
if (loads < 0)
error ("load-average not implemented for this operating system");
- ret = Qnil;
- while (loads > 0)
- ret = Fcons (make_number ((int) (load_ave[--loads] * 100.0)), ret);
+ while (loads-- > 0)
+ {
+ Lisp_Object load = (NILP (use_floats) ?
+ make_number ((int) (100.0 * load_ave[loads]))
+ : make_float (load_ave[loads]));
+ ret = Fcons (load, ret);
+ }
return ret;
}