1 /****************************************************************************
2 * Copyright (c) 2000 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey *
31 ****************************************************************************/
33 #include <curses.priv.h>
38 MODULE_ID("$Id: lib_tgoto.c,v 1.2 2000/09/24 00:19:14 tom Exp $")
42 is_termcap(const char *string)
46 while ((*string != '\0') && result) {
56 } else if (string[0] == '$' && string[1] == '<') {
65 tgoto_internal(const char *string, int x, int y)
84 while (*string != 0) {
85 if ((used + need) > length) {
86 length += (used + need);
87 if ((result = _nc_doalloc(result, length)) == 0) {
111 *value += (*++string & 0xff);
115 * Guard against tputs() seeing a truncated string. The
116 * termcap documentation refers to a similar fixup for \n
117 * and \r, but I don't see that it could work -TD
124 *value = 0200; /* tputs will treat this as \0 */
127 result[used++] = *value++;
130 result[used++] = *string;
142 if (*value > string[1])
146 case 'n': /* Datamedia 2500 */
151 *value = 16 * (*value / 10) + (*value % 10);
153 case 'D': /* Reverse coding (Delta Data) */
154 *value -= 2 * (*value / 16);
158 sprintf(result + used, fmt, *value++);
159 used += strlen(result + used);
162 if (value - param > 2) {
167 result[used++] = *string;
172 strcpy(result + used, BC);
181 * Retained solely for upward compatibility. Note the intentional reversing of
182 * the last two arguments when invoking tparm().
185 tgoto(const char *string, int x, int y)
189 T((T_CALLED("tgoto(%s, %d, %d)"), _nc_visbuf(string), x, y));
191 if (is_termcap(string))
192 result = tgoto_internal(string, x, y);
195 result = tparm((NCURSES_CONST char *) string, y, x);