- T((T_CALLED("tgetstr(%s,%p)"), id, area));
- if (cur_term != 0) {
- TERMTYPE *tp = &(cur_term->type);
- for_each_string(i, tp) {
- const char *capname = ExtStrname(tp, i, strcodes);
- if (!strncmp(id, capname, 2)) {
- result = tp->Strings[i];
- TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result)));
- /* setupterm forces canceled strings to null */
- if (VALID_STRING(result)) {
- if (result == exit_attribute_mode
- && FIX_SGR0 != 0) {
- result = FIX_SGR0;
- TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
- }
- if (area != 0
- && *area != 0) {
- (void) strcpy(*area, result);
- result = *area;
- *area += strlen(*area) + 1;
- }
+ entry_ptr = _nc_find_type_entry(id, STRING, TRUE);
+ if (entry_ptr != 0) {
+ j = entry_ptr->nte_index;
+ }
+#if NCURSES_XNAMES
+ else {
+ int i;
+ for_each_ext_string(i, tp) {
+ const char *capname = ExtStrname(tp, i, strcodes);
+ if (same_tcname(id, capname) && ValidExt(capname)) {
+ j = i;
+ break;
+ }
+ }
+ }
+#endif
+ if (j >= 0) {
+ result = tp->Strings[j];
+ TR(TRACE_DATABASE, ("found match %d: %s", j, _nc_visbuf(result)));
+ /* setupterm forces canceled strings to null */
+ if (VALID_STRING(result)) {
+ if (result == exit_attribute_mode
+ && FIX_SGR0 != 0) {
+ result = FIX_SGR0;
+ TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
+ }
+ if (area != 0
+ && *area != 0) {
+ _nc_STRCPY(*area, result, 1024);
+ result = *area;
+ *area += strlen(*area) + 1;