From 0484f68b693744b4c15963edf8f9384b2fd3ad9d Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 28 Jan 2007 00:52:21 +0200 Subject: [PATCH] get_color_string: Return a pointer to const. --- src/config/opttypes.c | 4 ++-- src/scripting/lua/core.c | 2 +- src/util/color.c | 4 ++-- src/util/color.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config/opttypes.c b/src/config/opttypes.c index 5f49ebb3d..db8b7b7dc 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -166,7 +166,7 @@ redir_add(struct option *opt, unsigned char *str) /* Support functions for config file parsing. */ static void -add_optstring_to_string(struct string *s, unsigned char *q, int qlen) +add_optstring_to_string(struct string *s, const unsigned char *q, int qlen) { if (!commandline) add_char_to_string(s, '"'); add_quoted_to_string(s, q, qlen); @@ -364,7 +364,7 @@ color_wr(struct option *opt, struct string *str) { color_T color = opt->value.color; unsigned char hexcolor[8]; - unsigned char *strcolor = get_color_string(color, hexcolor); + const unsigned char *strcolor = get_color_string(color, hexcolor); add_optstring_to_string(str, strcolor, strlen(strcolor)); } diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c index 469bf4e25..b3b47bfcc 100644 --- a/src/scripting/lua/core.c +++ b/src/scripting/lua/core.c @@ -599,7 +599,7 @@ l_get_option(LS) { color_T color; unsigned char hexcolor[8]; - unsigned char *strcolor; + const unsigned char *strcolor; color = opt->value.color; strcolor = get_color_string(color, hexcolor); diff --git a/src/util/color.c b/src/util/color.c index 92abadb1e..33d41122a 100644 --- a/src/util/color.c +++ b/src/util/color.c @@ -18,7 +18,7 @@ #include "util/string.h" struct color_spec { - char *name; + const char *name; color_T rgb; }; @@ -135,7 +135,7 @@ decode_hex_color: return -1; /* Not found */ } -unsigned char * +const unsigned char * get_color_string(color_T color, unsigned char hexcolor[8]) { struct color_spec *cs; diff --git a/src/util/color.h b/src/util/color.h index 5e0240c82..7fb6c46e9 100644 --- a/src/util/color.h +++ b/src/util/color.h @@ -17,7 +17,7 @@ int decode_color(unsigned char *str, int slen, color_T *color); /* Returns a string containing the color info. If no ``English'' name can be * found the hex color (#rrggbb) is returned in the given buffer. */ -unsigned char *get_color_string(color_T color, unsigned char hexcolor[8]); +const unsigned char *get_color_string(color_T color, unsigned char hexcolor[8]); /* Translate rgb color to string in #rrggbb format. str should be a pointer to * a 8 bytes memory space. */