aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo/lib_tgoto.c')
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tgoto.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
index 73557eb7cc25..19edb4f31a11 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2000,2001 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 *
@@ -35,7 +35,7 @@
#include <ctype.h>
#include <termcap.h>
-MODULE_ID("$Id: lib_tgoto.c,v 1.2 2000/09/24 00:19:14 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.7 2001/03/24 22:25:55 tom Exp $")
#if !PURE_TERMINFO
static bool
@@ -43,20 +43,24 @@ is_termcap(const char *string)
{
bool result = TRUE;
- while ((*string != '\0') && result) {
- if (*string == '%') {
- switch (*++string) {
- case 'p':
+ if (string == 0 || *string == '\0') {
+ result = FALSE; /* tparm() handles empty strings */
+ } else {
+ while ((*string != '\0') && result) {
+ if (*string == '%') {
+ switch (*++string) {
+ case 'p':
+ result = FALSE;
+ break;
+ case '\0':
+ string--;
+ break;
+ }
+ } else if (string[0] == '$' && string[1] == '<') {
result = FALSE;
- break;
- case '\0':
- string--;
- break;
}
- } else if (string[0] == '$' && string[1] == '<') {
- result = FALSE;
+ string++;
}
- string++;
}
return result;
}
@@ -90,7 +94,7 @@ tgoto_internal(const char *string, int x, int y)
}
}
if (*string == '%') {
- char *fmt = 0;
+ const char *fmt = 0;
switch (*++string) {
case '\0':
@@ -108,7 +112,7 @@ tgoto_internal(const char *string, int x, int y)
*value %= 1000;
break;
case '+':
- *value += (*++string & 0xff);
+ *value += CharOf(*++string);
/* FALLTHRU */
case '.':
/*
@@ -181,8 +185,9 @@ tgoto_internal(const char *string, int x, int y)
* Retained solely for upward compatibility. Note the intentional reversing of
* the last two arguments when invoking tparm().
*/
-char *
-tgoto(const char *string, int x, int y)
+NCURSES_EXPORT(char *)
+tgoto
+(const char *string, int x, int y)
{
char *result;