]> code.delx.au - gnu-emacs/blobdiff - src/fns.c
(Fnext_property_change): Properly offset interval
[gnu-emacs] / src / fns.c
index 97548e70f30a1af39949551de3430f0bd3502910..6ca612b2153a4bd3fa7897b64d4b68ffbb4f028d 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA.  */
 #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.  */
@@ -39,7 +40,7 @@ Boston, MA 02111-1307, USA.  */
 #include "intervals.h"
 #include "frame.h"
 #include "window.h"
-#ifdef HAVE_MENUS
+#if defined (HAVE_MENUS) && defined (HAVE_X_WINDOWS)
 #include "xterm.h"
 #endif
 
@@ -219,10 +220,12 @@ Symbols are also allowed; their print names are used instead.")
 }
 
 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\
@@ -728,8 +731,8 @@ concat (nargs, args, target_type, last_special)
                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,
@@ -940,19 +943,27 @@ string_make_unibyte (string)
 
 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);
 }
 
@@ -963,6 +974,8 @@ If STRING is unibyte, the result is STRING itself.")
   (string)
      Lisp_Object string;
 {
+  CHECK_STRING (string, 0);
+
   if (STRING_MULTIBYTE (string))
     {
       string = Fcopy_sequence (string);
@@ -979,6 +992,8 @@ If STRING is multibyte, the result is STRING itself.")
   (string)
      Lisp_Object string;
 {
+  CHECK_STRING (string, 0);
+
   if (! STRING_MULTIBYTE (string))
     {
       int nbytes = STRING_BYTES (XSTRING (string));
@@ -2488,24 +2503,31 @@ and can edit it until it has been confirmed.")
     }
 }
 \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;
 }