I've added the `string' function present in FSFmacs 20 (originally
called `concat-chars'), because it is both useful and consistent with
`list', `vector', etc.
In agreement with Stallman, load-average now accepts a USE-FLOATS
argument that makes it use floats.
P.S.
Compare our Fstring with the FSFmacs 20.3 implementation. The
difference shows much in the ways of cleanliness and robustness of
implementations. We rule. :-)
1998-04-24 Hrvoje Niksic <hniksic(a)srce.hr>
* fns.c (Fload_average): New argument USE_FLOATS.
* alloc.c (Fstring): New function, synched with FSF 20.3.
--- etc/NEWS.orig Fri Apr 24 16:55:41 1998
+++ etc/NEWS Fri Apr 24 17:05:22 1998
@@ -173,6 +173,15 @@
`call-count-profile-table', and is utilized by `profile-results' as
well as the new function `profile-call-count-results'.
+** The new function `string' concatenates all its argument characters
+and returns the resulting string. This is consistent with other
+functions, like `list', `vector', etc.
+
+** The `load-average' function now accepts a USE-FLOATS argument
+which, when non-nil, means to use floats instead of integers
+multiplied by 100. At a future date, `load-average' will use floats
+by default.
+
** The `make-event' function now supports the TYPE and PLIST
arguments, which can be used to create various events from Lisp. See
the documentation for details.
--- src/alloc.c.orig Fri Apr 24 00:54:35 1998
+++ src/alloc.c Fri Apr 24 01:14:51 1998
@@ -2361,6 +2361,23 @@
return val;
}
+DEFUN ("string", Fstring, 0, MANY, 0, /*
+Concatenate all the argument characters and make the result a string.
+*/
+ (int nargs, Lisp_Object *args))
+{
+ Bufbyte *storage = alloca_array (Bufbyte, nargs * MAX_EMCHAR_LEN);
+ Bufbyte *p = storage;
+
+ for (; nargs; nargs--, args++)
+ {
+ Lisp_Object lisp_char = *args;
+ CHECK_CHAR_COERCE_INT (lisp_char);
+ p += set_charptr_emchar (p, XCHAR (lisp_char));
+ }
+ return make_string (storage, p - storage);
+}
+
/* Take some raw memory, which MUST already be in internal format,
and package it up into a Lisp string. */
Lisp_Object
@@ -5056,6 +5073,7 @@
DEFSUBR (Fmake_vector);
DEFSUBR (Fmake_bit_vector);
DEFSUBR (Fmake_string);
+ DEFSUBR (Fstring);
DEFSUBR (Fmake_symbol);
DEFSUBR (Fmake_marker);
DEFSUBR (Fpurecopy);
--- src/fns.c.orig Fri Apr 24 16:41:51 1998
+++ src/fns.c Fri Apr 24 17:09:18 1998
@@ -3322,24 +3322,26 @@
/* #### this function doesn't belong in this file! */
-/* #### The incredibly disgusting historical "let's multiply it with
- 100" hack this function performs should be destroyed. */
-DEFUN ("load-average", Fload_average, 0, 0, 0, /*
+DEFUN ("load-average", Fload_average, 0, 1, 0, /*
Return list of 1 minute, 5 minute and 15 minute load averages.
Each of the three load averages is multiplied by 100,
then converted to integer.
+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.
On some systems, this won't work due to permissions on /dev/kmem,
in which case you can't use this.
*/
- ())
+ (use_floats))
{
double load_ave[3];
int loads = getloadavg (load_ave, countof (load_ave));
+ Lisp_Object ret = Qnil;
if (loads == -2)
error ("load-average not implemented for this operating system");
@@ -3347,12 +3349,14 @@
signal_simple_error ("Could not get load-average",
lisp_strerror (errno));
- {
- Lisp_Object ret = Qnil;
- while (loads > 0)
- ret = Fcons (make_int ((int) (load_ave[--loads] * 100.0)), ret);
- return ret;
- }
+ while (loads-- > 0)
+ {
+ Lisp_Object load = (NILP (use_floats) ?
+ make_int ((int) (100.0 * load_ave[loads]))
+ : make_float (load_ave[loads]));
+ ret = Fcons (load, ret);
+ }
+ return ret;
}
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Jone's law: The man who smiles when things go wrong has thought of
someone to blame it on.