comparison src/keymap.c @ 7809:cf23573fa6fb

(Fkey_description): Avoid using Fmapconcat--do it directly.
author Richard M. Stallman <rms@gnu.org>
date Sun, 05 Jun 1994 18:30:59 +0000
parents 93b5868150b9
children d385199b26b6
comparison
equal deleted inserted replaced
7808:52e2eb6245d4 7809:cf23573fa6fb
1290 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\"\n\ 1290 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\"\n\
1291 spaces are put between sequence elements, etc.") 1291 spaces are put between sequence elements, etc.")
1292 (keys) 1292 (keys)
1293 Lisp_Object keys; 1293 Lisp_Object keys;
1294 { 1294 {
1295 int len;
1296 int i;
1297 Lisp_Object sep;
1298 Lisp_Object *args;
1299
1295 if (XTYPE (keys) == Lisp_String) 1300 if (XTYPE (keys) == Lisp_String)
1296 { 1301 {
1297 Lisp_Object vector; 1302 Lisp_Object vector;
1298 int i;
1299 vector = Fmake_vector (Flength (keys), Qnil); 1303 vector = Fmake_vector (Flength (keys), Qnil);
1300 for (i = 0; i < XSTRING (keys)->size; i++) 1304 for (i = 0; i < XSTRING (keys)->size; i++)
1301 { 1305 {
1302 if (XSTRING (keys)->data[i] & 0x80) 1306 if (XSTRING (keys)->data[i] & 0x80)
1303 XFASTINT (XVECTOR (vector)->contents[i]) 1307 XFASTINT (XVECTOR (vector)->contents[i])
1306 XFASTINT (XVECTOR (vector)->contents[i]) 1310 XFASTINT (XVECTOR (vector)->contents[i])
1307 = XSTRING (keys)->data[i]; 1311 = XSTRING (keys)->data[i];
1308 } 1312 }
1309 keys = vector; 1313 keys = vector;
1310 } 1314 }
1311 return Fmapconcat (Qsingle_key_description, keys, build_string (" ")); 1315
1316 /* In effect, this computes
1317 (mapconcat 'single-key-description keys " ")
1318 but we shouldn't use mapconcat because it can do GC. */
1319
1320 len = XVECTOR (keys)->size;
1321 sep = build_string (" ");
1322 /* This has one extra element at the end that we don't pass to Fconcat. */
1323 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
1324
1325 for (i = 0; i < len; i++)
1326 {
1327 args[i * 2] = Fsingle_key_description (XVECTOR (keys)->contents[i]);
1328 args[i * 2 + 1] = sep;
1329 }
1330
1331 return Fconcat (len * 2 - 1, args);
1312 } 1332 }
1313 1333
1314 char * 1334 char *
1315 push_key_description (c, p) 1335 push_key_description (c, p)
1316 register unsigned int c; 1336 register unsigned int c;