diff options
Diffstat (limited to 'lib/libcurses/tinfo')
-rw-r--r-- | lib/libcurses/tinfo/comp_expand.c | 40 | ||||
-rw-r--r-- | lib/libcurses/tinfo/lib_raw.c | 12 | ||||
-rw-r--r-- | lib/libcurses/tinfo/name_match.c | 67 | ||||
-rw-r--r-- | lib/libcurses/tinfo/write_entry.c | 6 |
4 files changed, 72 insertions, 53 deletions
diff --git a/lib/libcurses/tinfo/comp_expand.c b/lib/libcurses/tinfo/comp_expand.c index c78ec3c117e..bf2bb3d397d 100644 --- a/lib/libcurses/tinfo/comp_expand.c +++ b/lib/libcurses/tinfo/comp_expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_expand.c,v 1.2 1999/03/02 06:23:28 millert Exp $ */ +/* $OpenBSD: comp_expand.c,v 1.3 1999/03/11 21:03:57 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -37,7 +37,7 @@ #include <ctype.h> #include <tic.h> -MODULE_ID("$From: comp_expand.c,v 1.10 1999/02/23 23:14:59 tom Exp $") +MODULE_ID("$From: comp_expand.c,v 1.11 1999/03/07 00:51:07 tom Exp $") static int trailing_spaces(const char *src) { @@ -51,7 +51,7 @@ static int trailing_spaces(const char *src) #define REALCTL(s) (CHAR_OF(s) < 127 && iscntrl(CHAR_OF(s))) #define REALPRINT(s) (CHAR_OF(s) < 127 && isprint(CHAR_OF(s))) -char *_nc_tic_expand(const char *srcp, bool tic_format, bool numbers) +char *_nc_tic_expand(const char *srcp, bool tic_format, int numbers) { static char * buffer; static size_t length; @@ -75,18 +75,21 @@ int ch; /* * Though the character literals are more compact, most * terminal descriptions use numbers and are not easy - * to read in character-literal form. This is the - * default option for tic/infocmp. + * to read in character-literal form. */ - if (numbers - && str[0] == S_QUOTE - && str[1] != '\\' - && REALPRINT(str+1) - && str[2] == S_QUOTE) { + switch (numbers) { + case -1: + if (str[0] == S_QUOTE + && str[1] != '\\' + && REALPRINT(str+1) + && str[2] == S_QUOTE) { sprintf(buffer+bufp, "{%d}", str[1]); bufp += strlen(buffer+bufp); str += 2; - } + } else { + buffer[bufp++] = *str; + } + break; /* * If we have a "%{number}", try to translate it into * a "%'char'" form, since that will run a little faster @@ -94,9 +97,9 @@ int ch; * for the constant makes it simpler to compare terminal * descriptions. */ - else if (!numbers - && str[0] == L_BRACE - && isdigit(str[1])) { + case 1: + if (str[0] == L_BRACE + && isdigit(str[1])) { char *dst = 0; long value = strtol(str+1, &dst, 0); if (dst != 0 @@ -115,8 +118,13 @@ int ch; } else { buffer[bufp++] = *str; } - } else { - buffer[bufp++] = *str; + } else { + buffer[bufp++] = *str; + } + break; + default: + buffer[bufp++] = *str; + break; } } else if (ch == 128) { diff --git a/lib/libcurses/tinfo/lib_raw.c b/lib/libcurses/tinfo/lib_raw.c index a9280a57edb..fc414144c3a 100644 --- a/lib/libcurses/tinfo/lib_raw.c +++ b/lib/libcurses/tinfo/lib_raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_raw.c,v 1.1 1999/01/18 19:10:19 millert Exp $ */ +/* $OpenBSD: lib_raw.c,v 1.2 1999/03/11 21:03:57 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -51,7 +51,7 @@ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$From: lib_raw.c,v 1.2 1998/12/20 00:42:58 tom Exp $") +MODULE_ID("$From: lib_raw.c,v 1.3 1999/03/06 22:28:24 tom Exp $") #if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE) #define _POSIX_SOURCE @@ -82,7 +82,7 @@ int raw(void) if (SP != 0 && cur_term != 0) { SP->_raw = TRUE; - SP->_cbreak = TRUE; + SP->_cbreak = 1; #ifdef __EMX__ setmode(SP->_ifd, O_BINARY); @@ -107,7 +107,7 @@ int cbreak(void) { T((T_CALLED("cbreak()"))); - SP->_cbreak = TRUE; + SP->_cbreak = 1; #ifdef __EMX__ setmode(SP->_ifd, O_BINARY); @@ -151,7 +151,7 @@ int noraw(void) T((T_CALLED("noraw()"))); SP->_raw = FALSE; - SP->_cbreak = FALSE; + SP->_cbreak = 0; #ifdef __EMX__ setmode(SP->_ifd, O_TEXT); @@ -173,7 +173,7 @@ int nocbreak(void) { T((T_CALLED("nocbreak()"))); - SP->_cbreak = FALSE; + SP->_cbreak = 0; #ifdef __EMX__ setmode(SP->_ifd, O_TEXT); diff --git a/lib/libcurses/tinfo/name_match.c b/lib/libcurses/tinfo/name_match.c index 814e780a4d4..77099d601be 100644 --- a/lib/libcurses/tinfo/name_match.c +++ b/lib/libcurses/tinfo/name_match.c @@ -1,7 +1,7 @@ -/* $OpenBSD: name_match.c,v 1.1 1999/01/18 19:10:21 millert Exp $ */ +/* $OpenBSD: name_match.c,v 1.2 1999/03/11 21:03:57 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1999 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,15 +29,14 @@ ****************************************************************************/ /**************************************************************************** - * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * - * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * Author: Thomas E. Dickey <dickey@clark.net> 1999 * ****************************************************************************/ #include <curses.priv.h> #include <term.h> #include <tic.h> -MODULE_ID("$From: name_match.c,v 1.7 1998/09/19 20:27:49 Todd.Miller Exp $") +MODULE_ID("$From: name_match.c,v 1.8 1999/03/07 01:58:36 tom Exp $") /* * _nc_first_name(char *names) @@ -48,16 +47,16 @@ MODULE_ID("$From: name_match.c,v 1.7 1998/09/19 20:27:49 Todd.Miller Exp $") char *_nc_first_name(const char *const sp) /* get the first name from the given name list */ { - static char buf[MAX_NAME_SIZE+1]; - register char *cp; + static char buf[MAX_NAME_SIZE+1]; + register unsigned n; - (void) strlcpy(buf, sp, sizeof(buf)); - - cp = strchr(buf, '|'); - if (cp) - *cp = '\0'; - - return(buf); + for (n = 0; n < sizeof(buf)-1; n++) { + if ((buf[n] = sp[n]) == '\0' + || (buf[n] == '|')) + break; + } + buf[n] = '\0'; + return(buf); } /* @@ -67,21 +66,33 @@ char *_nc_first_name(const char *const sp) */ int _nc_name_match(const char *const namelst, const char *const name, const char *const delim) -/* microtune this, it occurs in several critical loops */ { -char namecopy[MAX_ENTRY_SIZE]; /* this may get called on a TERMCAP value */ -register char *cp; + const char *s, *d, *t; + int code, found; - if (namelst == 0) - return(FALSE); - (void) strlcpy (namecopy, namelst, sizeof(namecopy)); - if ((cp = strtok(namecopy, delim)) != 0) { - do { - /* avoid strcmp() function-call cost if possible */ - if (cp[0] == name[0] && strcmp(cp, name) == 0) - return(TRUE); - } while - ((cp = strtok((char *)0, delim)) != 0); + if ((s = namelst) != 0) { + while (*s != '\0') { + for (d = name; *d != '\0'; d++) { + if (*s != *d) + break; + s++; + } + found = FALSE; + for (code = TRUE; *s != '\0'; code = FALSE, s++) { + for (t = delim; *t != '\0'; t++) { + if (*s == *t) { + found = TRUE; + break; + } + } + if (found) + break; + } + if (code && *d == '\0') + return code; + if (*s++ == 0) + break; + } } - return(FALSE); + return FALSE; } diff --git a/lib/libcurses/tinfo/write_entry.c b/lib/libcurses/tinfo/write_entry.c index a085849b491..9ca111ce5c2 100644 --- a/lib/libcurses/tinfo/write_entry.c +++ b/lib/libcurses/tinfo/write_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: write_entry.c,v 1.2 1999/03/02 06:23:29 millert Exp $ */ +/* $OpenBSD: write_entry.c,v 1.3 1999/03/11 21:03:57 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -56,7 +56,7 @@ #define TRACE_OUT(p) /*nothing*/ #endif -MODULE_ID("$From: write_entry.c,v 1.45 1999/02/28 22:26:33 tom Exp $") +MODULE_ID("$From: write_entry.c,v 1.46 1999/03/06 22:48:21 tom Exp $") static int total_written; @@ -379,7 +379,7 @@ static int compute_offsets(char **Strings, int strmax, short *offsets) return nextfree; } -static void convert_shorts(char *buf, short *Numbers, int count) +static void convert_shorts(unsigned char *buf, short *Numbers, int count) { int i; for (i = 0; i < count; i++) { |