* 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 <pinard@iro.umontreal.ca>
* java.c: New.
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;
}
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;
}
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)
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)
{
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)
{
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)
while (true)
{
unsigned short lookup = value;
- unsigned short *result = hash_lookup (table, &lookup);
+ unsigned short *result
+ = (unsigned short *) hash_lookup (table, &lookup);
if (result)
{
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))
while (true)
{
unsigned short lookup = value;
- unsigned short *result = hash_lookup (table, &lookup);
+ unsigned short *result
+ = (unsigned short *) hash_lookup (table, &lookup);
if (result)
{
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;
}
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;
}
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)
{
}
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)
}
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);
}
}
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)
if (hasher == NULL || comparator == NULL)
return NULL;
- table = malloc (sizeof *table);
+ table = (Hash_table *) malloc (sizeof *table);
if (table == NULL)
return NULL;
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;
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,
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);
{
void *data = bucket->data;
- if (delete)
+ if (delete_)
{
if (bucket->next)
{
{
void *data = cursor->next->data;
- if (delete)
+ if (delete_)
{
struct hash_entry *next = cursor->next;
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;
}
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;
}
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))
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;
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);
}
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;
}
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);
{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)
}
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)
{
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)
}
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)
static const char *
get_charset_aliases (void)
{
+ static char empty[1] = "";
char *cp;
cp = charset_aliases;
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. */
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)
{
}
fclose (fp);
if (res_size == 0)
- cp = "";
+ cp = empty;
else
{
*(res_ptr + res_size) = '\0';
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];
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);
}
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;
}
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)
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_*.
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);
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;
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;
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++;
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)
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. */
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;
}
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++;
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;
/* 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. */
/* 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. */
{
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 */
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)
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)
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)
{
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;
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);
}
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;
}
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;
}
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 */
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
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. */
}
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. */
{
/* 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;
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]];
&& (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]];
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++;
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;
}
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;
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;
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)
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;
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;
}
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;
}
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;
}
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
char *
xstrdup (char const *string)
{
- return xmemdup (string, strlen (string) + 1);
+ return (char *) xmemdup (string, strlen (string) + 1);
}