/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_set_term.c,v 1.150 2014/11/01 12:30:47 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.153 2015/08/07 23:57:58 tom Exp $")
#ifdef USE_TERM_DRIVER
#define MaxColors InfoOf(sp).maxcolors
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
+ FreeIfNeeded(sp->out_buffer);
free(sp);
/*
COLOR_PAIRS = 0;
#endif
_nc_set_screen(0);
+#if USE_WIDEC_SUPPORT
+ if (SP == 0) {
+ FreeIfNeeded(_nc_wacs);
+ _nc_wacs = 0;
+ }
+#endif
}
}
_nc_unlock_global(curses);
static const char *
extract_fgbg(const char *src, int *result)
{
- char *dst = 0;
- long value = strtol(src, &dst, 0);
+ const char *dst = 0;
+ char *tmp = 0;
+ long value = strtol(src, &tmp, 0);
- if (dst == 0) {
+ if ((dst = tmp) == 0) {
dst = src;
} else if (value >= 0) {
*result = value;
}
#endif
-#define ReturnScreenError() { _nc_set_screen(0); \
+#define ReturnScreenError() do { _nc_set_screen(0); \
returnCode(ERR); } while (0)
/* OS-independent screen initializations */
if (sp->_default_fg >= MaxColors) {
if (set_a_foreground != ABSENT_STRING
&& !strcmp(set_a_foreground, "\033[3%p1%dm")) {
- set_a_foreground = "\033[3%?%p1%{8}%>%t9%e%p1%d%;m";
+ set_a_foreground = strdup("\033[3%?%p1%{8}%>%t9%e%p1%d%;m");
} else {
sp->_default_fg %= MaxColors;
}
if (sp->_default_bg >= MaxColors) {
if (set_a_background != ABSENT_STRING
&& !strcmp(set_a_background, "\033[4%p1%dm")) {
- set_a_background = "\033[4%?%p1%{8}%>%t9%e%p1%d%;m";
+ set_a_background = strdup("\033[4%?%p1%{8}%>%t9%e%p1%d%;m");
} else {
sp->_default_bg %= MaxColors;
}
NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_ARG);
#if USE_WIDEC_SUPPORT
sp->_screen_unicode = _nc_unicode_locale();
- _nc_init_wacs();
+ if (_nc_wacs == 0) {
+ _nc_init_wacs();
+ }
if (_nc_wacs == 0) {
ReturnScreenError();
}