Integrate changes from Thomas Dickey's luit-20100601 fork

    * add -alias option to allow override of locale.alias pathname.
    * improve fix waitForInput as suggested in Freedesktop #26383.
    * fix warnings from clang --analyze
Signed-off-by: Jeremy Huddleston Sequoia's avatarJeremy Huddleston <jeremyhu@apple.com>
parent 3b2bbab4
dnl ---------------------------------------------------------------------------
dnl
dnl Copyright 2006-2009,2010 by Thomas E. Dickey
dnl
dnl All Rights Reserved
dnl
dnl Permission to use, copy, modify, and distribute this software and its
dnl documentation for any purpose and without fee is hereby granted,
dnl provided that the above copyright notice appear in all copies and that
dnl both that copyright notice and this permission notice appear in
dnl supporting documentation, and that the name of the above listed
dnl copyright holder(s) not be used in advertising or publicity pertaining
dnl to distribution of the software without specific, written prior
dnl permission.
dnl
dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dnl
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
dnl ------------
dnl See if the poll function really works. Some platforms have poll(), but
dnl it does not work for terminals or files.
AC_DEFUN([CF_FUNC_POLL],[
AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
AC_TRY_RUN([
#include <stdio.h>
#ifdef HAVE_POLL_H
#include <poll.h>
#else
#include <sys/poll.h>
#endif
int main() {
struct pollfd myfds;
int ret;
myfds.fd = 0;
myfds.events = POLLIN;
ret = poll(&myfds, 1, 100);
${cf_cv_main_return:-return}(ret != 0);
}],
[cf_cv_working_poll=yes],
[cf_cv_working_poll=no],
[cf_cv_working_poll=unknown])])
test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL, 1, [poll() works])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
dnl -----------
dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
dnl programs need this test).
dnl
dnl This is really a MacOS X 10.4.3 workaround. Defining _POSIX_C_SOURCE
dnl forces SIGWINCH to be undefined (breaks xterm, ncurses). Oddly, the struct
dnl winsize declaration is left alone - we may revisit this if Apple choose to
dnl break that part of the interface as well.
AC_DEFUN([CF_SIGWINCH],
[
AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/signal.h>
],[int x = SIGWINCH],
[cf_cv_define_sigwinch=yes],
[AC_TRY_COMPILE([
#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include <sys/types.h>
#include <sys/signal.h>
],[int x = SIGWINCH],
[cf_cv_define_sigwinch=maybe],
[cf_cv_define_sigwinch=no])
])
])
if test "$cf_cv_define_sigwinch" = maybe ; then
AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
cf_cv_fixup_sigwinch=unknown
cf_sigwinch=32
while test $cf_sigwinch != 1
do
AC_TRY_COMPILE([
#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include <sys/types.h>
#include <sys/signal.h>
],[
#if SIGWINCH != $cf_sigwinch
make an error
#endif
int x = SIGWINCH],
[cf_cv_fixup_sigwinch=$cf_sigwinch
break])
cf_sigwinch=`expr $cf_sigwinch - 1`
done
])
if test "$cf_cv_fixup_sigwinch" != unknown ; then
CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
fi
fi
])dnl
This diff is collapsed.
......@@ -19,7 +19,12 @@ 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.
*/
/* $XFree86: xc/programs/luit/charset.h,v 1.3 2002/07/01 02:25:59 tsi Exp $ */
/* $XFree86: xc/programs/luit/charset.h,v 1.4 2002/10/17 01:06:09 dawes Exp $ */
#ifndef LUIT_CHARSET_H
#define LUIT_CHARSET_H 1
#include "other.h"
#define T_FAILED 0
#define T_94 1
......@@ -36,13 +41,13 @@ THE SOFTWARE.
#define CHARSET_REGULAR(c) ((c)->type != T_128)
typedef struct _Charset {
char *name;
const char *name;
int type;
unsigned char final;
unsigned int (*recode)(unsigned int, struct _Charset *self);
int (*reverse)(unsigned int, struct _Charset *self);
void *data;
int (*other_stack)(unsigned char c, OtherStatePtr aux);
unsigned int (*recode) (unsigned int, const struct _Charset * self);
int (*reverse) (unsigned int, const struct _Charset * self);
const void *data;
int (*other_stack) (unsigned c, OtherStatePtr aux);
OtherState *other_aux;
unsigned int (*other_recode)(unsigned int c, OtherStatePtr aux);
unsigned int (*other_reverse)(unsigned int c, OtherStatePtr aux);
......@@ -60,12 +65,16 @@ typedef struct _LocaleCharset {
const char *other;
} LocaleCharsetRec, *LocaleCharsetPtr;
CharsetPtr getUnknownCharset(int);
CharsetPtr getCharset(unsigned char, int);
CharsetPtr getCharsetByName(const char*);
const CharsetRec *getUnknownCharset(int);
const CharsetRec *getCharset(unsigned, int);
const CharsetRec *getCharsetByName(const char *);
void reportCharsets(void);
int getLocaleState(const char *locale, char *charset,
int getLocaleState(const char *locale, const char *charset,
int *gl_return, int *gr_return,
CharsetPtr *g0_return, CharsetPtr *g1_return,
CharsetPtr *g2_return, CharsetPtr *g3_return,
CharsetPtr *other_return);
const CharsetRec * *g0_return,
const CharsetRec * *g1_return,
const CharsetRec * *g2_return,
const CharsetRec * *g3_return,
const CharsetRec * *other_return);
#endif /* LUIT_CHARSET_H */
dnl Copyright 2005 Red Hat, Inc.
dnl
dnl Permission to use, copy, modify, distribute, and sell this software and its
......@@ -71,6 +70,25 @@ case $host_os in
;;
esac
AC_CHECK_HEADERS([pty.h stropts.h sys/ioctl.h sys/param.h sys/poll.h sys/select.h sys/time.h termios.h])
AC_CHECK_FUNCS([grantpt putenv select strdup])
if test "x$ac_cv_func_grantpt" != "xyes" ; then
AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
if test "$cf_have_openpty" = yes ; then
LIBS="-lutil $LIBS"
AC_DEFINE(HAVE_OPENPTY, 1, [Have openpty in libutil])
AC_CHECK_HEADERS( \
util.h \
libutil.h \
pty.h \
)
fi
fi
CF_FUNC_POLL
CF_SIGWINCH
LUIT_CFLAGS="$LUIT_CFLAGS $OS_CFLAGS"
AC_SUBST(LUIT_CFLAGS)
AC_SUBST(LUIT_LIBS)
......
This diff is collapsed.
......@@ -19,7 +19,11 @@ 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.
*/
/* $XFree86: xc/programs/luit/iso2022.h,v 1.4 2002/07/01 02:25:59 tsi Exp $ */
#ifndef LUIT_ISO2022_H
#define LUIT_ISO2022_H 1
#include "charset.h"
#define ESC 0x1B
#define CSI 0x9B
......@@ -58,19 +62,20 @@ THE SOFTWARE.
#define OF_PASSTHRU 8
typedef struct _Iso2022 {
CharsetPtr *glp, *grp;
CharsetPtr g[4];
CharsetPtr other;
const CharsetRec **glp;
const CharsetRec **grp;
const CharsetRec *g[4];
const CharsetRec *other;
int parserState;
int shiftState;
int inputFlags;
int outputFlags;
unsigned char *buffered;
int buffered_len;
int buffered_count;
size_t buffered_len;
size_t buffered_count;
int buffered_ku;
unsigned char *outbuf;
int outbuf_count;
size_t outbuf_count;
} Iso2022Rec, *Iso2022Ptr;
#define GL(i) (*(i)->glp)
......@@ -85,10 +90,12 @@ typedef struct _Iso2022 {
Iso2022Ptr allocIso2022(void);
void destroyIso2022(Iso2022Ptr);
int initIso2022(char *, char *, Iso2022Ptr);
int initIso2022(const char *, const char *, Iso2022Ptr);
int mergeIso2022(Iso2022Ptr, Iso2022Ptr);
void reportIso2022(Iso2022Ptr);
void terminate(Iso2022Ptr, int);
void terminateEsc(Iso2022Ptr, int, unsigned char*, int);
void terminateEsc(Iso2022Ptr, int, unsigned char *, unsigned);
void copyIn(Iso2022Ptr, int, unsigned char*, int);
void copyOut(Iso2022Ptr, int, unsigned char*, int);
void copyOut(Iso2022Ptr, int, unsigned char *, unsigned);
#endif /* LUIT_ISO2022_H */
This diff is collapsed.
......@@ -20,12 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef LUIT_LUIT_H
#define LUIT_LUIT_H 1
extern const char *locale_alias;
extern int iso2022;
extern int verbose;
extern int sevenbit;
extern int ilog;
extern int olog;
void child(char*, char*, char**);
void child(char *, char *, char *const *);
void parent(int, int);
#endif /* LUIT_LUIT_H */
.\" $XFree86: xc/programs/luit/luit.man,v 1.7 2003/02/24 01:10:25 dawes Exp $
.\"
.\"
.\" 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 LUIT 1 __vendorversion__
.SH NAME
luit \- Locale and ISO\ 2022 support for Unicode terminals
......@@ -38,12 +46,19 @@ Display some summary help and quit.
.B \-list
List the supported charsets and encodings, then quit.
.TP
.B \-V
Print luit's version and quit.
.TP
.B \-v
Be verbose.
.TP
.B \-c
Function as a simple converter from standard input to standard output.
.TP
.B \-p
In startup, establish a handshake between parent and child processes.
This is needed for some systems, e.g., FreeBSD.
.TP
.B \-x
Exit as soon as the child dies. This may cause
.B luit
......@@ -132,6 +147,11 @@ Log into
.I filename
all the bytes sent to the terminal emulator.
.TP
.BI \-alias " filename"
the locale alias file
.br
(default: __locale_alias__).
.TP
.B \-\-
End of options.
.SH EXAMPLES
......@@ -177,18 +197,15 @@ M-x set-terminal-coding-system RET iso-2022-8bit-ss2 RET
.PP
.SH FILES
.TP
.B __projectroot__/lib/X11/fonts/encodings/encodings.dir
The system-wide encodings directory.
.TP
.B __localealiasfile__
.B __locale_alias__
The file mapping locales to locale encodings.
.SH SECURITY
On systems with SVR4 (``Unix-98'') ptys (Linux version 2.2 and later,
On systems with SVR4 (\*(``Unix-98\*('') ptys (Linux version 2.2 and later,
SVR4),
.B luit
should be run as the invoking user.
On systems without SVR4 (``Unix-98'') ptys (notably BSD variants),
On systems without SVR4 (\*(``Unix-98\*('') ptys (notably BSD variants),
running
.B luit
as an ordinary user will leave the tty world-writable; this is a
......@@ -213,12 +230,17 @@ Charsets with a non-trivial intermediary byte are not yet supported.
Selecting alternate sets of control characters is not supported and
will never be.
.SH SEE ALSO
xterm(1), unicode(7), utf-8(7), charsets(7).
xterm(__mansuffix__), unicode(7), utf-8(7), charsets(7).
.nf
.br
.I Character Code Structure and Extension Techniques (ISO\ 2022, ECMA-35).
.br
.I Control Functions for Coded Character Sets (ISO\ 6429, ECMA-48).
.fi
.SH AUTHOR
The version of
.B Luit
included in this X.Org Foundation release
was originally written by Juliusz Chroboczek <jch@freedesktop.org>
for the XFree86 Project.
for the XFree86 Project and includes additional contributions from
Thomas E. Dickey required for newer releases of xterm(__mansuffix__).
This diff is collapsed.
......@@ -19,7 +19,19 @@ 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.
*/
/* $XFree86: xc/programs/luit/other.h,v 1.1 2002/10/17 01:06:09 dawes Exp $ */
#ifndef LUIT_OTHER_H
#define LUIT_OTHER_H 1
#include "config.h" /* include this, for self-contained headers */
#ifndef GCC_UNUSED
#define GCC_UNUSED /* ARGSUSED */
#endif
#include <X11/fonts/fontenc.h>
#define UChar(n) ((unsigned char)(n))
typedef struct {
FontMapPtr mapping;
......@@ -69,25 +81,26 @@ typedef union {
int init_gbk(OtherStatePtr);
unsigned int mapping_gbk(unsigned int, OtherStatePtr);
unsigned int reverse_gbk(unsigned int, OtherStatePtr);
int stack_gbk(unsigned char, OtherStatePtr);
int stack_gbk(unsigned, OtherStatePtr);
int init_utf8(OtherStatePtr);
unsigned int mapping_utf8(unsigned int, OtherStatePtr);
unsigned int reverse_utf8(unsigned int, OtherStatePtr);
int stack_utf8(unsigned char, OtherStatePtr);
int stack_utf8(unsigned, OtherStatePtr);
int init_sjis(OtherStatePtr);
unsigned int mapping_sjis(unsigned int, OtherStatePtr);
unsigned int reverse_sjis(unsigned int, OtherStatePtr);
int stack_sjis(unsigned char, OtherStatePtr);
int stack_sjis(unsigned, OtherStatePtr);
int init_hkscs(OtherStatePtr);
unsigned int mapping_hkscs(unsigned int, OtherStatePtr);
unsigned int reverse_hkscs(unsigned int, OtherStatePtr);
int stack_hkscs(unsigned char, OtherStatePtr);
int stack_hkscs(unsigned, OtherStatePtr);
int init_gb18030(OtherStatePtr);
unsigned int mapping_gb18030(unsigned int, OtherStatePtr);
unsigned int reverse_gb18030(unsigned int, OtherStatePtr);
int stack_gb18030(unsigned char, OtherStatePtr);
int stack_gb18030(unsigned, OtherStatePtr);
#endif /* LUIT_OTHER_H */
......@@ -19,13 +19,18 @@ 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.
*/
/* $XFree86$ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "luit.h"
#include "parser.h"
#include "sys.h"
static char keyword[MAX_KEYWORD_LENGTH];
......@@ -76,7 +81,7 @@ getString(FILE *f, int string_end, int *c_return)
if(c == '\n')
continue;
}
keyword[i++] = c;
keyword[i++] = (char) c;
if(i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
......@@ -117,7 +122,7 @@ getToken(FILE *f, int c, int parse_assignments, int *c_return)
if(c == '\n')
continue;
}
keyword[i++] = c;
keyword[i++] = (char) c;
if(i >= MAX_KEYWORD_LENGTH)
return TOK_ERROR;
c = getc(f);
......@@ -130,7 +135,6 @@ getToken(FILE *f, int c, int parse_assignments, int *c_return)
return TOK_KEYWORD;
}
/* Can parse both the old and new formats for locale.alias */
static int
parseTwoTokenLine(FILE *f, char *first, char *second)
......@@ -146,7 +150,7 @@ parseTwoTokenLine(FILE *f, char *first, char *second)
else if(tok == TOK_EOL)
goto again;
else if(tok == TOK_KEYWORD) {
int len = strlen(keyword);
size_t len = strlen(keyword);
if(keyword[len - 1] == ':')
keyword[len - 1] = '\0';
strcpy(first, keyword);
......@@ -173,37 +177,32 @@ resolveLocale(const char *locale)
char first[MAX_KEYWORD_LENGTH], second[MAX_KEYWORD_LENGTH];
char *resolved = NULL;
int rc;
int found = 0;
f = fopen(LOCALE_ALIAS_FILE, "r");
if(f == NULL)
goto bail;
f = fopen(locale_alias, "r");
if (f != NULL) {
do {
rc = parseTwoTokenLine(f, first, second);
if(rc < -1)
goto bail;
break;
if(!strcmp(first, locale)) {
resolved = strdup(second);
if(resolved == NULL)
goto bail;
resolved = strmalloc(second);
found = 1;
break;
}
} while(rc >= 0);
if (!found) {
if(resolved == NULL) {
resolved = strdup(locale);
if(resolved == NULL)
goto bail;
resolved = strmalloc(locale);
}
}
fclose(f);
} else {
perror(locale_alias);
}
return resolved;
bail:
if(f != NULL)
fclose(f);
if(resolved != NULL)
free(resolved);
return NULL;
}
......@@ -20,6 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef LUIT_PARSER_H
#define LUIT_PARSER_H 1
#ifndef LOCALE_ALIAS_FILE
#define LOCALE_ALIAS_FILE "/usr/X11R6/lib/X11/locale/locale.alias"
#endif
......@@ -33,3 +36,5 @@ THE SOFTWARE.
#define TOK_KEYWORD 2
char *resolveLocale(const char *locale);
#endif /* LUIT_PARSER_H */
This diff is collapsed.
/* $XFree86$ */
/*
Copyright (c) 2001 by Juliusz Chroboczek
......@@ -21,6 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef LUIT_SYS_H
#define LUIT_SYS_H 1
#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
#define USE_IGNORE_RC
extern int ignore_unused;
#define IGNORE_RC(func) ignore_unused = (int) func
#else
#define IGNORE_RC(func) (void) func
#endif /* gcc workarounds */
int waitForOutput(int fd);
int waitForInput(int fd1, int fd2);
int setWindowSize(int sfd, int dfd);
......@@ -33,3 +43,15 @@ char *my_basename(char *path);
int allocatePty(int *pty_return, char **line_return);
int openTty(char *line);
int droppriv(void);
char *strmalloc(const char *value);
#ifdef NO_LEAKS
void luit_leaks(void);
void charset_leaks(void);
void iso2022_leaks(void);
void ExitProgram(int code);
#else
#define ExitProgram(code) exit(code)
#endif
#endif /* LUIT_SYS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment