MCPcopy Create free account
hub / github.com/NetHack/NetHack / decode_mixed

Function decode_mixed

src/windows.c:1465–1512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1463}
1464
1465char *
1466decode_mixed(char *buf, const char *str)
1467{
1468 char *put = buf;
1469 glyph_info glyphinfo = nul_glyphinfo;
1470
1471 if (!str)
1472 return strcpy(buf, "");
1473
1474 while (*str) {
1475 if (*str == '\\') {
1476 int dcount, so, ggv;
1477 const char *save_str;
1478
1479 save_str = str++;
1480 switch (*str) {
1481 case 'G': /* glyph value \GXXXXNNNN*/
1482 if ((dcount = decode_glyph(str + 1, &ggv))) {
1483 str += (dcount + 1);
1484 map_glyphinfo(0, 0, ggv, 0, &glyphinfo);
1485 so = glyphinfo.gm.sym.symidx;
1486 *put++ = gs.showsyms[so];
1487 /* 'str' is ready for the next loop iteration and '*str'
1488 should not be copied at the end of this iteration */
1489 continue;
1490 } else {
1491 /* possible forgery - leave it the way it is */
1492 str = save_str;
1493 }
1494 break;
1495 case '\\':
1496 break;
1497 case '\0':
1498 /* String ended with '\\'. This can happen when someone
1499 names an object with a name ending with '\\', drops the
1500 named object on the floor nearby and does a look at all
1501 nearby objects. */
1502 /* brh - should we perhaps not allow things to have names
1503 that contain '\\' */
1504 str = save_str;
1505 break;
1506 }
1507 }
1508 *put++ = *str++;
1509 }
1510 *put = '\0';
1511 return buf;
1512}
1513
1514
1515/*

Callers 7

tty_putmixedFunction · 0.85
tty_status_updateFunction · 0.85
curses_putmixedFunction · 0.85
curses_status_updateFunction · 0.85
X11_status_update_ttyFunction · 0.85
genl_putmixedFunction · 0.85
do_lookFunction · 0.85

Calls 2

decode_glyphFunction · 0.85
map_glyphinfoFunction · 0.85

Tested by

no test coverage detected