/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.126 2020/05/31 00:02:03 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.129 2021/02/14 00:09:49 tom Exp $")
/*
* char *
} TPARM_DATA;
#if HAVE_TSEARCH
-static void *cached_tparm;
-static int count_tparm;
+#define MyCache _nc_globals.cached_tparm
+#define MyCount _nc_globals.count_tparm
#if NO_LEAKS
static int which_tparm;
static TPARM_DATA **delete_tparm;
_nc_free_tparm(void)
{
#if HAVE_TSEARCH
- if (count_tparm != 0) {
- delete_tparm = typeMalloc(TPARM_DATA *, count_tparm);
+ if (MyCount != 0) {
+ delete_tparm = typeMalloc(TPARM_DATA *, MyCount);
which_tparm = 0;
- twalk(cached_tparm, visit_nodes);
- for (which_tparm = 0; which_tparm < count_tparm; ++which_tparm) {
+ twalk(MyCache, visit_nodes);
+ for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
TPARM_DATA *ptr = delete_tparm[which_tparm];
- tdelete(ptr, &cached_tparm, cmp_format);
+ tdelete(ptr, &MyCache, cmp_format);
free((char *) ptr->format);
free(ptr);
}
which_tparm = 0;
- twalk(cached_tparm, visit_nodes);
+ twalk(MyCache, visit_nodes);
FreeAndNull(delete_tparm);
- count_tparm = 0;
+ MyCount = 0;
which_tparm = 0;
}
#endif
* may be cases that we cannot see the explicit parameter numbers.
*/
NCURSES_EXPORT(int)
-_nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
+_nc_tparm_analyze(const char *string, char **p_is_s, int *popcount)
{
size_t len2;
int i;
void *ft;
result->format = string;
- if ((ft = tfind(result, &cached_tparm, cmp_format)) != 0) {
+ if ((ft = tfind(result, &MyCache, cmp_format)) != 0) {
fs = *(TPARM_DATA **) ft;
*result = *fs;
} else
if ((fs = typeCalloc(TPARM_DATA, 1)) != 0) {
*fs = *result;
if ((fs->format = strdup(string)) != 0) {
- if ((ft = tsearch(fs, &cached_tparm, cmp_format)) != 0) {
- ++count_tparm;
+ if (tsearch(fs, &MyCache, cmp_format) != 0) {
+ ++MyCount;
} else {
rc = ERR;
}
get_space((size_t) 1);
TPS(out_buff)[TPS(out_used)] = '\0';
+ if (TPS(stack_ptr) && !_nc_tparm_err) {
+ DEBUG(2, ("tparm: stack has %d item%s on return",
+ TPS(stack_ptr),
+ TPS(stack_ptr) == 1 ? "" : "s"));
+ _nc_tparm_err++;
+ }
+
T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));
return (TPS(out_buff));
}