comparison src/data.c @ 9966:d64bdd958254

(Farray_length): Delete this obsolete function. (Faref, Faset): If object is a string, use XSTRING, not XVECTOR.
author Karl Heuer <kwzh@gnu.org>
date Wed, 16 Nov 1994 03:41:56 +0000
parents 18b408b05189
children f0637b2f1671
comparison
equal deleted inserted replaced
9965:f68eab303ddb 9966:d64bdd958254
1332 { 1332 {
1333 register int idxval; 1333 register int idxval;
1334 1334
1335 CHECK_NUMBER (idx, 1); 1335 CHECK_NUMBER (idx, 1);
1336 idxval = XINT (idx); 1336 idxval = XINT (idx);
1337 if (!VECTORP (array) && !STRINGP (array) && !COMPILEDP (array))
1338 array = wrong_type_argument (Qarrayp, array);
1339 if (idxval < 0 || idxval >= XVECTOR (array)->size)
1340 args_out_of_range (array, idx);
1341 if (STRINGP (array)) 1337 if (STRINGP (array))
1342 { 1338 {
1343 Lisp_Object val; 1339 Lisp_Object val;
1340 if (idxval < 0 || idxval >= XSTRING (array)->size)
1341 args_out_of_range (array, idx);
1344 XSETFASTINT (val, (unsigned char) XSTRING (array)->data[idxval]); 1342 XSETFASTINT (val, (unsigned char) XSTRING (array)->data[idxval]);
1345 return val; 1343 return val;
1346 } 1344 }
1347 else 1345 else
1348 return XVECTOR (array)->contents[idxval]; 1346 {
1347 if (!VECTORP (array) && !COMPILEDP (array))
1348 array = wrong_type_argument (Qarrayp, array);
1349 if (idxval < 0 || idxval >= XVECTOR (array)->size)
1350 args_out_of_range (array, idx);
1351 return XVECTOR (array)->contents[idxval];
1352 }
1349 } 1353 }
1350 1354
1351 DEFUN ("aset", Faset, Saset, 3, 3, 0, 1355 DEFUN ("aset", Faset, Saset, 3, 3, 0,
1352 "Store into the element of ARRAY at index IDX the value NEWELT.\n\ 1356 "Store into the element of ARRAY at index IDX the value NEWELT.\n\
1353 ARRAY may be a vector or a string. IDX starts at 0.") 1357 ARRAY may be a vector or a string. IDX starts at 0.")
1359 1363
1360 CHECK_NUMBER (idx, 1); 1364 CHECK_NUMBER (idx, 1);
1361 idxval = XINT (idx); 1365 idxval = XINT (idx);
1362 if (!VECTORP (array) && !STRINGP (array)) 1366 if (!VECTORP (array) && !STRINGP (array))
1363 array = wrong_type_argument (Qarrayp, array); 1367 array = wrong_type_argument (Qarrayp, array);
1364 if (idxval < 0 || idxval >= XVECTOR (array)->size)
1365 args_out_of_range (array, idx);
1366 CHECK_IMPURE (array); 1368 CHECK_IMPURE (array);
1367 1369
1368 if (VECTORP (array)) 1370 if (VECTORP (array))
1369 XVECTOR (array)->contents[idxval] = newelt; 1371 {
1372 if (idxval < 0 || idxval >= XVECTOR (array)->size)
1373 args_out_of_range (array, idx);
1374 XVECTOR (array)->contents[idxval] = newelt;
1375 }
1370 else 1376 else
1371 { 1377 {
1378 if (idxval < 0 || idxval >= XSTRING (array)->size)
1379 args_out_of_range (array, idx);
1372 CHECK_NUMBER (newelt, 2); 1380 CHECK_NUMBER (newelt, 2);
1373 XSTRING (array)->data[idxval] = XINT (newelt); 1381 XSTRING (array)->data[idxval] = XINT (newelt);
1374 } 1382 }
1375 1383
1376 return newelt; 1384 return newelt;
1377 }
1378
1379 Lisp_Object
1380 Farray_length (array)
1381 register Lisp_Object array;
1382 {
1383 register Lisp_Object size;
1384 if (!VECTORP (array) && !STRINGP (array) && !COMPILEDP (array))
1385 array = wrong_type_argument (Qarrayp, array);
1386 XSETFASTINT (size, XVECTOR (array)->size);
1387 return size;
1388 } 1385 }
1389 1386
1390 /* Arithmetic functions */ 1387 /* Arithmetic functions */
1391 1388
1392 enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; 1389 enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal };