XFree86 3.1.2Ec - xterm patch #19 - 1996/7/21 - T.Dickey
This patch does the following:
+ fixes the core dump that I reported on IRIX 5.2 (in main.c)
(it's worth noting that this bug exists in X11R6.1, so I'd like
to assume that someone's already submitted a fix to X Consortium...)
+ change the interpretation of zero rows or columns in a resize-window
request to use the root window's size (looking more carefully at
dtterm, that seems to be what it does).
+ change some memmove calls to memcpy for slightly better performance.
(also, a couple of memset calls to bzero - Quantify says bzero runs
20% faster, I assume because there's one less argument).
+ interpret character sets 1 and 2 (so that vttest gives a reasonable
result) Both rxvt and dtterm do something equivalent.
+ fix a minor memory leak in the logic that retrieves the window or
icon names (Purify found this for me while I ran vttest).
To do:
+ document the new escape sequences (next patch)
+ modify xterm so that if color isn't enabled, it doesn't allocate
memory for colors
--------------------------------------------------------------------------------
button.c | 6 ++--
charproc.c | 72 ++++++++++++++++++++++++++++++++++++++---------------------
main.c | 18 +++++++-------
screen.c | 27 +++++++++-------------
4 files changed, 71 insertions, 52 deletions
--------------------------------------------------------------------------------
Index: button.c
--- xterm-18+/button.c Sun Jun 30 12:03:00 1996
+++ xterm-19/button.c Sun Jul 21 17:37:38 1996
@@ -1205,7 +1205,7 @@
*targetP++ = XA_COMPOUND_TEXT(d);
*targetP++ = XA_LENGTH(d);
*targetP++ = XA_LIST_LENGTH(d);
- memmove( (char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
+ memcpy ( (char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
XtFree((char*)std_targets);
*type = XA_ATOM;
*format = 32;
@@ -1230,7 +1230,7 @@
*(long*)*value = 1;
else {
long temp = 1;
- memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ memcpy ( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
}
*type = XA_INTEGER;
*length = 1;
@@ -1243,7 +1243,7 @@
*(long*)*value = xterm->screen.selection_length;
else {
long temp = xterm->screen.selection_length;
- memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ memcpy ( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
}
*type = XA_INTEGER;
*length = 1;
Index: charproc.c
--- xterm-18+/charproc.c Thu Jul 18 22:00:40 1996
+++ xterm-19/charproc.c Sun Jul 21 18:24:56 1996
@@ -1797,9 +1797,11 @@
*s = '\036'; /* UK pound sign*/
break;
+ case '1':
case 'B': /* ASCII set */
break;
+ case '2':
case '0': /* special graphics (line drawing) */
for (s=buf; s<ptr; ++s)
if (*s>=0x5f && *s<=0x7e)
@@ -1962,7 +1964,7 @@
if((j = func == bitset ? 132 : 80) !=
((termw->flags & IN132COLUMNS) ? 132 : 80) ||
j != screen->max_col + 1)
- RequestResize(termw, 0, j, TRUE);
+ RequestResize(termw, -1, j, TRUE);
(*func)(&termw->flags, IN132COLUMNS);
}
break;
@@ -2170,7 +2172,7 @@
if((j = (screen->save_modes[1] & IN132COLUMNS)
? 132 : 80) != ((termw->flags & IN132COLUMNS)
? 132 : 80) || j != screen->max_col + 1)
- RequestResize(termw, 0, j, TRUE);
+ RequestResize(termw, -1, j, TRUE);
termw->flags &= ~IN132COLUMNS;
termw->flags |= screen->save_modes[1] &
IN132COLUMNS;
@@ -2277,15 +2279,18 @@
unparseputc(']', screen->respond);
unparseputc(code, screen->respond);
- if (ok
- && XTextPropertyToStringList(text, &list, &length)) {
- int n, c;
- for (n = 0; n < length; n++) {
- char *s = list[n];
- while ((c = *s++) != '\0')
- unparseputc(c, screen->respond);
+ if (ok) {
+ if (XTextPropertyToStringList(text, &list, &length)) {
+ int n, c;
+ for (n = 0; n < length; n++) {
+ char *s = list[n];
+ while ((c = *s++) != '\0')
+ unparseputc(c, screen->respond);
+ }
+ XFreeStringList(list);
}
- XFreeStringList(list);
+ if (text->value != 0)
+ XFree(text->value);
}
unparseputc(ESC, screen->respond);
@@ -2574,9 +2579,9 @@
char *save [MAX_PTRS * MAX_ROWS];
Size_t len = MAX_PTRS * sizeof(char *) * rows;
- memmove( (char *)save, (char *)screen->buf, len);
- memmove( (char *)screen->buf, (char *)screen->altbuf, len);
- memmove( (char *)screen->altbuf, (char *)save, len);
+ memcpy ( (char *)save, (char *)screen->buf, len);
+ memcpy ( (char *)screen->buf, (char *)screen->altbuf, len);
+ memcpy ( (char *)screen->altbuf, (char *)save, len);
}
void
@@ -2642,7 +2647,8 @@
if (event->type == GraphicsExpose)
if (HandleExposure (screen, event))
screen->cursor_state = OFF;
- if ((event->type == NoExpose) || ((XGraphicsExposeEvent *)event)->count == 0) {
+ if ((event->type == NoExpose)
+ || ((XGraphicsExposeEvent *)event)->count == 0) {
if (screen->incopy <= 0 && screen->scrolls > 0)
screen->scrolls--;
if (screen->scrolls)
@@ -2689,27 +2695,43 @@
Dimension replyWidth, replyHeight;
Dimension askedWidth, askedHeight;
XtGeometryResult status;
+ XWindowAttributes attrs;
askedWidth = cols;
askedHeight = rows;
- if (text) {
- if (askedHeight <= 0)
- askedHeight = screen->max_row + 1;
- if (askedWidth <= 0)
- askedWidth = screen->max_col + 1;
- askedWidth *= FontWidth(screen);
- askedHeight *= FontHeight(screen);
+ if (askedHeight == 0
+ || askedWidth == 0) {
+ XGetWindowAttributes(XtDisplay(termw),
+ RootWindowOfScreen(XtScreen(termw)), &attrs);
+ }
+
+ if (text) {
+ if (rows != 0) {
+ if (rows < 0)
+ askedHeight = screen->max_row + 1;
+ askedHeight *= FontHeight(screen);
+ askedHeight += (2 * screen->border);
+ }
- askedWidth += (2 * screen->border) + screen->scrollbar;
- askedHeight += (2 * screen->border);
+ if (cols != 0) {
+ if (cols < 0)
+ askedWidth = screen->max_col + 1;
+ askedWidth *= FontWidth(screen);
+ askedWidth += (2 * screen->border) + screen->scrollbar;
+ }
} else {
- if (askedHeight <= 0)
+ if (rows < 0)
askedHeight = FullHeight(screen);
- if (askedWidth <= 0)
+ if (cols < 0)
askedWidth = FullWidth(screen);
}
+
+ if (rows == 0)
+ askedHeight = attrs.height;
+ if (cols == 0)
+ askedWidth = attrs.width;
status = XtMakeResizeRequest (
(Widget) termw,
Index: main.c
--- xterm-18+/main.c Mon Jul 8 12:42:24 1996
+++ xterm-19/main.c Sun Jul 21 17:37:39 1996
@@ -2354,7 +2354,7 @@
#endif /* USE_SYSV_TERMIO */
#if defined(UTMP) && defined(USE_SYSV_UTMP)
char* ptyname;
- char* ptynameptr;
+ char* ptynameptr = 0;
#endif
#ifdef USE_USG_PTYS
@@ -2912,12 +2912,14 @@
*/
#ifdef CRAY
#define PTYCHARLEN 4
-#else
+#endif
+
#ifdef __osf__
#define PTYCHARLEN 5
-#else
-#define PTYCHARLEN 2
#endif
+
+#ifndef PTYCHARLEN
+#define PTYCHARLEN 2
#endif
(void) setutent ();
@@ -2929,12 +2931,10 @@
ptynameptr = ptyname;
else
ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN;
- (void) strncpy(utmp.ut_id, ptynameptr, sizeof (utmp.ut_id));
#else
- (void) strncpy(utmp.ut_id,ptyname + sizeof("/dev/tty")-1,
- sizeof (utmp.ut_id));
-
+ ptynameptr = ptyname + sizeof("/dev/tty")-1;
#endif
+ (void) strncpy(utmp.ut_id, ptynameptr, sizeof (utmp.ut_id));
utmp.ut_type = DEAD_PROCESS;
/* position to entry in utmp file */
@@ -3741,7 +3741,7 @@
struct utmp *utptr;
#endif
char* ptyname;
- char* ptynameptr;
+ char* ptynameptr = 0;
#if defined(WTMP) && !defined(SVR4)
int fd; /* for /etc/wtmp */
int i;
Index: screen.c
--- xterm-18+/screen.c Thu Jul 18 22:00:40 1996
+++ xterm-19/screen.c Sun Jul 21 18:48:07 1996
@@ -180,7 +180,7 @@
tmp += ncol*move_down;
}
for (i = 0; i < minrows; i++, tmp += ncol) {
- memmove( tmp, base[i], mincols);
+ memcpy( tmp, base[i], mincols);
}
/*
* update the pointers in sbuf
@@ -225,13 +225,10 @@
wrappedbit = *attrs0&LINEWRAPPED;
flags &= ATTRIBUTES;
flags |= CHARDRAWN;
- memmove( col, str, length);
- while(length-- > 0)
- {
- *attrs++ = flags;
- *fgs++ = cur_fg;
- *bgs++ = cur_bg;
- }
+ memcpy( col, str, length);
+ memset( attrs, flags, length);
+ memset( fgs, cur_fg, length);
+ memset( bgs, cur_bg, length);
if (wrappedbit)
*attrs0 |= LINEWRAPPED;
}
@@ -248,7 +245,7 @@
register int i;
/* save n lines at where */
- memmove( (char *)save,
+ memcpy ( (char *)save,
(char *) &sb[MAX_PTRS * where],
MAX_PTRS * sizeof(char *) * n);
@@ -257,7 +254,7 @@
int last = (n * MAX_PTRS);
int flags = (term->flags & (FG_COLOR|BG_COLOR));
for (i = 0; i < last; i += MAX_PTRS) {
- memset(save[i+0], 0, size);
+ bzero(save[i+0], size);
memset(save[i+1], flags, size);
memset(save[i+2], term->cur_foreground, size);
memset(save[i+3], term->cur_background, size);
@@ -299,7 +296,7 @@
MAX_PTRS * sizeof (char *) * (last - where));
/* reuse storage for new lines at where */
- memmove( (char *) &sb[MAX_PTRS * where],
+ memcpy ( (char *) &sb[MAX_PTRS * where],
(char *)save,
MAX_PTRS * sizeof(char *) * n);
}
@@ -326,7 +323,7 @@
MAX_PTRS * sizeof (char *) * ((last -= n - 1) - where));
/* reuse storage for new bottom lines */
- memmove( (char *) &sb[MAX_PTRS * last],
+ memcpy ( (char *) &sb[MAX_PTRS * last],
(char *)save,
MAX_PTRS * sizeof(char *) * n);
}
@@ -379,9 +376,9 @@
register Size_t nbytes = (size - n - col);
int wrappedbit = attrs[0]&LINEWRAPPED;
- memmove( ptr + col, ptr + col + n, nbytes);
- memmove( attrs + col, attrs + col + n, nbytes);
- bzero (ptr + size - n, n);
+ memcpy (ptr + col, ptr + col + n, nbytes);
+ memcpy (attrs + col, attrs + col + n, nbytes);
+ bzero (ptr + size - n, n);
memset (attrs + size - n, term->flags & (FG_COLOR|BG_COLOR), n);
if (term->flags & FG_COLOR)
memset(BUF_FORES(sb, row) + size - n, term->cur_foreground, n);