Function: fillarray
fillarray is a function defined in fns.c.
Signature
(fillarray ARRAY ITEM)
Documentation
Store each element of ARRAY with ITEM.
ARRAY is a vector, string, char-table, or bool-vector.
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
register ptrdiff_t size, idx;
if (VECTORP (array))
for (idx = 0, size = ASIZE (array); idx < size; idx++)
ASET (array, idx, item);
else if (CHAR_TABLE_P (array))
{
int i;
for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
set_char_table_contents (array, i, item);
set_char_table_defalt (array, item);
}
else if (STRINGP (array))
{
unsigned char *p = SDATA (array);
CHECK_CHARACTER (item);
int charval = XFIXNAT (item);
size = SCHARS (array);
if (size != 0)
{
CHECK_IMPURE (array, XSTRING (array));
unsigned char str[MAX_MULTIBYTE_LENGTH];
int len;
if (STRING_MULTIBYTE (array))
len = CHAR_STRING (charval, str);
else
{
str[0] = charval;
len = 1;
}
ptrdiff_t size_byte = SBYTES (array);
if (len == 1 && size == size_byte)
memset (p, str[0], size);
else
{
ptrdiff_t product;
if (INT_MULTIPLY_WRAPV (size, len, &product)
|| product != size_byte)
error ("Attempt to change byte length of a string");
for (idx = 0; idx < size_byte; idx++)
*p++ = str[idx % len];
}
}
}
else if (BOOL_VECTOR_P (array))
return bool_vector_fill (array, item);
else
wrong_type_argument (Qarrayp, array);
return array;
}