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

Function tc_store

sys/share/tclib.c:97–134  ·  view source on GitHub ↗

copy the entry into the output buffer */

Source from the content-addressed store, hash-verified

95
96/* copy the entry into the output buffer */
97static int
98tc_store(const char *trm, const char *ent)
99{
100 const char *bar, *col;
101 char *s;
102 size_t n;
103 int k;
104
105 if (!ent || !*ent || !trm || !*trm || (col = strchr(ent, ':')) == 0)
106 return 0;
107 (void) strcpy(tc_entry, trm);
108 if (((bar = strchr(ent, '|')) != 0 && bar < col)
109 || ((long) (n = strlen(trm)) == (long) (col - ent)
110 && strncmp(ent, trm, n) == 0))
111 (void) strcat(tc_entry, col);
112 else if (*ent == ':')
113 (void) strcat(tc_entry, ent);
114 else
115 (void) strcat(strcat(tc_entry, ":"), ent);
116
117 /* initialize global variables */
118 k = tgetnum("pc");
119 PC = (k == -1) ? '\0' : (char) k;
120 BC = s = bc_up_buf;
121 if (!tgetstr("bc", &s))
122 (void) strcpy(s, "\b"), s += 2;
123 UP = s;
124 (void) tgetstr("up", &s);
125#ifndef NO_DELAY_PADDING
126 /* caller must set `ospeed' */
127 if ((int) ospeed >= (int) SIZE(baud_rates))
128 ospeed = (short) (SIZE(baud_rates) - 1);
129 else if (ospeed < 0)
130 ospeed = 0;
131#endif /* !NO_DELAY_PADDING */
132
133 return 1;
134}
135
136/* search for an entry in the termcap file */
137static char *

Callers 1

tgetentFunction · 0.85

Calls 2

tgetnumFunction · 0.85
tgetstrFunction · 0.85

Tested by

no test coverage detected