diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-03-09 14:45:40 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-03-09 14:45:40 +0000 |
commit | 5b3e1cd121a50c5c3b76c34d6c0e0c6430cefe93 (patch) | |
tree | bdbf56fc5e747e21dad1aabcf4c3275e8f62ce61 /app | |
parent | e18c4ea24ad92ea4dd3afea7e9a3a583f143cacd (diff) |
Update to xterm 291. Tested by many.
Diffstat (limited to 'app')
45 files changed, 1676 insertions, 3389 deletions
diff --git a/app/xterm/INSTALL b/app/xterm/INSTALL index 1b7dcc7b0..13a18f031 100644 --- a/app/xterm/INSTALL +++ b/app/xterm/INSTALL @@ -1,6 +1,6 @@ --- $XTermId: INSTALL,v 1.139 2012/10/10 23:33:29 tom Exp $ +-- $XTermId: INSTALL,v 1.142 2013/02/03 19:36:47 tom Exp $ ------------------------------------------------------------------------------- --- Copyright 1997-2011,2012 by Thomas E. Dickey +-- Copyright 1997-2012,2013 by Thomas E. Dickey -- -- All Rights Reserved -- @@ -215,7 +215,7 @@ The options (in alphabetic order): type. If you do not need input method (and are troubled by the warning messages), it is safe to disable this option. - --disable-leaks test: set to test memory leaks + --disable-leaks test: free permanent memory, analyze leaks Compile-in code which frees memory which might confuse a leak-testing tool. Normally these chunks of memory are retained as long as xterm @@ -565,13 +565,23 @@ The options (in alphabetic order): Use --without-app-defaults or --with-app-defaults=no to disable the feature. + --with-dmalloc test: use Gray Watson's dmalloc library + + Check for and link with dmalloc. + + --with-dbmalloc test: use Conor Cahill's dbmalloc library + + Check for and link with dbmalloc. + --with-desktop-category=XXX one or more desktop catgories or auto This is a list of names. The configure script maps blanks and commas to semicolons (";") which are used by the desktop utils as a separator. The default value "auto" tells the configure script to look at existing ".desktop" files for xterm and common terminal - emulators, to use those. + emulators, to use those. If none are found, the script uses this + default: + System;TerminalEmulator;Utility; --with-freetype-config configure script to use for FreeType @@ -704,6 +714,11 @@ The options (in alphabetic order): If xterm is not installed setuid'd to root, this option is not needed, since it cannot change the tty device's ownership. + --with-valgrind test: use valgrind + + Activate the --disable-leaks option, and ensure that "-g" is added to + CFLAGS. + --with-xpm=DIR use Xpm library for colored icon, may specify path Use Xpm library to show colored icon in window decoration, e.g., diff --git a/app/xterm/Imakefile b/app/xterm/Imakefile index fcfacedf2..3b365ad0c 100644 --- a/app/xterm/Imakefile +++ b/app/xterm/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XTermId: Imakefile,v 1.105 2011/11/29 10:19:20 Thorsten.Glaser Exp $ +XCOMM $XTermId: Imakefile,v 1.107 2013/01/01 12:16:40 tom Exp $ XCOMM XCOMM Attention xterm porters XCOMM @@ -126,19 +126,6 @@ module.o: ; $(CC) -c defines $(CFLAGS) module.c LOCAL_LDFLAGS = -Wl,-bind_at_load #endif -#ifdef OS2Architecture -/* - * Only used in os2main.c, see ptyx.h for OPT_I18N_SUPPORT - * <werner@suse.de> - */ -#if XtermWithI18N - I18NDEF = -DI18N - FEATURE_DEFINES = -DDEBUG -DALLOWLOGGING $(I18NDEF) -#else - FEATURE_DEFINES = -DDEBUG -DALLOWLOGGING -#endif -#endif - OSMAJORVERSION = OSMajorVersion OSMINORVERSION = OSMinorVersion @@ -190,13 +177,8 @@ TERMCAPDEFINES=-DUSE_TERMINFO -DHAVE_TIGETSTR DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF) INCLUDES = -I. $(XRFINCLUDES) -#ifdef OS2Architecture - MAINSRC = os2main.c - MAINOBJ = os2main.o -#else MAINSRC = main.c MAINOBJ = main.o -#endif #ifdef TraceXTerm TRACESRC = trace.c TRACEOBJ = trace.o @@ -204,17 +186,17 @@ TERMCAPDEFINES=-DUSE_TERMINFO -DHAVE_TIGETSTR SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \ data.c doublechr.c fontutils.c input.c \ linedata.c menu.c misc.c print.c ptydata.c scrollback.c \ - screen.c scrollbar.c tabs.c util.c xstrings.c xtermcap.c \ - TekPrsTbl.c Tekproc.c VTPrsTbl.c \ + screen.c scrollbar.c tabs.c util.c version.c xstrings.c \ + xtermcap.c TekPrsTbl.c Tekproc.c VTPrsTbl.c \ $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC) OBJS1 = button.o cachedGCs.o charproc.o charsets.o cursor.o \ data.o doublechr.o fontutils.o input.o \ linedata.o menu.o misc.o print.o ptydata.o scrollback.o \ - screen.o scrollbar.o tabs.o util.o xstrings.o xtermcap.o \ - TekPrsTbl.o Tekproc.o VTPrsTbl.o \ + screen.o scrollbar.o tabs.o util.o version.o xstrings.o \ + xtermcap.o TekPrsTbl.o Tekproc.o VTPrsTbl.o \ $(MAINOBJ) $(EXTRAOBJ) $(UTF8OBJ) $(TRACEOBJ) - SRCS2 = resize.c xstrings.c - OBJS2 = resize.o xstrings.o + SRCS2 = resize.c version.c xstrings.c + OBJS2 = resize.o version.o xstrings.o SRCS = $(SRCS1) $(SRCS2) OBJS = $(OBJS1) $(OBJS2) PROGRAMS = ProgramTargetName(resize) ProgramTargetName(xterm) diff --git a/app/xterm/MANIFEST b/app/xterm/MANIFEST index 6a341da95..dad1577f3 100644 --- a/app/xterm/MANIFEST +++ b/app/xterm/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for xterm-287, version xterm-287 +MANIFEST for xterm-291, version xterm-291 -------------------------------------------------------------------------------- MANIFEST this file 256colres.h resource-definitions for 256-color mode @@ -62,12 +62,10 @@ menu.c popup/pulldown menus for 'xterm' menu.h interface of menu.c minstall.in script for installing manpages misc.c miscellaneous utility functions for 'xterm' -os2main.c main program for OS/2 EMX port of 'xterm' plink.sh script to prune unneeded libraries from link precompose.c table of precompose sequences precompose.h interface of precompose.c print.c VT100+ print support functions -proto.h macros to simplify function prototypes ptydata.c functions to manipulate data read from pty ptyx.h structure-definitions for 'xterm' resize.c program to compute/modify xterm's window size @@ -87,6 +85,7 @@ util.c miscellaneous utility functions for 'xterm' uxterm wrapper script to make unicode-xterm uxterm.desktop sample desktop file for uxterm uxterm.man manpage for uxterm, from Debian +version.c xterm package version, used also in resize version.h version of xterm vms.c VMS version of xterm's spawn(), etc. vms.h system headers and definitions for vms.c diff --git a/app/xterm/Makefile b/app/xterm/Makefile index a6ab46897..102051cce 100644 --- a/app/xterm/Makefile +++ b/app/xterm/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.21 2012/04/07 20:22:27 matthieu Exp $ +# $OpenBSD: Makefile,v 1.22 2013/03/09 14:45:38 matthieu Exp $ .include <bsd.xconf.mk> SUBDIR= icons resize @@ -23,7 +23,7 @@ SRCS= TekPrsTbl.c Tekproc.c VTPrsTbl.c button.c cachedGCs.c \ charclass.c xtermcap.c charproc.c charsets.c cursor.c \ data.c doublechr.c fontutils.c input.c linedata.c main.c menu.c \ misc.c precompose.c print.c ptydata.c wcwidth.c screen.c \ - scrollback.c scrollbar.c tabs.c trace.c util.c xstrings.c + scrollback.c scrollbar.c tabs.c trace.c util.c version.c xstrings.c MANDIR= ${X11BASE}/man/man XETC?= /etc/X11 diff --git a/app/xterm/button.c b/app/xterm/button.c index 5716c8d34..98e9ecb5d 100644 --- a/app/xterm/button.c +++ b/app/xterm/button.c @@ -1,7 +1,7 @@ -/* $XTermId: button.c,v 1.435 2012/11/20 01:15:57 tom Exp $ */ +/* $XTermId: button.c,v 1.451 2013/02/06 09:56:15 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -1320,10 +1320,11 @@ xtermUtf8ToTextList(XtermWidget xw, for (i = 0; i < (*text_list_count); ++i) { data = (Char *) (*text_list)[i]; size = strlen((*text_list)[i]) + 1; - data = UTF8toLatin1(screen, data, size, &size); - memcpy(tmp, data, size + 1); - new_text_list[i] = tmp; - tmp += size + 1; + if ((data = UTF8toLatin1(screen, data, size, &size)) != 0) { + memcpy(tmp, data, size + 1); + new_text_list[i] = tmp; + tmp += size + 1; + } } XFreeStringList((*text_list)); *text_list = new_text_list; @@ -1345,7 +1346,6 @@ parseItem(char *value, char *nextc) } *nextc = *nextp; *nextp = '\0'; - x_strtrim(value); return nextp; } @@ -1404,30 +1404,32 @@ overrideTargets(Widget w, String value, Atom ** resultp) count = 0; do { char *nextp = parseItem(listp, &nextc); - size_t len = strlen(listp); + char *item = x_strtrim(listp); + size_t len = (item ? strlen(item) : 0); if (len == 0) { /* EMPTY */ ; } #if OPT_WIDE_CHARS - else if (sameItem(listp, "UTF8")) { + else if (sameItem(item, "UTF8")) { result[count++] = XA_UTF8_STRING(XtDisplay(w)); } #endif - else if (sameItem(listp, "I18N")) { + else if (sameItem(item, "I18N")) { if (screen->i18nSelections) { result[count++] = XA_TEXT(XtDisplay(w)); result[count++] = XA_COMPOUND_TEXT(XtDisplay(w)); } - } else if (sameItem(listp, "TEXT")) { + } else if (sameItem(item, "TEXT")) { result[count++] = XA_TEXT(XtDisplay(w)); - } else if (sameItem(listp, "COMPOUND_TEXT")) { + } else if (sameItem(item, "COMPOUND_TEXT")) { result[count++] = XA_COMPOUND_TEXT(XtDisplay(w)); - } else if (sameItem(listp, "STRING")) { + } else if (sameItem(item, "STRING")) { result[count++] = XA_STRING; } *nextp++ = nextc; listp = nextp; + free(item); } while (nextc != '\0'); if (count) { result[count] = None; @@ -1437,6 +1439,7 @@ overrideTargets(Widget w, String value, Atom ** resultp) XtFree((char *) result); } } + free(copied); } else { TRACE(("Couldn't allocate copy of selection types\n")); } @@ -1597,6 +1600,10 @@ MapSelections(XtermWidget xw, String * params, Cardinal num_params) : params[j])); if (result[j] == 0) { UnmapSelections(xw); + while (j != 0) { + free((void *) result[--j]); + } + free(result); result = 0; break; } @@ -3771,8 +3778,10 @@ ConvertSelection(Widget w, *value = (XtPointer) targetP; - while (*my_targets != None) { - *targetP++ = *my_targets++; + if (my_targets != 0) { + while (*my_targets != None) { + *targetP++ = *my_targets++; + } } *targetP++ = XA_LENGTH(dpy); *targetP++ = XA_LIST_LENGTH(dpy); @@ -4180,15 +4189,21 @@ BtnCode(XButtonEvent * event, int button) { int result = (int) (32 + (KeyState(event->state) << 2)); + if (event->type == MotionNotify) + result += 32; + if (button < 0 || button > 5) { result += 3; } else { if (button > 3) result += (64 - 4); - if (event->type == MotionNotify) - result += 32; result += button; } + TRACE(("BtnCode button %d, %s state " FMT_MODIFIER_NAMES " ->%#x\n", + button, + visibleEventType(event->type), + ARG_MODIFIER_NAMES(event->state), + result)); return result; } @@ -4229,6 +4244,22 @@ EmitButtonCode(TScreen * screen, return count; } +static int +FirstBitN(int bits) +{ + int result = -1; + if (bits > 0) { + result = 0; + while (!(bits & 1)) { + bits /= 2; + ++result; + } + } + return result; +} + +#define ButtonBit(button) ((button >= 0) ? (1 << (button)) : 0) + #define EMIT_BUTTON(button) EmitButtonCode(screen, line, count, event, button) static void @@ -4305,7 +4336,7 @@ EditorButton(XtermWidget xw, XButtonEvent * event) /* Button-Motion events */ switch (event->type) { case ButtonPress: - screen->mouse_button = button; + screen->mouse_button |= ButtonBit(button); count = EMIT_BUTTON(button); break; case ButtonRelease: @@ -4315,6 +4346,7 @@ EditorButton(XtermWidget xw, XButtonEvent * event) * release for buttons 1..3 to a -1, which will be later mapped * into a "0" (some button was released). */ + screen->mouse_button &= ~ButtonBit(button); if (button < 3) { switch (screen->extend_coords) { case SET_SGR_EXT_MODE_MOUSE: @@ -4325,7 +4357,6 @@ EditorButton(XtermWidget xw, XButtonEvent * event) break; } } - screen->mouse_button = button; count = EMIT_BUTTON(button); break; case MotionNotify: @@ -4336,7 +4367,7 @@ EditorButton(XtermWidget xw, XButtonEvent * event) && (col == screen->mouse_col)) { changed = False; } else { - count = EMIT_BUTTON(screen->mouse_button); + count = EMIT_BUTTON(FirstBitN(screen->mouse_button)); } break; default: @@ -4502,6 +4533,7 @@ getDataFromScreen(XtermWidget xw, String method, CELL * start, CELL * finish) lookupSelectUnit(xw, 0, method); screen->selectUnit = screen->selectMap[0]; + memset(start, 0, sizeof(*start)); start->row = screen->cur_row; start->col = screen->cur_col; *finish = *start; @@ -4617,6 +4649,7 @@ tokenizeFormat(String format) if (!pass) { result = TypeCallocN(char *, argc + 1); if (result == 0) { + free(blob); break; } } @@ -4805,9 +4838,11 @@ expandFormat(XtermWidget xw, static void executeCommand(char **argv) { - if (fork() == 0) { - execvp(argv[0], argv); - exit(EXIT_FAILURE); + if (argv != 0 && argv[0] != 0) { + if (fork() == 0) { + execvp(argv[0], argv); + exit(EXIT_FAILURE); + } } } @@ -4846,13 +4881,14 @@ HandleExecFormatted(Widget w, data = getSelectionString(xw, w, event, params, num_params, &start, &finish); - argv = tokenizeFormat(params[0]); - blob = argv[0]; - for (argc = 0; argv[argc] != 0; ++argc) { - argv[argc] = expandFormat(xw, argv[argc], data, &start, &finish); + if ((argv = tokenizeFormat(params[0])) != 0) { + blob = argv[0]; + for (argc = 0; argv[argc] != 0; ++argc) { + argv[argc] = expandFormat(xw, argv[argc], data, &start, &finish); + } + executeCommand(argv); + freeArgv(blob, argv); } - executeCommand(argv); - freeArgv(blob, argv); } } } @@ -4876,14 +4912,18 @@ HandleExecSelectable(Widget w, int argc; data = getDataFromScreen(xw, params[1], &start, &finish); - argv = tokenizeFormat(params[0]); - blob = argv[0]; - for (argc = 0; argv[argc] != 0; ++argc) { - argv[argc] = expandFormat(xw, argv[argc], data, &start, &finish); + if (data != 0) { + if ((argv = tokenizeFormat(params[0])) != 0) { + blob = argv[0]; + for (argc = 0; argv[argc] != 0; ++argc) { + argv[argc] = expandFormat(xw, argv[argc], data, + &start, &finish); + } + executeCommand(argv); + freeArgv(blob, argv); + free(data); + } } - executeCommand(argv); - freeArgv(blob, argv); - free(data); } } } @@ -4903,11 +4943,14 @@ HandleInsertFormatted(Widget w, CELL start, finish; char *data; char *temp = x_strdup(params[0]); + char *exps; data = getSelectionString(xw, w, event, params, num_params, &start, &finish); - temp = expandFormat(xw, temp, data, &start, &finish); - unparseputs(xw, temp); + if ((exps = expandFormat(xw, temp, data, &start, &finish)) != 0) { + unparseputs(xw, exps); + free(exps); + } free(data); free(temp); } @@ -4929,11 +4972,17 @@ HandleInsertSelectable(Widget w, CELL start, finish; char *data; char *temp = x_strdup(params[0]); + char *exps; data = getDataFromScreen(xw, params[1], &start, &finish); - temp = expandFormat(xw, temp, data, &start, &finish); - unparseputs(xw, temp); - free(data); + if (data != 0) { + exps = expandFormat(xw, temp, data, &start, &finish); + if (exps != 0) { + unparseputs(xw, exps); + free(exps); + } + free(data); + } free(temp); } } diff --git a/app/xterm/charproc.c b/app/xterm/charproc.c index 816ac689b..63ef02197 100644 --- a/app/xterm/charproc.c +++ b/app/xterm/charproc.c @@ -1,7 +1,7 @@ -/* $XTermId: charproc.c,v 1.1270 2012/11/25 19:25:10 Balazs.Kezes Exp $ */ +/* $XTermId: charproc.c,v 1.1283 2013/02/05 01:47:58 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -1768,7 +1768,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) */ #if OPT_VT52_MODE if (sp->vt52_cup) { - if (nparam < NPARAM) { + if (nparam < NPARAM - 1) { SetParam(nparam++, (int) (c & 0x7f) - 32); parms.is_sub[nparam] = 0; } @@ -3932,11 +3932,16 @@ v_write(int f, const Char * data, unsigned len) int riten; TRACE2(("v_write(%d:%s)\n", len, visibleChars(data, len))); - if (v_bufstr == NULL && len > 0) { - v_buffer = (Char *) XtMalloc((Cardinal) len); - v_bufstr = v_buffer; - v_bufptr = v_buffer; - v_bufend = v_buffer + len; + if (v_bufstr == NULL) { + if (len > 0) { + v_buffer = (Char *) XtMalloc((Cardinal) len); + v_bufstr = v_buffer; + v_bufptr = v_buffer; + v_bufend = v_buffer + len; + } + if (v_bufstr == NULL) { + return; + } } #ifdef DEBUG if (debug) { @@ -4347,7 +4352,7 @@ in_put(XtermWidget xw) #endif } if (need_cleanup) - Cleanup(0); + NormalExit(); #if OPT_DOUBLE_BUFFER if (screen->needSwap) { XdbeSwapInfo swap; @@ -5937,6 +5942,7 @@ window_ops(XtermWidget xw) unsigned root_height; #endif int code = zero_if_default(0); + char *label; TRACE(("window_ops %d\n", code)); switch (code) { @@ -6106,14 +6112,16 @@ window_ops(XtermWidget xw) case ewGetIconTitle: /* Report the icon's label */ if (AllowWindowOps(xw, ewGetIconTitle)) { TRACE(("...get icon's label\n")); - report_win_label(xw, 'L', get_icon_label(xw)); + report_win_label(xw, 'L', label = get_icon_label(xw)); + free(label); } break; case ewGetWinTitle: /* Report the window's title */ if (AllowWindowOps(xw, ewGetWinTitle)) { TRACE(("...get window's label\n")); - report_win_label(xw, 'l', get_window_label(xw)); + report_win_label(xw, 'l', label = get_window_label(xw)); + free(label); } break; @@ -6309,7 +6317,7 @@ unparseputc(XtermWidget xw, int c) IChar *buf = screen->unparse_bfr; unsigned len; - if ((screen->unparse_len + 2) >= sizeof(screen->unparse_bfr)) + if ((screen->unparse_len + 2) >= sizeof(screen->unparse_bfr) / sizeof(IChar)) unparse_end(xw); len = screen->unparse_len; @@ -7021,7 +7029,7 @@ set_flags_from_list(char *target, Cardinal n; int value = -1; - while (*source != '\0') { + while (!IsEmpty(source)) { char *next = ParseList(&source); Boolean found = False; @@ -7253,7 +7261,7 @@ VTInitialize(Widget wrequest, TRACE((" Actual foreground 0x%06lx\n", wnew->old_foreground)); TRACE((" Actual background 0x%06lx\n", wnew->old_background)); - TScreenOf(wnew)->mouse_button = -1; + TScreenOf(wnew)->mouse_button = 0; TScreenOf(wnew)->mouse_row = -1; TScreenOf(wnew)->mouse_col = -1; @@ -7963,8 +7971,8 @@ releaseWindowGCs(XtermWidget xw, VTwin * win) #define TRACE_FREE_LEAK(name) \ if (name) { \ - free((void *) name); \ TRACE(("freed " #name ": %p\n", (const void *) name)); \ + free((void *) name); \ name = 0; \ } @@ -9228,7 +9236,7 @@ ShowCursor(void) * If the cursor happens to be on blanks, and the foreground color is set * but not the background, do not treat it as a colored cell. */ - if ((flags & TERM_COLOR_FLAGS(xw)) == BG_COLOR + if ((flags & TERM_COLOR_FLAGS(xw)) == FG_COLOR && base == ' ') { flags &= ~TERM_COLOR_FLAGS(xw); } @@ -9246,6 +9254,24 @@ ShowCursor(void) fg_pix = getXtermForeground(xw, flags, extract_fg(xw, fg_bg, flags)); bg_pix = getXtermBackground(xw, flags, extract_bg(xw, fg_bg, flags)); + /* + * If we happen to have the same foreground/background colors, choose + * a workable foreground color from which we can obtain a visible cursor. + */ + if (fg_pix == bg_pix) { + long bg_diff = (long) (bg_pix - T_COLOR(TScreenOf(xw), TEXT_BG)); + long fg_diff = (long) (bg_pix - T_COLOR(TScreenOf(xw), TEXT_FG)); + if (bg_diff < 0) + bg_diff = -bg_diff; + if (fg_diff < 0) + fg_diff = -fg_diff; + if (bg_diff < fg_diff) { + fg_pix = T_COLOR(TScreenOf(xw), TEXT_FG); + } else { + fg_pix = T_COLOR(TScreenOf(xw), TEXT_BG); + } + } + if (OutsideSelection(screen, screen->cur_row, screen->cur_col)) in_selection = False; else @@ -10095,7 +10121,9 @@ DoSetSelectedFont(Widget w, { XtermWidget xw = getXtermWidget(w); - if ((xw == 0) || *type != XA_STRING || *format != 8) { + if (xw == 0) { + xtermWarning("unexpected widget in DoSetSelectedFont\n"); + } else if (*type != XA_STRING || *format != 8) { Bell(xw, XkbBI_MinorError, 0); } else { Boolean failed = False; @@ -10127,6 +10155,7 @@ DoSetSelectedFont(Widget w, XLFD allows up to 255 characters and no control characters; we are a little more liberal here. */ if (len < 1000 + && used != 0 && !strchr(used, '\n') && (test = x_strdup(used)) != 0) { TScreenOf(xw)->MenuFontName(fontMenu_fontsel) = test; @@ -10159,7 +10188,7 @@ FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe) { TScreen *screen = TScreenOf(xw); static AtomPtr *atoms; - unsigned int atomCount = 0; + static unsigned int atomCount = 0; AtomPtr *pAtom; unsigned a; Atom target; @@ -10171,12 +10200,16 @@ FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe) TRACE(("FindFontSelection(%s)\n", atom_name)); for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { - if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) + if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) { + TRACE(("...found atom %d:%s\n", a + 1, atom_name)); break; + } } if (!a) { atoms = TypeXtReallocN(AtomPtr, atoms, atomCount + 1); *(pAtom = &atoms[atomCount]) = XmuMakeAtom(atom_name); + ++atomCount; + TRACE(("...added atom %d:%s\n", atomCount, atom_name)); } target = XmuInternAtom(XtDisplay(xw), *pAtom); diff --git a/app/xterm/configure.in b/app/xterm/configure.in index 0a25e0fed..23afc833c 100644 --- a/app/xterm/configure.in +++ b/app/xterm/configure.in @@ -1,9 +1,9 @@ -dnl $XTermId: configure.in,v 1.306 2012/10/10 23:32:47 tom Exp $ +dnl $XTermId: configure.in,v 1.312 2013/02/03 19:30:48 tom Exp $ dnl dnl ----------------------------------------------------------------------------- dnl this file is part of xterm dnl -dnl Copyright 1997-2011,2012 by Thomas E. Dickey +dnl Copyright 1997-2012,2013 by Thomas E. Dickey dnl dnl All Rights Reserved dnl @@ -53,8 +53,8 @@ esac CF_PROG_CC AC_PROG_CPP -AC_PROG_GCC_TRADITIONAL AC_PROG_AWK +CF_PROG_GROFF AC_PROG_INSTALL AC_PROG_LN_S AC_ARG_PROGRAM @@ -112,7 +112,9 @@ CF_WITH_APP_DEFAULTS CF_WITH_ICON_NAME(xterm-color) CF_WITH_ICON_THEME([icons/$ICON_NAME icons/${ICON_NAME}_48x48],,,icons/${ICON_NAME}_48x48) CF_DISABLE_DESKTOP(xterm) -CF_WITH_DESKTOP_CATEGORY(xterm,[*rxvt*|konsole|*-terminal],[System|TerminalEmulator|Utility|*]) +CF_WITH_DESKTOP_CATEGORY(xterm, + [*rxvt*|konsole|*-terminal], + [System|TerminalEmulator|Utility|*]) AC_MSG_CHECKING(for install-permissions reference) AC_ARG_WITH(reference, @@ -926,16 +928,7 @@ if test "$enable_trace" = yes ; then EXTRAOBJS="$EXTRAOBJS trace.o" fi -AC_MSG_CHECKING(if you want to test memory leaks) -CF_ARG_DISABLE(leaks, - [ --disable-leaks test: set to test memory leaks], - [disable_leaks=yes], - [disable_leaks=no]) -AC_MSG_RESULT($disable_leaks) -if test "$disable_leaks" = yes ; then - AC_DEFINE(NO_LEAKS,1,[Define to 1 to test memory leaks]) -fi - +CF_DISABLE_LEAKS CF_DISABLE_ECHO AC_MSG_CHECKING(if you want magic cookie emulation) diff --git a/app/xterm/ctlseqs.ms b/app/xterm/ctlseqs.ms index c4d1a0713..72479f88c 100644 --- a/app/xterm/ctlseqs.ms +++ b/app/xterm/ctlseqs.ms @@ -1,9 +1,9 @@ .\"#! troff -ms $1 -*- Nroff -*- .\" "Xterm Control Sequences" document -.\" $XTermId: ctlseqs.ms,v 1.276 2012/11/25 16:23:14 tom Exp $ +.\" $XTermId: ctlseqs.ms,v 1.285 2013/02/07 01:59:09 tom Exp $ .\" .\" -.\" Copyright 1996-2011,2012 by Thomas E. Dickey +.\" Copyright 1996-2012,2013 by Thomas E. Dickey .\" .\" All Rights Reserved .\" @@ -69,8 +69,8 @@ .\" .ds XT XTerm .ds xt xterm -.ds LF Patch #287 -.ds RF 2012/11/25 +.ds LF Patch #289 +.ds RF 2013/02/06 .\" .if n .pl 9999v \" no page breaks in nroff .ND @@ -111,6 +111,8 @@ .de Ss .LP .B +\\$* +.br .. .ds CH \" as nothing .ds LH \*(XT Control Sequences @@ -409,8 +411,7 @@ discussion of character sets. . .St .\" -.Ss -Single-character functions +.Ss Single-character functions .\" .IP \\*(Be Bell (Ctrl-G). @@ -453,8 +454,7 @@ Vertical Tab (Ctrl-K). This is treated the same as LF. .\" .\" .St -.Ss -Controls beginning with \*(Es +.Ss Controls beginning with \*(Es .LP This excludes controls where \*(Es is part of a 7-bit equivalent to 8-bit C1 controls, ordered by the final character(s). .\" @@ -598,16 +598,14 @@ Invoke the G1 Character Set as GR (LS1R). .Ed . .St -.Ss -Application Program-Control functions +.Ss Application Program-Control functions .IP \\*(AP\\*(Pt\\*s\\*(ST None. \fIxterm\fP implements no \*(AP functions; \*(Pt is ignored. \*(Pt need not be printable characters. .Ed . .St -.Ss -Device-Control functions +.Ss Device-Control functions .IP \\*(Dc\\*(Ps\\*;\\*(Ps\\*|\\*(Pt\\*s\\*(ST User-Defined Keys (DECUDK). The first parameter: @@ -670,8 +668,7 @@ The strings are encoded in hexadecimal (2 digits per character). .Ed .\" .St -.Ss -Functions using \*(Cs, ordered by the final character(s) +.Ss Functions using \*(Cs, ordered by the final character(s) .IP \\*(Cs\\*(Ps\\*s\\*@ Insert \*(Ps (Blank) Character(s) (default = 1) (ICH). . @@ -1478,17 +1475,16 @@ position in the \*(xt window, encoded as ASCII decimal. .br The ``page'' parameter is not used by \*(xt, and will be omitted. . -.IP \\*(Cs\\*(Pm\\*s\\*(Sp\\*} +.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*} Insert \*(Ps Column(s) (default = 1) (DECIC), VT420 and up. . -.IP \\*(Cs\\*(Pm\\*s\\*(Sp\\*~ +.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*~ Delete \*(Ps Column(s) (default = 1) (DECDC), VT420 and up. . .Ed . .St -.Ss -Operating System Controls +.Ss Operating System Controls . .IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(ST .IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be @@ -1639,8 +1635,7 @@ The \fIdynamic colors\fR can also be reset to their default (resource) values: \*(Ps = \*1\*1\*8 \(-> Reset Tektronix cursor color. . .St -.Ss -Privacy Message +.Ss Privacy Message .IP \\*(PM\\*(Pt\\*s\\*(ST \fIxterm\fP implements no \*(PM functions; \*(Pt is ignored. \*(Pt need not be printable characters. @@ -1679,12 +1674,15 @@ shift the key from codes 0-127 to 128-255 by adding 128. The table shows the result for a given character "x" with modifiers according to the default translations with the resources set on or off. This assumes \fBaltIsNotMeta\fP is set: -.ne 23 -.TS +.\" page-eject to work around grohtml bugs +.if t .bp +.TS H center; -lf3 lf3 lf3 lf3 lf3w(2c) lf3w(2c) lf3w(2c) lf3w(2c) . _ +.TH +.T& +l | l | l | l . key altSendsEscape metaSendsEscape result _ x off off x @@ -1721,13 +1719,14 @@ or by the "DECSET \*1\*0\*3\*5" control sequence. .lP The cursor keys transmit the following escape sequences depending on the mode specified via the \fBDECCKM\fP escape sequence. -.ne 10 -.TS +.TS H center; -cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) . Key Normal Application _ +.TH +.T& +l | l | l . Cursor Up \*(Cs\*A \*(S3\*A Cursor Down \*(Cs\*(cB \*(S3\*(cB Cursor Right \*(Cs\*C \*(S3\*C @@ -1738,13 +1737,14 @@ The home- and end-keys (unlike PageUp and other keys also on the 6-key editing keypad) are considered "cursor keys" by \fIxterm\fP. Their mode is also controlled by the \fBDECCKM\fP escape sequence: -.ne 8 -.TS +.TS H center; -cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) . Key Normal Application _ +.TH +.T& +l | l | l . Home \*(Cs\*H \*(S3\*H End \*(Cs\*F \*(S3\*F _ @@ -1756,13 +1756,14 @@ Use the NumLock key to override the application mode. .lP Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are supported by the program. -.ne 30 -.TS +.TS H center; -cf3 cf3 cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) lf3w(2c) lf3w(2c) . Key Numeric Application Terminfo Termcap _ +.TH +.T& +l | l | l | l | l . Space \*(Sp \*(S3\*(Sp - - Tab \*(Ta \*(S3\*I - - Enter \*(Cr \*(S3\*M kent @8 @@ -1791,13 +1792,14 @@ _ .TE .br They also provide 12 function keys, as well as a few other special-purpose keys: -.ne 18 -.TS +.TS H center; -cf3 cf3 lf3w(2c) lf3w(2c) . Key Escape Sequence _ +.TH +.T& +l | l . F1 \*(S3\*P F2 \*(S3\*Q F3 \*(S3\*R @@ -1817,13 +1819,14 @@ Older versions of \fIxterm\fP implement different escape sequences for F1 throug These can be activated by setting the \fBoldXtermFKeys\fP resource. However, since they do not correspond to any hardware terminal, they have been deprecated. (The DEC VT220 reserves F1 through F5 for local functions such as \fBSetup\fP). -.ne 10 -.TS +.TS H center; -cf3 cf3 lf3w(2c) lf3w(2c) . Key Escape Sequence _ +.TH +.T& +l | l . F1 \*(Cs\*1\*1\*(c~ F2 \*(Cs\*1\*2\*(c~ F3 \*(Cs\*1\*3\*(c~ @@ -1835,13 +1838,14 @@ when the \fBsunKeyboard\fP resource is false, \fIxterm\fP recognizes function key modifiers which are parameters appended before the final character of the control sequence. -.ne 13 -.TS +.TS H center; -cf3 lf3 cf3w(2c) lf3w(2c) . Code Modifiers _ +.TH +.T& +l | l . 2 Shift 3 Alt 4 Shift + Alt @@ -1864,13 +1868,14 @@ to act like a VT220 keyboard. .lP The VT102/VT220 application keypad transmits unique escape sequences in application mode, which are distinct from the cursor and scrolling keypad: -.ne 32 -.TS +.TS H center; -cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) . Key Numeric Application _ +.TH +.T& +l | l | l . Space \*(Sp \*(S3\*(Sp Tab \*(Ta \*(S3\*I Enter \*(Cr \*(S3\*M @@ -1900,13 +1905,14 @@ _ The VT220 provides a 6-key editing keypad, which is analogous to that on the PC keyboard. It is not affected by \fBDECCKM\fP or \fBDECKPNM\fP/\fBDECKPAM\fP: -.ne 12 -.TS +.TS H center; -cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) . Key Normal Application _ +.TH +.T& +l | l | l . \f1Insert\fP \*(Cs\*2\*(c~ \*(Cs\*2\*(c~ \f1Delete\fP \*(Cs\*3\*(c~ \*(Cs\*3\*(c~ \f1Home\fP \*(Cs\*1\*(c~ \*(Cs\*1\*(c~ @@ -1918,13 +1924,14 @@ _ .LP The VT220 provides 8 additional function keys. With a Sun/PC keyboard, access these keys by Control/F1 for F13, etc. -.ne 16 -.TS +.TS H center; -cf3 cf3 lf3w(2c) lf3w(2c) . Key Escape Sequence _ +.TH +.T& +l | l . F13 \*(Cs\*2\*5\*(c~ F14 \*(Cs\*2\*6\*(c~ F15 \*(Cs\*2\*8\*(c~ @@ -1940,13 +1947,14 @@ _ A VT52 does not have function keys, but it does have a numeric keypad and cursor keys. They differ from the other emulations by the prefix. Also, the cursor keys do not change: -.ne 13 -.TS +.TS H center; -cf3 cf3 lf3w(2c) lf3w(2c) . Key Normal/Application _ +.TH +.T& +l | l . Cursor Up \*(Es\*A Cursor Down \*(Es\*(cB Cursor Right \*(Es\*C @@ -1954,13 +1962,14 @@ Cursor Left \*(Es\*D _ .TE The keypad is similar: -.ne 33 -.TS +.TS H center; -cf3 cf3 cf3 lf3w(2c) lf3w(2c) lf3w(2c) . Key Numeric Application _ +.TH +.T& +l | l | l . Space \*(Sp \*(Es\*?\*(Sp Tab \*(Ta \*(Es\*?\*I Enter \*(Cr \*(Es\*?\*M @@ -2140,6 +2149,7 @@ For example, \*! specifies the value 1. The upper left character position on the terminal is denoted as 1,1. This scheme dates back to X10, though the normal mouse-tracking (from X11) is more elaborate. +.Ss X10 compatbility mode .lP X10 compatibility mode sends an escape sequence only on button press, encoding the location and the mouse button pressed. @@ -2151,6 +2161,7 @@ On button press, \fIxterm\fP sends .bP \*(Cx and \*(Cy are the x and y coordinates of the mouse when the button was pressed. +.Ss Normal tracking mode .lP Normal tracking mode sends an escape sequence on both button press and release. @@ -2172,6 +2183,7 @@ and is not necessarily the "Meta" key (see \fIxmodmap\fP). .bP \*(Cx and \*(Cy are the x and y coordinates of the mouse event, encoded as in X10 mode. +.Ss Wheel mice .lP Wheel mice may return buttons 4 and 5. Those buttons are represented by the same event codes @@ -2188,6 +2200,7 @@ then cursor up/down controls are sent when the terminal is displaying the alternate screen. The initial state of Alternate Scroll mode is set using the \fBalternateScroll\fP resource. +.Ss Highlight tracking .lP Mouse highlight tracking notifies a program of a button press, receives a range of lines from the program, highlights the region covered by @@ -2235,6 +2248,7 @@ ending character positions of the region. give the location of the mouse at button up, which may not be over a character. .RE +.Ss Button-event tracking .lP Button-event tracking is essentially the same as normal tracking, but \fIxterm\fP also reports button-motion events. @@ -2255,16 +2269,19 @@ down is reported as \*(Cs\*M\*@\*(Cx\*(Cy. Similarly, motion with button 3 down is reported as \*(Cs\*M\*(cB\*(Cx\*(Cy. (\ \*(cB = 32 + 2 (button 3) + 32 (motion indicator)\ ). +.Ss Any-event tracking .lP Any-event mode is the same as button-event mode, except that all motion events are reported, even if no mouse button is down. It is enabled by specifying 1003 to DECSET. +.Ss FocusIn/FocusOut .lP FocusIn/FocusOut can be combined with any of the mouse events since it uses a different protocol. When set, it causes \fIxterm\fP to send \*(Cs\*I when the terminal gains focus, and \*(Cs\*O when it loses focus. +.Ss Extended coordinates .lP The original X10 mouse protocol limits the \*(Cx and \*(Cy ordinates to 223 (=255\ -\ 32). @@ -2295,13 +2312,17 @@ encoded button value, the \*(Cx and \*(Cy ordinates and a final character which is \*M for button press and \*m for button release. -.IP +.RS +.bP The encoded button value in this case does not add 32 since that was useful only in the X10 scheme for ensuring that the byte containing the button value is a printable code. +.bP The modifiers are encoded in the same way. +.bP A different final character is used for button release to resolve the X10 ambiguity regarding which button was released. +.RE .IP The highlight tracking responses are also modified to an SGR-like format, using the same SGR-style scheme and button-encodings. diff --git a/app/xterm/ctlseqs.txt b/app/xterm/ctlseqs.txt index ec9f5f444..63ad449d7 100644 --- a/app/xterm/ctlseqs.txt +++ b/app/xterm/ctlseqs.txt @@ -21,7 +21,7 @@ Thomas Dickey XFree86 Project (1996-2006) invisible-island.net (2006-2012) - updated for XTerm Patch #287 (2012/11/25) + updated for XTerm Patch #289 (2013/02/06) @@ -921,9 +921,9 @@ CSI Ps ' | mal. The ``page'' parameter is not used by xterm, and will be omit- ted. -CSI Pm SP } +CSI Pm ' } Insert Ps Column(s) (default = 1) (DECIC), VT420 and up. -CSI Pm SP ~ +CSI Pm ' ~ Delete Ps Column(s) (default = 1) (DECDC), VT420 and up. Operating System Controls @@ -1089,24 +1089,24 @@ This assumes altIsNotMeta is set: ----------------------------------------------------------- key altSendsEscape metaSendsEscape result - ----------------------------------------------------------- - x off off x - Meta-x off off shift - Alt-x off off shift - Alt+Meta-x off off shift - x ON off x - Meta-x ON off shift - Alt-x ON off ESC x - Alt+Meta-x ON off ESC shift - x off ON x - Meta-x off ON ESC x - Alt-x off ON shift - Alt+Meta-x off ON ESC shift - x ON ON x - Meta-x ON ON ESC x - Alt-x ON ON ESC x - Alt+Meta-x ON ON ESC x - ----------------------------------------------------------- + -----------+----------------+-----------------+------------ + x | off | off | x + Meta-x | off | off | shift + Alt-x | off | off | shift + Alt+Meta-x | off | off | shift + x | ON | off | x + Meta-x | ON | off | shift + Alt-x | ON | off | ESC x + Alt+Meta-x | ON | off | ESC shift + x | off | ON | x + Meta-x | off | ON | ESC x + Alt-x | off | ON | shift + Alt+Meta-x | off | ON | ESC shift + x | ON | ON | x + Meta-x | ON | ON | ESC x + Alt-x | ON | ON | ESC x + Alt+Meta-x | ON | ON | ESC x + -----------+----------------+-----------------+------------ PC-Style Function Keys @@ -1124,23 +1124,23 @@ recognized as modifiers when enabled by the numLock resource, or by the The cursor keys transmit the following escape sequences depending on the mode specified via the DECCKM escape sequence. - Key Normal Application - -------------------------------------- - Cursor Up CSI A SS3 A - Cursor Down CSI B SS3 B - Cursor Right CSI C SS3 C - Cursor Left CSI D SS3 D - -------------------------------------- + Key Normal Application + -------------+----------+------------- + Cursor Up | CSI A | SS3 A + Cursor Down | CSI B | SS3 B + Cursor Right | CSI C | SS3 C + Cursor Left | CSI D | SS3 D + -------------+----------+------------- The home- and end-keys (unlike PageUp and other keys also on the 6-key editing keypad) are considered "cursor keys" by xterm. Their mode is also controlled by the DECCKM escape sequence: - Key Normal Application - ---------------------------------- - Home CSI H SS3 H - End CSI F SS3 F - ---------------------------------- + Key Normal Application + ---------+----------+------------- + Home | CSI H | SS3 H + End | CSI F | SS3 F + ---------+----------+------------- The application keypad transmits the following escape sequences depend- @@ -1150,52 +1150,52 @@ Use the NumLock key to override the application mode. Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are supported by the program. - Key Numeric Application Terminfo Termcap - -------------------------------------------------------------- - Space SP SS3 SP - - - Tab TAB SS3 I - - - Enter CR SS3 M kent @8 - PF1 SS3 P SS3 P kf1 k1 - PF2 SS3 Q SS3 Q kf2 k2 - PF3 SS3 R SS3 R kf3 k3 - PF4 SS3 S SS3 S kf4 k4 - * (multiply) * SS3 j - - - + (add) + SS3 k - - - , (comma) , SS3 l - - - - (minus) - SS3 m - - - . (Delete) . CSI 3 ~ - - - / (divide) / SS3 o - - - 0 (Insert) 0 CSI 2 ~ - - - 1 (End) 1 SS3 F kc1 K4 - 2 (DownArrow) 2 CSI B - - - 3 (PageDown) 3 CSI 6 ~ kc3 K5 - 4 (LeftArrow) 4 CSI D - - - 5 (Begin) 5 CSI E kb2 K2 - 6 (RightArrow) 6 CSI C - - - 7 (Home) 7 SS3 H ka1 K1 - 8 (UpArrow) 8 CSI A - - - 9 (PageUp) 9 CSI 5 ~ ka3 K3 - = (equal) = SS3 X - - - -------------------------------------------------------------- + Key Numeric Application Terminfo Termcap + ---------------+----------+-------------+----------+---------- + Space | SP | SS3 SP | - | - + Tab | TAB | SS3 I | - | - + Enter | CR | SS3 M | kent | @8 + PF1 | SS3 P | SS3 P | kf1 | k1 + PF2 | SS3 Q | SS3 Q | kf2 | k2 + PF3 | SS3 R | SS3 R | kf3 | k3 + PF4 | SS3 S | SS3 S | kf4 | k4 + * (multiply) | * | SS3 j | - | - + + (add) | + | SS3 k | - | - + , (comma) | , | SS3 l | - | - + - (minus) | - | SS3 m | - | - + . (Delete) | . | CSI 3 ~ | - | - + / (divide) | / | SS3 o | - | - + 0 (Insert) | 0 | CSI 2 ~ | - | - + 1 (End) | 1 | SS3 F | kc1 | K4 + 2 (DownArrow) | 2 | CSI B | - | - + 3 (PageDown) | 3 | CSI 6 ~ | kc3 | K5 + 4 (LeftArrow) | 4 | CSI D | - | - + 5 (Begin) | 5 | CSI E | kb2 | K2 + 6 (RightArrow) | 6 | CSI C | - | - + 7 (Home) | 7 | SS3 H | ka1 | K1 + 8 (UpArrow) | 8 | CSI A | - | - + 9 (PageUp) | 9 | CSI 5 ~ | ka3 | K3 + = (equal) | = | SS3 X | - | - + ---------------+----------+-------------+----------+---------- They also provide 12 function keys, as well as a few other special-pur- pose keys: - Key Escape Sequence - --------------------------- - F1 SS3 P - F2 SS3 Q - F3 SS3 R - F4 SS3 S - F5 CSI 1 5 ~ - F6 CSI 1 7 ~ - F7 CSI 1 8 ~ - F8 CSI 1 9 ~ - F9 CSI 2 0 ~ - F10 CSI 2 1 ~ - F11 CSI 2 3 ~ - F12 CSI 2 4 ~ - --------------------------- + Key Escape Sequence + ---------+----------------- + F1 | SS3 P + F2 | SS3 Q + F3 | SS3 R + F4 | SS3 S + F5 | CSI 1 5 ~ + F6 | CSI 1 7 ~ + F7 | CSI 1 8 ~ + F8 | CSI 1 9 ~ + F9 | CSI 2 0 ~ + F10 | CSI 2 1 ~ + F11 | CSI 2 3 ~ + F12 | CSI 2 4 ~ + ---------+----------------- Older versions of xterm implement different escape sequences for F1 @@ -1204,28 +1204,28 @@ resource. However, since they do not correspond to any hardware termi- nal, they have been deprecated. (The DEC VT220 reserves F1 through F5 for local functions such as Setup). - Key Escape Sequence - --------------------------- - F1 CSI 1 1 ~ - F2 CSI 1 2 ~ - F3 CSI 1 3 ~ - F4 CSI 1 4 ~ - --------------------------- + Key Escape Sequence + ---------+----------------- + F1 | CSI 1 1 ~ + F2 | CSI 1 2 ~ + F3 | CSI 1 3 ~ + F4 | CSI 1 4 ~ + ---------+----------------- In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is false, xterm recognizes function key modifiers which are parameters appended before the final character of the control sequence. Code Modifiers - --------------------------------- - 2 Shift - 3 Alt - 4 Shift + Alt - 5 Control - 6 Shift + Control - 7 Alt + Control - 8 Shift + Alt + Control - --------------------------------- + ---------+----------------------- + 2 | Shift + 3 | Alt + 4 | Shift + Alt + 5 | Control + 6 | Shift + Control + 7 | Alt + Control + 8 | Shift + Alt + Control + ---------+----------------------- For example, shift-F5 would be sent as CSI 1 5 ; 2 ~ @@ -1241,61 +1241,61 @@ The VT102/VT220 application keypad transmits unique escape sequences in application mode, which are distinct from the cursor and scrolling key- pad: - Key Numeric Application - -------------------------------------- - Space SP SS3 SP - Tab TAB SS3 I - Enter CR SS3 M - PF1 SS3 P SS3 P - PF2 SS3 Q SS3 Q - PF3 SS3 R SS3 R - PF4 SS3 S SS3 S - * (multiply) * SS3 j - + (add) + SS3 k - , (comma) , SS3 l - - (minus) - SS3 m - . (period) . SS3 n - / (divide) / SS3 o - 0 0 SS3 p - 1 1 SS3 q - 2 2 SS3 r - 3 3 SS3 s - 4 4 SS3 t - 5 5 SS3 u - 6 6 SS3 v - 7 7 SS3 w - 8 8 SS3 x - 9 9 SS3 y - = (equal) = SS3 X - -------------------------------------- + Key Numeric Application + -------------+----------+------------- + Space | SP | SS3 SP + Tab | TAB | SS3 I + Enter | CR | SS3 M + PF1 | SS3 P | SS3 P + PF2 | SS3 Q | SS3 Q + PF3 | SS3 R | SS3 R + PF4 | SS3 S | SS3 S + * (multiply) | * | SS3 j + + (add) | + | SS3 k + , (comma) | , | SS3 l + - (minus) | - | SS3 m + . (period) | . | SS3 n + / (divide) | / | SS3 o + 0 | 0 | SS3 p + 1 | 1 | SS3 q + 2 | 2 | SS3 r + 3 | 3 | SS3 s + 4 | 4 | SS3 t + 5 | 5 | SS3 u + 6 | 6 | SS3 v + 7 | 7 | SS3 w + 8 | 8 | SS3 x + 9 | 9 | SS3 y + = (equal) | = | SS3 X + -------------+----------+------------- The VT220 provides a 6-key editing keypad, which is analogous to that on the PC keyboard. It is not affected by DECCKM or DECKPNM/DECKPAM: - Key Normal Application - ---------------------------------- - Insert CSI 2 ~ CSI 2 ~ - Delete CSI 3 ~ CSI 3 ~ - Home CSI 1 ~ CSI 1 ~ - End CSI 4 ~ CSI 4 ~ - PageUp CSI 5 ~ CSI 5 ~ - PageDown CSI 6 ~ CSI 6 ~ - ---------------------------------- + Key Normal Application + ---------+----------+------------- + Insert | CSI 2 ~ | CSI 2 ~ + Delete | CSI 3 ~ | CSI 3 ~ + Home | CSI 1 ~ | CSI 1 ~ + End | CSI 4 ~ | CSI 4 ~ + PageUp | CSI 5 ~ | CSI 5 ~ + PageDown | CSI 6 ~ | CSI 6 ~ + ---------+----------+------------- The VT220 provides 8 additional function keys. With a Sun/PC keyboard, access these keys by Control/F1 for F13, etc. - Key Escape Sequence - --------------------------- - F13 CSI 2 5 ~ - F14 CSI 2 6 ~ - F15 CSI 2 8 ~ - F16 CSI 2 9 ~ - F17 CSI 3 1 ~ - F18 CSI 3 2 ~ - F19 CSI 3 3 ~ - F20 CSI 3 4 ~ - --------------------------- + Key Escape Sequence + ---------+----------------- + F13 | CSI 2 5 ~ + F14 | CSI 2 6 ~ + F15 | CSI 2 8 ~ + F16 | CSI 2 9 ~ + F17 | CSI 3 1 ~ + F18 | CSI 3 2 ~ + F19 | CSI 3 3 ~ + F20 | CSI 3 4 ~ + ---------+----------------- VT52-Style Function Keys @@ -1303,43 +1303,43 @@ A VT52 does not have function keys, but it does have a numeric keypad and cursor keys. They differ from the other emulations by the prefix. Also, the cursor keys do not change: - Key Normal/Application - ---------------------------------- - Cursor Up ESC A - Cursor Down ESC B - Cursor Right ESC C - Cursor Left ESC D - ---------------------------------- + Key Normal/Application + -------------+-------------------- + Cursor Up | ESC A + Cursor Down | ESC B + Cursor Right | ESC C + Cursor Left | ESC D + -------------+-------------------- The keypad is similar: - Key Numeric Application - -------------------------------------- - Space SP ESC ? SP - Tab TAB ESC ? I - Enter CR ESC ? M - PF1 ESC P ESC P - PF2 ESC Q ESC Q - PF3 ESC R ESC R - PF4 ESC S ESC S - * (multiply) * ESC ? j - + (add) + ESC ? k - , (comma) , ESC ? l - - (minus) - ESC ? m - . (period) . ESC ? n - / (divide) / ESC ? o - 0 0 ESC ? p - 1 1 ESC ? q - 2 2 ESC ? r - 3 3 ESC ? s - 4 4 ESC ? t - 5 5 ESC ? u - 6 6 ESC ? v - 7 7 ESC ? w - 8 8 ESC ? x - 9 9 ESC ? y - = (equal) = ESC ? X - -------------------------------------- + Key Numeric Application + -------------+----------+------------- + Space | SP | ESC ? SP + Tab | TAB | ESC ? I + Enter | CR | ESC ? M + PF1 | ESC P | ESC P + PF2 | ESC Q | ESC Q + PF3 | ESC R | ESC R + PF4 | ESC S | ESC S + * (multiply) | * | ESC ? j + + (add) | + | ESC ? k + , (comma) | , | ESC ? l + - (minus) | - | ESC ? m + . (period) | . | ESC ? n + / (divide) | / | ESC ? o + 0 | 0 | ESC ? p + 1 | 1 | ESC ? q + 2 | 2 | ESC ? r + 3 | 3 | ESC ? s + 4 | 4 | ESC ? t + 5 | 5 | ESC ? u + 6 | 6 | ESC ? v + 7 | 7 | ESC ? w + 8 | 8 | ESC ? x + 9 | 9 | ESC ? y + = (equal) | = | ESC ? X + -------------+----------+------------- Sun-Style Function Keys @@ -1460,6 +1460,7 @@ parameters in a single character as value+32. For example, ! specifies the value 1. The upper left character position on the terminal is denoted as 1,1. This scheme dates back to X10, though the normal mouse- tracking (from X11) is more elaborate. +X10 compatbility mode X10 compatibility mode sends an escape sequence only on button press, encoding the location and the mouse button pressed. It is enabled by @@ -1468,6 +1469,7 @@ CbCxCy (6 characters). o Cb is button-1. o Cx and Cy are the x and y coordinates of the mouse when the button was pressed. +Normal tracking mode Normal tracking mode sends an escape sequence on both button press and release. Modifier key (shift, ctrl, meta) information is also sent. It @@ -1484,6 +1486,7 @@ o The next three bits encode the modifiers which were down when the the mod1 mask, and is not necessarily the "Meta" key (see xmodmap). o Cx and Cy are the x and y coordinates of the mouse event, encoded as in X10 mode. +Wheel mice Wheel mice may return buttons 4 and 5. Those buttons are represented by the same event codes as buttons 1 and 2 respectively, except that 64 is @@ -1494,6 +1497,7 @@ window, as if the scrollbar was used. However if Alternate Scroll mode is set, then cursor up/down controls are sent when the terminal is dis- playing the alternate screen. The initial state of Alternate Scroll mode is set using the alternateScroll resource. +Highlight tracking Mouse highlight tracking notifies a program of a button press, receives a range of lines from the program, highlights the region covered by the @@ -1525,6 +1529,7 @@ o otherwise: character positions of the region. - mousex and mousey give the location of the mouse at button up, which may not be over a character. +Button-event tracking Button-event tracking is essentially the same as normal tracking, but xterm also reports button-motion events. Motion events are reported @@ -1539,14 +1544,17 @@ o The other bits of the event code specify button and modifier keys as (motion indicator) ). Similarly, motion with button 3 down is reported as CSI M B CxCy. ( B = 32 + 2 (button 3) + 32 (motion indicator) ). +Any-event tracking Any-event mode is the same as button-event mode, except that all motion events are reported, even if no mouse button is down. It is enabled by specifying 1003 to DECSET. +FocusIn/FocusOut FocusIn/FocusOut can be combined with any of the mouse events since it uses a different protocol. When set, it causes xterm to send CSI I when the terminal gains focus, and CSI O when it loses focus. +Extended coordinates The original X10 mouse protocol limits the Cx and Cy ordinates to 223 (=255 - 32). Xterm supports more than one scheme for extending this @@ -1573,12 +1581,14 @@ SGR (1006) semicolon-separated encoded button value, the Cx and Cy ordi- nates and a final character which is M for button press and m for button release. - The encoded button value in this case does not add 32 since - that was useful only in the X10 scheme for ensuring that the - byte containing the button value is a printable code. The - modifiers are encoded in the same way. A different final - character is used for button release to resolve the X10 ambi- - guity regarding which button was released. + o The encoded button value in this case does not add 32 + since that was useful only in the X10 scheme for ensuring + that the byte containing the button value is a printable + code. + o The modifiers are encoded in the same way. + o A different final character is used for button release to + resolve the X10 ambiguity regarding which button was + released. The highlight tracking responses are also modified to an SGR- like format, using the same SGR-style scheme and button-encod- ings. diff --git a/app/xterm/fontutils.c b/app/xterm/fontutils.c index 14984e83a..1fb3df97a 100644 --- a/app/xterm/fontutils.c +++ b/app/xterm/fontutils.c @@ -1,4 +1,4 @@ -/* $XTermId: fontutils.c,v 1.383 2012/09/22 00:15:55 tom Exp $ */ +/* $XTermId: fontutils.c,v 1.386 2012/12/31 20:51:54 tom Exp $ */ /* * Copyright 1998-2011,2012 by Thomas E. Dickey @@ -89,8 +89,6 @@ } \ } -#define MAX_FONTNAME 200 - /* * A structure to hold the relevant properties from a font * we need to make a well formed font name for it. @@ -243,9 +241,6 @@ check_fontname(const char *name) if (IsEmpty(name)) { TRACE(("fontname missing\n")); result = False; - } else if (strlen(name) >= MAX_FONTNAME - 1) { - TRACE(("fontname too large: %s\n", name)); - result = False; } return result; } @@ -258,7 +253,7 @@ check_fontname(const char *name) * or NULL on error. */ static FontNameProperties * -get_font_name_props(Display * dpy, XFontStruct * fs, char *result) +get_font_name_props(Display * dpy, XFontStruct * fs, char **result) { static FontNameProperties props; static char *last_name; @@ -294,7 +289,9 @@ get_font_name_props(Display * dpy, XFontStruct * fs, char *result) if (result != 0) { if (!check_fontname(name)) return 0; - strcpy(result, name); + if (*result != 0) + free(*result); + *result = x_strdup(name); } /* @@ -515,7 +512,8 @@ xtermSpecialFont(TScreen * screen, unsigned atts, unsigned chrset) old_props.res_x = res_x; old_props.res_x = res_y; old_props.pixel_size = pixel_size; - old_props.spacing = strcpy(old_spacing, props->spacing); + old_props.spacing = old_spacing; + sprintf(old_spacing, "%.*s", (int) sizeof(old_spacing) - 2, props->spacing); } #endif @@ -584,13 +582,14 @@ same_font_name(const char *pattern, const char *match) static int got_bold_font(Display * dpy, XFontStruct * fs, String requested) { - char actual[MAX_FONTNAME]; + char *actual = 0; int got; - if (get_font_name_props(dpy, fs, actual) == 0) + if (get_font_name_props(dpy, fs, &actual) == 0) got = 0; else got = same_font_name(requested, actual); + free(actual); return got; } @@ -876,7 +875,7 @@ xtermLoadFont(XtermWidget xw, Pixel new_normal; Pixel new_revers; char *tmpname = NULL; - char normal[MAX_FONTNAME]; + char *normal = NULL; Boolean proportional = False; fontWarningTypes warn[fMAX]; int j; @@ -945,10 +944,10 @@ xtermLoadFont(XtermWidget xw, goto bad; } - strcpy(normal, myfonts.f_n); + normal = x_strdup(myfonts.f_n); if (!check_fontname(myfonts.f_b)) { warn[fBold] = fwAlways; - fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal); + fp = get_font_name_props(screen->display, fnts[fNorm].fs, &normal); if (fp != 0) { myfonts.f_b = bold_font_name(fp, fp->average_width); if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], fwAlways, False)) { @@ -984,12 +983,12 @@ xtermLoadFont(XtermWidget xw, */ if_OPT_WIDE_CHARS(screen, { Boolean derived; - char bold[MAX_FONTNAME]; + char *bold = NULL; if (check_fontname(myfonts.f_w)) { cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w); } else if (screen->utf8_fonts && !is_double_width_font(fnts[fNorm].fs)) { - fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal); + fp = get_font_name_props(screen->display, fnts[fNorm].fs, &normal); if (fp != 0) { myfonts.f_w = wide_font_name(fp); warn[fWide] = fwAlways; @@ -1007,7 +1006,7 @@ xtermLoadFont(XtermWidget xw, derived = False; if (!check_fontname(myfonts.f_wb)) { - fp = get_font_name_props(screen->display, fnts[fBold].fs, bold); + fp = get_font_name_props(screen->display, fnts[fBold].fs, &bold); if (fp != 0) { myfonts.f_wb = widebold_font_name(fp); warn[fWBold] = fwAlways; @@ -1059,6 +1058,8 @@ xtermLoadFont(XtermWidget xw, TRACE(("...cannot load wide bold font, use wide %s\n", NonNull(myfonts.f_w))); } + free(bold); + if (EmptyFont(fnts[fWBold].fs)) goto bad; /* can't use a 0-sized font */ }); @@ -1251,12 +1252,16 @@ xtermLoadFont(XtermWidget xw, screen->menu_font_sizes[fontnum] = FontSize(fnts[fNorm].fs); #endif } + if (normal) + free(normal); set_cursor_gcs(xw); xtermUpdateFontInfo(xw, doresize); TRACE(("Success Cgs - xtermLoadFont\n")); return 1; bad: + if (normal) + free(normal); if (tmpname) free(tmpname); @@ -1537,9 +1542,9 @@ HandleLoadVTFonts(Widget w, char name_buf[80]; char class_buf[80]; String name = (String) ((*param_count > 0) ? params[0] : empty); - char *myName = (char *) MyStackAlloc(strlen(name), name_buf); + char *myName = (char *) MyStackAlloc(strlen(name) + 1, name_buf); String convert = (String) ((*param_count > 1) ? params[1] : myName); - char *myClass = (char *) MyStackAlloc(strlen(convert), class_buf); + char *myClass = (char *) MyStackAlloc(strlen(convert) + 1, class_buf); int n; TRACE(("HandleLoadVTFonts(%d)\n", *param_count)); diff --git a/app/xterm/input.c b/app/xterm/input.c index 60258b6a7..e506a9b6e 100644 --- a/app/xterm/input.c +++ b/app/xterm/input.c @@ -1,4 +1,4 @@ -/* $XTermId: input.c,v 1.344 2012/11/23 18:43:35 tom Exp $ */ +/* $XTermId: input.c,v 1.345 2013/02/06 09:51:33 tom Exp $ */ /* * Copyright 1999-2011,2012 by Thomas E. Dickey @@ -143,42 +143,6 @@ static void sunfuncvalue(ANSI *, KEY_DATA *); static void hpfuncvalue(ANSI *, KEY_DATA *); static void scofuncvalue(ANSI *, KEY_DATA *); -#if OPT_TRACE -static const char * -ModifierName(unsigned modifier) -{ - const char *s = ""; - if (modifier & ShiftMask) - s = " Shift"; - else if (modifier & LockMask) - s = " Lock"; - else if (modifier & ControlMask) - s = " Control"; - else if (modifier & Mod1Mask) - s = " Mod1"; - else if (modifier & Mod2Mask) - s = " Mod2"; - else if (modifier & Mod3Mask) - s = " Mod3"; - else if (modifier & Mod4Mask) - s = " Mod4"; - else if (modifier & Mod5Mask) - s = " Mod5"; - return s; -} - -#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s" -#define ARG_MODIFIER_NAMES(state) \ - ModifierName(state & ShiftMask), \ - ModifierName(state & LockMask), \ - ModifierName(state & ControlMask), \ - ModifierName(state & Mod1Mask), \ - ModifierName(state & Mod2Mask), \ - ModifierName(state & Mod3Mask), \ - ModifierName(state & Mod4Mask), \ - ModifierName(state & Mod5Mask) -#endif - static void AdjustAfterInput(XtermWidget xw) { diff --git a/app/xterm/koi8rxterm.man b/app/xterm/koi8rxterm.man index ad060b7b6..436752066 100644 --- a/app/xterm/koi8rxterm.man +++ b/app/xterm/koi8rxterm.man @@ -1,4 +1,4 @@ -.\" $XTermId: koi8rxterm.man,v 1.5 2012/10/23 23:27:24 tom Exp $ +.\" $XTermId: koi8rxterm.man,v 1.6 2013/01/01 00:43:18 tom Exp $ .\" .\" Copyright 2004 Branden Robinson .\" @@ -19,22 +19,33 @@ .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER .\" DEALINGS IN THE SOFTWARE. +.\" +.ds N Koi8rxterm +.ds n koi8rxterm +.\" +.ie \n(.g .ds AQ \(aq +.el .ds AQ ' +.ie \n(.g .ds `` \(lq +.el .ds `` `` +.ie \n(.g .ds '' \(rq +.el .ds '' '' +.\" .TH KOI8RXTERM 1 "__app_date__" "__app_version__" "X Window System" .SH NAME koi8rxterm \- X terminal emulator for KOI8-R environments .SH SYNOPSIS -.B koi8rxterm +.B \*n [ .I xterm-options ] .SH DESCRIPTION -.B koi8rxterm +.B \*n is a wrapper around the .BR xterm(1) -program that invokes the latter program with the \(oqKOI8R__default_class__\(cq X +program that invokes the latter program with the \*(``KOI8R__default_class__\*('' X resource class set. All arguments to -.B koi8rxterm +.B \*n are passed to .B xterm without processing; the @@ -47,9 +58,9 @@ See the manual page for more information on .IR xterm-options . .PP -The environment's locale settings (see \(lqENVIRONMENT\(rq below) are +The environment's locale settings (see \*(``ENVIRONMENT\*('' below) are used to discern the locale's character set. -If no current locale can be determined, the locale \(oqru_RU.KOI8-R\(cq +If no current locale can be determined, the locale \*(``ru_RU.KOI8-R\*('' (the Russian language as used in the territory of Russia, with the KOI8-R character set) is assumed. The @@ -57,20 +68,20 @@ The utility is used to determine whether the system supports the selected locale. If it does not, -.B koi8rxterm +.B \*n will exit with an error and report the output of .BR locale . .PP -.B Note: koi8rxterm +.B Note: \*n may produce unexpected results if the current locale is set to one in which the KOI8-R character encoding is not supported, or if fonts using that encoding are not available. -In the Debian system, the \(oqxfonts\-cyrillic\(cq package provides the +In the Debian system, the \*(``xfonts\-cyrillic\*('' package provides the fonts that -.B koi8rxterm +.B \*n uses by default. To change the fonts -.B koi8rxterm +.B \*n uses, edit the .I __apploaddir__/KOI8R__default_class__ file. @@ -84,7 +95,7 @@ is available for Unicode UTF-8 environments. The values of these variables are checked, in order, to determine the character set used by the current locale. .SH AUTHOR -.B koi8rxterm +.B \*n was written by Branden Robinson and is very heavily based on .BR uxterm , by Thomas Dickey. diff --git a/app/xterm/linedata.c b/app/xterm/linedata.c index ada5f76be..31a726a42 100644 --- a/app/xterm/linedata.c +++ b/app/xterm/linedata.c @@ -1,7 +1,7 @@ -/* $XTermId: linedata.c,v 1.81 2012/09/21 20:40:21 tom Exp $ */ +/* $XTermId: linedata.c,v 1.82 2013/02/08 00:11:16 tom Exp $ */ /* - * Copyright 2009-2010,2011 by Thomas E. Dickey + * Copyright 2009-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -31,7 +31,6 @@ */ #include <xterm.h> -#include <data.h> /* FIXME - needed for 'term' */ #include <assert.h> @@ -64,6 +63,7 @@ getLineData(TScreen * screen, int row) result = (LineData *) scrnHeadAddr(screen, buffer, (unsigned) row); if (result != 0) { #if 1 /* FIXME - these should be done in setupLineData, etc. */ + result->lineSize = (Dimension) MaxCols(screen); #if OPT_WIDE_CHARS if (screen->wide_chars) { result->combSize = (Char) screen->max_combining; diff --git a/app/xterm/main.c b/app/xterm/main.c index 1faf8deab..13c4594d0 100644 --- a/app/xterm/main.c +++ b/app/xterm/main.c @@ -1,7 +1,7 @@ -/* $XTermId: main.c,v 1.689 2012/11/19 10:33:33 tom Exp $ */ +/* $XTermId: main.c,v 1.716 2013/02/03 23:10:05 tom Exp $ */ /* - * Copyright 2002-2011,2012 by Thomas E. Dickey + * Copyright 2002-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -90,6 +90,7 @@ #define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) #include <xterm.h> +#include <version.h> #include <X11/cursorfont.h> #include <X11/Xlocale.h> @@ -445,7 +446,7 @@ extern char *ptsname(int); #endif #ifndef VMS -static SIGNAL_T reapchild(int /* n */ ); +static void reapchild(int /* n */ ); static int spawnXTerm(XtermWidget /* xw */ ); static void remove_termcap_entry(char *, const char *); #ifdef USE_PTY_SEARCH @@ -1534,9 +1535,10 @@ parseArg(int *num, char **argv, char **valuep) if (result != 0) { TRACE(("...result %s\n", result->option)); /* expand abbreviations */ - if (result->argKind != XrmoptionStickyArg - && strcmp(argv[*num], x_strdup(result->option))) { - argv[*num] = x_strdup(result->option); + if (result->argKind != XrmoptionStickyArg) { + if (strcmp(argv[*num], result->option)) { + argv[*num] = x_strdup(result->option); + } } /* adjust (*num) to skip option value */ @@ -1998,7 +2000,9 @@ main(int argc, char *argv[]ENVP_ARG) for (n = 1; n < argc; n++) { if ((option_ptr = parseArg(&n, argv, &option_value)) == 0) { - if (isOption(argv[n])) { + if (argv[n] == 0) { + break; + } else if (isOption(argv[n])) { Syntax(argv[n]); } else if (explicit_shname != 0) { xtermWarning("Explicit shell already was %s\n", explicit_shname); @@ -2178,7 +2182,7 @@ main(int argc, char *argv[]ENVP_ARG) my_class, optionDescList, XtNumber(optionDescList), - &argc, argv, + &argc, (String *) argv, fallback_resources, sessionShellWidgetClass, NULL, 0); @@ -2889,11 +2893,10 @@ static const char *vtterm[] = }; /* ARGSUSED */ -static SIGNAL_T +static void hungtty(int i GCC_UNUSED) { siglongjmp(env, 1); - SIGNAL_RETURN; } #if OPT_PTY_HANDSHAKE @@ -2983,7 +2986,7 @@ HsSysError(int error) handshake.status = PTY_FATALERROR; handshake.error = errno; handshake.fatal_error = error; - strcpy(handshake.buffer, ttydev); + strncpy(handshake.buffer, ttydev, sizeof(handshake.buffer)); if (resource.ptyHandshake && (cp_pipe[1] >= 0)) { TRACE(("HsSysError errno=%d, error=%d device \"%s\"\n", @@ -3101,18 +3104,26 @@ static struct UTMP_STR * find_utmp(struct UTMP_STR *tofind) { struct UTMP_STR *result; + struct UTMP_STR limited; struct UTMP_STR working; for (;;) { memset(&working, 0, sizeof(working)); working.ut_type = tofind->ut_type; - memcpy(working.ut_id, tofind->ut_id, sizeof(tofind->ut_id)); + strncpy(working.ut_id, tofind->ut_id, sizeof(tofind->ut_id)); #if defined(__digital__) && defined(__unix__) && (defined(OSMAJORVERSION) && OSMAJORVERSION < 5) working.ut_type = 0; #endif if ((result = call_getutid(&working)) == 0) break; - if (!strcmp(result->ut_line, tofind->ut_line)) + /* + * ut_line may not be null-terminated, but if it is, there may be + * garbage after the null. Use strncpy to ensure that the value + * we check is null-terminated (if there is enough space in the + * buffer), and that unused space is nulled. + */ + strncpy(limited.ut_line, result->ut_line, sizeof(result->ut_line)); + if (!memcmp(limited.ut_line, tofind->ut_line, sizeof(limited.ut_line))) break; /* * Solaris, IRIX64 and HPUX manpages say to fill the static area @@ -3181,6 +3192,7 @@ spawnXTerm(XtermWidget xw) #endif /* sony */ #endif /* TERMIO_STRUCT */ + char *shell_path = 0; char *ptr, *shname, *shname_minus; int i; #if USE_NO_DEV_TTY @@ -3447,7 +3459,7 @@ spawnXTerm(XtermWidget xw) if (get_termcap(xw, next)) { free(TermName); TermName = next; - ok_termcap = True; + ok_termcap = True + 1; break; } else { free(next); @@ -3743,7 +3755,7 @@ spawnXTerm(XtermWidget xw) /* let our master know that the open failed */ handshake.status = PTY_BAD; handshake.error = errno; - strcpy(handshake.buffer, ttydev); + strncpy(handshake.buffer, ttydev, sizeof(handshake.buffer)); TRACE_HANDSHAKE("writing", &handshake); IGNORE_RC(write(cp_pipe[1], (const char *) &handshake, @@ -3763,6 +3775,8 @@ spawnXTerm(XtermWidget xw) } /* We have a new pty to try */ + if (ttyfd >= 0) + close(ttyfd); free(ttydev); ttydev = x_strdup(handshake.buffer); } @@ -4175,9 +4189,10 @@ spawnXTerm(XtermWidget xw) if (!utret) TRACE(("getutid: NULL\n")); else - TRACE(("getutid: pid=%d type=%d user=%s line=%s id=%s\n", + TRACE(("getutid: pid=%d type=%d user=%s line=%.*s id=%.*s\n", (int) utret->ut_pid, utret->ut_type, utret->ut_user, - utret->ut_line, utret->ut_id)); + (int) sizeof(utret->ut_line), utret->ut_line, + (int) sizeof(utret->ut_id), utret->ut_id)); #endif /* set up the new entry */ @@ -4219,9 +4234,9 @@ spawnXTerm(XtermWidget xw) if (!resource.utmpInhibit) { errno = 0; call_pututline(&utmp); - TRACE(("pututline: id %s, line %s, pid %ld, errno %d %s\n", - utmp.ut_id, - utmp.ut_line, + TRACE(("pututline: id %.*s, line %.*s, pid %ld, errno %d %s\n", + (int) sizeof(utmp.ut_id), utmp.ut_id, + (int) sizeof(utmp.ut_line), utmp.ut_line, (long) utmp.ut_pid, errno, (errno != 0) ? strerror(errno) : "")); } @@ -4343,7 +4358,7 @@ spawnXTerm(XtermWidget xw) if (resource.ptyHandshake) { handshake.status = UTMP_ADDED; handshake.error = 0; - strcpy(handshake.buffer, ttydev); + strncpy(handshake.buffer, ttydev, sizeof(handshake.buffer)); TRACE_HANDSHAKE("writing", &handshake); IGNORE_RC(write(cp_pipe[1], (char *) &handshake, sizeof(handshake))); } @@ -4368,8 +4383,8 @@ spawnXTerm(XtermWidget xw) #if OPT_PTY_HANDSHAKE if (resource.ptyHandshake) { /* mark the pipes as close on exec */ - fcntl(cp_pipe[1], F_SETFD, 1); - fcntl(pc_pipe[0], F_SETFD, 1); + (void) fcntl(cp_pipe[1], F_SETFD, 1); + (void) fcntl(pc_pipe[0], F_SETFD, 1); /* We are at the point where we are going to * exec our shell (or whatever). Let our parent @@ -4377,7 +4392,7 @@ spawnXTerm(XtermWidget xw) */ handshake.status = PTY_GOOD; handshake.error = 0; - (void) strcpy(handshake.buffer, ttydev); + (void) strncpy(handshake.buffer, ttydev, sizeof(handshake.buffer)); TRACE_HANDSHAKE("writing", &handshake); IGNORE_RC(write(cp_pipe[1], (const char *) &handshake, @@ -4491,22 +4506,29 @@ spawnXTerm(XtermWidget xw) * Incidentally, our setting of $SHELL tells luit to use that * program rather than choosing between $SHELL and "/bin/sh". */ - if ((ptr = explicit_shname) == NULL) { - if ((ptr = x_getenv("SHELL")) == NULL) { + if ((shell_path = explicit_shname) == NULL) { + if ((shell_path = x_getenv("SHELL")) == NULL) { if ((!OkPasswd(&pw) && !x_getpwuid(screen->uid, &pw)) - || *(ptr = pw.pw_shell) == 0) { - ptr = x_strdup("/bin/sh"); - } else if (ptr != 0) { - xtermSetenv("SHELL", ptr); + || *(shell_path = x_strdup(pw.pw_shell)) == 0) { + if (shell_path) + free(shell_path); + shell_path = x_strdup("/bin/sh"); + } else if (shell_path != 0) { + xtermSetenv("SHELL", shell_path); } } } else { xtermSetenv("SHELL", explicit_shname); } - xtermSetenv("XTERM_SHELL", ptr); + if (access(shell_path, X_OK) != 0) { + xtermPerror("Cannot use '%s' as shell", shell_path); + free(shell_path); + shell_path = x_strdup("/bin/sh"); + } + xtermSetenv("XTERM_SHELL", shell_path); - shname = x_basename(ptr); - TRACE(("shell path '%s' leaf '%s'\n", ptr, shname)); + shname = x_basename(shell_path); + TRACE(("shell path '%s' leaf '%s'\n", shell_path, shname)); #if OPT_LUIT_PROG /* @@ -4515,8 +4537,9 @@ spawnXTerm(XtermWidget xw) * to command that the user gave anyway. */ if (command_to_exec_with_luit && command_to_exec) { - xtermSetenv("XTERM_SHELL", - xtermFindShell(*command_to_exec_with_luit, False)); + char *myShell = xtermFindShell(*command_to_exec_with_luit, False); + xtermSetenv("XTERM_SHELL", myShell); + free(myShell); TRACE_ARGV("spawning luit command", command_to_exec_with_luit); execvp(*command_to_exec_with_luit, command_to_exec_with_luit); xtermPerror("Can't execvp %s", *command_to_exec_with_luit); @@ -4524,12 +4547,14 @@ spawnXTerm(XtermWidget xw) } #endif if (command_to_exec) { - xtermSetenv("XTERM_SHELL", - xtermFindShell(*command_to_exec, False)); + char *myShell = xtermFindShell(*command_to_exec, False); + xtermSetenv("XTERM_SHELL", myShell); + free(myShell); TRACE_ARGV("spawning command", command_to_exec); execvp(*command_to_exec, command_to_exec); if (command_to_exec[1] == 0) - execlp(ptr, shname, "-c", command_to_exec[0], (void *) 0); + execlp(shell_path, shname, "-c", command_to_exec[0], + (void *) 0); xtermPerror("Can't execvp %s", *command_to_exec); } #ifdef USE_SYSV_SIGHUP @@ -4569,13 +4594,14 @@ spawnXTerm(XtermWidget xw) xtermPerror("Can't execvp %s", *command_to_exec_with_luit); } #endif - execlp(ptr, + execlp(shell_path, (xw->misc.login_shell ? shname_minus : shname), (void *) 0); /* Exec failed. */ - xtermPerror("Could not exec %s", ptr); + xtermPerror("Could not exec %s", shell_path); IGNORE_RC(sleep(5)); + free(shell_path); exit(ERROR_EXEC); } /* end if in child after fork */ @@ -4625,7 +4651,7 @@ spawnXTerm(XtermWidget xw) exit(ERROR_PTYS); } handshake.status = PTY_NEW; - (void) strcpy(handshake.buffer, ttydev); + (void) strncpy(handshake.buffer, ttydev, sizeof(handshake.buffer)); TRACE_HANDSHAKE("writing", &handshake); IGNORE_RC(write(pc_pipe[1], (const char *) &handshake, @@ -4717,11 +4743,15 @@ spawnXTerm(XtermWidget xw) signal(SIGTERM, Exit); signal(SIGPIPE, Exit); #endif /* USE_SYSV_SIGNALS and not SIGTSTP */ +#ifdef NO_LEAKS + if (ok_termcap != True) + free(TermName); +#endif return 0; } /* end spawnXTerm */ -SIGNAL_T +void Exit(int n) { XtermWidget xw = term; @@ -4738,8 +4768,9 @@ Exit(int n) struct UTMP_STR *utptr; /* don't do this more than once */ - if (xterm_exiting) - SIGNAL_RETURN; + if (xterm_exiting) { + exit(n); + } xterm_exiting = True; #ifdef PUCC_PTYD @@ -4871,32 +4902,31 @@ Exit(int n) #ifdef NO_LEAKS if (n == 0) { + Display *dpy = TScreenOf(xw)->display; + TRACE(("Freeing memory leaks\n")); - if (xw != 0) { - Display *dpy = TScreenOf(xw)->display; - if (toplevel) { - XtDestroyWidget(toplevel); - TRACE(("destroyed top-level widget\n")); - } - sortedOpts(0, 0, 0); - noleaks_charproc(); - noleaks_ptydata(); + if (toplevel) { + XtDestroyWidget(toplevel); + TRACE(("destroyed top-level widget\n")); + } + sortedOpts(0, 0, 0); + noleaks_charproc(); + noleaks_ptydata(); #if OPT_WIDE_CHARS - noleaks_CharacterClass(); + noleaks_CharacterClass(); #endif - /* XrmSetDatabase(dpy, 0); increases leaks ;-) */ - XtCloseDisplay(dpy); - XtDestroyApplicationContext(app_con); - xtermCloseSession(); - TRACE(("closed display\n")); - } + /* XrmSetDatabase(dpy, 0); increases leaks ;-) */ + XtCloseDisplay(dpy); + XtDestroyApplicationContext(app_con); + xtermCloseSession(); + TRACE(("closed display\n")); + TRACE_CLOSE(); } #endif exit(n); - SIGNAL_RETURN; } /* ARGSUSED */ @@ -4938,14 +4968,16 @@ resize_termcap(XtermWidget xw) ? MaxRows(screen) : MaxCols(screen))); temp += strlen(temp); - ptr1 = strchr(ptr1, ':'); - strncpy(temp, ptr1, i = (size_t) (ptr2 - ptr1)); - temp += i; - sprintf(temp, "%d", (li_first - ? MaxCols(screen) - : MaxRows(screen))); - ptr2 = strchr(ptr2, ':'); - strcat(temp, ptr2); + if ((ptr1 = strchr(ptr1, ':')) != 0 && (ptr1 < ptr2)) { + strncpy(temp, ptr1, i = (size_t) (ptr2 - ptr1)); + temp += i; + sprintf(temp, "%d", (li_first + ? MaxCols(screen) + : MaxRows(screen))); + if ((ptr2 = strchr(ptr2, ':')) != 0) { + strcat(temp, ptr2); + } + } TRACE((" ==> %s\n", newtc)); TRACE((" new size %dx%d\n", MaxRows(screen), MaxCols(screen))); } @@ -4985,7 +5017,7 @@ nonblocking_wait(void) #ifndef VMS /* ARGSUSED */ -static SIGNAL_T +static void reapchild(int n GCC_UNUSED) { int olderrno = errno; @@ -5012,7 +5044,6 @@ reapchild(int n GCC_UNUSED) } while ((pid = nonblocking_wait()) > 0); errno = olderrno; - SIGNAL_RETURN; } #endif /* !VMS */ diff --git a/app/xterm/menu.c b/app/xterm/menu.c index 118ec282b..308f37066 100644 --- a/app/xterm/menu.c +++ b/app/xterm/menu.c @@ -1,7 +1,7 @@ -/* $XTermId: menu.c,v 1.310 2012/09/22 14:53:45 tom Exp $ */ +/* $XTermId: menu.c,v 1.313 2013/02/03 21:53:58 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -842,7 +842,7 @@ domenu(Widget w, FindFontSelection(xw, NULL, True); SetItemSensitivity( fontMenuEntries[fontMenu_fontsel].widget, - (screen->menu_font_names[fontMenu_fontsel] + (screen->menu_font_names[fontMenu_fontsel][fNorm] ? True : False)); break; @@ -1639,6 +1639,7 @@ do_vtfont(Widget gw GCC_UNUSED, char *entryname = (char *) closure; int i; + TRACE(("do_vtfont(%s)\n", entryname)); for (i = 0; i < NMENUFONTS; i++) { if (strcmp(entryname, fontMenuEntries[i].name) == 0) { SetVTFont(xw, i, True, NULL); diff --git a/app/xterm/minstall.in b/app/xterm/minstall.in index 928520adc..7a76865e2 100644 --- a/app/xterm/minstall.in +++ b/app/xterm/minstall.in @@ -1,5 +1,5 @@ #!/bin/sh -# $XTermId: minstall.in,v 1.15 2012/10/29 09:23:22 tom Exp $ +# $XTermId: minstall.in,v 1.18 2013/01/01 01:18:24 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # @@ -42,7 +42,8 @@ # $4 = app-defaults directory # $5 = app-defaults class # $6 = application name, normally "xterm" -# $7 = pixmap directory +# $7 = application name transformed +# $8 = pixmap directory # # Other values correspond to definitions in xtermcfg.h, and cannot be directly # modified using "make". They are substituted directly into this script. @@ -72,7 +73,8 @@ END_FILE="$3" APPS_DIR="$4" APP_TYPE="$5" APP_name="$6" -XPMS_DIR="$7" +USE_name="$7" +XPMS_DIR="$8" suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'` NEW_FILE=temp$$ @@ -122,16 +124,25 @@ VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,versi PATCH_NUM=`fgrep XTERM_PATCH $VERSION_H|sed -e 's/[^0-9]*//g'` PATCH_YMD=`fgrep XTERM_DATE $VERSION_H|sed -e 's,[^0-9/.-]*,,g'` -# Provide for renaming in test-builds: -APP_Name=`echo "$APP_name" | sed -e s/xterm/Xterm/` +# Make capitalization variants +APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'` +APP_chr1=`echo "$APP_name" | sed -e 's/^.//'` +APP_Name=${APP_chr0}${APP_chr1} APP_NAME=`echo "$APP_name" | tr '[a-z]' '[A-Z]'` +# Provide for renaming in test-builds: +USE_chr0=`echo "$USE_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'` +USE_chr1=`echo "$USE_name" | sed -e 's/^.//'` +USE_Name=${USE_chr0}${USE_chr1} +USE_NAME=`echo "$USE_name" | tr '[a-z]' '[A-Z]'` + sed -e 's%__vendorversion__%"X Window System"%' \ -e 's%__app_version__%Patch\ \#'$PATCH_NUM% \ -e 's%__app_date__%'$PATCH_YMD% \ - -e "s%^\.TH [^ ][^ ]*%.TH $APP_NAME%" \ - -e "s%^\.ds N Xterm%.ds N $APP_Name%" \ - -e "s%^\.ds n xterm%.ds n $APP_name%" \ + -e "s%^\.TH [^ ][^ ]*%.TH $USE_NAME%" \ + -e "s%^\.ds N $APP_Name%.ds N $USE_Name%" \ + -e "s%^\.ds n $APP_name%.ds n $USE_name%" \ + -e 's%^'"$APP_name"' \\- %'"$USE_name"' \- %' \ -e s%__default_termname__%@default_TERM@% \ -e s%__default_termid__%@default_termid@% \ -e s%__alt_sends_esc__%@alt_sends_esc@% \ @@ -149,6 +160,7 @@ sed -e 's%__vendorversion__%"X Window System"%' \ -e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \ -e s%/etc/wtmp%$WTMP_PATH%g \ $OLD_FILE >$NEW_FILE +# diff -u $OLD_FILE $NEW_FILE echo "$MINSTALL $OLD_FILE $END_FILE" eval "$MINSTALL $NEW_FILE $END_FILE" diff --git a/app/xterm/misc.c b/app/xterm/misc.c index 84487ca1b..b44d58ec6 100644 --- a/app/xterm/misc.c +++ b/app/xterm/misc.c @@ -1,7 +1,7 @@ -/* $XTermId: misc.c,v 1.631 2012/11/25 16:05:51 tom Exp $ */ +/* $XTermId: misc.c,v 1.658 2013/02/03 23:18:38 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -126,6 +126,8 @@ static Boolean xtermAllocColor(XtermWidget, XColor *, const char *); static Cursor make_hidden_cursor(XtermWidget); +static char emptyString[] = ""; + #if OPT_EXEC_XTERM /* Like readlink(2), but returns a malloc()ed buffer, or NULL on error; adapted from libc docs */ @@ -551,7 +553,7 @@ xevents(void) XtInputMask input_mask; if (need_cleanup) - Cleanup(0); + NormalExit(); if (screen->scroll_amt) FlushScroll(xw); @@ -844,13 +846,12 @@ HandleSpawnTerminal(Widget w GCC_UNUSED, xtermWarning("exec of '%s': %s\n", child_exe, SysErrorMsg(errno)); } _exit(0); - } else { - /* We are the parent; clean up */ - if (child_cwd) - free(child_cwd); - if (child_exe) - free(child_exe); } + + /* We are the parent; clean up */ + if (child_cwd) + free(child_cwd); + free(child_exe); } #endif /* OPT_EXEC_XTERM */ @@ -1563,6 +1564,7 @@ RequestMaximize(XtermWidget xw, int maximize) success = True; } else if (screen->restore_data) { success = True; + maximize = 0; } if (success) { @@ -1764,7 +1766,7 @@ creat_as(uid_t uid, gid_t gid, Bool append, char *pathname, unsigned mode) int childstat = 0; #ifndef HAVE_WAITPID int waited; - SIGNAL_T(*chldfunc) (int); + void (*chldfunc) (int); chldfunc = signal(SIGCHLD, SIG_DFL); #endif /* HAVE_WAITPID */ @@ -1830,7 +1832,7 @@ creat_as(uid_t uid, gid_t gid, Bool append, char *pathname, unsigned mode) */ do if (waited == TScreenOf(term)->pid) - Cleanup(0); + NormalExit(); while ((waited = nonblocking_wait()) > 0) ; #endif /* HAVE_WAITPID */ #ifndef WIFEXITED @@ -1866,7 +1868,7 @@ xtermResetIds(TScreen * screen) */ #ifdef ALLOWLOGFILEEXEC -static SIGNAL_T +static void logpipe(int sig GCC_UNUSED) { XtermWidget xw = term; @@ -1945,8 +1947,34 @@ StartLog(XtermWidget xw) static char *shell; struct passwd pw; - if (pipe(p) < 0 || (pid = fork()) < 0) + if ((shell = x_getenv("SHELL")) == NULL) { + + if (x_getpwuid(screen->uid, &pw)) { + char *name = x_getlogin(screen->uid, &pw); + if (*(pw.pw_shell)) { + shell = pw.pw_shell; + } + free(name); + } + } + + if (shell == 0) { + static char dummy[] = "/bin/sh"; + shell = dummy; + } + + if (access(shell, X_OK) != 0) { + xtermPerror("Can't execute `%s'\n", shell); return; + } + + if (pipe(p) < 0) { + xtermPerror("Can't make a pipe connection\n"); + return; + } else if ((pid = fork()) < 0) { + xtermPerror("Can't fork...\n"); + return; + } if (pid == 0) { /* child */ /* * Close our output (we won't be talking back to the @@ -1963,21 +1991,6 @@ StartLog(XtermWidget xw) close(ConnectionNumber(screen->display)); close(screen->respond); - if ((shell = x_getenv("SHELL")) == NULL) { - - if (x_getpwuid(screen->uid, &pw)) { - x_getlogin(screen->uid, &pw); - if (*(pw.pw_shell)) { - shell = pw.pw_shell; - } - } - } - - if (shell == 0) { - static char dummy[] = "/bin/sh"; - shell = dummy; - } - signal(SIGHUP, SIG_DFL); signal(SIGCHLD, SIG_DFL); @@ -1985,9 +1998,12 @@ StartLog(XtermWidget xw) if (xtermResetIds(screen) < 0) exit(ERROR_SETUID); - execl(shell, shell, "-c", &screen->logfile[1], (void *) 0); - - xtermWarning("Can't exec `%s'\n", &screen->logfile[1]); + if (access(shell, X_OK) == 0) { + execl(shell, shell, "-c", &screen->logfile[1], (void *) 0); + xtermWarning("Can't exec `%s'\n", &screen->logfile[1]); + } else { + xtermWarning("Can't execute `%s'\n", shell); + } exit(ERROR_LOGEXEC); } close(p[0]); @@ -2701,9 +2717,9 @@ ManipulateSelectionData(XtermWidget xw, TScreen * screen, char *buf, int final) }; const char *base = buf; - char *used = x_strdup(base); + char *used; Cardinal j, n = 0; - String *select_args = 0; + String *select_args; TRACE(("Manipulate selection data\n")); @@ -2716,46 +2732,54 @@ ManipulateSelectionData(XtermWidget xw, TScreen * screen, char *buf, int final) if (*base == '\0') base = "s0"; - if ((select_args = TypeCallocN(String, 1 + strlen(base))) == 0) - return; - while (*base != '\0') { - for (j = 0; j < XtNumber(table); ++j) { - if (*base == table[j].given) { - used[n] = *base; - select_args[n++] = table[j].result; - TRACE(("atom[%d] %s\n", n, table[j].result)); - break; - } - } - ++base; - } - used[n] = 0; - if (!strcmp(buf, "?")) { - if (AllowWindowOps(xw, ewGetSelection)) { - TRACE(("Getting selection\n")); - unparseputc1(xw, ANSI_OSC); - unparseputs(xw, "52"); - unparseputc(xw, ';'); - - unparseputs(xw, used); - unparseputc(xw, ';'); - - /* Tell xtermGetSelection data is base64 encoded */ - screen->base64_paste = n; - screen->base64_final = final; - - /* terminator will be written in this call */ - xtermGetSelection((Widget) xw, (Time) 0, select_args, n, NULL); - } - } else { - if (AllowWindowOps(xw, ewSetSelection)) { - TRACE(("Setting selection with %s\n", buf)); - ClearSelectionBuffer(screen); - while (*buf != '\0') - AppendToSelectionBuffer(screen, CharOf(*buf++)); - CompleteSelection(xw, select_args, n); + if ((used = x_strdup(base)) != 0) { + if ((select_args = TypeCallocN(String, 2 + strlen(base))) != 0) { + while (*base != '\0') { + for (j = 0; j < XtNumber(table); ++j) { + if (*base == table[j].given) { + used[n] = *base; + select_args[n++] = table[j].result; + TRACE(("atom[%d] %s\n", n, table[j].result)); + break; + } + } + ++base; + } + used[n] = 0; + + if (!strcmp(buf, "?")) { + if (AllowWindowOps(xw, ewGetSelection)) { + TRACE(("Getting selection\n")); + unparseputc1(xw, ANSI_OSC); + unparseputs(xw, "52"); + unparseputc(xw, ';'); + + unparseputs(xw, used); + unparseputc(xw, ';'); + + /* Tell xtermGetSelection data is base64 encoded */ + screen->base64_paste = n; + screen->base64_final = final; + + /* terminator will be written in this call */ + xtermGetSelection((Widget) xw, + (Time) 0, + select_args, n, + NULL); + } + } else { + if (AllowWindowOps(xw, ewSetSelection)) { + TRACE(("Setting selection with %s\n", buf)); + ClearSelectionBuffer(screen); + while (*buf != '\0') + AppendToSelectionBuffer(screen, CharOf(*buf++)); + CompleteSelection(xw, select_args, n); + } + } + free(select_args); } + free(used); } } } @@ -3569,7 +3593,7 @@ parse_decudk(const char *cp) { while (*cp) { const char *base = cp; - char *str = CastMallocN(char, strlen(cp) + 1); + char *str = CastMallocN(char, strlen(cp) + 2); unsigned key = 0; int lo, hi; int len = 0; @@ -3584,6 +3608,7 @@ parse_decudk(const char *cp) } } if (len > 0 && key < MAX_UDK) { + str[len] = '\0'; if (user_keys[key].str != 0) free(user_keys[key].str); user_keys[key].str = str; @@ -3623,7 +3648,7 @@ parse_decdld(ANSI * params, const char *string) ? Pcmw : (Pcmw + 3))); int char_high = ((Pcmh == 0) - ? ((Pcmw >= 2 || Pcmw <= 4) + ? ((Pcmw >= 2 && Pcmw <= 4) ? 10 : 20) : Pcmh); @@ -3869,7 +3894,7 @@ do_dcs(XtermWidget xw, Char * dcsbuf, size_t dcslen) if (okay) { unparseputc1(xw, ANSI_DCS); - unparseputc(xw, okay ? '1' : '0'); + unparseputc(xw, '1'); unparseputc(xw, '$'); unparseputc(xw, 'r'); cp = reply; @@ -4538,7 +4563,6 @@ ChangeGroup(XtermWidget xw, const char *attribute, char *value) #if OPT_WIDE_CHARS static Char *converted; /* NO_LEAKS */ #endif - static char empty[1]; Arg args[1]; Boolean changed = True; @@ -4555,14 +4579,16 @@ ChangeGroup(XtermWidget xw, const char *attribute, char *value) return; if (value == 0) - value = empty; + value = emptyString; if (IsTitleMode(xw, tmSetBase16)) { const char *temp; char *test; value = x_decode_hex(value, &temp); - if (*temp != '\0') + if (*temp != '\0') { + free(value); return; + } for (test = value; *test != '\0'; ++test) { if (CharOf(*test) < 32) { *test = '\0'; @@ -4668,13 +4694,12 @@ ChangeGroup(XtermWidget xw, const char *attribute, char *value) } #endif } - - free(my_attr); - - if (IsTitleMode(xw, tmSetBase16)) - free(value); - } + if (IsTitleMode(xw, tmSetBase16)) { + free(value); + } + free(my_attr); + return; } @@ -4682,8 +4707,7 @@ void ChangeIconName(XtermWidget xw, char *name) { if (name == 0) { - static char dummy[] = ""; - name = dummy; + name = emptyString; } if (!showZIconBeep(xw, name)) ChangeGroup(xw, XtNiconName, name); @@ -4895,44 +4919,48 @@ SysError(int code) Cleanup(code); } -/* - * cleanup by sending SIGHUP to client processes - */ void -Cleanup(int code) +NormalExit(void) { static Bool cleaning; - TScreen *screen = TScreenOf(term); /* * Process "-hold" and session cleanup only for a normal exit. */ - if (code == 0) { - if (cleaning) { - hold_screen = 0; - return; - } - - cleaning = True; - need_cleanup = False; + if (cleaning) { + hold_screen = 0; + return; + } - TRACE(("Cleanup %d\n", code)); + cleaning = True; + need_cleanup = False; - if (hold_screen) { - hold_screen = 2; - while (hold_screen) { - xevents(); - Sleep(10); - } + if (hold_screen) { + hold_screen = 2; + while (hold_screen) { + xevents(); + Sleep(10); } + } #if OPT_SESSION_MGT - if (resource.sessionMgt) { - XtVaSetValues(toplevel, - XtNjoinSession, False, - (void *) 0); - } -#endif + if (resource.sessionMgt) { + XtVaSetValues(toplevel, + XtNjoinSession, False, + (void *) 0); } +#endif + Cleanup(0); +} + +/* + * cleanup by sending SIGHUP to client processes + */ +void +Cleanup(int code) +{ + TScreen *screen = TScreenOf(term); + + TRACE(("Cleanup %d\n", code)); if (screen->pid > 1) { (void) kill_process_group(screen->pid, SIGHUP); @@ -4947,10 +4975,12 @@ Cleanup(int code) char * xtermFindShell(char *leaf, Bool warning) { + char *s0; char *s; char *d; char *tmp; char *result = leaf; + Bool allocated = False; TRACE(("xtermFindShell(%s)\n", leaf)); @@ -4963,13 +4993,14 @@ xtermFindShell(char *leaf, Bool warning) if (getcwd(buffer, need) != 0) { sprintf(buffer + strlen(buffer), "/%s", result); result = buffer; + allocated = True; } else { free(buffer); } } } else if (*result != '\0' && strchr("+/-", *result) == 0) { /* find it in $PATH */ - if ((s = x_getenv("PATH")) != 0) { + if ((s = s0 = x_getenv("PATH")) != 0) { if ((tmp = TypeMallocN(char, strlen(leaf) + strlen(s) + 2)) != 0) { Bool found = False; while (*s != '\0') { @@ -4987,17 +5018,17 @@ xtermFindShell(char *leaf, Bool warning) && access(tmp, X_OK) == 0) { result = x_strdup(tmp); found = True; + allocated = True; } break; } - if (found) - break; } if (found) break; } free(tmp); } + free(s0); } } TRACE(("...xtermFindShell(%s)\n", result)); @@ -5006,8 +5037,13 @@ xtermFindShell(char *leaf, Bool warning) || access(result, X_OK) != 0) { if (warning) xtermWarning("No absolute path found for shell: %s\n", result); + if (allocated) + free(result); result = 0; } + /* be consistent, so that caller can always free the result */ + if (result != 0 && !allocated) + result = x_strdup(result); return result; } #endif /* VMS */ @@ -5468,7 +5504,9 @@ sortedOpts(OptionHelp * options, XrmOptionDescRec * descs, Cardinal numDescs) } else { code = 0; } - strcpy(temp, opt_array[j].desc); + sprintf(temp, "%.*s", + (int) sizeof(temp) - 2, + opt_array[j].desc); if (x_strindex(temp, "inhibit") != 0) code = -code; if (code != 0 @@ -5577,45 +5615,6 @@ xtermEnvUTF8(void) #endif /* OPT_WIDE_CHARS */ /* - * Returns the version-string used in the "-v' message as well as a few other - * places. It is derived (when possible) from the __vendorversion__ symbol - * that some newer imake configurations define. - */ -char * -xtermVersion(void) -{ - static char vendor_version[] = __vendorversion__; - static char *result; - - if (result == 0) { - char *vendor = vendor_version; - char first[BUFSIZ]; - char second[BUFSIZ]; - - result = CastMallocN(char, strlen(vendor) + 9); - if (result == 0) - result = vendor; - else { - /* some vendors leave trash in this string */ - for (;;) { - if (!strncmp(vendor, "Version ", (size_t) 8)) - vendor += 8; - else if (isspace(CharOf(*vendor))) - ++vendor; - else - break; - } - if (strlen(vendor) < BUFSIZ && - sscanf(vendor, "%[0-9.] %[A-Za-z_0-9.]", first, second) == 2) - sprintf(result, "%s %s(%d)", second, first, XTERM_PATCH); - else - sprintf(result, "%s(%d)", vendor, XTERM_PATCH); - } - } - return result; -} - -/* * Check if the current widget, or any parent, is the VT100 "xterm" widget. */ XtermWidget @@ -5643,7 +5642,7 @@ die_callback(Widget w GCC_UNUSED, XtPointer client_data GCC_UNUSED, XtPointer call_data GCC_UNUSED) { - Cleanup(0); + NormalExit(); } static void diff --git a/app/xterm/os2main.c b/app/xterm/os2main.c deleted file mode 100644 index 44b6f904c..000000000 --- a/app/xterm/os2main.c +++ /dev/null @@ -1,2230 +0,0 @@ -/* $XTermId: os2main.c,v 1.277 2012/10/14 18:55:18 tom Exp $ */ - -/* removed all foreign stuff to get the code more clear (hv) - * and did some rewrite for the obscure OS/2 environment - */ - -/*********************************************************** - -Copyright (c) 1987, 1988 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be used in -advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -/* os2main.c */ -#define INCL_DOSFILEMGR -#define INCL_DOSDEVIOCTL -#define INCL_DOSSEMAPHORES -#ifdef __INNOTEK_LIBC__ -#define INCL_DOSDEVICES -#endif -#define I_NEED_OS2_H -#include <os2.h> -#define XTERM_MAIN - -#define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) - -#include <xterm.h> - -#include <X11/cursorfont.h> -#ifdef I18N -#include <X11/Xlocale.h> -#endif - -#if OPT_TOOLBAR - -#if defined(HAVE_LIB_XAW) -#include <X11/Xaw/Form.h> -#elif defined(HAVE_LIB_XAW3D) -#include <X11/Xaw3d/Form.h> -#elif defined(HAVE_LIB_NEXTAW) -#include <X11/neXtaw/Form.h> -#elif defined(HAVE_LIB_XAWPLUS) -#include <X11/XawPlus/Form.h> -#endif - -#endif /* OPT_TOOLBAR */ - -#include <pwd.h> -#include <ctype.h> - -#include <data.h> -#include <error.h> -#include <menu.h> -#include <main.h> -#include <xstrings.h> -#include <xtermcap.h> -#include <xterm_io.h> - -#if OPT_WIDE_CHARS -#include <charclass.h> -#endif - -int -setpgrp(pid_t pid, gid_t pgid) -{ - return 0; -} - -int -chown(const char *fn, pid_t pid, gid_t gid) -{ - return 0; -} - -char * -ttyname(int fd) -{ - return "/dev/tty"; -} - -#include <sys/stat.h> -#include <sys/param.h> /* for NOFILE */ -#include <stdio.h> -#include <signal.h> - -static SIGNAL_T reapchild(int n); -static int spawnXTerm(XtermWidget /* xw */ ); -static void resize_termcap(XtermWidget xw); -static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode); - -static Bool added_utmp_entry = False; - -static uid_t save_ruid; -static gid_t save_rgid; - -/* -** Ordinarily it should be okay to omit the assignment in the following -** statement. Apparently the c89 compiler on AIX 4.1.3 has a bug, or does -** it? Without the assignment though the compiler will init command_to_exec -** to 0xffffffff instead of NULL; and subsequent usage, e.g. in spawnXTerm() to -** SEGV. -*/ -static char **command_to_exec = NULL; - -#if OPT_LUIT_PROG -static char **command_to_exec_with_luit = NULL; -#endif - -/* The following structures are initialized in main() in order -** to eliminate any assumptions about the internal order of their -** contents. -*/ -static struct termio d_tio; - -/* allow use of system default characters if defined and reasonable */ -#ifndef CEOF -#define CEOF CONTROL('D') -#endif -#ifndef CEOL -#define CEOL 0 -#endif -#ifndef CFLUSH -#define CFLUSH CONTROL('O') -#endif -#ifndef CLNEXT -#define CLNEXT CONTROL('V') -#endif -#ifndef CNUL -#define CNUL 0 -#endif -#ifndef CQUIT -#define CQUIT CONTROL('\\') -#endif -#ifndef CRPRNT -#define CRPRNT CONTROL('R') -#endif -#ifndef CSTART -#define CSTART CONTROL('Q') -#endif -#ifndef CSTOP -#define CSTOP CONTROL('S') -#endif -#ifndef CSUSP -#define CSUSP CONTROL('Z') -#endif -#ifndef CSWTCH -#define CSWTCH 0 -#endif -#ifndef CWERASE -#define CWERASE CONTROL('W') -#endif - -#define TERMIO_STRUCT struct termio - -/* - * SYSV has the termio.c_cc[V] and ltchars; BSD has tchars and ltchars; - * SVR4 has only termio.c_cc, but it includes everything from ltchars. - * POSIX termios has termios.c_cc, which is similar to SVR4. - */ -#define TTYMODE(name) { name, sizeof(name)-1, 0, 0 } -static Boolean override_tty_modes = False; -/* *INDENT-OFF* */ -static struct _xttymodes { - const char *name; - size_t len; - int set; - int value; -} ttymodelist[] = { - TTYMODE("intr"), /* tchars.t_intrc ; VINTR */ -#define XTTYMODE_intr 0 - TTYMODE("quit"), /* tchars.t_quitc ; VQUIT */ -#define XTTYMODE_quit 1 - TTYMODE("erase"), /* sgttyb.sg_erase ; VERASE */ -#define XTTYMODE_erase 2 - TTYMODE("kill"), /* sgttyb.sg_kill ; VKILL */ -#define XTTYMODE_kill 3 - TTYMODE("eof"), /* tchars.t_eofc ; VEOF */ -#define XTTYMODE_eof 4 - TTYMODE("eol"), /* VEOL */ -#define XTTYMODE_eol 5 - TTYMODE("swtch"), /* VSWTCH */ -#define XTTYMODE_swtch 6 - TTYMODE("start"), /* tchars.t_startc ; VSTART */ -#define XTTYMODE_start 7 - TTYMODE("stop"), /* tchars.t_stopc ; VSTOP */ -#define XTTYMODE_stop 8 - TTYMODE("brk"), /* tchars.t_brkc */ -#define XTTYMODE_brk 9 - TTYMODE("susp"), /* ltchars.t_suspc ; VSUSP */ -#define XTTYMODE_susp 10 - TTYMODE("dsusp"), /* ltchars.t_dsuspc ; VDSUSP */ -#define XTTYMODE_dsusp 11 - TTYMODE("rprnt"), /* ltchars.t_rprntc ; VREPRINT */ -#define XTTYMODE_rprnt 12 - TTYMODE("flush"), /* ltchars.t_flushc ; VDISCARD */ -#define XTTYMODE_flush 13 - TTYMODE("weras"), /* ltchars.t_werasc ; VWERASE */ -#define XTTYMODE_weras 14 - TTYMODE("lnext"), /* ltchars.t_lnextc ; VLNEXT */ -#define XTTYMODE_lnext 15 - { NULL, 0, 0, '\0' }, /* end of data */ -}; -/* *INDENT-ON* */ - -#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value - -static int parse_tty_modes(char *s, struct _xttymodes *modelist); - -static char passedPty[2]; /* name if pty if slave */ - -static int Console; -#include <X11/Xmu/SysUtil.h> /* XmuGetHostname */ -#define MIT_CONSOLE_LEN 12 -#define MIT_CONSOLE "MIT_CONSOLE_" -static char mit_console_name[255 + MIT_CONSOLE_LEN + 1] = MIT_CONSOLE; -static Atom mit_console; - -static int tslot; -static jmp_buf env; - -/* used by VT (charproc.c) */ - -static XtResource application_resources[] = -{ - Sres("iconGeometry", "IconGeometry", icon_geometry, NULL), - Sres(XtNtitle, XtCTitle, title, NULL), - Sres(XtNiconHint, XtCIconHint, icon_hint, NULL), - Sres(XtNiconName, XtCIconName, icon_name, NULL), - Sres("termName", "TermName", term_name, NULL), - Sres("ttyModes", "TtyModes", tty_modes, NULL), - Bres("hold", "Hold", hold_screen, False), - Bres("utmpInhibit", "UtmpInhibit", utmpInhibit, False), - Bres("utmpDisplayId", "UtmpDisplayId", utmpDisplayId, True), - Bres("messages", "Messages", messages, True), - Ires("minBufSize", "MinBufSize", minBufSize, 4096), - Ires("maxBufSize", "MaxBufSize", maxBufSize, 32768), - Sres("menuLocale", "MenuLocale", menuLocale, DEF_MENU_LOCALE), - Sres("omitTranslation", "OmitTranslation", omitTranslation, NULL), - Sres("keyboardType", "KeyboardType", keyboardType, "unknown"), -#if OPT_PRINT_ON_EXIT - Ires("printModeImmediate", "PrintModeImmediate", printModeNow, 0), - Ires("printOptsImmediate", "PrintOptsImmediate", printOptsNow, 9), - Sres("printFileImmediate", "PrintFileImmediate", printFileNow, NULL), - Ires("printModeOnXError", "PrintModeOnXError", printModeOnXError, 0), - Ires("printOptsOnXError", "PrintOptsOnXError", printOptsOnXError, 9), - Sres("printFileOnXError", "PrintFileOnXError", printFileOnXError, NULL), -#endif -#if OPT_SUNPC_KBD - Bres("sunKeyboard", "SunKeyboard", sunKeyboard, False), -#endif -#if OPT_HP_FUNC_KEYS - Bres("hpFunctionKeys", "HpFunctionKeys", hpFunctionKeys, False), -#endif -#if OPT_SCO_FUNC_KEYS - Bres("scoFunctionKeys", "ScoFunctionKeys", scoFunctionKeys, False), -#endif -#if OPT_SUN_FUNC_KEYS - Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False), -#endif -#if OPT_TCAP_FKEYS - Bres("tcapFunctionKeys", "TcapFunctionKeys", termcapKeys, False), -#endif -#if OPT_INITIAL_ERASE - Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE), - Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE), -#endif - Bres("useInsertMode", "UseInsertMode", useInsertMode, False), -#if OPT_ZICONBEEP - Ires("zIconBeep", "ZIconBeep", zIconBeep, 0), - Sres("zIconTitleFormat", "ZIconTitleFormat", zIconFormat, "*** %s"), -#endif -#if OPT_PTY_HANDSHAKE - Bres("waitForMap", "WaitForMap", wait_for_map, False), - Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True), - Bres("ptySttySize", "PtySttySize", ptySttySize, DEF_PTY_STTY_SIZE), -#endif -#if OPT_SAME_NAME - Bres("sameName", "SameName", sameName, True), -#endif -#if OPT_SESSION_MGT - Bres("sessionMgt", "SessionMgt", sessionMgt, True), -#endif -#if OPT_TOOLBAR - Bres(XtNtoolBar, XtCToolBar, toolBar, True), -#endif -#if OPT_MAXIMIZE - Bres(XtNmaximized, XtCMaximized, maximized, False), - Sres(XtNfullscreen, XtCFullscreen, fullscreen_s, "off"), -#endif -}; - -static String fallback_resources[] = -{ -#if OPT_TOOLBAR - "*toolBar: false", -#endif - "*SimpleMenu*menuLabel.vertSpace: 100", - "*SimpleMenu*HorizontalMargins: 16", - "*SimpleMenu*Sme.height: 16", - "*SimpleMenu*Cursor: left_ptr", - "*mainMenu.Label: Main Options (no app-defaults)", - "*vtMenu.Label: VT Options (no app-defaults)", - "*fontMenu.Label: VT Fonts (no app-defaults)", -#if OPT_TEK4014 - "*tekMenu.Label: Tek Options (no app-defaults)", -#endif - NULL -}; - -/* Command line options table. Only resources are entered here...there is a - pass over the remaining options after XrmParseCommand is let loose. */ -/* *INDENT-OFF* */ -static XrmOptionDescRec optionDescList[] = { -{"-geometry", "*vt100.geometry",XrmoptionSepArg, (XPointer) NULL}, -{"-132", "*c132", XrmoptionNoArg, (XPointer) "on"}, -{"+132", "*c132", XrmoptionNoArg, (XPointer) "off"}, -{"-ah", "*alwaysHighlight", XrmoptionNoArg, (XPointer) "on"}, -{"+ah", "*alwaysHighlight", XrmoptionNoArg, (XPointer) "off"}, -{"-aw", "*autoWrap", XrmoptionNoArg, (XPointer) "on"}, -{"+aw", "*autoWrap", XrmoptionNoArg, (XPointer) "off"}, -#ifndef NO_ACTIVE_ICON -{"-ai", "*activeIcon", XrmoptionNoArg, (XPointer) "off"}, -{"+ai", "*activeIcon", XrmoptionNoArg, (XPointer) "on"}, -#endif /* NO_ACTIVE_ICON */ -{"-b", "*internalBorder",XrmoptionSepArg, (XPointer) NULL}, -{"-bc", "*cursorBlink", XrmoptionNoArg, (XPointer) "on"}, -{"+bc", "*cursorBlink", XrmoptionNoArg, (XPointer) "off"}, -{"-bcf", "*cursorOffTime",XrmoptionSepArg, (XPointer) NULL}, -{"-bcn", "*cursorOnTime",XrmoptionSepArg, (XPointer) NULL}, -{"-bdc", "*colorBDMode", XrmoptionNoArg, (XPointer) "off"}, -{"+bdc", "*colorBDMode", XrmoptionNoArg, (XPointer) "on"}, -{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "off"}, -{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "on"}, -{"-cc", "*charClass", XrmoptionSepArg, (XPointer) NULL}, -{"-cm", "*colorMode", XrmoptionNoArg, (XPointer) "off"}, -{"+cm", "*colorMode", XrmoptionNoArg, (XPointer) "on"}, -{"-cn", "*cutNewline", XrmoptionNoArg, (XPointer) "off"}, -{"+cn", "*cutNewline", XrmoptionNoArg, (XPointer) "on"}, -{"-cr", "*cursorColor", XrmoptionSepArg, (XPointer) NULL}, -{"-cu", "*curses", XrmoptionNoArg, (XPointer) "on"}, -{"+cu", "*curses", XrmoptionNoArg, (XPointer) "off"}, -{"-dc", "*dynamicColors",XrmoptionNoArg, (XPointer) "off"}, -{"+dc", "*dynamicColors",XrmoptionNoArg, (XPointer) "on"}, -{"-fb", "*boldFont", XrmoptionSepArg, (XPointer) NULL}, -{"-fbb", "*freeBoldBox", XrmoptionNoArg, (XPointer)"off"}, -{"+fbb", "*freeBoldBox", XrmoptionNoArg, (XPointer)"on"}, -{"-fbx", "*forceBoxChars", XrmoptionNoArg, (XPointer)"off"}, -{"+fbx", "*forceBoxChars", XrmoptionNoArg, (XPointer)"on"}, -#ifndef NO_ACTIVE_ICON -{"-fi", "*iconFont", XrmoptionSepArg, (XPointer) NULL}, -#endif /* NO_ACTIVE_ICON */ -#if OPT_RENDERFONT -{"-fa", "*faceName", XrmoptionSepArg, (XPointer) NULL}, -{"-fd", "*faceNameDoublesize", XrmoptionSepArg, (XPointer) NULL}, -{"-fs", "*faceSize", XrmoptionSepArg, (XPointer) NULL}, -#endif -#if OPT_WIDE_CHARS -{"-fw", "*wideFont", XrmoptionSepArg, (XPointer) NULL}, -{"-fwb", "*wideBoldFont", XrmoptionSepArg, (XPointer) NULL}, -#endif -#if OPT_INPUT_METHOD -{"-fx", "*ximFont", XrmoptionSepArg, (XPointer) NULL}, -#endif -#if OPT_HIGHLIGHT_COLOR -{"-hc", "*highlightColor", XrmoptionSepArg, (XPointer) NULL}, -{"-hm", "*highlightColorMode", XrmoptionNoArg, (XPointer) "on"}, -{"+hm", "*highlightColorMode", XrmoptionNoArg, (XPointer) "off"}, -{"-selfg", "*highlightTextColor", XrmoptionSepArg, (XPointer) NULL}, -{"-selbg", "*highlightColor", XrmoptionSepArg, (XPointer) NULL}, -#endif -#if OPT_HP_FUNC_KEYS -{"-hf", "*hpFunctionKeys",XrmoptionNoArg, (XPointer) "on"}, -{"+hf", "*hpFunctionKeys",XrmoptionNoArg, (XPointer) "off"}, -#endif -{"-hold", "*hold", XrmoptionNoArg, (XPointer) "on"}, -{"+hold", "*hold", XrmoptionNoArg, (XPointer) "off"}, -#if OPT_INITIAL_ERASE -{"-ie", "*ptyInitialErase", XrmoptionNoArg, (XPointer) "on"}, -{"+ie", "*ptyInitialErase", XrmoptionNoArg, (XPointer) "off"}, -#endif -{"-j", "*jumpScroll", XrmoptionNoArg, (XPointer) "on"}, -{"+j", "*jumpScroll", XrmoptionNoArg, (XPointer) "off"}, -#if OPT_C1_PRINT -{"-k8", "*allowC1Printable", XrmoptionNoArg, (XPointer) "on"}, -{"+k8", "*allowC1Printable", XrmoptionNoArg, (XPointer) "off"}, -#endif -{"-kt", "*keyboardType", XrmoptionSepArg, (XPointer) NULL}, -/* parse logging options anyway for compatibility */ -{"-l", "*logging", XrmoptionNoArg, (XPointer) "on"}, -{"+l", "*logging", XrmoptionNoArg, (XPointer) "off"}, -{"-lf", "*logFile", XrmoptionSepArg, (XPointer) NULL}, -{"-ls", "*loginShell", XrmoptionNoArg, (XPointer) "on"}, -{"+ls", "*loginShell", XrmoptionNoArg, (XPointer) "off"}, -{"-mb", "*marginBell", XrmoptionNoArg, (XPointer) "on"}, -{"+mb", "*marginBell", XrmoptionNoArg, (XPointer) "off"}, -{"-mc", "*multiClickTime", XrmoptionSepArg, (XPointer) NULL}, -{"-mesg", "*messages", XrmoptionNoArg, (XPointer) "off"}, -{"+mesg", "*messages", XrmoptionNoArg, (XPointer) "on"}, -{"-ms", "*pointerColor",XrmoptionSepArg, (XPointer) NULL}, -{"-nb", "*nMarginBell", XrmoptionSepArg, (XPointer) NULL}, -{"-nul", "*underLine", XrmoptionNoArg, (XPointer) "off"}, -{"+nul", "*underLine", XrmoptionNoArg, (XPointer) "on"}, -{"-pc", "*boldColors", XrmoptionNoArg, (XPointer) "on"}, -{"+pc", "*boldColors", XrmoptionNoArg, (XPointer) "off"}, -{"-rw", "*reverseWrap", XrmoptionNoArg, (XPointer) "on"}, -{"+rw", "*reverseWrap", XrmoptionNoArg, (XPointer) "off"}, -{"-s", "*multiScroll", XrmoptionNoArg, (XPointer) "on"}, -{"+s", "*multiScroll", XrmoptionNoArg, (XPointer) "off"}, -{"-sb", "*scrollBar", XrmoptionNoArg, (XPointer) "on"}, -{"+sb", "*scrollBar", XrmoptionNoArg, (XPointer) "off"}, -#ifdef SCROLLBAR_RIGHT -{"-leftbar", "*rightScrollBar", XrmoptionNoArg, (XPointer) "off"}, -{"-rightbar", "*rightScrollBar", XrmoptionNoArg, (XPointer) "on"}, -#endif -{"-rvc", "*colorRVMode", XrmoptionNoArg, (XPointer) "off"}, -{"+rvc", "*colorRVMode", XrmoptionNoArg, (XPointer) "on"}, -{"-sf", "*sunFunctionKeys", XrmoptionNoArg, (XPointer) "on"}, -{"+sf", "*sunFunctionKeys", XrmoptionNoArg, (XPointer) "off"}, -{"-sh", "*scaleHeight", XrmoptionSepArg, (XPointer) NULL}, -{"-si", "*scrollTtyOutput", XrmoptionNoArg, (XPointer) "off"}, -{"+si", "*scrollTtyOutput", XrmoptionNoArg, (XPointer) "on"}, -{"-sk", "*scrollKey", XrmoptionNoArg, (XPointer) "on"}, -{"+sk", "*scrollKey", XrmoptionNoArg, (XPointer) "off"}, -{"-sl", "*saveLines", XrmoptionSepArg, (XPointer) NULL}, -#if OPT_SUNPC_KBD -{"-sp", "*sunKeyboard", XrmoptionNoArg, (XPointer) "on"}, -{"+sp", "*sunKeyboard", XrmoptionNoArg, (XPointer) "off"}, -#endif -#if OPT_TEK4014 -{"-t", "*tekStartup", XrmoptionNoArg, (XPointer) "on"}, -{"+t", "*tekStartup", XrmoptionNoArg, (XPointer) "off"}, -#endif -{"-ti", "*decTerminalID",XrmoptionSepArg, (XPointer) NULL}, -{"-tm", "*ttyModes", XrmoptionSepArg, (XPointer) NULL}, -{"-tn", "*termName", XrmoptionSepArg, (XPointer) NULL}, -#if OPT_WIDE_CHARS -{"-u8", "*utf8", XrmoptionNoArg, (XPointer) "2"}, -{"+u8", "*utf8", XrmoptionNoArg, (XPointer) "0"}, -#endif -#if OPT_LUIT_PROG -{"-lc", "*locale", XrmoptionNoArg, (XPointer) "on"}, -{"+lc", "*locale", XrmoptionNoArg, (XPointer) "off"}, -{"-lcc", "*localeFilter",XrmoptionSepArg, (XPointer) NULL}, -{"-en", "*locale", XrmoptionSepArg, (XPointer) NULL}, -#endif -{"-uc", "*cursorUnderLine", XrmoptionNoArg, (XPointer) "on"}, -{"+uc", "*cursorUnderLine", XrmoptionNoArg, (XPointer) "off"}, -{"-ulc", "*colorULMode", XrmoptionNoArg, (XPointer) "off"}, -{"+ulc", "*colorULMode", XrmoptionNoArg, (XPointer) "on"}, -{"-ulit", "*italicULMode", XrmoptionNoArg, (XPointer) "off"}, -{"+ulit", "*italicULMode", XrmoptionNoArg, (XPointer) "on"}, -{"-ut", "*utmpInhibit", XrmoptionNoArg, (XPointer) "on"}, -{"+ut", "*utmpInhibit", XrmoptionNoArg, (XPointer) "off"}, -{"-im", "*useInsertMode", XrmoptionNoArg, (XPointer) "on"}, -{"+im", "*useInsertMode", XrmoptionNoArg, (XPointer) "off"}, -{"-vb", "*visualBell", XrmoptionNoArg, (XPointer) "on"}, -{"+vb", "*visualBell", XrmoptionNoArg, (XPointer) "off"}, -{"-pob", "*popOnBell", XrmoptionNoArg, (XPointer) "on"}, -{"+pob", "*popOnBell", XrmoptionNoArg, (XPointer) "off"}, -#if OPT_WIDE_CHARS -{"-wc", "*wideChars", XrmoptionNoArg, (XPointer) "on"}, -{"+wc", "*wideChars", XrmoptionNoArg, (XPointer) "off"}, -{"-mk_width", "*mkWidth", XrmoptionNoArg, (XPointer) "on"}, -{"+mk_width", "*mkWidth", XrmoptionNoArg, (XPointer) "off"}, -{"-cjk_width", "*cjkWidth", XrmoptionNoArg, (XPointer) "on"}, -{"+cjk_width", "*cjkWidth", XrmoptionNoArg, (XPointer) "off"}, -#endif -{"-wf", "*waitForMap", XrmoptionNoArg, (XPointer) "on"}, -{"+wf", "*waitForMap", XrmoptionNoArg, (XPointer) "off"}, -#if OPT_ZICONBEEP -{"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (XPointer) NULL}, -#endif -#if OPT_SAME_NAME -{"-samename", "*sameName", XrmoptionNoArg, (XPointer) "on"}, -{"+samename", "*sameName", XrmoptionNoArg, (XPointer) "off"}, -#endif -#if OPT_SESSION_MGT -{"-sm", "*sessionMgt", XrmoptionNoArg, (XPointer) "on"}, -{"+sm", "*sessionMgt", XrmoptionNoArg, (XPointer) "off"}, -#endif -#if OPT_TOOLBAR -{"-tb", "*"XtNtoolBar, XrmoptionNoArg, (XPointer) "on"}, -{"+tb", "*"XtNtoolBar, XrmoptionNoArg, (XPointer) "off"}, -#endif -#if OPT_MAXIMIZE -{"-maximized", "*maximized", XrmoptionNoArg, (XPointer) "on"}, -{"+maximized", "*maximized", XrmoptionNoArg, (XPointer) "off"}, -{"-fullscreen", "*fullscreen", XrmoptionNoArg, (XPointer) "on"}, -{"+fullscreen", "*fullscreen", XrmoptionNoArg, (XPointer) "off"}, -#endif -/* options that we process ourselves */ -{"-help", NULL, XrmoptionSkipNArgs, (XPointer) NULL}, -{"-version", NULL, XrmoptionSkipNArgs, (XPointer) NULL}, -{"-class", NULL, XrmoptionSkipArg, (XPointer) NULL}, -{"-e", NULL, XrmoptionSkipLine, (XPointer) NULL}, -{"-into", NULL, XrmoptionSkipArg, (XPointer) NULL}, -/* bogus old compatibility stuff for which there are - standard XtOpenApplication options now */ -{"%", "*tekGeometry", XrmoptionStickyArg, (XPointer) NULL}, -{"#", ".iconGeometry",XrmoptionStickyArg, (XPointer) NULL}, -{"-T", ".title", XrmoptionSepArg, (XPointer) NULL}, -{"-n", "*iconName", XrmoptionSepArg, (XPointer) NULL}, -{"-r", "*reverseVideo",XrmoptionNoArg, (XPointer) "on"}, -{"+r", "*reverseVideo",XrmoptionNoArg, (XPointer) "off"}, -{"-rv", "*reverseVideo",XrmoptionNoArg, (XPointer) "on"}, -{"+rv", "*reverseVideo",XrmoptionNoArg, (XPointer) "off"}, -{"-w", ".borderWidth", XrmoptionSepArg, (XPointer) NULL}, -}; - -static OptionHelp xtermOptions[] = { -{ "-version", "print the version number" }, -{ "-help", "print out this message" }, -{ "-display displayname", "X server to contact" }, -{ "-geometry geom", "size (in characters) and position" }, -{ "-/+rv", "turn on/off reverse video" }, -{ "-bg color", "background color" }, -{ "-fg color", "foreground color" }, -{ "-bd color", "border color" }, -{ "-bw number", "border width in pixels" }, -{ "-fn fontname", "normal text font" }, -{ "-fb fontname", "bold text font" }, -{ "-/+fbb", "turn on/off normal/bold font comparison inhibit"}, -{ "-/+fbx", "turn off/on linedrawing characters"}, -#if OPT_RENDERFONT -{ "-fa pattern", "FreeType font-selection pattern" }, -{ "-fd pattern", "FreeType Doublesize font-selection pattern" }, -{ "-fs size", "FreeType font-size" }, -#endif -#if OPT_WIDE_CHARS -{ "-fw fontname", "doublewidth text font" }, -{ "-fwb fontname", "doublewidth bold text font" }, -#endif -#if OPT_INPUT_METHOD -{ "-fx fontname", "XIM fontset" }, -#endif -{ "-iconic", "start iconic" }, -{ "-name string", "client instance, icon, and title strings" }, -{ "-class string", "class string (XTerm)" }, -{ "-title string", "title string" }, -{ "-xrm resourcestring", "additional resource specifications" }, -{ "-/+132", "turn on/off 80/132 column switching" }, -{ "-/+ah", "turn on/off always highlight" }, -#ifndef NO_ACTIVE_ICON -{ "-/+ai", "turn off/on active icon" }, -{ "-fi fontname", "icon font for active icon" }, -#endif /* NO_ACTIVE_ICON */ -{ "-b number", "internal border in pixels" }, -{ "-/+bc", "turn on/off text cursor blinking" }, -{ "-bcf milliseconds", "time text cursor is off when blinking"}, -{ "-bcn milliseconds", "time text cursor is on when blinking"}, -{ "-/+bdc", "turn off/on display of bold as color"}, -{ "-/+cb", "turn on/off cut-to-beginning-of-line inhibit" }, -{ "-cc classrange", "specify additional character classes" }, -{ "-/+cm", "turn off/on ANSI color mode" }, -{ "-/+cn", "turn on/off cut newline inhibit" }, -{ "-cr color", "text cursor color" }, -{ "-/+cu", "turn on/off curses emulation" }, -{ "-/+dc", "turn off/on dynamic color selection" }, -#if OPT_HIGHLIGHT_COLOR -{ "-/+hm", "turn on/off selection-color override" }, -{ "-selbg color", "selection background color" }, -{ "-selfg color", "selection foreground color" }, -#endif -#if OPT_HP_FUNC_KEYS -{ "-/+hf", "turn on/off HP Function Key escape codes" }, -#endif -{ "-/+hold", "turn on/off logic that retains window after exit" }, -#if OPT_INITIAL_ERASE -{ "-/+ie", "turn on/off initialization of 'erase' from pty" }, -#endif -{ "-/+im", "use insert mode for TERMCAP" }, -{ "-/+j", "turn on/off jump scroll" }, -#if OPT_C1_PRINT -{ "-/+k8", "turn on/off C1-printable classification"}, -#endif -{ "-kt keyboardtype", "set keyboard type:" KEYBOARD_TYPES }, -#ifdef ALLOWLOGGING -{ "-/+l", "turn on/off logging" }, -{ "-lf filename", "logging filename" }, -#else -{ "-/+l", "turn on/off logging (not supported)" }, -{ "-lf filename", "logging filename (not supported)" }, -#endif -{ "-/+ls", "turn on/off login shell" }, -{ "-/+mb", "turn on/off margin bell" }, -{ "-mc milliseconds", "multiclick time in milliseconds" }, -{ "-/+mesg", "forbid/allow messages" }, -{ "-ms color", "pointer color" }, -{ "-nb number", "margin bell in characters from right end" }, -{ "-/+nul", "turn off/on display of underlining" }, -{ "-/+aw", "turn on/off auto wraparound" }, -{ "-/+pc", "turn on/off PC-style bold colors" }, -{ "-/+rw", "turn on/off reverse wraparound" }, -{ "-/+s", "turn on/off multiscroll" }, -{ "-/+sb", "turn on/off scrollbar" }, -#ifdef SCROLLBAR_RIGHT -{ "-rightbar", "force scrollbar right (default left)" }, -{ "-leftbar", "force scrollbar left" }, -#endif -{ "-/+rvc", "turn off/on display of reverse as color" }, -{ "-/+sf", "turn on/off Sun Function Key escape codes" }, -{ "-/+si", "turn on/off scroll-on-tty-output inhibit" }, -{ "-/+sk", "turn on/off scroll-on-keypress" }, -{ "-sl number", "number of scrolled lines to save" }, -#if OPT_SUNPC_KBD -{ "-/+sp", "turn on/off Sun/PC Function/Keypad mapping" }, -#endif -#if OPT_TEK4014 -{ "-/+t", "turn on/off Tek emulation window" }, -#endif -#if OPT_TOOLBAR -{ "-/+tb", "turn on/off toolbar" }, -#endif -{ "-ti termid", "terminal identifier" }, -{ "-tm string", "terminal mode keywords and characters" }, -{ "-tn name", "TERM environment variable name" }, -#if OPT_WIDE_CHARS -{ "-/+u8", "turn on/off UTF-8 mode (implies wide-characters)" }, -#endif -#if OPT_LUIT_PROG -{ "-/+lc", "turn on/off locale mode using luit" }, -{ "-lcc path", "filename of locale converter (" DEFLOCALEFILTER ")" }, -#endif -{ "-/+uc", "turn on/off underline cursor" }, -{ "-/+ulc", "turn off/on display of underline as color" }, -{ "-/+ulit", "turn off/on display of underline as italics" }, -{ "-/+ut", "turn on/off utmp inhibit (not supported)" }, -{ "-/+vb", "turn on/off visual bell" }, -{ "-/+pob", "turn on/off pop on bell" }, -#if OPT_WIDE_CHARS -{ "-/+wc", "turn on/off wide-character mode" }, -{ "-/+mk_width", "turn on/off simple width convention" }, -{ "-/+cjk_width", "turn on/off legacy CJK width convention" }, -#endif -{ "-/+wf", "turn on/off wait for map before command exec" }, -{ "-e command args ...", "command to execute" }, -#if OPT_TEK4014 -{ "%geom", "Tek window geometry" }, -#endif -{ "#geom", "icon window geometry" }, -{ "-T string", "title name for window" }, -{ "-n string", "icon name for window" }, -{ "-C", "intercept console messages" }, -{ "-Sccn", "slave mode on \"ttycc\", file descriptor \"n\"" }, -{ "-into windowId", "use the window id given to -into as the parent window rather than the default root window" }, -#if OPT_ZICONBEEP -{ "-ziconbeep percent", "beep and flag icon of window having hidden output" }, -#endif -#if OPT_SAME_NAME -{ "-/+samename", "turn on/off the no-flicker option for title and icon name" }, -#endif -#if OPT_SESSION_MGT -{ "-/+sm", "turn on/off the session-management support" }, -#endif -#if OPT_MAXIMIZE -{"-/+maximized", "turn on/off maxmize on startup" }, -{"-/+fullscreen", "turn on/off fullscreen on startup" }, -#endif -{ NULL, NULL }}; -/* *INDENT-ON* */ - -#ifdef DBG_CONSOLE -FILE *confd; - -static void -closecons(void) -{ - if (confs != 0) { - fclose(confd); - confd = 0; - } -} -static void -opencons(void) -{ - closecons(); - if ((confd = fopen("/dev/console$", "w")) < 0) { - fputs("!!! Cannot open console device.\n", - stderr); - exit(1); - } -} -#else -#define opencons() /* nothing */ -#define closecons() /* nothing */ -#endif - -static const char *message[] = -{ - "Fonts should be fixed width and, if both normal and bold are specified, should", - "have the same size. If only a normal font is specified, it will be used for", - "both normal and bold text (by doing overstriking). The -e option, if given,", - "must appear at the end of the command line, otherwise the user's default shell", - "will be started. Options that start with a plus sign (+) restore the default.", - NULL}; - -/* - * Decode a key-definition. This combines the termcap and ttyModes, for - * comparison. Note that octal escapes in ttyModes are done by the normal - * resource translation. Also, ttyModes allows '^-' as a synonym for disabled. - */ -static int -decode_keyvalue(char **ptr, int termcap) -{ - char *string = *ptr; - int value = -1; - - TRACE(("decode_keyvalue '%s'\n", string)); - if (*string == '^') { - switch (*++string) { - case '?': - value = A2E(ANSI_DEL); - break; - case '-': - if (!termcap) { - errno = 0; -#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H) - value = _POSIX_VDISABLE; -#endif -#if defined(_PC_VDISABLE) - if (value == -1) { - value = (int) fpathconf(0, _PC_VDISABLE); - if (value == -1) { - if (errno != 0) - break; /* skip this (error) */ - value = 0377; - } - } -#elif defined(VDISABLE) - if (value == -1) - value = VDISABLE; -#endif - break; - } - /* FALLTHRU */ - default: - value = CONTROL(*string); - break; - } - ++string; - } else if (termcap && (*string == '\\')) { - char *d; - int temp = (int) strtol(string + 1, &d, 8); - if (temp > 0 && d != string) { - value = temp; - string = d; - } - } else { - value = CharOf(*string); - ++string; - } - *ptr = string; - TRACE(("...decode_keyvalue %#x\n", value)); - return value; -} - -static int -abbrev(const char *tst, const char *cmp, size_t need) -{ - size_t len = strlen(tst); - return ((len >= need) && (!strncmp(tst, cmp, len))); -} - -static void -Syntax(char *badOption) -{ - OptionHelp *opt; - OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList)); - int col; - - xtermWarning("bad command line option \"%s\"\r\n\n", badOption); - - fprintf(stderr, "usage: %s", ProgramName); - col = 8 + (int) strlen(ProgramName); - for (opt = list; opt->opt; opt++) { - int len = 3 + (int) strlen(opt->opt); /* space [ string ] */ - if (col + len > 79) { - fprintf(stderr, "\r\n "); /* 3 spaces */ - col = 3; - } - fprintf(stderr, " [%s]", opt->opt); - col += len; - } - - fprintf(stderr, "\r\n\nType %s -help for a full description.\r\n\n", - ProgramName); - exit(1); -} - -static void -Version(void) -{ - printf("%s\n", xtermVersion()); - fflush(stdout); -} - -static void -Help(void) -{ - OptionHelp *opt; - OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList)); - const char **cpp; - - printf("%s usage:\n %s [-options ...] [-e command args]\n\n", - xtermVersion(), ProgramName); - printf("where options include:\n"); - for (opt = list; opt->opt; opt++) { - printf(" %-28s %s\n", opt->opt, opt->desc); - } - - putchar('\n'); - for (cpp = message; *cpp; cpp++) - puts(*cpp); - putchar('\n'); - fflush(stdout); -} - -/* ARGSUSED */ -static Boolean -ConvertConsoleSelection(Widget w GCC_UNUSED, - Atom * selection GCC_UNUSED, - Atom * target GCC_UNUSED, - Atom * type GCC_UNUSED, - XtPointer *value GCC_UNUSED, - unsigned long *length GCC_UNUSED, - int *format GCC_UNUSED) -{ - /* we don't save console output, so can't offer it */ - return False; -} - -#if OPT_SESSION_MGT -static void -die_callback(Widget w GCC_UNUSED, - XtPointer client_data GCC_UNUSED, - XtPointer call_data GCC_UNUSED) -{ - Cleanup(0); -} - -static void -save_callback(Widget w GCC_UNUSED, - XtPointer client_data GCC_UNUSED, - XtPointer call_data) -{ - XtCheckpointToken token = (XtCheckpointToken) call_data; - /* we have nothing to save */ - token->save_success = True; -} - -static void -icewatch(IceConn iceConn, - IcePointer clientData GCC_UNUSED, - Bool opening, - IcePointer * watchData GCC_UNUSED) -{ - if (opening) { - ice_fd = IceConnectionNumber(iceConn); - TRACE(("got IceConnectionNumber %d\n", ice_fd)); - } else { - ice_fd = -1; - TRACE(("reset IceConnectionNumber\n")); - } -} - -#endif /* OPT_SESSION_MGT */ - -/* - * DeleteWindow(): Action proc to implement ICCCM delete_window. - */ -/* ARGSUSED */ -static void -DeleteWindow(Widget w, - XEvent * event GCC_UNUSED, - String * params GCC_UNUSED, - Cardinal *num_params GCC_UNUSED) -{ -#if OPT_TEK4014 - if (w == toplevel) { - if (TEK4014_SHOWN(term)) - hide_vt_window(); - else - do_hangup(w, (XtPointer) 0, (XtPointer) 0); - } else if (TScreenOf(term)->Vshow) - hide_tek_window(); - else -#endif - do_hangup(w, (XtPointer) 0, (XtPointer) 0); -} - -/* ARGSUSED */ -static void -KeyboardMapping(Widget w GCC_UNUSED, - XEvent * event, - String * params GCC_UNUSED, - Cardinal *num_params GCC_UNUSED) -{ - switch (event->type) { - case MappingNotify: - XRefreshKeyboardMapping(&event->xmapping); - break; - } -} - -static XtActionsRec actionProcs[] = -{ - {"DeleteWindow", DeleteWindow}, - {"KeyboardMapping", KeyboardMapping}, -}; - -char **gblenvp; - -int -main(int argc, char **argv ENVP_ARG) -{ - Widget form_top, menu_top; - Dimension menu_high; - TScreen *screen; - int mode; - char *my_class = DEFCLASS; - Window winToEmbedInto = None; -#if OPT_COLOR_RES - Bool reversed = False; -#endif - - ProgramName = argv[0]; - - save_ruid = getuid(); - save_rgid = getgid(); - - /* Do these first, since we may not be able to open the display */ - TRACE_OPTS(xtermOptions, optionDescList, XtNumber(optionDescList)); - TRACE_ARGV("Before XtOpenApplication", argv); - if (argc > 1) { - int n; - size_t unique = 2; - Bool quit = False; - - for (n = 1; n < argc; n++) { - TRACE(("parsing %s\n", argv[n])); - if (abbrev(argv[n], "-version", unique)) { - Version(); - quit = True; - } else if (abbrev(argv[n], "-help", unique)) { - Help(); - quit = True; - } else if (abbrev(argv[n], "-class", (size_t) 3)) { - if ((my_class = argv[++n]) == 0) { - Help(); - quit = True; - } - } - } - if (quit) - exit(0); - } - - /* XXX: for some obscure reason EMX seems to lose the value of - * the environ variable, don't understand why, so save it recently - */ - gblenvp = envp; - -#ifdef I18N - setlocale(LC_ALL, NULL); -#endif - - opencons(); - - ttydev = TypeMallocN(char, PTMS_BUFSZ); - ptydev = TypeMallocN(char, PTMS_BUFSZ); - if (!ttydev || !ptydev) { - xtermWarning("unable to allocate memory for ttydev or ptydev\n"); - exit(1); - } - strcpy(ttydev, TTYDEV); - strcpy(ptydev, PTYDEV); - - /* Initialization is done here rather than above in order - * to prevent any assumptions about the order of the contents - * of the various terminal structures (which may change from - * implementation to implementation). - */ - d_tio.c_iflag = ICRNL | IXON; - d_tio.c_oflag = OPOST | ONLCR | TAB3; - d_tio.c_cflag = B38400 | CS8 | CREAD | PARENB | HUPCL; - d_tio.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK; - d_tio.c_line = 0; - d_tio.c_cc[VINTR] = CONTROL('C'); /* '^C' */ - d_tio.c_cc[VERASE] = ANSI_DEL; /* DEL */ - d_tio.c_cc[VKILL] = CONTROL('U'); /* '^U' */ - d_tio.c_cc[VQUIT] = CQUIT; /* '^\' */ - d_tio.c_cc[VEOF] = CEOF; /* '^D' */ - d_tio.c_cc[VEOL] = CEOL; /* '^@' */ - - XtSetErrorHandler(xt_error); -#if OPT_SESSION_MGT - toplevel = XtOpenApplication(&app_con, my_class, - optionDescList, - XtNumber(optionDescList), - &argc, argv, fallback_resources, - sessionShellWidgetClass, - NULL, 0); - IceAddConnectionWatch(icewatch, NULL); -#else - toplevel = XtAppInitialize(&app_con, my_class, - optionDescList, - XtNumber(optionDescList), - &argc, argv, fallback_resources, - NULL, 0); -#endif /* OPT_SESSION_MGT */ - XtSetErrorHandler((XtErrorHandler) 0); - - XtGetApplicationResources(toplevel, (XtPointer) &resource, - application_resources, - XtNumber(application_resources), NULL, 0); - TRACE_XRES(); -#if OPT_MAXIMIZE - resource.fullscreen = extendedBoolean(resource.fullscreen_s, - tblFullscreen, - XtNumber(tblFullscreen)); -#endif - - /* - * ICCCM delete_window. - */ - XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs)); - - /* - * fill in terminal modes - */ - if (resource.tty_modes) { - int n = parse_tty_modes(resource.tty_modes, ttymodelist); - if (n < 0) { - xtermWarning("bad tty modes \"%s\"\n", resource.tty_modes); - } else if (n > 0) { - override_tty_modes = True; - } - } - initZIconBeep(); - hold_screen = resource.hold_screen ? 1 : 0; - if (resource.icon_geometry != NULL) { - int scr, junk; - int ix, iy; - Arg args[2]; - - for (scr = 0; /* yyuucchh */ - XtScreen(toplevel) != ScreenOfDisplay(XtDisplay(toplevel), scr); - scr++) ; - - args[0].name = XtNiconX; - args[1].name = XtNiconY; - XGeometry(XtDisplay(toplevel), scr, resource.icon_geometry, "", - 0, 0, 0, 0, 0, &ix, &iy, &junk, &junk); - args[0].value = (XtArgVal) ix; - args[1].value = (XtArgVal) iy; - XtSetValues(toplevel, args, 2); - } - - XtSetValues(toplevel, ourTopLevelShellArgs, - number_ourTopLevelShellArgs); - -#if OPT_WIDE_CHARS - /* seems as good a place as any */ - init_classtab(); -#endif - - /* Parse the rest of the command line */ - TRACE_ARGV("After XtOpenApplication", argv); - for (argc--, argv++; argc > 0; argc--, argv++) { - if (**argv != '-') - Syntax(*argv); - - TRACE(("parsing %s\n", argv[0])); - switch (argv[0][1]) { - case 'h': /* -help */ - Help(); - exit(0); - case 'v': /* -version */ - Version(); - exit(0); - case 'C': - { - struct stat sbuf; - - /* Must be owner and have read/write permission. - xdm cooperates to give the console the right user. */ - if (!stat("/dev/console", &sbuf) && - (sbuf.st_uid == save_ruid) && - !access("/dev/console", R_OK | W_OK)) { - Console = True; - } else - Console = False; - } - continue; - case 'S': - if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty + 1, - &am_slave) != 3) - Syntax(*argv); - continue; -#ifdef DEBUG - case 'D': - debug = True; - continue; -#endif /* DEBUG */ - case 'c': /* -class param */ - if (strcmp(argv[0] + 1, "class") == 0) - argc--, argv++; - else - Syntax(*argv); - continue; - case 'e': - if (argc <= 1) - Syntax(*argv); - command_to_exec = ++argv; - break; - case 'i': - if (argc <= 1) { - Syntax(*argv); - } else { - char *endPtr; - --argc; - ++argv; - winToEmbedInto = (Window) strtol(argv[0], &endPtr, 10); - } - continue; - - default: - Syntax(*argv); - } - break; - } - - SetupMenus(toplevel, &form_top, &menu_top, &menu_high); - - term = (XtermWidget) XtVaCreateManagedWidget("vt100", xtermWidgetClass, - form_top, -#if OPT_TOOLBAR - XtNmenuBar, menu_top, - XtNresizable, True, - XtNfromVert, menu_top, - XtNleft, XawChainLeft, - XtNright, XawChainRight, - XtNtop, XawChainTop, - XtNbottom, XawChainBottom, - XtNmenuHeight, menu_high, -#endif - (XtPointer) 0); - decode_keyboard_type(term, &resource); - - screen = TScreenOf(term); - screen->inhibit = 0; - -#ifdef ALLOWLOGGING - if (term->misc.logInhibit) - screen->inhibit |= I_LOG; -#endif - if (term->misc.signalInhibit) - screen->inhibit |= I_SIGNAL; -#if OPT_TEK4014 - if (term->misc.tekInhibit) - screen->inhibit |= I_TEK; -#endif - - /* - * We might start by showing the tek4014 window. - */ -#if OPT_TEK4014 - if (screen->inhibit & I_TEK) - TEK4014_ACTIVE(term) = False; - - if (TEK4014_ACTIVE(term) && !TekInit()) - SysError(ERROR_INIT); -#endif - - /* - * Start the toolbar at this point, after the first window has been setup. - */ -#if OPT_TOOLBAR - ShowToolbar(resource.toolBar); -#endif - -#if OPT_SESSION_MGT - if (resource.sessionMgt) { - TRACE(("Enabling session-management callbacks\n")); - XtAddCallback(toplevel, XtNdieCallback, die_callback, NULL); - XtAddCallback(toplevel, XtNsaveCallback, save_callback, NULL); - } -#endif - - /* - * Set title and icon name if not specified - */ - if (command_to_exec) { - Arg args[2]; - - if (!resource.title) { - if (command_to_exec) { - resource.title = x_basename(command_to_exec[0]); - } /* else not reached */ - } - - if (!resource.icon_name) - resource.icon_name = resource.title; - XtSetArg(args[0], XtNtitle, resource.title); - XtSetArg(args[1], XtNiconName, resource.icon_name); - - TRACE(("setting:\n\ttitle \"%s\"\n\ticon \"%s\"\n\thint \"%s\"\n\tbased on command \"%s\"\n", - resource.title, - resource.icon_name, - NonNull(resource.icon_hint), - *command_to_exec)); - - XtSetValues(toplevel, args, 2); - } -#if OPT_LUIT_PROG - if (term->misc.callfilter) { - int u = (term->misc.use_encoding ? 2 : 0); - if (command_to_exec) { - int n; - char **c; - for (n = 0, c = command_to_exec; *c; n++, c++) ; - c = TypeMallocN(char *, (unsigned) (n + 3 + u)); - if (c == NULL) - SysError(ERROR_LUMALLOC); - memcpy(c + 2 + u, command_to_exec, (unsigned) (n + 1) * sizeof(char *)); - c[0] = term->misc.localefilter; - if (u) { - c[1] = "-encoding"; - c[2] = term->misc.locale_str; - } - c[1 + u] = "--"; - command_to_exec_with_luit = c; - } else { - static char *luit[6]; - luit[0] = term->misc.localefilter; - if (u) { - luit[1] = "-encoding"; - luit[2] = term->misc.locale_str; - luit[3] = NULL; - } else - luit[1] = NULL; - command_to_exec_with_luit = luit; - } - } -#endif - -#ifdef DEBUG - { - /* Set up stderr properly. Opening this log file cannot be - done securely by a privileged xterm process (although we try), - so the debug feature is disabled by default. */ - char dbglogfile[TIMESTAMP_LEN + 20]; - int i = -1; - if (debug) { - timestamp_filename(dbglogfile, "xterm.debug.log."); - if (creat_as(save_ruid, save_rgid, False, dbglogfile, 0600) > 0) { - i = open(dbglogfile, O_WRONLY | O_TRUNC); - } - } - if (i >= 0) { - dup2(i, 2); - - /* mark this file as close on exec */ - (void) fcntl(i, F_SETFD, 1); - } - } -#endif /* DEBUG */ - - spawnXTerm(term); - - /* Child process is out there, let's catch its termination */ - (void) signal(SIGCHLD, reapchild); - - /* Realize procs have now been executed */ - - if (am_slave >= 0) { /* Write window id so master end can read and use */ - char buf[80]; - - buf[0] = '\0'; - sprintf(buf, "%lx\n", XtWindow(SHELL_OF(CURRENT_EMU()))); - IGNORE_RC(write(screen->respond, buf, strlen(buf))); - } - - if (0 > (mode = fcntl(screen->respond, F_GETFL, 0))) - SysError(ERROR_F_GETFL); - mode |= O_NDELAY; - - if (fcntl(screen->respond, F_SETFL, mode)) - SysError(ERROR_F_SETFL); - - FD_ZERO(&pty_mask); - FD_ZERO(&X_mask); - FD_ZERO(&Select_mask); - FD_SET(screen->respond, &pty_mask); - FD_SET(ConnectionNumber(screen->display), &X_mask); - FD_SET(screen->respond, &Select_mask); - FD_SET(ConnectionNumber(screen->display), &Select_mask); - max_plus1 = ((screen->respond < ConnectionNumber(screen->display)) - ? (1 + ConnectionNumber(screen->display)) - : (1 + screen->respond)); - -#ifdef DEBUG - if (debug) - printf("debugging on\n"); -#endif /* DEBUG */ - XSetErrorHandler(xerror); - XSetIOErrorHandler(xioerror); - - initPtyData(&VTbuffer); -#ifdef ALLOWLOGGING - if (term->misc.log_on) { - StartLog(term); - } -#endif - - TRACE(("checking winToEmbedInto %#lx\n", winToEmbedInto)); - if (winToEmbedInto != None) { - XtRealizeWidget(toplevel); - /* - * This should probably query the tree or check the attributes of - * winToEmbedInto in order to verify that it exists, but I'm still not - * certain what is the best way to do it -GPS - */ - TRACE(("...reparenting toplevel %#lx into %#lx\n", - XtWindow(toplevel), - winToEmbedInto)); - XReparentWindow(XtDisplay(toplevel), - XtWindow(toplevel), - winToEmbedInto, 0, 0); - } -#if OPT_COLOR_RES - TRACE(("checking reverseVideo before rv %s fg %s, bg %s\n", - term->misc.re_verse0 ? "reverse" : "normal", - NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource), - NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource))); - - if (term->misc.re_verse0) { - if (isDefaultForeground(TScreenOf(term)->Tcolors[TEXT_FG].resource) - && isDefaultBackground(TScreenOf(term)->Tcolors[TEXT_BG].resource)) { - TScreenOf(term)->Tcolors[TEXT_FG].resource = x_strdup(XtDefaultBackground); - TScreenOf(term)->Tcolors[TEXT_BG].resource = x_strdup(XtDefaultForeground); - } else { - ReverseVideo(term); - } - term->misc.re_verse = True; - update_reversevideo(); - TRACE(("updated reverseVideo after rv %s fg %s, bg %s\n", - term->misc.re_verse ? "reverse" : "normal", - NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource), - NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource))); - } -#endif /* OPT_COLOR_RES */ - -#if OPT_MAXIMIZE - if (resource.maximized) - RequestMaximize(term, True); -#endif - for (;;) { -#if OPT_TEK4014 - if (TEK4014_ACTIVE(term)) - TekRun(); - else -#endif - VTRun(term); - } - return 0; -} - -/* - * Called from get_pty to iterate over likely pseudo terminals - * we might allocate. Used on those systems that do not have - * a functional interface for allocating a pty. - * Returns 0 if found a pty, 1 if fails. - */ -static int -pty_search(int *pty) -{ - char namebuf[PTMS_BUFSZ]; - - /* ask the PTY manager */ - int fd = open("/dev/ptms$", 0); - if (fd && ptioctl(fd, PTMS_GETPTY, namebuf) == 0) { - strcpy(ttydev, namebuf); - strcpy(ptydev, namebuf); - *x_basename(ttydev) = 't'; - close(fd); - if ((*pty = open(ptydev, O_RDWR)) >= 0) { -#ifdef PTYDEBUG - ptioctl(*pty, XTY_TRACE, 0); -#endif - return 0; - } else { - xtermWarning("Unable to open %s, errno=%d\n", ptydev, errno); - } - } - return 1; -} - -/* - * This function opens up a pty master and stuffs its value into pty. - * - * If it finds one, it returns a value of 0. If it does not find one, - * it returns a value of !0. This routine is designed to be re-entrant, - * so that if a pty master is found and later, we find that the slave - * has problems, we can re-enter this function and get another one. - */ -static int -get_pty(int *pty) -{ - return pty_search(pty); -} - -/* - * The only difference in /etc/termcap between 4014 and 4015 is that - * the latter has support for switching character sets. We support the - * 4015 protocol, but ignore the character switches. Therefore, we - * choose 4014 over 4015. - * - * Features of the 4014 over the 4012: larger (19") screen, 12-bit - * graphics addressing (compatible with 4012 10-bit addressing), - * special point plot mode, incremental plot mode (not implemented in - * later Tektronix terminals), and 4 character sizes. - * All of these are supported by xterm. - */ - -#if OPT_TEK4014 -static char *tekterm[] = -{ - "tek4014", - "tek4015", /* 4014 with APL character set support */ - "tek4012", /* 4010 with lower case */ - "tek4013", /* 4012 with APL character set support */ - "tek4010", /* small screen, upper-case only */ - "dumb", - 0 -}; -#endif - -/* The VT102 is a VT100 with the Advanced Video Option included standard. - * It also adds Escape sequences for insert/delete character/line. - * The VT220 adds 8-bit character sets, selective erase. - * The VT320 adds a 25th status line, terminal state interrogation. - * The VT420 has up to 48 lines on the screen. - */ - -static const char *vtterm[] = -{ -#ifdef USE_X11TERM - "x11term", /* for people who want special term name */ -#endif - DFT_TERMTYPE, /* for people who want special term name */ - "xterm", /* the prefered name, should be fastest */ - "vt102", - "vt100", - "ansi", - "dumb", - 0 -}; - -/* ARGSUSED */ -static SIGNAL_T -hungtty(int i GCC_UNUSED) -{ - longjmp(env, 1); - SIGNAL_RETURN; -} - -#if OPT_PTY_HANDSHAKE -struct { - int rows; - int cols; -} handshake = { - - -1, -1 -}; - -void -first_map_occurred(void) -{ - if (resource.wait_for_map) { - TScreen *screen = TScreenOf(term); - handshake.rows = screen->max_row; - handshake.cols = screen->max_col; - resource.wait_for_map = False; - } -} -#endif /* OPT_PTY_HANDSHAKE else !OPT_PTY_HANDSHAKE */ - -static void -set_owner(char *device, uid_t uid, gid_t gid, mode_t mode) -{ - int why; - - if (chown(device, uid, gid) < 0) { - why = errno; - if (why != ENOENT - && save_ruid == 0) { - xtermPerror("Cannot chown %s to %ld,%ld", - device, (long) uid, (long) gid); - } - } -} - -#define THE_PARENT 1 -#define THE_CHILD 2 -int whoami = -1; - -SIGNAL_T -killit(int sig) -{ - switch (whoami) { - case -1: - signal(sig, killit); - kill(-getpid(), sig); - break; - case THE_PARENT: - wait(NULL); - signal(SIGTERM, SIG_DFL); - kill(-getpid(), SIGTERM); - Exit(0); - break; - case THE_CHILD: - signal(SIGTERM, SIG_DFL); - kill(-getppid(), SIGTERM); - Exit(0); - break; - } - - SIGNAL_RETURN; -} - -#define close_fd(fd) close(fd), fd = -1 - -static int -spawnXTerm(XtermWidget xw) -/* - * Inits pty and tty and forks a login process. - * Does not close fd Xsocket. - * If slave, the pty named in passedPty is already open for use - */ -{ - TScreen *screen = TScreenOf(xw); - int Xsocket = ConnectionNumber(screen->display); - - int ttyfd = -1; - TERMIO_STRUCT tio; - int status; - Bool ok_termcap; - - char *TermName = NULL; - char *ptr, *shname, buf[64]; - int i, no_dev_tty = False; - char *dev_tty_name = (char *) 0; - TTYSIZE_STRUCT ts; - int pgrp = getpid(); - char numbuf[12], **envnew; - - screen->uid = save_ruid; - screen->gid = save_rgid; - - if (am_slave >= 0) { - screen->respond = am_slave; - ptydev[strlen(ptydev) - 2] = - ttydev[strlen(ttydev) - 2] = passedPty[0]; - ptydev[strlen(ptydev) - 1] = - ttydev[strlen(ttydev) - 1] = passedPty[1]; - - (void) xtermResetIds(screen); - } else { - Bool tty_got_hung; - - /* - * Sometimes /dev/tty hangs on open (as in the case of a pty - * that has gone away). Simply make up some reasonable - * defaults. - */ - - signal(SIGALRM, hungtty); - alarm(2); /* alarm(1) might return too soon */ - if (!setjmp(env)) { - ttyfd = open("/dev/tty", O_RDWR); - alarm(0); - tty_got_hung = False; - } else { - tty_got_hung = True; - ttyfd = -1; - errno = ENXIO; - } - signal(SIGALRM, SIG_DFL); - - /* - * Check results and ignore current control terminal if - * necessary. ENXIO is what is normally returned if there is - * no controlling terminal, but some systems (e.g. SunOS 4.0) - * seem to return EIO. Solaris 2.3 is said to return EINVAL. - */ - if (ttyfd < 0) { - if (tty_got_hung || errno == ENXIO || errno == EIO || - errno == EINVAL || errno == ENOTTY) { - no_dev_tty = True; - tio = d_tio; - } else { - SysError(ERROR_OPDEVTTY); - } - } else { - - /* Get a copy of the current terminal's state, - * if we can. Some systems (e.g., SVR4 and MacII) - * may not have a controlling terminal at this point - * if started directly from xdm or xinit, - * in which case we just use the defaults as above. - */ - if (ioctl(ttyfd, TCGETA, &tio) == -1) - tio = d_tio; - - close_fd(ttyfd); - } - - if (get_pty(&screen->respond)) { - /* no ptys! */ - exit(ERROR_PTYS); - } - } - - /* avoid double MapWindow requests */ - XtSetMappedWhenManaged(SHELL_OF(CURRENT_EMU()), False); - - wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", - False); - - if (!TEK4014_ACTIVE(xw)) - VTInit(xw); /* realize now so know window size for tty driver */ - - if (Console) { - /* - * Inform any running xconsole program - * that we are going to steal the console. - */ - XmuGetHostname(mit_console_name + MIT_CONSOLE_LEN, 255); - mit_console = XInternAtom(screen->display, mit_console_name, False); - /* the user told us to be the console, so we can use CurrentTime */ - XtOwnSelection(SHELL_OF(CURRENT_EMU()), - mit_console, CurrentTime, - ConvertConsoleSelection, NULL, NULL); - } -#if OPT_TEK4014 - if (TEK4014_ACTIVE(xw)) { - envnew = tekterm; - } else -#endif - { - envnew = vtterm; - } - - /* - * This used to exit if no termcap entry was found for the specified - * terminal name. That's a little unfriendly, so instead we'll allow - * the program to proceed (but not to set $TERMCAP) if the termcap - * entry is not found. - */ - ok_termcap = True; - if (!get_termcap(xw, TermName = resource.term_name)) { - const char *last = NULL; - char *next; - - TermName = x_strdup(*envnew); - ok_termcap = False; - while (*envnew != NULL) { - if (last == NULL || strcmp(last, *envnew)) { - next = x_strdup(*envnew); - if (get_termcap(xw, next)) { - free(TermName); - TermName = next; - ok_termcap = True; - break; - } else { - free(next); - } - } - last = *envnew; - envnew++; - } - } - if (ok_termcap) { - resource.term_name = TermName; - resize_termcap(xw); - } - - /* tell tty how big window is */ -#if OPT_TEK4014 - if (TEK4014_ACTIVE(xw)) { - TTYSIZE_ROWS(ts) = 38; - TTYSIZE_COLS(ts) = 81; - ts.ws_xpixel = TFullWidth(TekScreenOf(tekWidget)); - ts.ws_ypixel = TFullHeight(TekScreenOf(tekWidget)); - } else -#endif - { - TTYSIZE_ROWS(ts) = MaxRows(screen); - TTYSIZE_COLS(ts) = MaxCols(screen); - ts.ws_xpixel = FullWidth(screen); - ts.ws_ypixel = FullHeight(screen); - } - - if (am_slave < 0) { - - char sema[40]; - HEV sev; - /* start a child process - * use an event sema for sync - */ - sprintf(sema, "\\SEM32\\xterm%s", &ptydev[8]); - if (DosCreateEventSem(sema, &sev, DC_SEM_SHARED, False)) - SysError(ERROR_FORK); - - switch ((screen->pid = fork())) { - case -1: /* error */ - SysError(ERROR_FORK); - default: /* parent */ - whoami = THE_PARENT; - DosWaitEventSem(sev, 1000L); - DosCloseEventSem(sev); - break; - case 0: /* child */ - whoami = THE_CHILD; - - opencons(); - /* we don't need the socket, or the pty master anymore */ - close(ConnectionNumber(screen->display)); - close(screen->respond); - - /* Now is the time to set up our process group and - * open up the pty slave. - */ - if ((ttyfd = open(ttydev, O_RDWR)) < 0) { - /* dumm gelaufen */ - xtermWarning("Cannot open slave side of PTY\n"); - exit(1); - } - - /* use the same tty name that everyone else will use - * (from ttyname) - */ -#ifdef EMXNOTBOGUS - if ((ptr = ttyname(ttyfd)) != 0) { - ttydev = x_strdup(ptr); - } -#else - ptr = ttydev; -#endif - /* for safety: enable DUPs */ - ptioctl(ttyfd, XTY_ENADUP, 0); - - /* change ownership of tty to real group and user id */ - set_owner(ttydev, screen->uid, screen->gid, - (resource.messages ? 0622U : 0600U)); - - /* for the xf86sup-pty, we set the pty to bypass: OS/2 does - * not have a line discipline structure - */ - { - TERMIO_STRUCT t, t1; - if (ptioctl(ttyfd, TCGETA, (char *) &t) < 0) - t = d_tio; - - t.c_iflag = ICRNL; - t.c_oflag = OPOST | ONLCR; - t.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK; - - /* ignore error code, user will see it :-) */ - ptioctl(ttyfd, TCSETA, (char *) &t); - - /* set the console mode */ - if (Console) { - int on = 1; - if (ioctl(ttyfd, TIOCCONS, (char *) &on) == -1) - xtermPerror("cannot open console"); - } - } - - signal(SIGCHLD, SIG_DFL); - signal(SIGHUP, SIG_IGN); - - /* restore various signals to their defaults */ - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - signal(SIGTERM, SIG_DFL); - - xtermCopyEnv(gblenvp); - - xtermSetenv("TERM", resource.term_name); - if (!resource.term_name) - *get_tcap_buffer(xw) = 0; - - sprintf(buf, "%lu", - ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU())))); - xtermSetenv("WINDOWID", buf); - - /* put the display into the environment of the shell */ - xtermSetenv("DISPLAY", XDisplayString(screen->display)); - - xtermSetenv("XTERM_VERSION", xtermVersion()); - xtermSetenv("XTERM_LOCALE", xtermEnvLocale()); - - signal(SIGTERM, SIG_DFL); - - /* this is the time to go and set up stdin, out, and err - */ - /* dup the tty */ - for (i = 0; i <= 2; i++) - if (i != ttyfd) { - IGNORE_RC(close(i)); - IGNORE_RC(dup(ttyfd)); - } - - /* and close the tty */ - if (ttyfd > 2) - close_fd(ttyfd); - - setpgrp(0, pgrp); - (void) xtermResetIds(screen); - - if (handshake.rows > 0 && handshake.cols > 0) { - TRACE(("handshake ttysize: %dx%d\n", - handshake.rows, handshake.cols)); - set_max_row(screen, handshake.rows); - set_max_col(screen, handshake.cols); - TTYSIZE_ROWS(ts) = (ttySize_t) MaxRows(screen); - TTYSIZE_COLS(ts) = (ttySize_t) MaxCols(screen); - ts.ws_xpixel = (ttySize_t) FullWidth(screen); - ts.ws_ypixel = (ttySize_t) FullHeight(screen); - } - - sprintf(numbuf, "%d", MaxCols(screen)); - xtermSetenv("COLUMNS", numbuf); - sprintf(numbuf, "%d", MaxRows(screen)); - xtermSetenv("LINES", numbuf); - - gblenvp = environ; - - /* need to reset after all the ioctl bashing we did above */ - ptioctl(0, TIOCSWINSZ, (char *) &ts); - - signal(SIGHUP, SIG_DFL); - - /* okay everything seems right, so tell the parent, we are going */ - { - char sema[40]; - HEV sev; - sprintf(sema, "\\SEM32\\xterm%s", &ttydev[8]); - DosOpenEventSem(sema, &sev); - DosPostEventSem(sev); - DosCloseEventSem(sev); - } - -#if OPT_LUIT_PROG - /* - * Use two copies of command_to_exec, in case luit is not actually - * there, or refuses to run. In that case we will fall-through to - * to command that the user gave anyway. - */ - if (command_to_exec_with_luit) { - xtermSetenv("XTERM_SHELL", - xtermFindShell(*command_to_exec_with_luit, False)); - TRACE(("spawning command \"%s\"\n", *command_to_exec_with_luit)); - execvp(*command_to_exec_with_luit, command_to_exec_with_luit); - xtermPerror("Can't execvp %s", *command_to_exec_with_luit); - xtermWarning("cannot support your locale.\n"); - } -#endif - if (command_to_exec) { - xtermSetenv("XTERM_SHELL", - xtermFindShell(*command_to_exec, False)); - TRACE(("spawning command \"%s\"\n", *command_to_exec)); - execvpe(*command_to_exec, command_to_exec, gblenvp); - - /* print error message on screen */ - xtermWarning("Can't execvp %s\n", *command_to_exec); - } - - /* use a layered mechanism to find a shell */ - ptr = x_getenv("X11SHELL"); - if (!ptr) - ptr = x_getenv("SHELL"); - if (!ptr) - ptr = x_getenv("OS2_SHELL"); - if (!ptr) - ptr = "SORRY_NO_SHELL_FOUND"; - xtermSetenv("XTERM_SHELL", ptr); - - shname = x_basename(ptr); - if (command_to_exec) { - char *exargv[10]; /*XXX */ - - exargv[0] = ptr; - exargv[1] = "/C"; - exargv[2] = command_to_exec[0]; - exargv[3] = command_to_exec[1]; - exargv[4] = command_to_exec[2]; - exargv[5] = command_to_exec[3]; - exargv[6] = command_to_exec[4]; - exargv[7] = command_to_exec[5]; - exargv[8] = command_to_exec[6]; - exargv[9] = 0; - execvpe(exargv[0], exargv, gblenvp); - - /* print error message on screen */ - xtermWarning("Can't execvp %s\n", *command_to_exec); - } else { - execlpe(ptr, shname, 0, gblenvp); - - /* Exec failed. */ - xtermWarning("Could not exec %s!\n", ptr); - } - sleep(5); - - /* preventively shoot the parent */ - kill(-getppid(), SIGTERM); - - exit(ERROR_EXEC); - } /* endcase */ - } - /* !am_slave */ - signal(SIGHUP, SIG_IGN); -/* - * Unfortunately, System V seems to have trouble divorcing the child process - * from the process group of xterm. This is a problem because hitting the - * INTR or QUIT characters on the keyboard will cause xterm to go away if we - * don't ignore the signals. This is annoying. - */ - -/* signal (SIGINT, SIG_IGN);*/ - signal(SIGINT, killit); - signal(SIGTERM, killit); - - /* hung shell problem */ - signal(SIGQUIT, SIG_IGN); -/* signal (SIGTERM, SIG_IGN);*/ - return 0; -} /* end spawnXTerm */ - -SIGNAL_T -Exit(int n) -{ - XtermWidget xw = term; - TScreen *screen = TScreenOf(xw); - int pty = TScreenOf(xw)->respond; - close(pty); /* close explicitly to avoid race with slave side */ -#ifdef ALLOWLOGGING - if (screen->logging) - CloseLog(xw); -#endif - if (am_slave < 0) { - /* restore ownership of tty and pty */ - set_owner(ttydev, 0, 0, 0666U); - set_owner(ptydev, 0, 0, 0666U); - } - - /* - * Close after releasing ownership to avoid race condition: other programs - * grabbing it, and *then* having us release ownership.... - */ - close(screen->respond); /* close explicitly to avoid race with slave side */ -#ifdef ALLOWLOGGING - if (screen->logging) - CloseLog(xw); -#endif - -#ifdef NO_LEAKS - if (n == 0) { - TRACE(("Freeing memory leaks\n")); - if (xw != 0) { - Display *dpy = TScreenOf(xw)->display; - - if (toplevel) { - XtDestroyWidget(toplevel); - TRACE(("destroyed top-level widget\n")); - } - sortedOpts(0, 0, 0); - noleaks_charproc(); - noleaks_ptydata(); -#if OPT_WIDE_CHARS - noleaks_CharacterClass(); -#endif - /* XrmSetDatabase(dpy, 0); increases leaks ;-) */ - XtCloseDisplay(dpy); - XtDestroyApplicationContext(app_con); -#if OPT_SESSION_MGT - IceRemoveConnectionWatch(icewatch, NULL); -#endif - TRACE(("closed display\n")); - } - TRACE_CLOSE(); - } -#endif - - exit(n); - SIGNAL_RETURN; -} - -/* ARGSUSED */ -static void -resize_termcap(XtermWidget xw) -{ -} - -/* - * Does a non-blocking wait for a child process. If the system - * doesn't support non-blocking wait, do nothing. - * Returns the pid of the child, or 0 or -1 if none or error. - */ -int -nonblocking_wait(void) -{ - pid_t pid; - - pid = waitpid(-1, NULL, WNOHANG); - return pid; -} - -/* ARGSUSED */ -static SIGNAL_T -reapchild(int n GCC_UNUSED) -{ - int olderrno = errno; - int pid; - - pid = wait(NULL); - - /* cannot re-enable signal before waiting for child - * because then SVR4 loops. Sigh. HP-UX 9.01 too. - */ - (void) signal(SIGCHLD, reapchild); - - do { - if (pid == TScreenOf(term)->pid) { -#ifdef DEBUG - if (debug) - fputs("Exiting\n", stderr); -#endif - if (!hold_screen) - need_cleanup = True; - } - } while ((pid = nonblocking_wait()) > 0); - - errno = olderrno; - SIGNAL_RETURN; -} - -/* - * parse_tty_modes accepts lines of the following form: - * - * [SETTING] ... - * - * where setting consists of the words in the modelist followed by a character - * or ^char. - */ -static int -parse_tty_modes(char *s, struct _xttymodes *modelist) -{ - struct _xttymodes *mp; - int c; - int count = 0; - - TRACE(("parse_tty_modes\n")); - for (;;) { - size_t len; - - while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) - s++; - if (!*s) - return count; - - for (len = 0; isalnum(CharOf(s[len])); ++len) ; - for (mp = modelist; mp->name; mp++) { - if (len == mp->len - && strncmp(s, mp->name, mp->len) == 0) - break; - } - if (!mp->name) - return -1; - - s += mp->len; - while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) - s++; - if (!*s) - return -1; - - if ((c = decode_keyvalue(&s, False)) != -1) { - mp->value = c; - mp->set = 1; - count++; - TRACE(("...parsed #%d: %s=%#x\n", count, mp->name, c)); - } - } -} - -int -GetBytesAvailable(int fd) -{ - long arg; - ioctl(fd, FIONREAD, (char *) &arg); - return (int) arg; -} - -/* Utility function to try to hide system differences from - everybody who used to call killpg() */ - -int -kill_process_group(int pid, int sig) -{ - return kill(-pid, sig); -} - -int -ptioctl(int fd, int func, void *data) -{ - APIRET rc; - ULONG len; - struct pt_termios pt; - TERMIO_STRUCT *t; - int i; - - switch (func) { - case TCGETA: - rc = DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCGETA, - NULL, 0, NULL, - (ULONG *) & pt, sizeof(struct pt_termios), &len); - if (rc) - return -1; - t = (TERMIO_STRUCT *) data; - t->c_iflag = pt.c_iflag; - t->c_oflag = pt.c_oflag; - t->c_cflag = pt.c_cflag; - t->c_lflag = pt.c_lflag; - for (i = 0; i < NCC; i++) - t->c_cc[i] = pt.c_cc[i]; - return 0; - case TCSETA: - case TCSETAW: - case TCSETAF: - t = (TERMIO_STRUCT *) data; - pt.c_iflag = t->c_iflag; - pt.c_oflag = t->c_oflag; - pt.c_cflag = t->c_cflag; - pt.c_lflag = t->c_lflag; - - for (i = 0; i < NCC; i++) - pt.c_cc[i] = t->c_cc[i]; - if (func == TCSETA) - i = XTY_TIOCSETA; - else if (func == TCSETAW) - i = XTY_TIOCSETAW; - else - i = XTY_TIOCSETAF; - rc = DosDevIOCtl(fd, XFREE86_PTY, i, - (ULONG *) & pt, sizeof(struct pt_termios), &len, - NULL, 0, NULL); - return (rc) ? -1 : 0; - case TIOCCONS: - return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCCONS, - (ULONG *) data, sizeof(ULONG), &len, - NULL, 0, NULL); - case TIOCSWINSZ: - return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCSWINSZ, - (ULONG *) data, sizeof(TTYSIZE_STRUCT), &len, - NULL, 0, NULL); - case TIOCGWINSZ: - return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCGWINSZ, - NULL, 0, NULL, - (ULONG *) data, sizeof(TTYSIZE_STRUCT), &len); - case XTY_ENADUP: - i = 1; - return DosDevIOCtl(fd, XFREE86_PTY, XTY_ENADUP, - (ULONG *) & i, sizeof(ULONG), &len, - NULL, 0, NULL); - case XTY_TRACE: - i = 2; - return DosDevIOCtl(fd, XFREE86_PTY, XTY_TRACE, - (ULONG *) & i, sizeof(ULONG), &len, - NULL, 0, NULL); - case PTMS_GETPTY: - i = 1; - return DosDevIOCtl(fd, XFREE86_PTY, PTMS_GETPTY, - (ULONG *) & i, sizeof(ULONG), &len, - (UCHAR *) data, 14, &len); - default: - return -1; - } -} diff --git a/app/xterm/package/debian/changelog b/app/xterm/package/debian/changelog index 0b88f1881..046b60be1 100644 --- a/app/xterm/package/debian/changelog +++ b/app/xterm/package/debian/changelog @@ -1,3 +1,28 @@ +xterm-dev (291) unstable; urgency=low + + * Fix a different #282 change (Redhat #874327). + + -- Thomas E. Dickey <dickey@invisible-island.net> Tue, 26 Feb 2013 19:09:32 -0500 + +xterm-dev (290) unstable; urgency=low + + * Fix incomplete revert of #282 change. + + -- Thomas E. Dickey <dickey@invisible-island.net> Tue, 12 Feb 2013 19:48:21 -0500 + +xterm-dev (289) unstable; urgency=low + + * Miscellaneous fixes. + * Fix regression with XTERM_SHELL feature. + + -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 03 Feb 2013 13:59:20 -0500 + +xterm-dev (288) unstable; urgency=low + + * Miscellaneous fixes. + + -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 26 Nov 2012 20:53:23 -0500 + xterm-dev (287) unstable; urgency=low * Miscellaneous fixes. diff --git a/app/xterm/package/debian/rules b/app/xterm/package/debian/rules index f47960e7c..9f027791f 100644 --- a/app/xterm/package/debian/rules +++ b/app/xterm/package/debian/rules @@ -58,6 +58,7 @@ configure-stamp: --libdir=/etc/$(PACKAGE) \ --with-app-class=$(PKG_CLASS) \ --without-xterm-symlink \ + --disable-imake \ --enable-256-color \ --enable-88-color \ --enable-dabbrev \ diff --git a/app/xterm/package/freebsd/Makefile b/app/xterm/package/freebsd/Makefile index 303eba2f6..a09398b9a 100644 --- a/app/xterm/package/freebsd/Makefile +++ b/app/xterm/package/freebsd/Makefile @@ -5,7 +5,7 @@ # and "make makesum". PORTNAME= xterm -PORTVERSION= 286 +PORTVERSION= 290 CATEGORIES= x11 MASTER_SITES= ftp://invisible-island.net/xterm/ \ CRITICAL diff --git a/app/xterm/package/xterm.spec b/app/xterm/package/xterm.spec index 5a9314be3..e7fcdf40e 100644 --- a/app/xterm/package/xterm.spec +++ b/app/xterm/package/xterm.spec @@ -1,7 +1,7 @@ -# $XTermId: xterm.spec,v 1.40 2012/11/19 09:53:15 tom Exp $ +# $XTermId: xterm.spec,v 1.45 2013/02/27 00:09:35 tom Exp $ Summary: X terminal emulator (development version) Name: xterm-dev -Version: 287 +Version: 291 Release: 1 License: X11 Group: User Interface/X @@ -79,6 +79,7 @@ CPPFLAGS="-DMISC_EXP -DEXP_HTTP_HEADERS" \ --with-icondir=%{_iconsdir} \ %endif --with-app-class=%{my_class} \ + --disable-imake \ --enable-256-color \ --enable-88-color \ --enable-dabbrev \ diff --git a/app/xterm/precompose.c b/app/xterm/precompose.c index afe4c3f3f..f420e5440 100644 --- a/app/xterm/precompose.c +++ b/app/xterm/precompose.c @@ -4,8 +4,8 @@ * DO NOT EDIT BY HAND! This is generated by the script * unicode/make-precompose.sh */ -/* $XTermId: precompose.c,v 1.7 2004/12/01 01:27:47 tom Exp $ */ -/* $XFree86: xc/programs/xterm/precompose.c,v 1.3 2004/12/01 01:27:47 dickey Exp $ */ +/* $XTermId: precompose.c,v 1.9 2013/02/03 17:06:01 tom Exp $ */ +/* $XFree86$ */ #include <precompose.h> @@ -754,19 +754,17 @@ static struct { { 0x0F76, 0x0FB2, 0x0F80}, { 0x0F78, 0x0FB3, 0x0F80}, { 0x1026, 0x1025, 0x102E}, -{ 0x1D15E, 0x1D157, 0x1D165}, -{ 0x1D15F, 0x1D158, 0x1D165}, -{ 0x1D160, 0x1D15F, 0x1D16E}, -{ 0x1D161, 0x1D15F, 0x1D16F}, -{ 0x1D162, 0x1D15F, 0x1D170}, -{ 0x1D163, 0x1D15F, 0x1D171}, -{ 0x1D164, 0x1D15F, 0x1D172}, -{ 0x1D1BB, 0x1D1B9, 0x1D165}, -{ 0x1D1BC, 0x1D1BA, 0x1D165}, -{ 0x1D1BD, 0x1D1BB, 0x1D16E}, -{ 0x1D1BF, 0x1D1BB, 0x1D16F}, -{ 0x1D1BE, 0x1D1BC, 0x1D16E}, -{ 0x1D1C0, 0x1D1BC, 0x1D16F}, +{ 0x1B06, 0x1B05, 0x1B35}, +{ 0x1B08, 0x1B07, 0x1B35}, +{ 0x1B0A, 0x1B09, 0x1B35}, +{ 0x1B0C, 0x1B0B, 0x1B35}, +{ 0x1B0E, 0x1B0D, 0x1B35}, +{ 0x1B12, 0x1B11, 0x1B35}, +{ 0x1B3B, 0x1B3A, 0x1B35}, +{ 0x1B3D, 0x1B3C, 0x1B35}, +{ 0x1B40, 0x1B3E, 0x1B35}, +{ 0x1B41, 0x1B3F, 0x1B35}, +{ 0x1B43, 0x1B42, 0x1B35}, { 0x1E38, 0x1E36, 0x0304}, { 0x1E39, 0x1E37, 0x0304}, { 0x1E5C, 0x1E5A, 0x0304}, @@ -1016,18 +1014,39 @@ static struct { { 0x30FE, 0x30FD, 0x3099}, { 0xFB2C, 0xFB49, 0x05C1}, { 0xFB2D, 0xFB49, 0x05C2}, +{ 0x1109A, 0x11099, 0x110BA}, +{ 0x1109C, 0x1109B, 0x110BA}, +{ 0x110AB, 0x110A5, 0x110BA}, +{ 0x1112E, 0x11131, 0x11127}, +{ 0x1112F, 0x11132, 0x11127}, +{ 0x1D15E, 0x1D157, 0x1D165}, +{ 0x1D15F, 0x1D158, 0x1D165}, +{ 0x1D160, 0x1D15F, 0x1D16E}, +{ 0x1D161, 0x1D15F, 0x1D16F}, +{ 0x1D162, 0x1D15F, 0x1D170}, +{ 0x1D163, 0x1D15F, 0x1D171}, +{ 0x1D164, 0x1D15F, 0x1D172}, +{ 0x1D1BB, 0x1D1B9, 0x1D165}, +{ 0x1D1BC, 0x1D1BA, 0x1D165}, +{ 0x1D1BD, 0x1D1BB, 0x1D16E}, +{ 0x1D1BF, 0x1D1BB, 0x1D16F}, +{ 0x1D1BE, 0x1D1BC, 0x1D16E}, +{ 0x1D1C0, 0x1D1BC, 0x1D16F}, }; +#define UNICODE_SHIFT 21 + int do_precomposition(int base, int comb) { int min = 0; int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1; int mid; - unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that; + unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb; + unsigned long that; /* binary search */ while (max >= min) { mid = (min + max) / 2; - that = ((unsigned)precompositions[mid].base << 16) | ((unsigned)precompositions[mid].comb); + that = ((unsigned) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb); if (that < sought) { min = mid + 1; } else if (that > sought) { diff --git a/app/xterm/print.c b/app/xterm/print.c index 4de06a7b6..63921e607 100644 --- a/app/xterm/print.c +++ b/app/xterm/print.c @@ -1,4 +1,4 @@ -/* $XTermId: print.c,v 1.147 2012/10/29 10:41:53 tom Exp $ */ +/* $XTermId: print.c,v 1.149 2012/12/31 13:58:16 tom Exp $ */ /* * Copyright 1997-2011,2012 by Thomas E. Dickey @@ -659,14 +659,19 @@ xtermHasPrinter(XtermWidget xw) if (strlen(SPS.printer_command) != 0 && !result) { char **argv = x_splitargs(SPS.printer_command); - if (argv && argv[0]) { - if (xtermFindShell(argv[0], False) == 0) { - xtermWarning("No program found for printerCommand: %s\n", SPS.printer_command); - SPS.printer_command = x_strdup(""); - } else { - SPS.printer_checked = True; - result = True; + if (argv) { + if (argv[0]) { + char *myShell = xtermFindShell(argv[0], False); + if (myShell == 0) { + xtermWarning("No program found for printerCommand: %s\n", SPS.printer_command); + SPS.printer_command = x_strdup(""); + } else { + free(myShell); + SPS.printer_checked = True; + result = True; + } } + x_freeargs(argv); } TRACE(("xtermHasPrinter:%d\n", result)); } diff --git a/app/xterm/ptydata.c b/app/xterm/ptydata.c index 1fafe41f0..744222e41 100644 --- a/app/xterm/ptydata.c +++ b/app/xterm/ptydata.c @@ -1,7 +1,7 @@ -/* $XTermId: ptydata.c,v 1.101 2011/09/11 14:59:38 tom Exp $ */ +/* $XTermId: ptydata.c,v 1.103 2013/02/03 23:17:07 tom Exp $ */ /* - * Copyright 1999-2010,2011 by Thomas E. Dickey + * Copyright 1999-2011,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -203,7 +203,7 @@ readPtyData(XtermWidget xw, PtySelect * select_mask, PtyData * data) */ if (size <= 0) { if (save_err == EIO || save_err == 0) - Cleanup(0); + NormalExit(); else if (!E_TEST(save_err)) Panic("input: read returned unexpected error (%d)\n", save_err); size = 0; @@ -211,13 +211,13 @@ readPtyData(XtermWidget xw, PtySelect * select_mask, PtyData * data) #else /* !f*ugly */ if (size < 0) { if (save_err == EIO) - Cleanup(0); + NormalExit(); else if (!E_TEST(save_err)) Panic("input: read returned unexpected error (%d)\n", save_err); size = 0; } else if (size == 0) { -#if defined(__UNIXOS2__) || defined(__FreeBSD__) - Cleanup(0); +#if defined(__FreeBSD__) + NormalExit(); #else Panic("input: read returned zero\n", 0); #endif diff --git a/app/xterm/ptyx.h b/app/xterm/ptyx.h index 62312aba2..55cd8dd61 100644 --- a/app/xterm/ptyx.h +++ b/app/xterm/ptyx.h @@ -1,7 +1,7 @@ -/* $XTermId: ptyx.h,v 1.759 2012/11/25 16:05:51 tom Exp $ */ +/* $XTermId: ptyx.h,v 1.762 2013/02/13 00:42:21 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -231,11 +231,7 @@ #ifdef __hpux #define PTYCHAR1 "zyxwvutsrqp" #else /* !__hpux */ -#ifdef __UNIXOS2__ -#define PTYCHAR1 "pq" -#else #define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ" -#endif /* !__UNIXOS2__ */ #endif /* !__hpux */ #endif /* !PTYCHAR1 */ @@ -866,13 +862,17 @@ typedef enum { , MOUSE_FG /* mouse foreground */ , MOUSE_BG /* mouse background */ #if OPT_TEK4014 - , TEK_FG /* tektronix foreground */ + , TEK_FG = 5 /* tektronix foreground */ , TEK_BG /* tektronix background */ - , TEK_CURSOR /* tektronix cursor */ #endif #if OPT_HIGHLIGHT_COLOR - , HIGHLIGHT_BG /* highlight background */ - , HIGHLIGHT_FG /* highlight foreground */ + , HIGHLIGHT_BG = 7 /* highlight background */ +#endif +#if OPT_TEK4014 + , TEK_CURSOR = 8 /* tektronix cursor */ +#endif +#if OPT_HIGHLIGHT_COLOR + , HIGHLIGHT_FG = 9 /* highlight foreground */ #endif , NCOLORS /* total number of colors */ } TermColors; @@ -1897,7 +1897,6 @@ typedef struct { * Working variables for getLineData(). */ size_t lineExtra; /* extra space for combining chars */ - Dimension widestLine; /* length of longest LineData */ /* * Pointer to the current visible buffer. */ diff --git a/app/xterm/resize.c b/app/xterm/resize.c index cc82168d9..987000e7e 100644 --- a/app/xterm/resize.c +++ b/app/xterm/resize.c @@ -1,7 +1,7 @@ -/* $XTermId: resize.c,v 1.118 2011/09/11 20:19:19 tom Exp $ */ +/* $XTermId: resize.c,v 1.129 2013/01/06 19:42:20 tom Exp $ */ /* - * Copyright 2003-2010,2011 by Thomas E. Dickey + * Copyright 2003-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -54,17 +54,15 @@ /* resize.c */ -#include <xterm.h> #include <stdio.h> #include <ctype.h> + +#include <xterm.h> +#include <version.h> #include <xstrings.h> #include <xtermcap.h> #include <xterm_io.h> -#ifdef APOLLO_SR9 -#define CANT_OPEN_DEV_TTY -#endif - #ifndef USE_TERMINFO /* avoid conflict with configure script */ #if defined(__QNX__) || defined(__SCO__) || defined(linux) || defined(__OpenBSD__) || defined(__UNIXWARE__) #define USE_TERMINFO @@ -140,14 +138,13 @@ static const char *getsize[EMULATIONS] = ESCAPE("7") ESCAPE("[r") ESCAPE("[999;999H") ESCAPE("[6n"), ESCAPE("[18t"), }; -#if defined(USE_STRUCT_TTYSIZE) -#elif defined(USE_STRUCT_WINSIZE) +#if defined(USE_STRUCT_WINSIZE) static const char *getwsize[EMULATIONS] = { /* size in pixels */ 0, ESCAPE("[14t"), }; -#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */ +#endif /* USE_STRUCT_WINSIZE */ static const char *restore[EMULATIONS] = { ESCAPE("8"), @@ -177,20 +174,54 @@ static char sunname[] = "sunsize"; static int tty; static FILE *ttyfp; -#if defined(USE_STRUCT_TTYSIZE) -#elif defined(USE_STRUCT_WINSIZE) +#if defined(USE_STRUCT_WINSIZE) static const char *wsize[EMULATIONS] = { 0, ESCAPE("[4;%hd;%hdt"), }; -#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */ +#endif /* USE_STRUCT_WINSIZE */ -static SIGNAL_T onintr(int sig); -static SIGNAL_T resize_timeout(int sig); -static int checkdigits(char *str); -static void Usage(void); -static void readstring(FILE *fp, char *buf, const char *str); +static void +failed(const char *s) +{ + int save = errno; + IGNORE_RC(write(2, myname, strlen(myname))); + IGNORE_RC(write(2, ": ", (size_t) 2)); + errno = save; + perror(s); + exit(EXIT_FAILURE); +} + +/* ARGSUSED */ +static void +onintr(int sig GCC_UNUSED) +{ +#ifdef USE_ANY_SYSV_TERMIO + (void) ioctl(tty, TCSETAW, &tioorig); +#elif defined(USE_TERMIOS) + (void) tcsetattr(tty, TCSADRAIN, &tioorig); +#else /* not USE_TERMIOS */ + (void) ioctl(tty, TIOCSETP, &sgorig); +#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */ + exit(EXIT_FAILURE); +} + +static void +resize_timeout(int sig) +{ + fprintf(stderr, "\n%s: Time out occurred\r\n", myname); + onintr(sig); +} + +static void +Usage(void) +{ + fprintf(stderr, strcmp(myname, sunname) == 0 ? + "Usage: %s [rows cols]\n" : + "Usage: %s [-v] [-u] [-c] [-s [rows cols]]\n", myname); + exit(EXIT_FAILURE); +} #ifdef USE_TERMCAP static void @@ -218,6 +249,58 @@ print_termcap(const char *termcap) } #endif /* USE_TERMCAP */ +static int +checkdigits(char *str) +{ + while (*str) { + if (!isdigit(CharOf(*str))) + return (0); + str++; + } + return (1); +} + +static void +readstring(FILE *fp, char *buf, const char *str) +{ + int last, c; +#if !defined(USG) + /* What is the advantage of setitimer() over alarm()? */ + struct itimerval it; +#endif + + signal(SIGALRM, resize_timeout); +#if defined(USG) + alarm(TIMEOUT); +#else + memset((char *) &it, 0, sizeof(struct itimerval)); + it.it_value.tv_sec = TIMEOUT; + setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); +#endif + if ((c = getc(fp)) == 0233) { /* meta-escape, CSI */ + c = ESCAPE("")[0]; + *buf++ = (char) c; + *buf++ = '['; + } else { + *buf++ = (char) c; + } + if (c != *str) { + fprintf(stderr, "%s: unknown character, exiting.\r\n", myname); + onintr(0); + } + last = str[strlen(str) - 1]; + while ((*buf++ = (char) getc(fp)) != last) { + ; + } +#if defined(USG) + alarm(0); +#else + memset((char *) &it, 0, sizeof(struct itimerval)); + setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); +#endif + *buf = 0; +} + /* resets termcap string to reflect current screen size */ @@ -231,6 +314,7 @@ main(int argc, char **argv ENVP_ARG) int emu = VT100; char *shell; int i; + int rc; int rows, cols; #ifdef USE_ANY_SYSV_TERMIO struct termio tio; @@ -269,6 +353,9 @@ main(int argc, char **argv ENVP_ARG) case 'c': /* C shell */ shell_type = SHELL_C; break; + case 'v': + printf("%s\n", xtermVersion()); + exit(EXIT_SUCCESS); default: Usage(); /* Never returns */ } @@ -295,9 +382,11 @@ main(int argc, char **argv ENVP_ARG) shell = x_basename(ptr); /* now that we know, what kind is it? */ - for (i = 0; shell_list[i].name; i++) - if (!strcmp(shell_list[i].name, shell)) + for (i = 0; shell_list[i].name; i++) { + if (!strcmp(shell_list[i].name, shell)) { break; + } + } shell_type = shell_list[i].type; } @@ -306,13 +395,14 @@ main(int argc, char **argv ENVP_ARG) fprintf(stderr, "%s: Can't set window size under %s emulation\n", myname, emuname[emu]); - exit(1); + exit(EXIT_FAILURE); } - if (!checkdigits(argv[0]) || !checkdigits(argv[1])) + if (!checkdigits(argv[0]) || !checkdigits(argv[1])) { Usage(); /* Never returns */ - } else if (argc != 0) + } + } else if (argc != 0) { Usage(); /* Never returns */ - + } #ifdef CANT_OPEN_DEV_TTY if ((name_of_tty = ttyname(fileno(stderr))) == NULL) #endif @@ -321,32 +411,35 @@ main(int argc, char **argv ENVP_ARG) if ((ttyfp = fopen(name_of_tty, "r+")) == NULL) { fprintf(stderr, "%s: can't open terminal %s\n", myname, name_of_tty); - exit(1); + exit(EXIT_FAILURE); } tty = fileno(ttyfp); #ifdef USE_TERMCAP if ((env = x_getenv("TERM")) == 0) { env = DFT_TERMTYPE; - if (SHELL_BOURNE == shell_type) + if (SHELL_BOURNE == shell_type) { setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n"; - else + } else { setname = "setenv TERM " DFT_TERMTYPE ";\n"; + } } termcap[0] = 0; /* ...just in case we've accidentally gotten terminfo */ - if (tgetent(termcap, env) <= 0 || termcap[0] == 0) + if (tgetent(termcap, env) <= 0 || termcap[0] == 0) { ok_tcap = 0; + } #endif /* USE_TERMCAP */ #ifdef USE_TERMINFO if (x_getenv("TERM") == 0) { - if (SHELL_BOURNE == shell_type) + if (SHELL_BOURNE == shell_type) { setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n"; - else + } else { setname = "setenv TERM " DFT_TERMTYPE ";\n"; + } } #endif /* USE_TERMINFO */ #ifdef USE_ANY_SYSV_TERMIO - ioctl(tty, TCGETA, &tioorig); + rc = ioctl(tty, TCGETA, &tioorig); tio = tioorig; UIntClr(tio.c_iflag, (ICRNL | IUCLC)); UIntClr(tio.c_lflag, (ICANON | ECHO)); @@ -354,7 +447,7 @@ main(int argc, char **argv ENVP_ARG) tio.c_cc[VMIN] = 6; tio.c_cc[VTIME] = 1; #elif defined(USE_TERMIOS) - tcgetattr(tty, &tioorig); + rc = tcgetattr(tty, &tioorig); tio = tioorig; UIntClr(tio.c_iflag, ICRNL); UIntClr(tio.c_lflag, (ICANON | ECHO)); @@ -362,23 +455,29 @@ main(int argc, char **argv ENVP_ARG) tio.c_cc[VMIN] = 6; tio.c_cc[VTIME] = 1; #else /* not USE_TERMIOS */ - ioctl(tty, TIOCGETP, &sgorig); + rc = ioctl(tty, TIOCGETP, &sgorig); sg = sgorig; sg.sg_flags |= RAW; UIntClr(sg.sg_flags, ECHO); #endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */ + if (rc != 0) + failed("get tty settings"); + signal(SIGINT, onintr); signal(SIGQUIT, onintr); signal(SIGTERM, onintr); + #ifdef USE_ANY_SYSV_TERMIO - ioctl(tty, TCSETAW, &tio); + rc = ioctl(tty, TCSETAW, &tio); #elif defined(USE_TERMIOS) - tcsetattr(tty, TCSADRAIN, &tio); + rc = tcsetattr(tty, TCSADRAIN, &tio); #else /* not USE_TERMIOS */ - ioctl(tty, TIOCSETP, &sg); + rc = ioctl(tty, TIOCSETP, &sg); #endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */ + if (rc != 0) + failed("set tty settings"); - if (argc == 2) { + if (argc == 2) { /* look for optional parameters of "-s" */ char *tmpbuf = TypeMallocN(char, strlen(setsize[emu]) + strlen(argv[0]) + @@ -401,14 +500,7 @@ main(int argc, char **argv ENVP_ARG) } if (restore[emu]) IGNORE_RC(write(tty, restore[emu], strlen(restore[emu]))); -#if defined(USE_STRUCT_TTYSIZE) - /* finally, set the tty's window size */ - if (ioctl(tty, TIOCGSIZE, &ts) != -1) { - TTYSIZE_ROWS(ts) = rows; - TTYSIZE_COLS(ts) = cols; - SET_TTYSIZE(tty, ts); - } -#elif defined(USE_STRUCT_WINSIZE) +#if defined(USE_STRUCT_WINSIZE) /* finally, set the tty's window size */ if (getwsize[emu]) { /* get the window size in pixels */ @@ -434,15 +526,18 @@ main(int argc, char **argv ENVP_ARG) TTYSIZE_COLS(ts) = (ttySize_t) cols; SET_TTYSIZE(tty, ts); } -#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */ +#endif /* USE_STRUCT_WINSIZE */ #ifdef USE_ANY_SYSV_TERMIO - ioctl(tty, TCSETAW, &tioorig); + rc = ioctl(tty, TCSETAW, &tioorig); #elif defined(USE_TERMIOS) - tcsetattr(tty, TCSADRAIN, &tioorig); + rc = tcsetattr(tty, TCSADRAIN, &tioorig); #else /* not USE_TERMIOS */ - ioctl(tty, TIOCSETP, &sgorig); + rc = ioctl(tty, TIOCSETP, &sgorig); #endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */ + if (rc != 0) + failed("set tty settings"); + signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); signal(SIGTERM, SIG_DFL); @@ -453,7 +548,7 @@ main(int argc, char **argv ENVP_ARG) /* first do columns */ if ((ptr = x_strindex(termcap, "co#")) == NULL) { fprintf(stderr, "%s: No `co#'\n", myname); - exit(1); + exit(EXIT_FAILURE); } i = ptr - termcap + 3; @@ -465,7 +560,7 @@ main(int argc, char **argv ENVP_ARG) /* now do lines */ if ((ptr = x_strindex(newtc, "li#")) == NULL) { fprintf(stderr, "%s: No `li#'\n", myname); - exit(1); + exit(EXIT_FAILURE); } i = ptr - newtc + 3; @@ -504,87 +599,5 @@ main(int argc, char **argv ENVP_ARG) setname, cols, rows); #endif /* USE_TERMINFO */ } - exit(0); -} - -static int -checkdigits(char *str) -{ - while (*str) { - if (!isdigit(CharOf(*str))) - return (0); - str++; - } - return (1); -} - -static void -readstring(FILE *fp, char *buf, const char *str) -{ - int last, c; -#if !defined(USG) && !defined(__UNIXOS2__) - /* What is the advantage of setitimer() over alarm()? */ - struct itimerval it; -#endif - - signal(SIGALRM, resize_timeout); -#if defined(USG) || defined(__UNIXOS2__) - alarm(TIMEOUT); -#else - memset((char *) &it, 0, sizeof(struct itimerval)); - it.it_value.tv_sec = TIMEOUT; - setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); -#endif - if ((c = getc(fp)) == 0233) { /* meta-escape, CSI */ - c = ESCAPE("")[0]; - *buf++ = (char) c; - *buf++ = '['; - } else { - *buf++ = (char) c; - } - if (c != *str) { - fprintf(stderr, "%s: unknown character, exiting.\r\n", myname); - onintr(0); - } - last = str[strlen(str) - 1]; - while ((*buf++ = (char) getc(fp)) != last) { - ; - } -#if defined(USG) || defined(__UNIXOS2__) - alarm(0); -#else - memset((char *) &it, 0, sizeof(struct itimerval)); - setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL); -#endif - *buf = 0; -} - -static void -Usage(void) -{ - fprintf(stderr, strcmp(myname, sunname) == 0 ? - "Usage: %s [rows cols]\n" : - "Usage: %s [-u] [-c] [-s [rows cols]]\n", myname); - exit(1); -} - -static SIGNAL_T -resize_timeout(int sig) -{ - fprintf(stderr, "\n%s: Time out occurred\r\n", myname); - onintr(sig); -} - -/* ARGSUSED */ -static SIGNAL_T -onintr(int sig GCC_UNUSED) -{ -#ifdef USE_ANY_SYSV_TERMIO - ioctl(tty, TCSETAW, &tioorig); -#elif defined(USE_TERMIOS) - tcsetattr(tty, TCSADRAIN, &tioorig); -#else /* not USE_TERMIOS */ - ioctl(tty, TIOCSETP, &sgorig); -#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */ - exit(1); + exit(EXIT_SUCCESS); } diff --git a/app/xterm/resize.man b/app/xterm/resize.man index 5b8c64c9e..9e26d900f 100644 --- a/app/xterm/resize.man +++ b/app/xterm/resize.man @@ -1,7 +1,42 @@ -.\" $XTermId: resize.man,v 1.21 2012/10/23 23:26:20 tom Exp $ +.\" $XTermId: resize.man,v 1.30 2013/01/06 16:13:44 tom Exp $ +.\" +.\" Copyright 1998-2012,2013 by Thomas E. Dickey +.\" +.\" All Rights Reserved +.\" +.\" Permission is hereby granted, free of charge, to any person obtaining a +.\" copy of this software and associated documentation files (the +.\" "Software"), to deal in the Software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the Software, and to +.\" permit persons to whom the Software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY +.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name(s) of the above copyright +.\" holders shall not be used in advertising or otherwise to promote the +.\" sale, use or other dealings in this Software without prior written +.\" authorization. .\" .\" updated by Thomas E. Dickey for XFree86, 1998-2006. .\" +.ds N Resize +.ds n resize +.\" +.\" Bulleted paragraph +.de bP +.IP \(bu 4 +.. .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds AQ \(aq .el .ds AQ ' @@ -13,14 +48,57 @@ .SH NAME resize \- set environment and terminal settings to current xterm window size .SH SYNOPSIS -.B resize -[ \fB\-u\fP | \fB\-c\fP ] [ \fB\-s\fP [ \fIrow col\fP ] ] +.B \*n +[ \fB\-v\fP | \fB\-u\fP | \fB\-c\fP ] [ \fB\-s\fP [ \fIrow col\fP ] ] .SH DESCRIPTION -.I Resize +.I \*N prints a shell command for setting the appropriate environment variables to indicate the current size of \fIxterm\fP window from which the command is run. -For this output to take effect, \fIresize\fP must either be evaluated +.PP +.I \*N +determines the command through several steps: +.bP +first, it finds the name of the user's shell program. +It uses the \fBSHELL\fP variable if set, +otherwise it uses the user's data from /etc/passwd. +.bP +then it decides whether to use Bourne shell syntax or C-Shell syntax. +It uses a built-in table of known shells, +which can be overridden by the \fB\-u\fP and \fB\-c\fP options. +.bP +then \fI\*n\fP asks the operating system for the terminal settings. +This is the same information which can be manipulated using \fIstty\fP. +.bP +then \fI\*n\fP asks the terminal for its size in characters. +Depending on whether the "\fB\-s\fP option is given, +\fI\*n\fP uses a different escape sequence to ask for this information. +.bP +at this point, \fI\*n\fP attempts to update the terminal settings +to reflect the terminal window's size in pixels: +.RS +.bP +if the \fB\-s\fP option is used, +\fI\*n\fP then asks the terminal for its size in pixels. +.bP +otherwise, +\fI\*n\fP asks the operating system for the information +and updates that after ensuring that the window's dimensions are +a multiple of the character height and width. +.bP +in either case, the updated terminal settings are done +using a different system call than used for \fIstty\fP. +.RE +.bP +then \fI\*n\fP updates the terminal settings to reflect any altered +values such as its size in rows or columns. +This affects the values shown by \fIstty\fP. +.bP +finally, \fI\*n\fP writes the shell command for setting the +environment variables to the standard output. +.SH EXAMPLES +For \*n's output to take effect, +\fI\*n\fP must either be evaluated as part of the command line (usually done with a shell alias or function) or else redirected to a file which can then be read in. From the C shell (usually @@ -28,7 +106,7 @@ known as \fI/bin/csh\fP), the following alias could be defined in the user's \fI.cshrc\fP: .sp .nf - % alias rs \*(AQset noglob; eval \fC\`\fPresize\fC\`\fP\*(AQ + % alias rs \*(AQset noglob; eval \fC\`\fP\*n\fC\`\fP\*(AQ .fi .sp After resizing the window, the user would type: @@ -43,41 +121,45 @@ functions will need to send the output to a temporary file and then read it back in with the \*(``.\*('' command: .sp .nf - $ resize > /tmp/out + $ \*n > /tmp/out $ .\0/tmp/out .fi -.PP -.I Resize -determines the user's current shell by first checking if \fB$SHELL\fP -is set, and using that. -Otherwise it determines the user's shell by looking in the password file. -Generally Bourne-shell variants (including \fIksh\fP) -do not modify \fB$SHELL\fP, -so it is possible for \fIresize\fP to be confused if one runs -\fIresize\fP from a Bourne shell spawned from a C shell. .SH OPTIONS -The following options may be used with \fIresize\fP: -.TP 8 -.B \-u -This option indicates that Bourne shell commands should be generated even if -the user's current shell isn't \fI/bin/sh\fP. +The following options may be used with \fI\*n\fP: .TP 8 .B \-c This option indicates that C shell commands should be generated even if the -user's current shell isn't \fI/bin/csh\fP. +user's current shell is not \fI/bin/csh\fP. .TP 8 .B \-s \fR[\fIrows columns\fP] This option indicates that Sun console escape sequences will be used instead of the VT100-style \fIxterm\fP escape codes. If \fIrows\fP and -\fIcolumns\fP are given, \fIresize\fP will ask the \fIxterm\fP to resize -itself. -However, the window manager may choose to disallow the change. +\fIcolumns\fP are given, +\fI\*n\fP will ask the \fIxterm\fP to resize itself using those values. +.IP +Both of the escape sequences used for this option +(first to obtain the window size and +second to modify it) +are subject to \fIxterm\fP's \fBallowWindowOps\fP resource setting. +The window manager may also choose to disallow the change. +.IP +The VT100-style escape sequence used to determine the +screen size always works for VT100-compatible terminals. +VT100s have no corresponding way to modify the screensize. +.TP 8 +.B \-u +This option indicates that Bourne shell commands should be generated even if +the user's current shell is not \fI/bin/sh\fP. +.TP 8 +.B \-v +This causes \fI\*n\fP to print a version number to the standard output, +and then exit. .PP Note that the Sun console escape sequences are recognized by XFree86 \fIxterm\fP and by \fIdtterm\fP. -The \fIresize\fP program may be installed as \fIsunsize\fP, +The \fI\*n\fP program may be installed as \fIsunsize\fP, which causes makes it assume the \fB\-s\fP option. .PP The \fIrows\fP and @@ -92,19 +174,44 @@ for the base termcap entry to modify. user's alias for the command. .SH ENVIRONMENT .TP 15 +SHELL +.I \*N +determines the user's current shell by first checking if \fB$SHELL\fP +is set, and using that. +Otherwise it determines the user's shell by looking in the password file +(/etc/passwd). +Generally Bourne-shell variants (including \fIksh\fP) +do not modify \fB$SHELL\fP, +so it is possible for \fI\*n\fP to be confused if one runs +\fI\*n\fP from a Bourne shell spawned from a C shell. +.TP 15 TERM -set to "__default_termname__" if not already set. +.I \*N +sets this to "__default_termname__" if not already set. .TP 15 TERMCAP -variable set on systems using termcap +.I \*N +sets this variable on systems using termcap, +e.g., when \*n is linked with the \fItermcap\fP library +rather than a \fIterminfo\fP library. +The latter does not provide the complete text for a termcap entry. .TP 15 COLUMNS, LINES -variables set on systems using terminfo +.I \*N +sets these variables on systems using terminfo. +Many applications (including the curses library) +use those variables when set to override their screensize. .SH "SEE ALSO" -csh(1), tset(1), xterm(__mansuffix__) +use_env(3) +.br +csh(1), stty(1), tset(1) +.br +xterm(__mansuffix__) .SH AUTHORS Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley) .br +Thomas Dickey (invisible-island.net). +.br Copyright (c) 1984, 1985 by X Consortium .br See diff --git a/app/xterm/resize/Makefile b/app/xterm/resize/Makefile index 72d61002e..3b42e51c9 100644 --- a/app/xterm/resize/Makefile +++ b/app/xterm/resize/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2011/06/23 22:48:59 naddy Exp $ +# $OpenBSD: Makefile,v 1.6 2013/03/09 14:45:39 matthieu Exp $ PROG= resize MAN= resize.1 @@ -13,7 +13,7 @@ CPPFLAGS+= -I${.CURDIR}/.. -I${X11BASE}/include \ X11BASE?= /usr/X11R6 MANDIR= ${X11BASE}/man/man -SRCS= resize.c xstrings.c +SRCS= resize.c version.c xstrings.c resize.1: resize.man sed -e 's#__vendorversion__#"X Window System"#g' \ diff --git a/app/xterm/screen.c b/app/xterm/screen.c index 352cd25ea..d3d7822dd 100644 --- a/app/xterm/screen.c +++ b/app/xterm/screen.c @@ -1,7 +1,7 @@ -/* $XTermId: screen.c,v 1.469 2012/10/25 23:12:20 tom Exp $ */ +/* $XTermId: screen.c,v 1.475 2013/02/13 00:42:30 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -72,6 +72,10 @@ #include <assert.h> #include <signal.h> +#ifndef _Xconst +#define _Xconst const /* Solaris 7 workaround */ +#endif /* _Xconst */ + #define inSaveBuf(screen, buf, inx) \ ((buf) == (screen)->saveBuf_index && \ ((inx) < (screen)->savelines || (screen)->savelines == 0)) @@ -323,8 +327,9 @@ allocScrnData(TScreen * screen, unsigned nrow, unsigned ncol) size_t length; AlignValue(ncol); - length = (nrow * sizeofScrnRow(screen, ncol)); - if ((result = (Char *) calloc(length, sizeof(Char))) == 0) + length = ((nrow + 1) * sizeofScrnRow(screen, ncol)); + if (length == 0 + || (result = (Char *) calloc(length, sizeof(Char))) == 0) SysError(ERROR_SCALLOC2); TRACE(("allocScrnData %ux%u -> %lu -> %p..%p\n", @@ -442,10 +447,6 @@ Reallocate(XtermWidget xw, return 0; } - if (screen->widestLine < ncol) - screen->widestLine = (Dimension) ncol; - ncol = screen->widestLine; - oldBufData = *sbufaddr; TRACE(("Reallocate %dx%d -> %dx%d\n", oldrow, MaxCols(screen), nrow, ncol)); @@ -545,10 +546,6 @@ ReallocateBufOffsets(XtermWidget xw, assert(nrow != 0); assert(ncol != 0); - if (screen->widestLine < ncol) - screen->widestLine = (Dimension) ncol; - ncol = screen->widestLine; - oldBufData = *sbufaddr; oldBufHead = *sbuf; @@ -1865,7 +1862,9 @@ ScreenResize(XtermWidget xw, /* update buffers if the screen has changed size */ if (MaxRows(screen) != rows || MaxCols(screen) != cols) { +#if !OPT_SAVE_LINES int whichBuf = 0; +#endif int delta_rows = rows - MaxRows(screen); #if OPT_TRACE int delta_cols = cols - MaxCols(screen); @@ -2124,8 +2123,10 @@ ScreenResize(XtermWidget xw, screen->cursorp.row += move_down_by; ScrollSelection(screen, move_down_by, True); +#if !OPT_SAVE_LINES if (whichBuf) SwitchBufPtrs(screen, whichBuf); /* put the pointers back */ +#endif } } @@ -2881,7 +2882,7 @@ FullScreen(XtermWidget xw, int new_ewmh_mode) TRACE(("FullScreen %d:%s\n", new_ewmh_mode, BtoS(new_ewmh_mode))); - if (new_ewmh_mode < 0 || new_ewmh_mode > MAX_EWMH_MODE) { + if (new_ewmh_mode < 0 || new_ewmh_mode >= MAX_EWMH_MODE) { TRACE(("BUG: FullScreen %d\n", new_ewmh_mode)); return; } else if (new_ewmh_mode == 0) { diff --git a/app/xterm/scrollbar.c b/app/xterm/scrollbar.c index 07fee3891..8c554e1e1 100644 --- a/app/xterm/scrollbar.c +++ b/app/xterm/scrollbar.c @@ -707,7 +707,9 @@ AlternateScroll(Widget w, long amount) amount /= FontHeight(screen); memset(&reply, 0, sizeof(reply)); - reply.a_type = ANSI_CSI; + reply.a_type = ((xw->keyboard.flags & MODE_DECCKM) + ? ANSI_SS3 + : ANSI_CSI); if (amount > 0) { reply.a_final = 'B'; } else { diff --git a/app/xterm/trace.c b/app/xterm/trace.c index 420d2ead5..ea495556c 100644 --- a/app/xterm/trace.c +++ b/app/xterm/trace.c @@ -1,7 +1,7 @@ -/* $XTermId: trace.c,v 1.142 2012/11/22 20:19:54 tom Exp $ */ +/* $XTermId: trace.c,v 1.145 2013/02/06 09:51:17 tom Exp $ */ /* - * Copyright 1997-2011,2012 by Thomas E. Dickey + * Copyright 1997-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -35,6 +35,7 @@ */ #include <xterm.h> /* for definition of GCC_UNUSED */ +#include <version.h> #if OPT_TRACE @@ -749,6 +750,29 @@ no_error(Display * dpy GCC_UNUSED, XErrorEvent * event GCC_UNUSED) return 1; } +const char * +ModifierName(unsigned modifier) +{ + const char *s = ""; + if (modifier & ShiftMask) + s = " Shift"; + else if (modifier & LockMask) + s = " Lock"; + else if (modifier & ControlMask) + s = " Control"; + else if (modifier & Mod1Mask) + s = " Mod1"; + else if (modifier & Mod2Mask) + s = " Mod2"; + else if (modifier & Mod3Mask) + s = " Mod3"; + else if (modifier & Mod4Mask) + s = " Mod4"; + else if (modifier & Mod5Mask) + s = " Mod5"; + return s; +} + void TraceTranslations(const char *name, Widget w) { diff --git a/app/xterm/trace.h b/app/xterm/trace.h index 56e459218..4d058e62d 100644 --- a/app/xterm/trace.h +++ b/app/xterm/trace.h @@ -1,4 +1,4 @@ -/* $XTermId: trace.h,v 1.67 2012/11/22 20:22:15 tom Exp $ */ +/* $XTermId: trace.h,v 1.68 2013/02/06 09:52:14 tom Exp $ */ /* * Copyright 1997-2011,2012 by Thomas E. Dickey @@ -116,6 +116,18 @@ extern XtGeometryResult TraceResizeRequest(const char * /* fn */, int /* ln */, (reqwide), (reqhigh), \ (gotwide), (gothigh)) +extern const char * ModifierName(unsigned /* modifier */); +#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s" +#define ARG_MODIFIER_NAMES(state) \ + ModifierName(state & ShiftMask), \ + ModifierName(state & LockMask), \ + ModifierName(state & ControlMask), \ + ModifierName(state & Mod1Mask), \ + ModifierName(state & Mod2Mask), \ + ModifierName(state & Mod3Mask), \ + ModifierName(state & Mod4Mask), \ + ModifierName(state & Mod5Mask) + #else #define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \ diff --git a/app/xterm/util.c b/app/xterm/util.c index 0e6636fee..0d6406dcc 100644 --- a/app/xterm/util.c +++ b/app/xterm/util.c @@ -1,7 +1,7 @@ -/* $XTermId: util.c,v 1.598 2012/10/05 00:26:28 tom Exp $ */ +/* $XTermId: util.c,v 1.600 2013/02/04 00:46:58 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -3541,24 +3541,17 @@ drawXtermText(XtermWidget xw, (unsigned) (last - first), on_wide); } #if OPT_WIDE_CHARS - if (ucs_workaround(xw, ch, flags, gc, - x, y, - chrset, on_wide)) { - /* - * if true, we drew at least one cell whether or not it is - * printable - */ - if (ch_width <= 0) - ch_width = 1; - } else -#endif - { - if (ch_width <= 0) - ch_width = 1; - xtermDrawBoxChar(xw, ch, flags, gc, - x, y, - ch_width); + /* + * One way or another, we will draw at least one cell. + */ + if (ch_width <= 0) + ch_width = 1; + if (!ucs_workaround(xw, ch, flags, gc, x, y, chrset, on_wide)) { + xtermDrawBoxChar(xw, ch, flags, gc, x, y, ch_width); } +#else + xtermDrawBoxChar(xw, ch, flags, gc, x, y, ch_width); +#endif x += (ch_width * FontWidth(screen)); first = last + 1; drewBoxes = True; diff --git a/app/xterm/uxterm.man b/app/xterm/uxterm.man index b3e95089d..fe99a9132 100644 --- a/app/xterm/uxterm.man +++ b/app/xterm/uxterm.man @@ -1,4 +1,4 @@ -.\" $XTermId: uxterm.man,v 1.5 2012/10/23 23:25:53 tom Exp $ +.\" $XTermId: uxterm.man,v 1.6 2013/01/01 00:40:55 tom Exp $ .\" .\" Copyright 2001, 2004 Branden Robinson .\" @@ -19,22 +19,33 @@ .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER .\" DEALINGS IN THE SOFTWARE. +.\" +.ds N Uxterm +.ds n uxterm +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds AQ \(aq +.el .ds AQ ' +.ie \n(.g .ds `` \(lq +.el .ds `` `` +.ie \n(.g .ds '' \(rq +.el .ds '' '' +.\" .TH UXTERM 1 "__app_date__" "__app_version__" "X Window System" .SH NAME uxterm \- X terminal emulator for Unicode (UTF-8) environments .SH SYNOPSIS -.B uxterm +.B \*n [ .I xterm-options ] .SH DESCRIPTION -.B uxterm +.B \*n is a wrapper around the .BR xterm(1) -program that invokes the latter program with the \(oqU__default_class__\(cq X resource +program that invokes the latter program with the \*(``U__default_class__\*('' X resource class set. All arguments to -.B uxterm +.B \*n are passed to .B xterm without processing; the @@ -47,29 +58,29 @@ See the manual page for more information on .IR xterm-options . .PP -The environment's locale settings (see \(lqENVIRONMENT\(rq below) are +The environment's locale settings (see \*(``ENVIRONMENT\*('' below) are used to discern the locale's character set. -If no current locale can be determined, the locale \(oqen_US\(cq (the +If no current locale can be determined, the locale \*(``en_US\*('' (the English language as used in the territory of the United States) is assumed. The .BR locale(1) utility is used to determine whether the system supports the selected locale. If it does not, -.B uxterm +.B \*n will exit with an error and report the output of .BR locale . .PP -.B Note: uxterm +.B Note: \*n may produce unexpected results if the current locale is set to one in which the UTF-8 character encoding is not supported, or if fonts using the ISO 10646-1 character set are not available. -In the Debian system, the \(oqxfonts\-base\(cq package provides the fonts +In the Debian system, the \*(``xfonts\-base\*('' package provides the fonts that -.B uxterm +.B \*n uses by default. To change the fonts -.B uxterm +.B \*n uses, edit the .I __apploaddir__/U__default_class__ file. diff --git a/app/xterm/proto.h b/app/xterm/version.c index d2463ceeb..07d9f02aa 100644 --- a/app/xterm/proto.h +++ b/app/xterm/version.c @@ -1,12 +1,10 @@ +/* $XTermId: version.c,v 1.1 2013/01/01 12:10:44 tom Exp $ */ + /* - * $XTermId: proto.h,v 1.10 2003/10/27 01:07:57 tom Exp $ - * ---------------------------------------------------------------------------- - * this file is part of xterm + * Copyright 2013 by Thomas E. Dickey * - * Copyright 1996-2008,2003 by Thomas E. Dickey - * * All Rights Reserved - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -14,10 +12,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -25,38 +23,52 @@ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. - * ---------------------------------------------------------------------------- */ -#ifndef included_proto_h -#define included_proto_h - -#define PROTO_XT_ACTIONS_ARGS \ - (Widget w, XEvent *event, String *params, Cardinal *num_params) +#include <ctype.h> +#include <xterm.h> +#include <version.h> -#define PROTO_XT_CALLBACK_ARGS \ - (Widget gw, XtPointer closure, XtPointer data) - -#define PROTO_XT_CVT_SELECT_ARGS \ - (Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format) - -#define PROTO_XT_EV_HANDLER_ARGS \ - (Widget w, XtPointer closure, XEvent *event, Boolean *cont) - -#define PROTO_XT_SEL_CB_ARGS \ - (Widget w, XtPointer client_data, Atom *selection, Atom *type, XtPointer value, unsigned long *length, int *format) +/* + * Returns the version-string used in the "-v' message as well as a few other + * places. It is derived (when possible) from the __vendorversion__ symbol + * that some newer imake configurations define. + */ +char * +xtermVersion(void) +{ + static char vendor_version[] = __vendorversion__; + static char *result; -#ifdef SIGNALRETURNSINT -#define SIGNAL_T int -#define SIGNAL_RETURN return 0 -#else -#define SIGNAL_T void -#define SIGNAL_RETURN return -#endif + if (result == 0) { + char *vendor = vendor_version; + char first[BUFSIZ]; + char second[BUFSIZ]; -#endif/*included_proto_h*/ + result = CastMallocN(char, strlen(vendor) + 9); + if (result == 0) + result = vendor; + else { + /* some vendors leave trash in this string */ + for (;;) { + if (!strncmp(vendor, "Version ", (size_t) 8)) + vendor += 8; + else if (isspace(CharOf(*vendor))) + ++vendor; + else + break; + } + if (strlen(vendor) < BUFSIZ && + sscanf(vendor, "%[0-9.] %[A-Za-z_0-9.]", first, second) == 2) + sprintf(result, "%s %s(%d)", second, first, XTERM_PATCH); + else + sprintf(result, "%s(%d)", vendor, XTERM_PATCH); + } + } + return result; +} diff --git a/app/xterm/version.h b/app/xterm/version.h index 02e36cf74..4866bc9d4 100644 --- a/app/xterm/version.h +++ b/app/xterm/version.h @@ -1,7 +1,7 @@ -/* $XTermId: version.h,v 1.352 2012/11/26 01:07:33 tom Exp $ */ +/* $XTermId: version.h,v 1.360 2013/02/26 23:48:28 tom Exp $ */ /* - * Copyright 1998-2011,2012 by Thomas E. Dickey + * Copyright 1998-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -30,15 +30,21 @@ * authorization. */ +#ifndef included_version_h +#define included_version_h /* * These definitions are used to build the string that's printed in response to * "xterm -version", or embedded in "xterm -help". It usually indicates the - * version of X to which this version of xterm has been built. The number in - * parentheses is my patch number (Thomas E. Dickey). + * version of X to which this version of xterm has been built. The resulting + * number in parentheses is my patch number (Thomas E. Dickey). */ -#define XTERM_PATCH 287 -#define XTERM_DATE 2012-11-25 +#define XTERM_PATCH 291 +#define XTERM_DATE 2013-02-26 #ifndef __vendorversion__ #define __vendorversion__ "XTerm/OpenBSD" #endif + +extern char *xtermVersion(void); + +#endif /* included_version_h */ diff --git a/app/xterm/wcwidth.c b/app/xterm/wcwidth.c index 77e101556..edeebb8b2 100644 --- a/app/xterm/wcwidth.c +++ b/app/xterm/wcwidth.c @@ -1,4 +1,4 @@ -/* $XTermId: wcwidth.c,v 1.22 2009/02/13 19:53:12 tom Exp $ */ +/* $XTermId: wcwidth.c,v 1.24 2013/02/03 18:54:31 tom Exp $ */ /* $XFree86: xc/programs/xterm/wcwidth.c,v 1.9 2006/06/19 00:36:52 dickey Exp $ */ @@ -132,54 +132,83 @@ int mk_wcwidth(wchar_t ucs) * uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c */ static const struct interval combining[] = { - { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 }, - { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, - { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, - { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 }, - { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, + { 0x0300, 0x036F }, { 0x0483, 0x0489 }, { 0x0591, 0x05BD }, + { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, { 0x05C4, 0x05C5 }, + { 0x05C7, 0x05C7 }, { 0x0600, 0x0604 }, { 0x0610, 0x061A }, + { 0x064B, 0x065F }, { 0x0670, 0x0670 }, { 0x06D6, 0x06DD }, + { 0x06DF, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, - { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 }, - { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, - { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, - { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, - { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, - { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, - { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, + { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0816, 0x0819 }, + { 0x081B, 0x0823 }, { 0x0825, 0x0827 }, { 0x0829, 0x082D }, + { 0x0859, 0x085B }, { 0x08E4, 0x08FE }, { 0x0900, 0x0902 }, + { 0x093A, 0x093A }, { 0x093C, 0x093C }, { 0x0941, 0x0948 }, + { 0x094D, 0x094D }, { 0x0951, 0x0957 }, { 0x0962, 0x0963 }, + { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, + { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, + { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, + { 0x0A4B, 0x0A4D }, { 0x0A51, 0x0A51 }, { 0x0A70, 0x0A71 }, + { 0x0A75, 0x0A75 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, - { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D }, - { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 }, - { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, - { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC }, - { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, - { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, + { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B44 }, { 0x0B4D, 0x0B4D }, + { 0x0B56, 0x0B56 }, { 0x0B62, 0x0B63 }, { 0x0B82, 0x0B82 }, + { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, + { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, + { 0x0C62, 0x0C63 }, { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF }, + { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, { 0x0CE2, 0x0CE3 }, + { 0x0D41, 0x0D44 }, { 0x0D4D, 0x0D4D }, { 0x0D62, 0x0D63 }, { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, - { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, + { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F8D, 0x0F97 }, { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, - { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, - { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F }, + { 0x1032, 0x1037 }, { 0x1039, 0x103A }, { 0x103D, 0x103E }, + { 0x1058, 0x1059 }, { 0x105E, 0x1060 }, { 0x1071, 0x1074 }, + { 0x1082, 0x1082 }, { 0x1085, 0x1086 }, { 0x108D, 0x108D }, + { 0x109D, 0x109D }, { 0x1160, 0x11FF }, { 0x135D, 0x135F }, { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B }, - { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, - { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, - { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, - { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, - { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, - { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, - { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, - { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x1A17, 0x1A18 }, { 0x1A56, 0x1A56 }, { 0x1A58, 0x1A5E }, + { 0x1A60, 0x1A60 }, { 0x1A62, 0x1A62 }, { 0x1A65, 0x1A6C }, + { 0x1A73, 0x1A7C }, { 0x1A7F, 0x1A7F }, { 0x1B00, 0x1B03 }, + { 0x1B34, 0x1B34 }, { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, + { 0x1B42, 0x1B42 }, { 0x1B6B, 0x1B73 }, { 0x1B80, 0x1B81 }, + { 0x1BA2, 0x1BA5 }, { 0x1BA8, 0x1BA9 }, { 0x1BAB, 0x1BAB }, + { 0x1BE6, 0x1BE6 }, { 0x1BE8, 0x1BE9 }, { 0x1BED, 0x1BED }, + { 0x1BEF, 0x1BF1 }, { 0x1C2C, 0x1C33 }, { 0x1C36, 0x1C37 }, + { 0x1CD0, 0x1CD2 }, { 0x1CD4, 0x1CE0 }, { 0x1CE2, 0x1CE8 }, + { 0x1CED, 0x1CED }, { 0x1CF4, 0x1CF4 }, { 0x1DC0, 0x1DE6 }, + { 0x1DFC, 0x1DFF }, { 0x200B, 0x200F }, { 0x202A, 0x202E }, + { 0x2060, 0x2064 }, { 0x206A, 0x206F }, { 0x20D0, 0x20F0 }, + { 0x2CEF, 0x2CF1 }, { 0x2D7F, 0x2D7F }, { 0x2DE0, 0x2DFF }, + { 0x302A, 0x302D }, { 0x3099, 0x309A }, { 0xA66F, 0xA672 }, + { 0xA674, 0xA67D }, { 0xA69F, 0xA69F }, { 0xA6F0, 0xA6F1 }, + { 0xA802, 0xA802 }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xA8C4, 0xA8C4 }, { 0xA8E0, 0xA8F1 }, + { 0xA926, 0xA92D }, { 0xA947, 0xA951 }, { 0xA980, 0xA982 }, + { 0xA9B3, 0xA9B3 }, { 0xA9B6, 0xA9B9 }, { 0xA9BC, 0xA9BC }, + { 0xAA29, 0xAA2E }, { 0xAA31, 0xAA32 }, { 0xAA35, 0xAA36 }, + { 0xAA43, 0xAA43 }, { 0xAA4C, 0xAA4C }, { 0xAAB0, 0xAAB0 }, + { 0xAAB2, 0xAAB4 }, { 0xAAB7, 0xAAB8 }, { 0xAABE, 0xAABF }, + { 0xAAC1, 0xAAC1 }, { 0xAAEC, 0xAAED }, { 0xAAF6, 0xAAF6 }, + { 0xABE5, 0xABE5 }, { 0xABE8, 0xABE8 }, { 0xABED, 0xABED }, + { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE26 }, + { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, { 0x101FD, 0x101FD }, { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, - { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, - { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, - { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, - { 0xE0100, 0xE01EF } + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x11001, 0x11001 }, + { 0x11038, 0x11046 }, { 0x11080, 0x11081 }, { 0x110B3, 0x110B6 }, + { 0x110B9, 0x110BA }, { 0x110BD, 0x110BD }, { 0x11100, 0x11102 }, + { 0x11127, 0x1112B }, { 0x1112D, 0x11134 }, { 0x11180, 0x11181 }, + { 0x111B6, 0x111BE }, { 0x116AB, 0x116AB }, { 0x116AD, 0x116AD }, + { 0x116B0, 0x116B5 }, { 0x116B7, 0x116B7 }, { 0x16F8F, 0x16F92 }, + { 0x1D167, 0x1D169 }, { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, + { 0x1D1AA, 0x1D1AD }, { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, + { 0xE0020, 0xE007F }, { 0xE0100, 0xE01EF } }; /* test for 8-bit control characters */ @@ -283,29 +312,34 @@ int mk_wcwidth_cjk(wchar_t ucs) { 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 }, { 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 }, - { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, - { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, - { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B }, - { 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 }, - { 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 }, - { 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E }, - { 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 }, - { 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 }, - { 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F }, - { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 }, - { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, - { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B }, - { 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 }, - { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 }, - { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 }, - { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 }, - { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 }, - { 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 }, - { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 }, - { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 }, - { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F }, - { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF }, - { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } + { 0x2189, 0x2189 }, { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, + { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, + { 0x2200, 0x2200 }, { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, + { 0x220B, 0x220B }, { 0x220F, 0x220F }, { 0x2211, 0x2211 }, + { 0x2215, 0x2215 }, { 0x221A, 0x221A }, { 0x221D, 0x2220 }, + { 0x2223, 0x2223 }, { 0x2225, 0x2225 }, { 0x2227, 0x222C }, + { 0x222E, 0x222E }, { 0x2234, 0x2237 }, { 0x223C, 0x223D }, + { 0x2248, 0x2248 }, { 0x224C, 0x224C }, { 0x2252, 0x2252 }, + { 0x2260, 0x2261 }, { 0x2264, 0x2267 }, { 0x226A, 0x226B }, + { 0x226E, 0x226F }, { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, + { 0x2295, 0x2295 }, { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, + { 0x22BF, 0x22BF }, { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, + { 0x24EB, 0x254B }, { 0x2550, 0x2573 }, { 0x2580, 0x258F }, + { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, + { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, + { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, + { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, + { 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F }, + { 0x2614, 0x2615 }, { 0x261C, 0x261C }, { 0x261E, 0x261E }, + { 0x2640, 0x2640 }, { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, + { 0x2663, 0x2665 }, { 0x2667, 0x266A }, { 0x266C, 0x266D }, + { 0x266F, 0x266F }, { 0x269E, 0x269F }, { 0x26BE, 0x26BF }, + { 0x26C4, 0x26CD }, { 0x26CF, 0x26E1 }, { 0x26E3, 0x26E3 }, + { 0x26E8, 0x26FF }, { 0x273D, 0x273D }, { 0x2757, 0x2757 }, + { 0x2776, 0x277F }, { 0x2B55, 0x2B59 }, { 0x3248, 0x324F }, + { 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD }, { 0x1F100, 0x1F10A }, + { 0x1F110, 0x1F12D }, { 0x1F130, 0x1F169 }, { 0x1F170, 0x1F19A }, + { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } }; /* binary search in table of non-spacing characters */ diff --git a/app/xterm/xstrings.c b/app/xterm/xstrings.c index 395def5ab..9b0e1a868 100644 --- a/app/xterm/xstrings.c +++ b/app/xterm/xstrings.c @@ -1,7 +1,7 @@ -/* $XTermId: xstrings.c,v 1.50 2012/03/30 10:54:12 tom Exp $ */ +/* $XTermId: xstrings.c,v 1.57 2013/02/03 22:11:25 tom Exp $ */ /* - * Copyright 2000-2011,2012 by Thomas E. Dickey + * Copyright 2000-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -64,10 +64,6 @@ x_basename(char *name) char *cp; cp = strrchr(name, '/'); -#ifdef __UNIXOS2__ - if (cp == 0) - cp = strrchr(name, '\\'); -#endif return (cp ? cp + 1 : name); } @@ -168,6 +164,7 @@ login_alias(char *login_name, uid_t uid, struct passwd *in_out) /* use the other passwd-data including shell */ alloc_pw(in_out, &pw2); } else { + free(login_name); login_name = NULL; } } @@ -188,6 +185,7 @@ x_getlogin(uid_t uid, struct passwd *in_out) login_name = login_alias(x_getenv("LOGNAME"), uid, in_out); if (IsEmpty(login_name)) { + free(login_name); login_name = login_alias(x_getenv("USER"), uid, in_out); } #ifdef HAVE_GETLOGIN @@ -199,14 +197,15 @@ x_getlogin(uid_t uid, struct passwd *in_out) */ if (IsEmpty(login_name)) { TRACE2(("...try getlogin\n")); - login_name = login_alias(getlogin(), uid, in_out); + free(login_name); + login_name = login_alias(x_strdup(getlogin()), uid, in_out); } #endif - if (IsEmpty(login_name)) - login_name = in_out->pw_name; - if (!IsEmpty(login_name)) - login_name = x_strdup(login_name); + if (IsEmpty(login_name)) { + free(login_name); + login_name = x_strdup(in_out->pw_name); + } TRACE2(("x_getloginid ->%s\n", NonNull(login_name))); return login_name; @@ -303,6 +302,14 @@ x_skip_nonblanks(String s) return s; } +static const char * +skip_blanks(const char *s) +{ + while (isspace(CharOf(*s))) + ++s; + return s; +} + /* * Split a command-string into an argv[]-style array. */ @@ -312,38 +319,43 @@ x_splitargs(const char *command) char **result = 0; if (command != 0) { - char *blob = x_strdup(command); + const char *first = skip_blanks(command); + char *blob = x_strdup(first); size_t count; size_t n; int state; int pass; - for (pass = 0; pass < 2; ++pass) { - for (n = count = 0, state = 0; command[n] != '\0'; ++n) { - switch (state) { - case 0: - if (!isspace(CharOf(command[n]))) { - state = 1; - if (pass) - result[count] = blob + n; - ++count; - } else { - blob[n] = '\0'; + if (blob != 0) { + for (pass = 0; pass < 2; ++pass) { + for (n = count = 0, state = 0; first[n] != '\0'; ++n) { + switch (state) { + case 0: + if (!isspace(CharOf(first[n]))) { + state = 1; + if (pass) + result[count] = blob + n; + ++count; + } else { + blob[n] = '\0'; + } + break; + case 1: + if (isspace(CharOf(first[n]))) { + blob[n] = '\0'; + state = 0; + } + break; } - break; - case 1: - if (isspace(CharOf(command[n]))) { - blob[n] = '\0'; - state = 0; + } + if (!pass) { + result = TypeCallocN(char *, count + 1); + if (!result) { + free(blob); + break; } - break; } } - if (!pass) { - result = TypeCallocN(char *, count + 1); - if (!result) - break; - } } } else { result = TypeCalloc(char *); @@ -351,6 +363,19 @@ x_splitargs(const char *command) return result; } +/* + * Free storage allocated by x_splitargs(). + */ +void +x_freeargs(char **argv) +{ + if (argv != 0) { + if (*argv != 0) + free(*argv); + free(argv); + } +} + int x_strcasecmp(const char *s1, const char *s2) { @@ -426,17 +451,19 @@ x_strtrim(const char *source) if (source != 0 && *source != '\0') { char *t = x_strdup(source); - s = t; - d = s; - while (isspace(CharOf(*s))) - ++s; - while ((*d++ = *s++) != '\0') { - ; - } - if (*t != '\0') { - s = t + strlen(t); - while (s != t && isspace(CharOf(s[-1]))) { - *--s = '\0'; + if (t != 0) { + s = t; + d = s; + while (isspace(CharOf(*s))) + ++s; + while ((*d++ = *s++) != '\0') { + ; + } + if (*t != '\0') { + s = t + strlen(t); + while (s != t && isspace(CharOf(s[-1]))) { + *--s = '\0'; + } } } result = t; diff --git a/app/xterm/xstrings.h b/app/xterm/xstrings.h index 372d949e8..fb8676dee 100644 --- a/app/xterm/xstrings.h +++ b/app/xterm/xstrings.h @@ -1,4 +1,4 @@ -/* $XTermId: xstrings.h,v 1.27 2012/03/25 23:31:52 tom Exp $ */ +/* $XTermId: xstrings.h,v 1.28 2012/11/26 21:55:10 tom Exp $ */ /* * Copyright 2000-2011,2012 by Thomas E. Dickey @@ -59,6 +59,7 @@ extern int x_strcasecmp(const char * /* s1 */, const char * /* s2 */); extern int x_strncasecmp(const char * /* s1 */, const char * /* s2 */, unsigned /* n */); extern unsigned x_countargv(char ** /* argv */); extern void x_appendargv(char ** /* target */, char ** /* source */); +extern void x_freeargs(char ** /* argv */); /* *INDENT-ON* */ diff --git a/app/xterm/xterm.h b/app/xterm/xterm.h index cf5dbd258..1ab0d9da3 100644 --- a/app/xterm/xterm.h +++ b/app/xterm/xterm.h @@ -1,7 +1,7 @@ -/* $XTermId: xterm.h,v 1.710 2012/10/25 23:18:58 tom Exp $ */ +/* $XTermId: xterm.h,v 1.716 2013/02/03 23:21:00 tom Exp $ */ /* - * Copyright 1999-2011,2012 by Thomas E. Dickey + * Copyright 1999-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -123,7 +123,7 @@ #define HAVE_TCGETATTR 1 #endif -#if defined(__UNIXOS2__) || defined(__SCO__) || defined(__UNIXWARE__) +#if defined(__SCO__) || defined(__UNIXWARE__) #define USE_TERMCAP 1 #endif @@ -286,7 +286,21 @@ extern int errno; /***====================================================================***/ -#include <proto.h> +#define PROTO_XT_ACTIONS_ARGS \ + (Widget w, XEvent *event, String *params, Cardinal *num_params) + +#define PROTO_XT_CALLBACK_ARGS \ + (Widget gw, XtPointer closure, XtPointer data) + +#define PROTO_XT_CVT_SELECT_ARGS \ + (Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format) + +#define PROTO_XT_EV_HANDLER_ARGS \ + (Widget w, XtPointer closure, XEvent *event, Boolean *cont) + +#define PROTO_XT_SEL_CB_ARGS \ + (Widget w, XtPointer client_data, Atom *selection, Atom *type, XtPointer value, unsigned long *length, int *format) + #include <ptyx.h> #if (XtSpecificationRelease >= 6) && !defined(NO_XPOLL_H) && !defined(sun) @@ -327,10 +341,6 @@ extern int errno; #include <setjmp.h> -#if defined(__UNIXOS2__) && !defined(XTERM_MAIN) -#define environ gblenvp /* circumvent a bug */ -#endif - #if !defined(VMS) && !(defined(linux) && defined(__USE_GNU)) && !defined(__hpux) && !defined(_ALL_SOURCE) && !defined(__osf__) extern char **environ; #endif @@ -936,11 +946,7 @@ extern void saveCellData(TScreen * /* screen */, CellData * /* data */, Cardinal extern void restoreCellData(TScreen * /* screen */, CellData * /* data */, Cardinal /* cell */, LineData * /* ld */, int /* column */); /* main.c */ -#ifndef __UNIXOS2__ #define ENVP_ARG /**/ -#else -#define ENVP_ARG , char ** /* envp */ -#endif extern int main (int /* argc */, char ** /* argv */ ENVP_ARG); extern int GetBytesAvailable (int /* fd */); @@ -953,9 +959,7 @@ extern void first_map_occurred (void); #define first_map_occurred() /* nothing */ #endif -#ifdef SIGNAL_T -extern SIGNAL_T Exit (int /* n */) GCC_NORETURN; -#endif +extern void Exit (int /* n */) GCC_NORETURN; #ifndef SIG_ATOMIC_T #define SIG_ATOMIC_T int @@ -989,7 +993,6 @@ extern XtermWidget getXtermWidget (Widget /* w */); extern char *udk_lookup (int /* keycode */, int * /* len */); extern char *xtermEnvEncoding (void); extern char *xtermFindShell (char * /* leaf */, Bool /* warning */); -extern char *xtermVersion (void); extern const char *SysErrorMsg (int /* n */); extern const char *SysReasonMsg (int /* n */); extern int ResetAnsiColorRequest (XtermWidget, char *, int); @@ -1006,7 +1009,7 @@ extern void ChangeGroup(XtermWidget /* xw */, const char * /* attribute */, char extern void ChangeIconName (XtermWidget /* xw */, char * /* name */); extern void ChangeTitle (XtermWidget /* xw */, char * /* name */); extern void ChangeXprop (char * /* name */); -extern void Cleanup (int /* code */); +extern void Cleanup (int /* code */) GCC_NORETURN; extern void HandleBellPropertyChange PROTO_XT_EV_HANDLER_ARGS; extern void HandleEightBitKeyPressed PROTO_XT_ACTIONS_ARGS; extern void HandleEnterWindow PROTO_XT_EV_HANDLER_ARGS; @@ -1016,6 +1019,7 @@ extern void HandleKeyPressed PROTO_XT_ACTIONS_ARGS; extern void HandleLeaveWindow PROTO_XT_EV_HANDLER_ARGS; extern void HandleSpawnTerminal PROTO_XT_ACTIONS_ARGS; extern void HandleStringEvent PROTO_XT_ACTIONS_ARGS; +extern void NormalExit (void); extern void Panic (const char * /* s */, int /* a */); extern void Redraw (void); extern void ReverseOldColors (void); diff --git a/app/xterm/xterm.log.html b/app/xterm/xterm.log.html index 4f5c31007..862ab36f1 100644 --- a/app/xterm/xterm.log.html +++ b/app/xterm/xterm.log.html @@ -3,7 +3,7 @@ ***************************************************************************** * this file is part of xterm * * * - * Copyright 1997-2011,2012 by Thomas E. Dickey * + * Copyright 1997-2012,2013 by Thomas E. Dickey * * * * All Rights Reserved * * * @@ -31,7 +31,7 @@ * sale, use or other dealings in this Software without prior written * * authorization. * ***************************************************************************** - $XTermId: xterm.log.html,v 1.1282 2012/11/26 00:52:40 tom Exp $ + $XTermId: xterm.log.html,v 1.1319 2013/02/27 00:19:22 tom Exp $ --> <html> @@ -52,7 +52,7 @@ <a href= "http://invisible-island.net/">http://invisible-island.net/</a><a href="http://invisible-island.net/xterm/">xterm/</a><br> - Copyright © 1997-2011,2012 by <a href= + Copyright © 1997-2012,2013 by <a href= "mailto:dickey@invisible-island.net">Thomas E. Dickey</a> <hr> @@ -70,6 +70,14 @@ the latest version of this file.</p> <ul> + <li><a href="#xterm_291">Patch #291 - 2013/02/26</a></li> + + <li><a href="#xterm_290">Patch #290 - 2013/02/12</a></li> + + <li><a href="#xterm_289">Patch #289 - 2013/02/08</a></li> + + <li><a href="#xterm_288">Patch #288 - 2013/01/09</a></li> + <li><a href="#xterm_287">Patch #287 - 2012/11/25</a></li> <li><a href="#xterm_286">Patch #286 - 2012/10/29</a></li> @@ -857,6 +865,164 @@ <li><a href="#xterm_01">Patch #1 - 1996/1/6</a></li> </ul> + <h1><a name="xterm_291" id="xterm_291">Patch #291 - + 2013/02/26</a></h1> + + <ul> + <li>add validity check for xterm widget parameter to + <code>AlternateScroll</code> function, needed to handle wheel + mouse events in the scrollbar area since <a href= + "#xterm_282">patch #282</a> changes which introduced + <code>alternateScroll</code> feature (Redhat #874327).</li> + </ul> + + <h1><a name="xterm_290" id="xterm_290">Patch #290 - + 2013/02/12</a></h1> + + <ul> + <li>revert of <a href="#xterm_282">patch #282</a> change was + incomplete (report by Jim Reisert).</li> + + <li>fix typo in manpage (report by Vincent Lefevre).</li> + </ul> + + <h1><a name="xterm_289" id="xterm_289">Patch #289 - + 2013/02/08</a></h1> + + <ul> + <li>revert the <a href="#xterm_282">patch #282</a> change which + restored "lost" text after shrinking/growing the screen size. + If the screen was updated between the two resizing operations, + unexpected text might be shown at the end (report/testcase by + Joe Peterson).</li> + + <li>reverse the arrow-keys sent for + <code>alternateScroll</code> to match the usage in browsers + (suggested by Dieter Roelants).</li> + + <li>modify mouse reports to consistently indicate motion events + whether or not a button is pressed. Old behavior (since + <a href="#xterm_127">patch #127</a> modified encoding for wheel + mouse) showed only that the button was released if no button + had been pressed (report by Andy Koppe).</li> + + <li>correct and improve behavior for SGR 1006 mouse protocol on + button release in any-event mode. Initial implementation in + <a href="#xterm_277">patch #277</a> left internal state showing + the last button pressed when reporting motion events. It now + keeps track of all buttons which have been pressed and + released, showing the lowest remaining button by number in the + response (reports by Hayaki Saito, Andy Koppe).</li> + + <li>fix inconsistency between <code>TermColors</code> and + <code>OscTextColors</code> enums which interchanged values for + tektronix cursor color and highlight foreground in control + sequences in <a href="#xterm_225">patch #225</a> (report/patch + by Peder Stray).</li> + + <li>fix inconsistent use of noreturn-attribute in + <code>Exit</code> function which interfered with analysis by + clang.</li> + + <li>remove incorrect <code>free</code> used in computation of + <code>XTERM_SHELL</code> variable, from Coverity fixes in + <a href="#xterm_288">patch #288</a> (FreeBSD #175782).</li> + + <li>add <code>--with-valgrind</code> option to configure script + for consistency with my other programs.</li> + + <li>update table of ambiguous width characters in wcwidth.c + based on Unicode 6.2.0</li> + + <li>update table of combining characters in wcwidth.c based on + Unicode 6.2.0</li> + + <li>update precompose.c based on Unicode 6.2.0</li> + </ul> + + <h1><a name="xterm_288" id="xterm_288">Patch #288 - + 2013/01/09</a></h1> + + <ul> + <li>fix a special case in <code>ShowCursor</code> where the + foreground and background colors of the current position are + the same. In that case, choose the further of the window's + foreground and background colors for the cursor color.</li> + + <li>modify <code>alternateScroll</code> feature added in + <a href="#xterm_282">patch #282</a> to use either + <code>CSI</code> or <code>SS3</code> according to the cursor + keys application mode setting, to simplify using it in vi, etc. + (suggested by Dietar Roelants).</li> + + <li>revise manpage for <code>resize</code> to clarify the + changes which <code>resize</code> may make to the terminal + settings as well as to the terminal itself.</li> + + <li>remove code such as <code>struct ttysize</code>, used for + SunOS 3 and 4.</li> + + <li>modify configure script and makefile to check for + <code>groff</code> and suppress groff-specific rules if groff + is not found.</li> + + <li>modify ctlseqs.ms and makefile to work around bugs in + <code>grohtml</code> which cause ".png" files to be truncated + when producing html documentation.</li> + + <li>modify suffix rules for "make docs" to make the names of + the generated ".png" files predictable, helping to work around + longstanding problems with this feature of groff—none of + its releases work for <em>all</em> of xterm's tables..</li> + + <li>correct typo in ctlseqs.ms for DECIC and DECDC; the + character preceding the final "<code>~</code>" is an ASCII + single-quote "<code>'</code>" rather than a space (report by + Paul LeoNerd Evans).</li> + + <li>update CF_GCC_VERSION macro, handling both Debian and + Darwin.</li> + + <li>improve configure script checks for the + <code>--with-desktop-category</code> option. After <a href= + "#xterm_280">patch #280</a> changes, if no value was given for + this option, and no existing desktop files found for + comparison, the incorrect "auto" value was passed into the + generated desktop file (report by Julien Cristau).</li> + + <li>modify sample build-scripts to disable check for + <code>imake</code> due to code-rot in Xorg.</li> + + <li>add <code>-v</code> command-line option to + <code>resize</code>, reporting the same version string as + <code>xterm</code> and the two shell-wrappers.</li> + + <li>make name-transformation apply to other occurrences of + <code>resize</code>, other manpages.</li> + + <li>special-case the name-transformation in xterm's manpage in + the NAME section so that the result works with + <code>makewhatis</code> (report by Julien Cristau).</li> + + <li>modify install-rules for manpages to put each program's + respective transformed name into the header rather than + xterm's.</li> + + <li>remove deprecated files: proto.h, os2main.c</li> + + <li>minor fixes based on Coverity scan, including: + + <ul> + <li>correct caching of Atom value for the font menu's + "Selection" entry.</li> + + <li>ensure that utmp/utmpx calls do not depend upon + trailing nulls in the <code>ut_id</code> and + <code>ut_line</code> values.</li> + </ul> + </li> + </ul> + <h1><a name="xterm_287" id="xterm_287">Patch #287 - 2012/11/25</a></h1> diff --git a/app/xterm/xterm.man b/app/xterm/xterm.man index 0656348e0..f5048b4c2 100644 --- a/app/xterm/xterm.man +++ b/app/xterm/xterm.man @@ -1,5 +1,5 @@ '\" t -.\" $XTermId: xterm.man,v 1.554 2012/11/22 18:42:30 tom Exp $ +.\" $XTermId: xterm.man,v 1.556 2013/02/13 00:47:18 tom Exp $ .\" .\" Copyright 1996-2011,2012 by Thomas E. Dickey .\" @@ -85,7 +85,7 @@ .el .ds '' '' .TH XTERM 1 "__app_date__" "__app_version__" "X Window System" .SH NAME -\*n \- terminal emulator for X +xterm \- terminal emulator for X .SH SYNOPSIS .B \*n [\-\fItoolkitoption\fP ...] [\-\fIoption\fP ...] [\fIshell\fP] @@ -3785,7 +3785,7 @@ Set window/icon labels using hexadecimal Query window/icon labels using hexadecimal .TP 5 2 -Set window/icon labels using UTF-8 (overrides \fButf8Titles\fP resource). +Set window/icon labels using UTF-8 (overrides \fButf8Title\fP resource). .TP 5 3 Query window/icon labels using UTF-8 diff --git a/app/xterm/xterm_io.h b/app/xterm/xterm_io.h index 7c6f5deca..bde26a3ad 100644 --- a/app/xterm/xterm_io.h +++ b/app/xterm/xterm_io.h @@ -1,7 +1,7 @@ -/* $XTermId: xterm_io.h,v 1.54 2012/03/16 09:48:56 tom Exp $ */ +/* $XTermId: xterm_io.h,v 1.56 2013/01/06 15:20:45 tom Exp $ */ /* - * Copyright 2000-2011,2012 by Thomas E. Dickey + * Copyright 2000-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -52,10 +52,6 @@ #define USE_SYSV_TERMIO #endif -#ifdef __UNIXOS2__ -#define USE_SYSV_TERMIO -#endif - #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__) || defined(__hpux) #ifndef USE_POSIX_TERMIOS #define USE_POSIX_TERMIOS @@ -171,11 +167,6 @@ #include <sys/ptem.h> /* get struct winsize */ #endif #endif /* USE_USG_PTYS */ -#elif defined(sun) && !defined(SVR4) -#include <sys/ttycom.h> -#ifdef TIOCSWINSZ -#undef TIOCSSIZE -#endif #endif /* SYSV */ /* @@ -186,56 +177,6 @@ #define TIOCSPGRP (_IOW('t', 118, pid_t)) #endif -#ifdef __UNIXOS2__ - -#define XFREE86_PTY 0x76 - -#define XTY_TIOCSETA 0x48 -#define XTY_TIOCSETAW 0x49 -#define XTY_TIOCSETAF 0x4a -#define XTY_TIOCCONS 0x4d -#define XTY_TIOCSWINSZ 0x53 -#define XTY_ENADUP 0x5a -#define XTY_TRACE 0x5b -#define XTY_TIOCGETA 0x65 -#define XTY_TIOCGWINSZ 0x66 -#define PTMS_GETPTY 0x64 -#define PTMS_BUFSZ 14 - -#ifndef NCCS -#define NCCS 11 -#endif - -#define TIOCCONS 108 -#define TIOCSWINSZ 113 -#define TIOCGWINSZ 117 - -struct pt_termios -{ - unsigned short c_iflag; - unsigned short c_oflag; - unsigned short c_cflag; - unsigned short c_lflag; - unsigned char c_cc[NCCS]; - long _reserved_[4]; -}; - -struct winsize { - unsigned short ws_row; /* rows, in characters */ - unsigned short ws_col; /* columns, in characters */ - unsigned short ws_xpixel; /* horizontal size, pixels */ - unsigned short ws_ypixel; /* vertical size, pixels */ -}; -#define TTYSIZE_STRUCT struct winsize -#define USE_STRUCT_WINSIZE 1 - -#ifdef XTERM_MAIN -extern int ptioctl(int fd, int func, void* data); -#define ioctl ptioctl -#endif - -#endif /* __UNIXOS2__ */ - #ifdef __hpux #include <sys/bsdtty.h> /* defines TIOCSLTC */ #endif @@ -283,32 +224,19 @@ extern int ptioctl(int fd, int func, void* data); #endif #if !defined(TTYSIZE_STRUCT) -#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4)) -#define USE_STRUCT_TTYSIZE 1 -#define TTYSIZE_STRUCT struct ttysize -#elif defined(TIOCSWINSZ) +#if defined(TIOCSWINSZ) #define USE_STRUCT_WINSIZE 1 #define TTYSIZE_STRUCT struct winsize -#endif /* sun vs TIOCSWINSZ */ -#endif /* TTYSIZE_STRUCT */ - -#if defined(USE_STRUCT_TTYSIZE) - -#define TTYSIZE_STRUCT struct ttysize -#define GET_TTYSIZE(fd, data) ioctl(fd, TIOCGSIZE, &data) -#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSSIZE, &data) -#define TTYSIZE_COLS(data) data.ts_cols -#define TTYSIZE_ROWS(data) data.ts_lines - -#elif defined(USE_STRUCT_WINSIZE) - -#define TTYSIZE_STRUCT struct winsize #define GET_TTYSIZE(fd, data) ioctl(fd, TIOCGWINSZ, (char *) &data) #define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data) #define TTYSIZE_COLS(data) data.ws_col #define TTYSIZE_ROWS(data) data.ws_row +#endif /* TIOCSWINSZ */ +#endif /* TTYSIZE_STRUCT */ -#endif /* (USE_STRUCT_TTYSIZE) */ +#ifndef USE_STRUCT_WINSIZE +#error "There is a configuration error with struct winsize ifdef" +#endif #if OPT_TRACE #define TRACE_TTYSIZE(fd, id) { \ diff --git a/app/xterm/xtermcfg.hin b/app/xterm/xtermcfg.hin index bebae9267..a3d098e4f 100644 --- a/app/xterm/xtermcfg.hin +++ b/app/xterm/xtermcfg.hin @@ -1,7 +1,7 @@ -/* $XTermId: xtermcfg.hin,v 1.196 2012/10/05 00:27:29 tom Exp $ */ +/* $XTermId: xtermcfg.hin,v 1.197 2013/02/03 22:58:03 tom Exp $ */ /* - * Copyright 1997-2011,2012 by Thomas E. Dickey + * Copyright 1997-2012,2013 by Thomas E. Dickey * * All Rights Reserved * @@ -201,6 +201,7 @@ #ifndef __cplusplus #undef GCC_PRINTF #undef GCC_PRINTFLIKE +#undef GCC_NORETURN #undef GCC_UNUSED #endif |