/****************************************************************************
- * Copyright (c) 2011 Free Software Foundation, Inc. *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2011-2012,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 *
* authorization. *
****************************************************************************/
/*
- * $Id: color_name.h,v 1.2 2011/04/23 17:15:01 tom Exp $
+ * $Id: color_name.h,v 1.9 2021/04/24 23:25:29 tom Exp $
*/
#ifndef __COLORNAME_H
#include <test.priv.h>
#endif
-static NCURSES_CONST char *the_color_names[] =
+static NCURSES_CONST char *const the_color_names[] =
{
"black",
"red",
char *endp = 0;
size_t n;
- if ((result = strtol(color, &endp, 0)) >= 0
+ if ((result = (int) strtol(color, &endp, 0)) >= 0
&& (endp == 0 || *endp == 0)) {
;
} else if (!strcmp(color, "default")) {
}
return result;
}
-#endif /* NEED_COLOR_NAME */
+#endif /* NEED_COLOR_CODE */
#ifdef NEED_COLOR_NAME
static const char *
static char temp[20];
const char *result = 0;
- if (color > (int) SIZEOF(the_color_names)) {
- sprintf(temp, "%d", color);
+ if (color >= (int) SIZEOF(the_color_names)) {
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%d", color);
result = temp;
} else if (color < 0) {
result = "default";