required = MAX_MULTIBYTE_LENGTH * src_len;
if (encode_terminal_src_size < required)
{
- if (encode_terminal_src_size == 0)
- encode_terminal_src = xmalloc (required);
- else
+ if (encode_terminal_src)
encode_terminal_src = xrealloc (encode_terminal_src, required);
+ else
+ encode_terminal_src = xmalloc (required);
encode_terminal_src_size = required;
}
if (encode_terminal_dst_size == 0)
{
encode_terminal_dst_size = encode_terminal_src_size;
- encode_terminal_dst = xmalloc (encode_terminal_dst_size);
+ if (encode_terminal_dst)
+ encode_terminal_dst = xrealloc (encode_terminal_dst,
+ encode_terminal_dst_size);
+ else
+ encode_terminal_dst = xmalloc (encode_terminal_dst_size);
}
coding->destination = encode_terminal_dst;
coding->dst_bytes = encode_terminal_dst_size;
{
char *area = NULL;
char **address = &area;
- char *buffer = NULL;
int buffer_size = 4096;
register char *p = NULL;
int status;
int ctty = 0; /* 1 if asked to open controlling tty. */
if (!terminal_type)
- maybe_fatal (must_succeed, 0, 0,
+ maybe_fatal (must_succeed, 0,
"Unknown terminal type",
"Unknown terminal type");
terminal = create_terminal ();
#ifdef MSDOS
if (been_here > 0)
- maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
+ maybe_fatal (1, 0, "Attempt to create another terminal %s", "",
name, "");
been_here = 1;
tty = &the_only_display_info;
#endif /* O_IGNORE_CTTY */
if (fd < 0)
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Could not open file: %s",
"Could not open file: %s",
name);
if (!isatty (fd))
{
close (fd);
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Not a tty device: %s",
"Not a tty device: %s",
name);
Wcm_clear (tty);
- buffer = (char *) xmalloc (buffer_size);
+ tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
/* On some systems, tgetent tries to access the controlling
terminal. */
sigblock (sigmask (SIGTTOU));
- status = tgetent (buffer, terminal_type);
+ status = tgetent (tty->termcap_term_buffer, terminal_type);
sigunblock (sigmask (SIGTTOU));
if (status < 0)
{
#ifdef TERMINFO
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Cannot open terminfo database file",
"Cannot open terminfo database file");
#else
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Cannot open termcap database file",
"Cannot open termcap database file");
#endif
if (status == 0)
{
#ifdef TERMINFO
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type %s is not defined",
"Terminal type %s is not defined.\n\
If that is not the actual type of terminal you have,\n\
to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
terminal_type);
#else
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type %s is not defined",
"Terminal type %s is not defined.\n\
If that is not the actual type of terminal you have,\n\
}
#ifndef TERMINFO
- if (strlen (buffer) >= buffer_size)
+ if (strlen (tty->termcap_term_buffer) >= buffer_size)
abort ();
- buffer_size = strlen (buffer);
+ buffer_size = strlen (tty->termcap_term_buffer);
#endif
- area = (char *) xmalloc (buffer_size);
-
+ tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size);
tty->TS_ins_line = tgetstr ("al", address);
tty->TS_ins_multi_lines = tgetstr ("AL", address);
tty->TS_bell = tgetstr ("bl", address);
FrameRows (tty) = tgetnum ("li");
if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Screen size %dx%d is too small"
"Screen size %dx%d is too small",
FrameCols (tty), FrameRows (tty));
if (Wcm_init (tty) == -1) /* can't do cursor motion */
{
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type \"%s\" is not powerful enough to run Emacs",
# ifdef TERMINFO
"Terminal type \"%s\" is not powerful enough to run Emacs.\n\
}
if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Could not determine the frame size",
"Could not determine the frame size");
init_baud_rate (fileno (tty->input));
- /* Don't do this. I think termcap may still need the buffer. */
- /* xfree (buffer); */
-
#endif /* not DOS_NT */
/* Init system terminal modes (RAW or CBREAK, etc.). */
}
/* Auxiliary error-handling function for init_tty.
- Free BUFFER and delete TERMINAL, then call error or fatal
- with str1 or str2, respectively, according to MUST_SUCCEED. */
+ Delete TERMINAL, then call error or fatal with str1 or str2,
+ respectively, according to MUST_SUCCEED. */
static void
-maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
+maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2)
int must_succeed;
- char *buffer;
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{
- xfree (buffer);
-
if (terminal)
delete_tty (terminal);
xfree (tty->old_tty);
xfree (tty->Wcm);
+ if (tty->termcap_strings_buffer)
+ xfree (tty->termcap_strings_buffer);
+ if (tty->termcap_term_buffer)
+ xfree (tty->termcap_term_buffer);
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);
default_set_foreground = NULL;
default_set_background = NULL;
#endif /* !DOS_NT */
+
+ encode_terminal_src = NULL;
+ encode_terminal_dst = NULL;
}