X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_print.c;h=e7d8535ef603064326e4f1b5c2b77990b8ddb6de;hp=e30ceae87226ca1b698931b9777cdde77dd5442b;hb=HEAD;hpb=03f728e5bb3630a54fffc4a2ff2f8dbfcce9088e diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c index e30ceae8..e7d8535e 100644 --- a/ncurses/tinfo/lib_print.c +++ b/ncurses/tinfo/lib_print.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright 2018-2021,2023 Thomas E. Dickey * + * Copyright 1998-2011,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 * @@ -39,14 +40,14 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_print.c,v 1.21 2011/10/22 16:34:50 tom Exp $") +MODULE_ID("$Id: lib_print.c,v 1.31 2023/06/10 12:44:41 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) /* ship binary character data to the printer via mc4/mc5/mc5p */ { int result; - char *mybuf, *switchon; + char *mybuf = NULL, *switchon; size_t onsize, offsize; size_t need; @@ -59,7 +60,7 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) } if (prtr_non) { - switchon = TPARM_1(prtr_non, len); + switchon = TIPARM_1(prtr_non, len); onsize = strlen(switchon); offsize = 0; } else { @@ -72,14 +73,15 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) if (switchon == 0 || (mybuf = typeMalloc(char, need + 1)) == 0) { + free(mybuf); errno = ENOMEM; return (ERR); } - (void) strcpy(mybuf, switchon); + _nc_STRCPY(mybuf, switchon, need); memcpy(mybuf + onsize, data, (size_t) len); if (offsize) - (void) strcpy(mybuf + onsize + len, prtr_off); + _nc_STRCPY(mybuf + onsize + len, prtr_off, need); /* * We're relying on the atomicity of UNIX writes here. The @@ -88,14 +90,14 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) * data has actually been shipped to the terminal. If the write(2) * operation is truly atomic we're protected from this. */ - result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need); + result = (int) write(SP_PARM->_ofd, mybuf, need); /* * By giving up our scheduler slot here we increase the odds that the * kernel will ship the contiguous clist items from the last write * immediately. */ -#ifndef __MINGW32__ +#ifndef _NC_WINDOWS (void) sleep(0); #endif free(mybuf);