Commit 09204fe9 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

don't depend on PATH_MAX being available and correct (#109805). don't

* src/pty.c(_vte_pty_ptsname): don't depend on PATH_MAX being available and
	correct (#109805).
* src/vte.c(vte_terminal_set_termcap): don't depend on PATH_MAX being available
	and correct (#109805).
* src/vte.c(vte_terminal_io_read): fix signed/unsigned comparison (#108066).
parent ac8d4312
2003-04-21 nalin
* src/pty.c(_vte_pty_ptsname): don't depend on PATH_MAX being
available and correct (#109805).
* src/vte.c(vte_terminal_set_termcap): don't depend on PATH_MAX being
available and correct (#109805).
* src/vte.c(vte_terminal_io_read): fix signed/unsigned comparison
(#108066).
2003-04-21 nalin
* Makefile.am: add MESSAGE-OF-DOOM to EXTRA_DIST
* src/keymap.c: make Alt+Return generate ESC newline (#108863).
......
......@@ -304,26 +304,38 @@ forkpty (int *master_fd, char *name, struct termios *termp, struct winsize *winp
#endif /* HAVE_OPENPTY */
int
n_read (int fd, void *buffer, int n)
n_read (int fd, void *buf, int n)
{
int left, nread;
char *ptr;
char *ptr, *buffer;
buffer = (char*) buf;
ptr = buffer;
left = n;
while (left > 0){
if ((nread = read (fd, ptr, left)) < 0){
if (errno == EINTR)
nread = 0;
else
while (ptr < buffer + n) {
nread = read (fd, ptr, n - (ptr - buffer));
switch (nread) {
case -1:
switch (errno) {
case EINTR:
case EAGAIN:
/* suppress the error */
break;
default:
return -1;
} else if (nread == 0)
break; /* EOF */
left -= nread;
ptr += nread;
break;
}
break;
case 0:
/* EOF */
break;
}
if (nread > 0) {
ptr += nread;
} else {
break;
}
}
return n - left;
return (ptr - ((char*)buffer));
}
......@@ -589,16 +589,29 @@ static char *
_vte_pty_ptsname(int master)
{
#if defined(HAVE_PTSNAME_R)
char buf[PATH_MAX];
memset(buf, 0, sizeof(buf));
if (ptsname_r(master, buf, sizeof(buf) - 1) == 0) {
gsize len = 1024;
char *buf = NULL;
int i;
do {
buf = g_malloc0(len);
i = ptsname_r(master, buf, len - 1);
switch (i) {
case 0:
/* Return the allocated buffer with the name in it. */
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_PTY)) {
fprintf(stderr, "PTY slave is `%s'.\n", buf);
}
if (_vte_debug_on(VTE_DEBUG_PTY)) {
fprintf(stderr, "PTY slave is `%s'.\n", buf);
}
#endif
return g_strdup(buf);
}
return buf;
break;
default:
g_free(buf);
buf = NULL;
break;
}
len *= 2;
} while ((i != 0) && (errno == ERANGE));
#elif defined(HAVE_PTSNAME)
char *p;
if ((p = ptsname(master)) != NULL) {
......@@ -1034,7 +1047,7 @@ sigchld_handler(int signum)
int
main(int argc, char **argv)
{
pid_t child;
pid_t child = 0;
char c;
int ret;
signal(SIGCHLD, sigchld_handler);
......
......@@ -7099,8 +7099,16 @@ vte_terminal_io_read(GIOChannel *channel,
/* Read some data in from this channel. */
bcount = 0;
if (condition & G_IO_IN) {
bcount = sizeof(buf) -
_vte_buffer_length(terminal->pvt->incoming);
/* We try not to overfill the incoming buffer below by cutting
* down the read size if we already have pending data. */
bcount = sizeof(buf);
if (_vte_buffer_length(terminal->pvt->incoming) < sizeof(buf)) {
/* Shoot for exactly one "chunk" for processing. */
bcount -= _vte_buffer_length(terminal->pvt->incoming);
} else {
/* Read half of the chunk size. */
bcount = sizeof(buf) / 2;
}
bcount = read(fd, buf, MAX(bcount, sizeof(buf) / 2));
}
......@@ -10107,20 +10115,25 @@ vte_terminal_set_termcap(VteTerminal *terminal, const char *path,
gboolean reset)
{
struct stat st;
char path_default[PATH_MAX];
char *wpath;
GQuark q = 0;
if (path == NULL) {
snprintf(path_default, sizeof(path_default),
DATADIR "/" PACKAGE "/termcap/%s",
terminal->pvt->emulation ?
terminal->pvt->emulation : VTE_DEFAULT_EMULATION);
if (stat(path_default, &st) == 0) {
path = path_default;
} else {
path = "/etc/termcap";
}
wpath = g_strdup_printf(DATADIR "/" PACKAGE "/termcap/%s",
terminal->pvt->emulation ?
terminal->pvt->emulation :
VTE_DEFAULT_EMULATION);
if (stat(wpath, &st) != 0) {
g_free(wpath);
wpath = g_strdup("/etc/termcap");
}
q = g_quark_from_string(wpath);
g_free(wpath);
} else {
q = g_quark_from_string(path);
}
terminal->pvt->termcap_path = g_quark_to_string(g_quark_from_string(path));
terminal->pvt->termcap_path = g_quark_to_string(q);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_MISC)) {
fprintf(stderr, "Loading termcap `%s'...",
......@@ -10130,7 +10143,7 @@ vte_terminal_set_termcap(VteTerminal *terminal, const char *path,
if (terminal->pvt->termcap) {
_vte_termcap_free(terminal->pvt->termcap);
}
terminal->pvt->termcap = _vte_termcap_new(path);
terminal->pvt->termcap = _vte_termcap_new(terminal->pvt->termcap_path);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_MISC)) {
fprintf(stderr, "\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment