MCPcopy Index your code
hub / github.com/NetHack/NetHack / dowhatdoes_core

Function dowhatdoes_core

src/pager.c:2576–2655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2574#endif /* 0 */
2575
2576char *
2577dowhatdoes_core(char q, char *cbuf)
2578{
2579 char buf[BUFSZ];
2580#if 0
2581 dlb *fp;
2582 struct wd_stack_frame stack[WD_STACKLIMIT];
2583 boolean cond;
2584 int ctrl, meta, depth = 0, lnum = 0;
2585#endif /* 0 */
2586 const char *ec_desc;
2587
2588 if ((ec_desc = key2extcmddesc(q)) != NULL) {
2589 char keybuf[QBUFSZ];
2590
2591 /* note: if "%-8s" gets changed, the "%8.8s" in dowhatdoes() will
2592 need a comparable change */
2593 Sprintf(buf, "%-8s%s.", key2txt(q, keybuf), ec_desc);
2594 Strcpy(cbuf, buf);
2595 return cbuf;
2596 }
2597 return 0;
2598#if 0
2599 fp = dlb_fopen(CMDHELPFILE, "r");
2600 if (!fp) {
2601 pline("Cannot open \"%s\" data file!", CMDHELPFILE);
2602 return 0;
2603 }
2604
2605 meta = (0x80 & (uchar) q) != 0;
2606 if (meta)
2607 q &= 0x7f;
2608 ctrl = (0x1f & (uchar) q) == (uchar) q;
2609 if (ctrl)
2610 q |= 0x40; /* NUL -> '@', ^A -> 'A', ... ^Z -> 'Z', ^[ -> '[', ... */
2611 else if (q == 0x7f)
2612 ctrl = 1, q = '?';
2613
2614 (void) memset((genericptr_t) stack, 0, sizeof stack);
2615 cond = stack[0].active = 1;
2616 while (dlb_fgets(buf, sizeof buf, fp)) {
2617 ++lnum;
2618 if (buf[0] == '&' && buf[1] && strchr("?:.#", buf[1])) {
2619 cond = whatdoes_cond(buf, stack, &depth, lnum);
2620 continue;
2621 }
2622 if (!cond)
2623 continue;
2624 if (meta ? (buf[0] == 'M' && buf[1] == '-'
2625 && (ctrl ? buf[2] == '^' && highc(buf[3]) == q
2626 : buf[2] == q))
2627 : (ctrl ? buf[0] == '^' && highc(buf[1]) == q
2628 : buf[0] == q)) {
2629 (void) strip_newline(buf);
2630 if (strchr(buf, '\t'))
2631 (void) tabexpand(buf);
2632 if (meta && ctrl && buf[4] == ' ') {
2633 (void) strncpy(buf, "M-^? ", 8);

Callers 2

pager.cFile · 0.85
help_dirFunction · 0.85

Calls 11

key2extcmddescFunction · 0.85
key2txtFunction · 0.85
dlb_fopenFunction · 0.85
dlb_fgetsFunction · 0.85
whatdoes_condFunction · 0.85
highcFunction · 0.85
strip_newlineFunction · 0.85
tabexpandFunction · 0.85
dlb_fcloseFunction · 0.85
plineFunction · 0.70
impossibleFunction · 0.70

Tested by

no test coverage detected