diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-03-11 21:03:59 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-03-11 21:03:59 +0000 |
commit | 73a856115702157d58128365662b9519d7daeadc (patch) | |
tree | 6ff9a5f980b684e623391e394e48c512c960ced4 /lib/libcurses/tinfo/comp_expand.c | |
parent | 62849813a43735aeaa89e531a24138e11c68b595 (diff) |
ncurses-4.2-990307
Diffstat (limited to 'lib/libcurses/tinfo/comp_expand.c')
-rw-r--r-- | lib/libcurses/tinfo/comp_expand.c | 40 |
1 files changed, 24 insertions, 16 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) { |