/****************************************************************************
- * Copyright (c) 2012 Free Software Foundation, Inc. *
+ * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2012-2013,2016 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 *
#include <ncurses_cfg.h>
+#if HAVE_BSD_STRING_H
+#include <bsd/string.h>
+#endif
+
/*
- * $Id: nc_string.h,v 1.3 2012/02/23 10:21:17 tom Exp $
+ * $Id: nc_string.h,v 1.9 2021/04/25 00:10:43 tom Exp $
*
* String-hacks. Use these macros to stifle warnings on (presumably) correct
* uses of strcat, strcpy and sprintf.
*/
#ifdef __cplusplus
-#define NCURSES_VOID /* nothing */
+#define NCURSES_VOID /* nothing */
#else
#define NCURSES_VOID (void)
#endif
#if USE_STRING_HACKS && HAVE_STRLCAT
-#define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),(n))
+#define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
#else
#define _nc_STRCAT(d,s,n) NCURSES_VOID strcat((d),(s))
+#define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strncat((d),(s),(n))
#endif
#if USE_STRING_HACKS && HAVE_STRLCPY
-#define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),(n))
+#define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
#else
#define _nc_STRCPY(d,s,n) NCURSES_VOID strcpy((d),(s))
+#define _nc_STRNCPY(d,s,n) NCURSES_VOID strncpy((d),(s),(n))
#endif
#if USE_STRING_HACKS && HAVE_SNPRINTF
+#ifdef __cplusplus
#define _nc_SPRINTF NCURSES_VOID snprintf
-#define _nc_SLIMIT(n) (n),
+#else
+#define _nc_SPRINTF NCURSES_VOID (snprintf)
+#endif
+#define _nc_SLIMIT(n) NCURSES_CAST(size_t,n),
#else
#define _nc_SPRINTF NCURSES_VOID sprintf
#define _nc_SLIMIT(n) /* nothing */