Commit f03dc6ef authored by Paul Eggert's avatar Paul Eggert

* fns.c: Use much-faster test for byte-length change.

parent b4e50fa0
2011-06-18 Paul Eggert <eggert@cs.ucla.edu>
* fns.c (Ffillarray): Don't assume bool vector size fits in 'int'.
Use much-faster test for byte-length change.
* alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication.
......
......@@ -23,6 +23,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <time.h>
#include <setjmp.h>
#include <intprops.h>
#include "lisp.h"
#include "commands.h"
#include "character.h"
......@@ -2167,17 +2169,11 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
unsigned char str[MAX_MULTIBYTE_LENGTH];
int len = CHAR_STRING (charval, str);
EMACS_INT size_byte = SBYTES (array);
unsigned char *p1 = p, *endp = p + size_byte;
int i;
if (size != size_byte)
while (p1 < endp)
{
int this_len = BYTES_BY_CHAR_HEAD (*p1);
if (len != this_len)
error ("Attempt to change byte length of a string");
p1 += this_len;
}
if (INT_MULTIPLY_OVERFLOW (SCHARS (array), len)
|| SCHARS (array) * len != size_byte)
error ("Attempt to change byte length of a string");
for (i = 0; i < size_byte; i++)
*p++ = str[i % len];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment