X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_tgoto.c;h=9cf5e100ce87ff7abd3c90b0bdc15084e54b2f35;hp=77fc6ceabd4a8caad6f7623c67f4ad8bfd5afffe;hb=9b4c4abadc0a29999c5ddad5aa8d769fee28d687;hpb=46722468f47c2b77b3987729b4bcf2321cccfd01 diff --git a/ncurses/tinfo/lib_tgoto.c b/ncurses/tinfo/lib_tgoto.c index 77fc6cea..9cf5e100 100644 --- a/ncurses/tinfo/lib_tgoto.c +++ b/ncurses/tinfo/lib_tgoto.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2000-2001,2002 Free Software Foundation, Inc. * + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2000-2008,2012 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 +36,7 @@ #include #include -MODULE_ID("$Id: lib_tgoto.c,v 1.10 2002/08/31 22:14:47 Philippe.Blain Exp $") +MODULE_ID("$Id: lib_tgoto.c,v 1.21 2020/05/27 23:55:56 tom Exp $") #if !PURE_TERMINFO static bool @@ -125,10 +126,17 @@ tgoto_internal(const char *string, int x, int y) *value += 1; need_BC = TRUE; } else { - *value = 0200; /* tputs will treat this as \0 */ + /* tputs will pretend this is \0, which will almost + * always work since ANSI-compatible terminals ignore + * the character. ECMA-48 does not document a C1 + * control for this value. A few (obsolete) terminals + * can use this value in special cases, such as cursor + * addressing using single-byte coordinates. + */ + *value = 0200; } } - result[used++] = *value++; + result[used++] = (char) *value++; break; case '%': result[used++] = *string; @@ -155,11 +163,12 @@ tgoto_internal(const char *string, int x, int y) *value = 16 * (*value / 10) + (*value % 10); break; case 'D': /* Reverse coding (Delta Data) */ - *value -= 2 * (*value / 16); + *value -= 2 * (*value % 16); break; } if (fmt != 0) { - sprintf(result + used, fmt, *value++); + _nc_SPRINTF(result + used, _nc_SLIMIT(length - used) + fmt, *value++); used += strlen(result + used); fmt = 0; } @@ -174,7 +183,7 @@ tgoto_internal(const char *string, int x, int y) } if (result != 0) { if (need_BC) { - strcpy(result + used, BC); + _nc_STRCPY(result + used, BC, length - used); used += strlen(BC); } result[used] = '\0'; @@ -198,6 +207,6 @@ tgoto(const char *string, int x, int y) result = tgoto_internal(string, x, y); else #endif - result = tparm((NCURSES_CONST char *) string, y, x); + result = TIPARM_2(string, y, x); returnPtr(result); }