From 479ad8881d388fe6ffc27e5f7dfeb890cde05162 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 26 Jan 2018 21:27:33 +0000 Subject: [PATCH] names.c: fix FIXME: retype to avoid ugly casts for argmatch use --- src/names.c | 28 +++++++++------------------- src/outer.c | 6 +++--- src/recodext.h | 4 ++-- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/names.c b/src/names.c index 46f7b21..f2a1aaf 100644 --- a/src/names.c +++ b/src/names.c @@ -205,32 +205,22 @@ disambiguate_name (RECODE_OUTER outer, abort (); case ALIAS_FIND_AS_CHARSET: - /* FIXME: How to avoid those ugly casts? */ - ordinal = argmatch (hashname, - (const char *const *) outer->argmatch_charset_array, - NULL, 0); + ordinal = argmatch (hashname, outer->argmatch_charset_array, NULL, 0); result = ordinal < 0 ? NULL : outer->realname_charset_array[ordinal]; break; case ALIAS_FIND_AS_SURFACE: - ordinal = argmatch (hashname, - (const char *const *) outer->argmatch_surface_array, - NULL, 0); + ordinal = argmatch (hashname, outer->argmatch_surface_array, NULL, 0); result = ordinal < 0 ? NULL : outer->realname_surface_array[ordinal]; break; case ALIAS_FIND_AS_EITHER: - ordinal = argmatch (hashname, - (const char *const *) outer->argmatch_charset_array, - NULL, 0); + ordinal = argmatch (hashname, outer->argmatch_charset_array, NULL, 0); if (ordinal >= 0) result = outer->realname_charset_array[ordinal]; else { - ordinal = argmatch (hashname, - (const char *const *) - outer->argmatch_surface_array, - NULL, 0); + ordinal = argmatch (hashname, outer->argmatch_surface_array, NULL, 0); result = ordinal < 0 ? NULL : outer->realname_surface_array[ordinal]; } break; @@ -480,12 +470,12 @@ make_argmatch_arrays (RECODE_OUTER outer) if (outer->argmatch_charset_array) { - char **cursor; + const char **cursor; for (cursor = outer->argmatch_charset_array; *cursor; cursor++) - free (*cursor); + free ((char *) *cursor); for (cursor = outer->argmatch_surface_array; *cursor; cursor++) - free (*cursor); + free ((char *) *cursor); free (outer->argmatch_charset_array); } @@ -500,10 +490,10 @@ make_argmatch_arrays (RECODE_OUTER outer) /* Allocate the argmatch and realname arrays, each with a NULL sentinel. */ { - char **cursor; + const char **cursor; if (!ALLOC (cursor, 2*walk.charset_counter + 2*walk.surface_counter + 4, - char *)) + const char *)) return false; outer->argmatch_charset_array = cursor; diff --git a/src/outer.c b/src/outer.c index 996845b..ce85df3 100644 --- a/src/outer.c +++ b/src/outer.c @@ -561,12 +561,12 @@ recode_delete_outer (RECODE_OUTER outer) hash_free ((Hash_table *) outer->alias_table); if (outer->argmatch_charset_array) { - char **cursor; + const char **cursor; for (cursor = outer->argmatch_charset_array; *cursor; cursor++) - free (*cursor); + free ((char **) *cursor); for (cursor = outer->argmatch_surface_array; *cursor; cursor++) - free (*cursor); + free ((char **) *cursor); free (outer->argmatch_charset_array); } free ((void *) outer->one_to_same); diff --git a/src/recodext.h b/src/recodext.h index 5d37130..9d3dd47 100644 --- a/src/recodext.h +++ b/src/recodext.h @@ -137,8 +137,8 @@ struct recode_outer unsigned number_of_symbols; /* Arrays of strings ready for argmatch. */ - char **argmatch_charset_array; - char **argmatch_surface_array; + char const **argmatch_charset_array; + char const **argmatch_surface_array; const char **realname_charset_array; const char **realname_surface_array; -- 2.50.1