#include <tic.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.37 2022/04/30 17:00:05 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.44 2022/06/18 20:40:54 tom Exp $")
#if NCURSES_XNAMES
/*
na = to ? ((int) NUM_EXT_NAMES(to)) : 0;
nb = from ? ((int) NUM_EXT_NAMES(from)) : 0;
- DEBUG(2, (T_CALLED("align_termtype to(%d:%s), from(%d:%s)"),
+ DEBUG(2, (T_CALLED("_nc_align_termtype to(%d:%s), from(%d:%s)"),
na, to ? NonNull(to->term_names) : "?",
nb, from ? NonNull(from->term_names) : "?"));
break;
}
}
- if (same)
+ if (same) {
+ DEBUG(2, (T_RETURN("")));
return;
+ }
}
/*
* This is where we pay for having a simple extension representation.
int *newptr = 0;
#endif
- DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), dst, src, mode));
+ DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), (void *)
+ dst, (const void *) src, mode));
*dst = *src; /* ...to copy the sizes and string-tables */
TYPE_MALLOC(NCURSES_SBOOL, NUM_BOOLEANS(dst), dst->Booleans);
new_table = NULL;
for (pass = 0; pass < 2; ++pass) {
size_t str_size = 0;
- for (i = 0; i < NUM_STRINGS(dst); ++i) {
+ if (src->term_names != NULL) {
+ if (pass) {
+ dst->term_names = new_table + str_size;
+ strcpy(dst->term_names + str_size, src->term_names);
+ }
+ str_size += strlen(src->term_names) + 1;
+ }
+ for (i = 0; i < STRCOUNT; ++i) {
if (VALID_STRING(src->Strings[i])) {
if (pass) {
strcpy(new_table + str_size, src->Strings[i]);
new_table = NULL;
for (pass = 0; pass < 2; ++pass) {
size_t str_size = 0;
+ char *raw_data = src->ext_str_table;
+ if (raw_data != NULL) {
+ for (i = 0; i < src->ext_Strings; ++i) {
+ size_t skip = strlen(raw_data) + 1;
+ if (skip != 1) {
+ if (pass) {
+ strcpy(new_table + str_size, raw_data);
+ }
+ str_size += skip;
+ raw_data += skip;
+ }
+ }
+ }
for (i = 0; i < NUM_EXT_NAMES(dst); ++i) {
if (VALID_STRING(src->ext_Names[i])) {
if (pass) {
dst->ext_str_table = new_table;
} else {
++str_size;
- new_table = malloc(str_size);
+ new_table = calloc(str_size, 1);
}
}
} else {
NCURSES_EXPORT(void)
_nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src)
{
- DEBUG(2, (T_CALLED("_nc_copy_termtype(dst=%p, src=%p)"), dst, src));
+ DEBUG(2, (T_CALLED("_nc_copy_termtype(dst=%p, src=%p)"), (void *) dst,
+ (const void *) src));
copy_termtype((TERMTYPE2 *) dst, (const TERMTYPE2 *) src, 0);
DEBUG(2, (T_RETURN("")));
}
NCURSES_EXPORT(void)
_nc_copy_termtype2(TERMTYPE2 *dst, const TERMTYPE2 *src)
{
- DEBUG(2, (T_CALLED("_nc_copy_termtype2(dst=%p, src=%p)"), dst, src));
+ DEBUG(2, (T_CALLED("_nc_copy_termtype2(dst=%p, src=%p)"), (void *) dst,
+ (const void *) src));
copy_termtype(dst, src, srcINT | dstINT);
DEBUG(2, (T_RETURN("")));
}
NCURSES_EXPORT(void)
_nc_export_termtype2(TERMTYPE *dst, const TERMTYPE2 *src)
{
- DEBUG(2, (T_CALLED("_nc_export_termtype2(dst=%p, src=%p)"), dst, src));
+ DEBUG(2, (T_CALLED("_nc_export_termtype2(dst=%p, src=%p)"), (void *)
+ dst, (const void *) src));
copy_termtype((TERMTYPE2 *) dst, src, srcINT);
DEBUG(2, (T_RETURN("")));
}