-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/****************************************************************************
+ * Copyright (c) 1998 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 *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, 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 COPYRIGHT HOLDERS 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. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: captoinfo.c,v 1.15 1996/12/21 14:24:06 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.17 1998/02/11 12:13:54 tom Exp $")
#define MAX_PUSHED 16 /* max # args we can push onto the stack */
#define MAX_ENTRY 2048 /* maximum chars in a translated capability */
param++;
}
-static int cvtchar(register char *sp)
+static int cvtchar(register const char *sp)
/* convert a character to a terminfo push */
{
unsigned char c = 0;
char *_nc_captoinfo(
/* convert a termcap string to terminfo format */
-register char *const cap, /* relevant terminfo capability index */
-register char *s, /* string value of the capability */
+register const char *cap, /* relevant terminfo capability index */
+register const char *s, /* string value of the capability */
int const parametrized) /* do % translations if 1, pad translations if >=0 */
{
static char line[MAX_ENTRY];
- char *capstart;
+ const char *capstart;
stackptr = 0;
onstack = 0;
dp = line;
/* skip the initial padding (if we haven't been told not to) */
- capstart = (char *)NULL;
+ capstart = 0;
if (s == 0)
s = "";
if (parametrized >= 0 && isdigit(*s))
char *_nc_infotocap(
/* convert a terminfo string to termcap format */
-register char *const cap GCC_UNUSED, /* relevant termcap capability index */
-register char *str, /* string value of the capability */
+register const char *cap GCC_UNUSED, /* relevant termcap capability index */
+register const char *str, /* string value of the capability */
int const parametrized) /* do % translations if 1, pad translations if >=0 */
{
int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
- char *padding, ch1 = 0, ch2 = 0;
+ const char *padding;
+ const char *trimmed = 0;
+ char ch1 = 0, ch2 = 0;
char *bufptr = init_string();
char temp[256];
while (isdigit(*padding) || *padding == '.' || *padding == '*')
padding--;
if (*padding == '<' && *--padding == '$')
- *padding = '\0';
+ trimmed = padding;
padding += 2;
while (isdigit(*padding) || *padding == '.' || *padding == '*')
bufptr = save_char(bufptr, *padding++);
}
- for (; *str; str++)
+ for (; *str && str != trimmed; str++)
{
int c1, c2;
char *cp;
}
}
else if (*str >= '3')
- return((char *)NULL);
+ return(0);
break;
case 'i':
break;
default:
- return((char *)NULL);
+ return(0);
} /* endswitch (*str) */
} /* endelse (*str == '%') */
char buf[BUFSIZ];
++curr_line;
- if (fgets(buf, sizeof(buf), stdin) == (char *)NULL)
+ if (fgets(buf, sizeof(buf), stdin) == 0)
break;
buf[strlen(buf) - 1] = '\0';
_nc_set_source(buf);