From 5d16f148eb8a1d092a6b33e0c39d1d3d853c2328 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Pinard?= Date: Fri, 14 Mar 2008 13:18:57 -0400 Subject: [PATCH] Towards C++ --- src/ChangeLog | 4 ++++ src/combine.c | 46 +++++++++++++++++++------------------ src/hash.c | 24 +++++++++++--------- src/html.c | 21 +++++++++-------- src/ibmpc.c | 15 ++++++++----- src/localcharset.c | 9 ++++---- src/names.c | 56 ++++++++++++++++++++++++++-------------------- src/outer.c | 4 ++-- src/quotearg.c | 2 +- src/recode.c | 14 ++++++------ src/request.c | 20 ++++++++--------- src/rfc1345.c | 4 ++-- src/task.c | 5 +++-- src/testdump.c | 16 ++++++++----- src/xmalloc.c | 2 +- 15 files changed, 136 insertions(+), 106 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7c8060c..0dfcbb9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -3,6 +3,10 @@ * main.c: Inhibit iconv whenever -h is used. Reported by Richard Nault. + * combine.c, hash.c, html.c, ibmpc.c, localcharset.c, names.c, + outer.c, quotearg.c, recode.c, request.c, rfc1345.c, task.c, + testdump.c, xmalloc.c: Changes in view of C++. + 2008-03-13 François Pinard * java.c: New. diff --git a/src/combine.c b/src/combine.c index 02dcbac..b7fc116 100644 --- a/src/combine.c +++ b/src/combine.c @@ -65,7 +65,7 @@ static size_t combined_hash (const void *void_data, size_t table_size) { - const unsigned short *data = void_data; + const unsigned short *data = (const unsigned short *) void_data; return *data % table_size; } @@ -73,8 +73,8 @@ combined_hash (const void *void_data, size_t table_size) static bool combined_compare (const void *void_first, const void *void_second) { - const unsigned short *first = void_first; - const unsigned short *second = void_second; + const unsigned short *first = (const unsigned short *) void_first; + const unsigned short *second = (const unsigned short *) void_second; return *first == *second; } @@ -85,7 +85,7 @@ init_explode (RECODE_STEP step, RECODE_CONST_OPTION_LIST before_options, RECODE_CONST_OPTION_LIST after_options) { - const unsigned short *data = step->step_table; + const unsigned short *data = (const unsigned short *) step->step_table; Hash_table *table; if (before_options || after_options) @@ -121,13 +121,13 @@ init_explode (RECODE_STEP step, bool explode_byte_byte (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->step_table; + Hash_table *table = (Hash_table *) subtask->step->step_table; unsigned value; while (value = get_byte (subtask), value != EOF) { unsigned short lookup = value; - unsigned short *result = hash_lookup (table, &lookup); + unsigned short *result = (unsigned short *) hash_lookup (table, &lookup); if (result) { @@ -148,13 +148,13 @@ explode_byte_byte (RECODE_SUBTASK subtask) bool explode_ucs2_byte (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->step_table; + Hash_table *table = (Hash_table *) subtask->step->step_table; unsigned value; while (get_ucs2 (&value, subtask)) { unsigned short lookup = value; - unsigned short *result = hash_lookup (table, &lookup); + unsigned short *result = (unsigned short *) hash_lookup (table, &lookup); if (result) { @@ -175,7 +175,7 @@ explode_ucs2_byte (RECODE_SUBTASK subtask) bool explode_byte_ucs2 (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->step_table; + Hash_table *table = (Hash_table *) subtask->step->step_table; unsigned value; if (value = get_byte (subtask), value != EOF) @@ -186,7 +186,8 @@ explode_byte_ucs2 (RECODE_SUBTASK subtask) while (true) { unsigned short lookup = value; - unsigned short *result = hash_lookup (table, &lookup); + unsigned short *result + = (unsigned short *) hash_lookup (table, &lookup); if (result) { @@ -208,7 +209,7 @@ explode_byte_ucs2 (RECODE_SUBTASK subtask) bool explode_ucs2_ucs2 (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->step_table; + Hash_table *table = (Hash_table *) subtask->step->step_table; unsigned value; if (get_ucs2 (&value, subtask)) @@ -219,7 +220,8 @@ explode_ucs2_ucs2 (RECODE_SUBTASK subtask) while (true) { unsigned short lookup = value; - unsigned short *result = hash_lookup (table, &lookup); + unsigned short *result + = (unsigned short *) hash_lookup (table, &lookup); if (result) { @@ -265,7 +267,7 @@ struct state static size_t state_hash (const void *void_data, size_t table_size) { - const struct state *data = void_data; + const struct state *data = (const struct state *) void_data; return data->character % table_size; } @@ -273,8 +275,8 @@ state_hash (const void *void_data, size_t table_size) static bool state_compare (const void *void_first, const void *void_second) { - const struct state *first = void_first; - const struct state *second = void_second; + const struct state *first = (const struct state *) void_first; + const struct state *second = (const struct state *) void_second; return first->character == second->character; } @@ -282,8 +284,8 @@ state_compare (const void *void_first, const void *void_second) static void state_free (void *void_state) { - struct state *state = void_state; - struct state *shift = state->shift; + struct state *state = (struct state *) void_state; + struct state *shift = (struct state *) state->shift; while (shift != NULL) { @@ -321,11 +323,11 @@ prepare_shifted_state (struct state *state, unsigned character, } else { - Hash_table *table = step->step_table; + Hash_table *table = (Hash_table *) step->step_table; struct state lookup; lookup.character = character; - state = hash_lookup (table, &lookup); + state = (struct state *) hash_lookup (table, &lookup); if (!state) { if (state= (struct state *) malloc (sizeof (struct state)), !state) @@ -362,11 +364,11 @@ find_shifted_state (struct state *state, unsigned character, } else { - Hash_table *table = step->step_table; + Hash_table *table = (Hash_table *) step->step_table; struct state lookup; lookup.character = character; - return hash_lookup (table, &lookup); + return (struct state *) hash_lookup (table, &lookup); } } @@ -376,7 +378,7 @@ init_combine (RECODE_STEP step, RECODE_CONST_OPTION_LIST before_options, RECODE_CONST_OPTION_LIST after_options) { - const unsigned short *data = step->step_table; + const unsigned short *data = (const unsigned short *) step->step_table; Hash_table *table; if (before_options || after_options) diff --git a/src/hash.c b/src/hash.c index b926c3d..d8ba8d5 100644 --- a/src/hash.c +++ b/src/hash.c @@ -546,7 +546,7 @@ hash_initialize (size_t candidate, const Hash_tuning *tuning, if (hasher == NULL || comparator == NULL) return NULL; - table = malloc (sizeof *table); + table = (Hash_table *) malloc (sizeof *table); if (table == NULL) return NULL; @@ -577,7 +577,8 @@ hash_initialize (size_t candidate, const Hash_tuning *tuning, if (xalloc_oversized (table->n_buckets, sizeof *table->bucket)) goto fail; - table->bucket = calloc (table->n_buckets, sizeof *table->bucket); + table->bucket + = (struct hash_entry *) calloc (table->n_buckets, sizeof *table->bucket); table->bucket_limit = table->bucket + table->n_buckets; table->n_buckets_used = 0; table->n_entries = 0; @@ -704,23 +705,24 @@ hash_free (Hash_table *table) static struct hash_entry * allocate_entry (Hash_table *table) { - struct hash_entry *new; + struct hash_entry *new_; if (table->free_entry_list) { - new = table->free_entry_list; - table->free_entry_list = new->next; + new_ = table->free_entry_list; + table->free_entry_list = new_->next; } else { #if USE_OBSTACK - new = obstack_alloc (&table->entry_stack, sizeof *new); + new_ = (struct hash_entry *) obstack_alloc (&table->entry_stack, + sizeof *new_); #else - new = malloc (sizeof *new); + new_ = (struct hash_entry *) malloc (sizeof *new_); #endif } - return new; + return new_; } /* Free a hash entry which was part of some bucket overflow, @@ -742,7 +744,7 @@ free_entry (Hash_table *table, struct hash_entry *entry) static void * hash_find_entry (Hash_table *table, const void *entry, - struct hash_entry **bucket_head, bool delete) + struct hash_entry **bucket_head, bool delete_) { struct hash_entry *bucket = table->bucket + table->hasher (entry, table->n_buckets); @@ -762,7 +764,7 @@ hash_find_entry (Hash_table *table, const void *entry, { void *data = bucket->data; - if (delete) + if (delete_) { if (bucket->next) { @@ -789,7 +791,7 @@ hash_find_entry (Hash_table *table, const void *entry, { void *data = cursor->next->data; - if (delete) + if (delete_) { struct hash_entry *next = cursor->next; diff --git a/src/html.c b/src/html.c index 08a7acd..2f4a340 100644 --- a/src/html.c +++ b/src/html.c @@ -390,7 +390,7 @@ static struct ucs2_to_string translations [] = static size_t code_hash (const void *void_data, size_t table_size) { - struct ucs2_to_string const *data = void_data; + struct ucs2_to_string const *data = (struct ucs2_to_string const *) void_data; return data->code % table_size; } @@ -402,8 +402,10 @@ code_hash (const void *void_data, size_t table_size) static bool code_compare (const void *void_first, const void *void_second) { - struct ucs2_to_string const *first = void_first; - struct ucs2_to_string const *second = void_second; + struct ucs2_to_string const *first + = (struct ucs2_to_string const *) void_first; + struct ucs2_to_string const *second + = (struct ucs2_to_string const *) void_second; return first->code == second->code; } @@ -507,7 +509,7 @@ init_ucs2_html_v40 (RECODE_STEP step, static bool transform_ucs2_html (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->step_table; + Hash_table *table = (Hash_table *) subtask->step->step_table; unsigned value; while (get_ucs2 (&value, subtask)) @@ -516,7 +518,7 @@ transform_ucs2_html (RECODE_SUBTASK subtask) struct ucs2_to_string *entry; lookup.code = value; - entry = hash_lookup (table, &lookup); + entry = (struct ucs2_to_string *) hash_lookup (table, &lookup); if (entry) { const char *cursor = entry->string; @@ -571,7 +573,7 @@ transform_ucs2_html (RECODE_SUBTASK subtask) static size_t string_hash (const void *void_data, size_t table_size) { - struct ucs2_to_string const *data = void_data; + struct ucs2_to_string const *data = (struct ucs2_to_string const *) void_data; return hash_string (data->string, table_size); } @@ -583,8 +585,8 @@ string_hash (const void *void_data, size_t table_size) static bool string_compare (const void *void_first, const void *void_second) { - struct ucs2_to_string const *first = void_first; - struct ucs2_to_string const *second = void_second; + struct ucs2_to_string const *first = (struct ucs2_to_string const *) void_first; + struct ucs2_to_string const *second = (struct ucs2_to_string const *) void_second; return strcmp (first->string, second->string) == 0; } @@ -825,7 +827,8 @@ transform_html_ucs2 (RECODE_SUBTASK subtask) struct ucs2_to_string *entry; lookup.string = buffer; - entry = hash_lookup (subtask->step->step_table, &lookup); + entry = (struct ucs2_to_string *) hash_lookup + ((const Hash_table *) subtask->step->step_table, &lookup); if (entry) { put_ucs2 (entry->code, subtask); diff --git a/src/ibmpc.c b/src/ibmpc.c index c7e422e..6fcdffa 100644 --- a/src/ibmpc.c +++ b/src/ibmpc.c @@ -164,14 +164,16 @@ static struct recode_known_pair known_pairs[] = {255, 160}, /* no-break space */ }; -#define NUMBER_OF_PAIRS (sizeof (known_pairs) / sizeof (struct recode_known_pair)) +#define NUMBER_OF_PAIRS \ + (sizeof (known_pairs) / sizeof (struct recode_known_pair)) static bool transform_latin1_ibmpc (RECODE_SUBTASK subtask) { if (subtask->step->fallback_routine == reversibility) { - const unsigned char *table = subtask->step->step_table; + const unsigned char *table + = (const unsigned char *) subtask->step->step_table; int input_char; while (input_char = get_byte (subtask), input_char != EOF) @@ -185,7 +187,8 @@ transform_latin1_ibmpc (RECODE_SUBTASK subtask) } else { - const char *const *table = subtask->step->step_table; + const char *const *table + = (const char *const *) subtask->step->step_table; int input_char; while (input_char = get_byte (subtask), input_char != EOF) @@ -207,7 +210,8 @@ transform_ibmpc_latin1 (RECODE_SUBTASK subtask) { if (subtask->step->fallback_routine == reversibility) { - const unsigned char *table = subtask->step->step_table; + const unsigned char *table + = (const unsigned char *) subtask->step->step_table; int input_char = get_byte (subtask); while (input_char != EOF) @@ -240,7 +244,8 @@ transform_ibmpc_latin1 (RECODE_SUBTASK subtask) } else { - const char *const *table = subtask->step->step_table; + const char *const *table + = (const char *const *) subtask->step->step_table; int input_char = get_byte (subtask); while (input_char != EOF) diff --git a/src/localcharset.c b/src/localcharset.c index 54c75ba..564b2d7 100644 --- a/src/localcharset.c +++ b/src/localcharset.c @@ -78,6 +78,7 @@ static char * volatile charset_aliases; static const char * get_charset_aliases (void) { + static char empty[1] = ""; char *cp; cp = charset_aliases; @@ -106,7 +107,7 @@ get_charset_aliases (void) if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL) /* Out of memory or file not found, treat it as empty. */ - cp = ""; + cp = empty; else { /* Parse the file's contents. */ @@ -142,12 +143,12 @@ get_charset_aliases (void) if (res_size == 0) { res_size = l1 + 1 + l2 + 1; - res_ptr = malloc (res_size + 1); + res_ptr = (char *) malloc (res_size + 1); } else { res_size += l1 + 1 + l2 + 1; - res_ptr = realloc (res_ptr, res_size + 1); + res_ptr = (char *) realloc (res_ptr, res_size + 1); } if (res_ptr == NULL) { @@ -160,7 +161,7 @@ get_charset_aliases (void) } fclose (fp); if (res_size == 0) - cp = ""; + cp = empty; else { *(res_ptr + res_size) = '\0'; diff --git a/src/names.c b/src/names.c index 6e3e86a..1758520 100644 --- a/src/names.c +++ b/src/names.c @@ -29,7 +29,7 @@ int code_to_ucs2 (RECODE_CONST_SYMBOL charset, unsigned code) { - const struct strip_data *data = charset->data; + const struct strip_data *data = (const struct strip_data *) charset->data; const recode_ucs2 *pool = data->pool; unsigned offset = data->offset[code / STRIP_SIZE]; unsigned value = pool[offset + code % STRIP_SIZE]; @@ -87,7 +87,7 @@ check_restricted (RECODE_CONST_OUTER outer, static size_t alias_hasher (const void *void_alias, size_t limit) { - RECODE_CONST_ALIAS alias = void_alias; + RECODE_CONST_ALIAS alias = (RECODE_CONST_ALIAS) void_alias; return hash_string (alias->name, limit); } @@ -95,8 +95,8 @@ alias_hasher (const void *void_alias, size_t limit) static bool alias_comparator (const void *void_first, const void *void_second) { - RECODE_CONST_ALIAS first = void_first; - RECODE_CONST_ALIAS second = void_second; + RECODE_CONST_ALIAS first = (RECODE_CONST_ALIAS) void_first; + RECODE_CONST_ALIAS second = (RECODE_CONST_ALIAS) void_second; return strcmp (first->name, second->name) == 0; } @@ -104,7 +104,7 @@ alias_comparator (const void *void_first, const void *void_second) static void alias_free (void *void_alias) { - RECODE_ALIAS alias = void_alias; + RECODE_ALIAS alias = (RECODE_ALIAS) void_alias; struct recode_surface_list *list, *next; for (list = alias->implied_surfaces; list; list = next) @@ -291,7 +291,8 @@ find_alias (RECODE_OUTER outer, const char *name, if (!name) return NULL; lookup.name = name; - if (alias = hash_lookup (outer->alias_table, &lookup), alias) + if (alias = (RECODE_ALIAS) hash_lookup + ((const Hash_table *) outer->alias_table, &lookup), alias) return alias; /* If we reach this point, find_type is necessarily one of SYMBOL_CREATE_*. @@ -318,7 +319,7 @@ find_alias (RECODE_OUTER outer, const char *name, alias->name = name; alias->symbol = symbol; alias->implied_surfaces = NULL; - if (!hash_insert (outer->alias_table, alias)) + if (!hash_insert ((Hash_table *) outer->alias_table, alias)) { free (symbol); free (alias); @@ -350,7 +351,8 @@ declare_alias (RECODE_OUTER outer, const char *name, const char *old_name) symbol = alias->symbol; lookup.name = name; - if (alias = hash_lookup (outer->alias_table, &lookup), alias) + if (alias = (RECODE_ALIAS) hash_lookup + ((Hash_table *) outer->alias_table, &lookup), alias) { if (alias->symbol == symbol) return alias; @@ -366,7 +368,7 @@ declare_alias (RECODE_OUTER outer, const char *name, const char *old_name) alias->name = name; alias->symbol = symbol; alias->implied_surfaces = NULL; - if (!hash_insert (outer->alias_table, alias)) + if (!hash_insert ((Hash_table *) outer->alias_table, alias)) { free (alias); return NULL; @@ -420,8 +422,8 @@ struct make_argmatch_walk static bool make_argmatch_walker_1 (void *void_alias, void *void_walk) { - RECODE_ALIAS alias = void_alias; - struct make_argmatch_walk *walk = void_walk; + RECODE_ALIAS alias = (RECODE_ALIAS) void_alias; + struct make_argmatch_walk *walk = (struct make_argmatch_walk *) void_walk; if (alias->symbol->type == RECODE_CHARSET) walk->charset_counter++; @@ -434,8 +436,8 @@ make_argmatch_walker_1 (void *void_alias, void *void_walk) static bool make_argmatch_walker_2 (void *void_alias, void *void_walk) { - RECODE_ALIAS alias = void_alias; - struct make_argmatch_walk *walk = void_walk; + RECODE_ALIAS alias = (RECODE_ALIAS) void_alias; + struct make_argmatch_walk *walk = (struct make_argmatch_walk *) void_walk; RECODE_OUTER outer = walk->outer; if (alias->symbol->type == RECODE_CHARSET) @@ -490,7 +492,8 @@ make_argmatch_arrays (RECODE_OUTER outer) walk.outer = outer; walk.charset_counter = 0; walk.surface_counter = 0; - hash_do_for_each (outer->alias_table, make_argmatch_walker_1, &walk); + hash_do_for_each ((Hash_table *) outer->alias_table, + make_argmatch_walker_1, &walk); /* Allocate the argmatch and realname arrays, each with a NULL sentinel. */ @@ -522,7 +525,8 @@ make_argmatch_arrays (RECODE_OUTER outer) walk.charset_counter = 0; walk.surface_counter = 0; - hash_do_for_each (outer->alias_table, make_argmatch_walker_2, &walk); + hash_do_for_each ((Hash_table *) outer->alias_table, + make_argmatch_walker_2, &walk); return true; } @@ -645,8 +649,8 @@ struct list_symbols_walk static bool list_symbols_walker_1 (void *void_alias, void *void_walk) { - RECODE_ALIAS alias = void_alias; - struct list_symbols_walk *walk = void_walk; + RECODE_ALIAS alias = (RECODE_ALIAS) void_alias; + struct list_symbols_walk *walk = (struct list_symbols_walk *) void_walk; if (!alias->symbol->ignore) walk->number++; @@ -657,8 +661,8 @@ list_symbols_walker_1 (void *void_alias, void *void_walk) static bool list_symbols_walker_2 (void *void_alias, void *void_walk) { - RECODE_ALIAS alias = void_alias; - struct list_symbols_walk *walk = void_walk; + RECODE_ALIAS alias = (RECODE_ALIAS) void_alias; + struct list_symbols_walk *walk = (struct list_symbols_walk *) void_walk; if (!alias->symbol->ignore) walk->array[walk->number++] = *alias; @@ -676,7 +680,8 @@ list_all_symbols (RECODE_OUTER outer, RECODE_CONST_SYMBOL after) /* Count how many symbols we have. */ walk.number = 0; - hash_do_for_each (outer->alias_table, list_symbols_walker_1, &walk); + hash_do_for_each ((Hash_table *) outer->alias_table, + list_symbols_walker_1, &walk); /* Allocate a structure to hold them. */ @@ -686,7 +691,8 @@ list_all_symbols (RECODE_OUTER outer, RECODE_CONST_SYMBOL after) /* Copy all symbols in it. */ walk.number = 0; - hash_do_for_each (outer->alias_table, list_symbols_walker_2, &walk); + hash_do_for_each ((Hash_table *) outer->alias_table, + list_symbols_walker_2, &walk); /* Sort it. */ @@ -995,7 +1001,7 @@ list_full_charset (RECODE_OUTER outer, RECODE_CONST_SYMBOL charset) { case RECODE_EXPLODE_DATA: { - const unsigned short *data = charset->data; + const unsigned short *data = (const unsigned short *) charset->data; unsigned code; /* code counter */ unsigned expected; /* expected value for code counter */ bool insert_white; /* insert a while line before printing */ @@ -1088,7 +1094,8 @@ find_and_report_subsets (RECODE_OUTER outer) charset1; charset1 = charset1->next) { - const struct strip_data *table1 = charset1->data; + const struct strip_data *table1 + = (const struct strip_data *) charset1->data; RECODE_SYMBOL charset2; if (charset1->ignore || charset1->data_type != RECODE_STRIP_DATA) @@ -1098,7 +1105,8 @@ find_and_report_subsets (RECODE_OUTER outer) charset2; charset2 = charset2->next) { - const struct strip_data *table2 = charset2->data; + const struct strip_data *table2 + = (const struct strip_data *) charset2->data; if (charset2->ignore || charset2->data_type != RECODE_STRIP_DATA || charset2 == charset1) diff --git a/src/outer.c b/src/outer.c index 1d95d93..77bc183 100644 --- a/src/outer.c +++ b/src/outer.c @@ -542,7 +542,7 @@ unregister_all_modules (RECODE_OUTER outer) RECODE_OUTER recode_new_outer (unsigned flags) { - RECODE_OUTER outer = malloc (sizeof (struct recode_outer)); + RECODE_OUTER outer = (RECODE_OUTER) malloc (sizeof (struct recode_outer)); if (!outer) { @@ -621,7 +621,7 @@ recode_delete_outer (RECODE_OUTER outer) if (outer->pair_restriction) free (outer->pair_restriction); if (outer->alias_table) - hash_free (outer->alias_table); + hash_free ((Hash_table *) outer->alias_table); if (outer->argmatch_charset_array) { char **cursor; diff --git a/src/quotearg.c b/src/quotearg.c index 06f5fea..0bef8cb 100644 --- a/src/quotearg.c +++ b/src/quotearg.c @@ -352,7 +352,7 @@ quotearg_n_options (int n, char const *arg, if (size <= qsize) { slotvec[n].size = size = qsize + 1; - slotvec[n].val = val = xrealloc (val, size); + slotvec[n].val = val = (char *) xrealloc (val, size); quotearg_buffer (val, size, arg, (size_t) -1, options); } diff --git a/src/recode.c b/src/recode.c index e2ce127..7c4760a 100644 --- a/src/recode.c +++ b/src/recode.c @@ -391,7 +391,7 @@ transform_byte_to_ucs2 (RECODE_SUBTASK subtask) static size_t ucs2_to_byte_hash (const void *void_data, size_t table_size) { - const struct ucs2_to_byte *data = void_data; + const struct ucs2_to_byte *data = (const struct ucs2_to_byte *) void_data; return data->code % table_size; } @@ -399,8 +399,8 @@ ucs2_to_byte_hash (const void *void_data, size_t table_size) static bool ucs2_to_byte_compare (const void *void_first, const void *void_second) { - const struct ucs2_to_byte *first = void_first; - const struct ucs2_to_byte *second = void_second; + const struct ucs2_to_byte *first = (const struct ucs2_to_byte *) void_first; + const struct ucs2_to_byte *second = (const struct ucs2_to_byte *) void_second; return first->code == second->code; } @@ -449,7 +449,7 @@ init_ucs2_to_byte (RECODE_STEP step, bool transform_ucs2_to_byte (RECODE_SUBTASK subtask) { - Hash_table *table = subtask->step->local; + Hash_table *table = (Hash_table *) subtask->step->local; struct ucs2_to_byte lookup; struct ucs2_to_byte *entry; unsigned input_value; /* current UCS-2 character */ @@ -457,7 +457,7 @@ transform_ucs2_to_byte (RECODE_SUBTASK subtask) while (get_ucs2 (&input_value, subtask)) { lookup.code = input_value; - entry = hash_lookup (table, &lookup); + entry = (struct ucs2_to_byte *) hash_lookup (table, &lookup); if (entry) put_byte (entry->byte, subtask); else @@ -575,7 +575,7 @@ recode_format_table (RECODE_REQUEST request, if (step->step_type == RECODE_BYTE_TO_BYTE) { - const unsigned char *table = step->step_table; + const unsigned char *table = (const unsigned char *) step->step_table; /* Produce a one to one recoding table. */ @@ -617,7 +617,7 @@ recode_format_table (RECODE_REQUEST request, } else if (step->step_type == RECODE_BYTE_TO_STRING) { - const char *const *table = step->step_table; + const char *const *table = (const char *const *) step->step_table; /* Produce a one to many recoding table. */ diff --git a/src/request.c b/src/request.c index 9317101..9964425 100644 --- a/src/request.c +++ b/src/request.c @@ -472,7 +472,7 @@ complete_double_ucs2_step (RECODE_OUTER outer, RECODE_STEP step) { /* Construct the array of binding items for the charset. */ - data = side->charset->data; + data = (const struct strip_data *) side->charset->data; pool = data->pool; item_cursor = side->item; byte = 0; @@ -649,7 +649,7 @@ simplify_sequence (RECODE_REQUEST request) while (in < limit && (table_type (request, in) == RECODE_BYTE_TO_BYTE)) { - const unsigned char *table = in->step_table; + const unsigned char *table = (const unsigned char *) in->step_table; for (counter = 0; counter < 256; counter++) temp[counter] = table[accum[counter]]; @@ -670,7 +670,7 @@ simplify_sequence (RECODE_REQUEST request) && (ALLOC (string, 256, const char *))) { - const char *const *table = in->step_table; + const char *const *table = (const char *const *) in->step_table; for (counter = 0; counter < 256; counter++) string[counter] = table[accum[counter]]; @@ -754,11 +754,11 @@ scan_options (RECODE_REQUEST request) while (*request->scan_cursor == '+') { - RECODE_OPTION_LIST new - = ALLOC (new, 1, struct recode_option_list); + RECODE_OPTION_LIST new_ + = ALLOC (new_, 1, struct recode_option_list); char *copy; - if (!new) + if (!new_) break; /* FIXME: should interrupt decoding */ request->scan_cursor++; @@ -768,11 +768,11 @@ scan_options (RECODE_REQUEST request) break; /* FIXME: should interrupt decoding */ strcpy (copy, request->scanned_string); - new->option = copy; + new_->option = copy; if (!list) - list = new; - new->next = last; - last = new; + list = new_; + new_->next = last; + last = new_; } return list; } diff --git a/src/rfc1345.c b/src/rfc1345.c index 16afe1d..e80c146 100644 --- a/src/rfc1345.c +++ b/src/rfc1345.c @@ -92,7 +92,7 @@ struct local static bool transform_ucs2_rfc1345 (RECODE_SUBTASK subtask) { - struct local *local = subtask->step->local; + struct local *local = (struct local *) subtask->step->local; const char intro = local->intro; unsigned value; @@ -144,7 +144,7 @@ transform_ucs2_rfc1345 (RECODE_SUBTASK subtask) static bool transform_rfc1345_ucs2 (RECODE_SUBTASK subtask) { - struct local *local = subtask->step->local; + struct local *local = (struct local *) subtask->step->local; const char intro = local->intro; int character; diff --git a/src/task.c b/src/task.c index 9bdf6c2..ad1d5a6 100644 --- a/src/task.c +++ b/src/task.c @@ -223,7 +223,8 @@ transform_mere_copy (RECODE_SUBTASK subtask) bool transform_byte_to_byte (RECODE_SUBTASK subtask) { - unsigned const char *table = subtask->step->step_table; + unsigned const char *table + = (unsigned const char *) subtask->step->step_table; int input_char; while (input_char = get_byte (subtask), input_char != EOF) @@ -239,7 +240,7 @@ transform_byte_to_byte (RECODE_SUBTASK subtask) bool transform_byte_to_variable (RECODE_SUBTASK subtask) { - const char *const *table = subtask->step->step_table; + const char *const *table = (const char *const *) subtask->step->step_table; int input_char; const char *output_string; diff --git a/src/testdump.c b/src/testdump.c index 4252a53..7cb4950 100644 --- a/src/testdump.c +++ b/src/testdump.c @@ -121,7 +121,7 @@ struct ucs2_to_count static size_t ucs2_to_count_hash (const void *void_data, size_t table_size) { - const struct ucs2_to_count *data = void_data; + const struct ucs2_to_count *data = (const struct ucs2_to_count *) void_data; return data->code % table_size; } @@ -129,8 +129,10 @@ ucs2_to_count_hash (const void *void_data, size_t table_size) static bool ucs2_to_count_compare (const void *void_first, const void *void_second) { - const struct ucs2_to_count *first = void_first; - const struct ucs2_to_count *second = void_second; + const struct ucs2_to_count *first + = (const struct ucs2_to_count *) void_first; + const struct ucs2_to_count *second + = (const struct ucs2_to_count *) void_second; return first->code == second->code; } @@ -138,8 +140,10 @@ ucs2_to_count_compare (const void *void_first, const void *void_second) static int compare_item (const void *void_first, const void *void_second) { - struct ucs2_to_count *const *first = void_first; - struct ucs2_to_count *const *second = void_second; + struct ucs2_to_count *const *first + = (struct ucs2_to_count *const *) void_first; + struct ucs2_to_count *const *second + = (struct ucs2_to_count *const *) void_second; return (*first)->code - (*second)->code; } @@ -177,7 +181,7 @@ produce_count (RECODE_SUBTASK subtask) struct ucs2_to_count *entry; lookup.code = character; - entry = hash_lookup (table, &lookup); + entry = (struct ucs2_to_count *) hash_lookup (table, &lookup); if (entry) entry->count++; else diff --git a/src/xmalloc.c b/src/xmalloc.c index 687633c..d66054f 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -237,5 +237,5 @@ xmemdup (void const *p, size_t s) char * xstrdup (char const *string) { - return xmemdup (string, strlen (string) + 1); + return (char *) xmemdup (string, strlen (string) + 1); } -- 2.40.0