* listing.c: Convert to ISO-C.

* listing.h: Likewise.
	* macro.c: Likewise.
	* macro.h: Likewise.
This commit is contained in:
Kazu Hirata 2003-11-24 17:52:33 +00:00
parent 9e08b29bd1
commit 254d758cf9
6 changed files with 125 additions and 235 deletions

View File

@ -1,3 +1,10 @@
2003-11-24 Kazu Hirata <kazu@cs.umass.edu>
* listing.c: Convert to ISO-C.
* listing.h: Likewise.
* macro.c: Likewise.
* macro.h: Likewise.
2003-11-24 Jakub Jelinek <jakub@redhat.com>
* app.c (do_scrub_chars): Add PUT (ch) and ch = GET ()

View File

@ -204,27 +204,22 @@ static FILE *list_file;
static char *data_buffer;
/* Prototypes. */
static void listing_message PARAMS ((const char *name, const char *message));
static file_info_type *file_info PARAMS ((const char *file_name));
static void new_frag PARAMS ((void));
static char *buffer_line PARAMS ((file_info_type *file,
char *line, unsigned int size));
static void listing_page PARAMS ((list_info_type *list));
static unsigned int calc_hex PARAMS ((list_info_type *list));
static void print_lines PARAMS ((list_info_type *, unsigned int,
char *, unsigned int));
static void list_symbol_table PARAMS ((void));
static void print_source PARAMS ((file_info_type *current_file,
list_info_type *list,
char *buffer,
unsigned int width));
static int debugging_pseudo PARAMS ((list_info_type *, const char *));
static void listing_listing PARAMS ((char *name));
static void listing_message (const char *name, const char *message);
static file_info_type *file_info (const char *file_name);
static void new_frag (void);
static char *buffer_line (file_info_type *file, char *line, unsigned int size);
static void listing_page (list_info_type *list);
static unsigned int calc_hex (list_info_type *list);
static void print_lines (list_info_type *, unsigned int,
char *, unsigned int);
static void list_symbol_table (void);
static void print_source (file_info_type *current_file, list_info_type *list,
char *buffer, unsigned int width);
static int debugging_pseudo (list_info_type *, const char *);
static void listing_listing (char *name);
static void
listing_message (name, message)
const char *name;
const char *message;
listing_message (const char *name, const char *message)
{
if (listing_tail != (list_info_type *) NULL)
{
@ -237,22 +232,19 @@ listing_message (name, message)
}
void
listing_warning (message)
const char *message;
listing_warning (const char *message)
{
listing_message (_("Warning:"), message);
}
void
listing_error (message)
const char *message;
listing_error (const char *message)
{
listing_message (_("Error:"), message);
}
static file_info_type *
file_info (file_name)
const char *file_name;
file_info (const char *file_name)
{
/* Find an entry with this file name. */
file_info_type *p = file_info_head;
@ -278,7 +270,7 @@ file_info (file_name)
}
static void
new_frag ()
new_frag (void)
{
frag_wane (frag_now);
@ -287,8 +279,7 @@ new_frag ()
}
void
listing_newline (ps)
char *ps;
listing_newline (char *ps)
{
char *file;
unsigned int line;
@ -432,7 +423,7 @@ listing_newline (ps)
with the new instruction. */
void
listing_prev_line ()
listing_prev_line (void)
{
list_info_type *l;
fragS *f;
@ -459,10 +450,7 @@ listing_prev_line ()
file to make. */
static char *
buffer_line (file, line, size)
file_info_type *file;
char *line;
unsigned int size;
buffer_line (file_info_type *file, char *line, unsigned int size)
{
unsigned int count = 0;
int c;
@ -533,8 +521,7 @@ static char *subtitle; /* Current subtitle */
static unsigned int on_page; /* Number of lines printed on current page */
static void
listing_page (list)
list_info_type *list;
listing_page (list_info_type *list)
{
/* Grope around, see if we can see a title or subtitle edict coming up
soon. (we look down 10 lines of the page and see if it's there) */
@ -577,8 +564,7 @@ listing_page (list)
}
static unsigned int
calc_hex (list)
list_info_type *list;
calc_hex (list_info_type *list)
{
int data_buffer_size;
list_info_type *first = list;
@ -653,11 +639,8 @@ calc_hex (list)
}
static void
print_lines (list, lineno, string, address)
list_info_type *list;
unsigned int lineno;
char *string;
unsigned int address;
print_lines (list_info_type *list, unsigned int lineno,
char *string, unsigned int address)
{
unsigned int idx;
unsigned int nchars;
@ -761,7 +744,7 @@ print_lines (list, lineno, string, address)
}
static void
list_symbol_table ()
list_symbol_table (void)
{
extern symbolS *symbol_rootP;
int got_some = 0;
@ -869,11 +852,8 @@ list_symbol_table ()
}
static void
print_source (current_file, list, buffer, width)
file_info_type *current_file;
list_info_type *list;
char *buffer;
unsigned int width;
print_source (file_info_type *current_file, list_info_type *list,
char *buffer, unsigned int width)
{
if (!current_file->at_end)
{
@ -893,9 +873,7 @@ print_source (current_file, list, buffer, width)
records inserted by the compiler, see if the line is suspicious. */
static int
debugging_pseudo (list, line)
list_info_type *list;
const char *line;
debugging_pseudo (list_info_type *list, const char *line)
{
static int in_debug;
int was_debug;
@ -965,8 +943,7 @@ debugging_pseudo (list, line)
}
static void
listing_listing (name)
char *name ATTRIBUTE_UNUSED;
listing_listing (char *name ATTRIBUTE_UNUSED)
{
list_info_type *list = head;
file_info_type *current_hll_file = (file_info_type *) NULL;
@ -1107,8 +1084,7 @@ listing_listing (name)
}
void
listing_print (name)
char *name;
listing_print (char *name)
{
int using_stdout;
@ -1161,23 +1137,20 @@ listing_print (name)
}
void
listing_file (name)
const char *name;
listing_file (const char *name)
{
fn = name;
}
void
listing_eject (ignore)
int ignore ATTRIBUTE_UNUSED;
listing_eject (int ignore ATTRIBUTE_UNUSED)
{
if (listing)
listing_tail->edict = EDICT_EJECT;
}
void
listing_flags (ignore)
int ignore ATTRIBUTE_UNUSED;
listing_flags (int ignore ATTRIBUTE_UNUSED)
{
while ((*input_line_pointer++) && (*input_line_pointer != '\n'))
input_line_pointer++;
@ -1190,8 +1163,7 @@ listing_flags (ignore)
the current line should be listed, but the next line should not. */
void
listing_list (on)
int on;
listing_list (int on)
{
if (listing)
{
@ -1220,8 +1192,7 @@ listing_list (on)
}
void
listing_psize (width_only)
int width_only;
listing_psize (int width_only)
{
if (! width_only)
{
@ -1248,15 +1219,13 @@ listing_psize (width_only)
}
void
listing_nopage (ignore)
int ignore ATTRIBUTE_UNUSED;
listing_nopage (int ignore ATTRIBUTE_UNUSED)
{
paper_height = 0;
}
void
listing_title (depth)
int depth;
listing_title (int depth)
{
int quoted;
char *start;
@ -1308,8 +1277,7 @@ listing_title (depth)
}
void
listing_source_line (line)
unsigned int line;
listing_source_line (unsigned int line)
{
if (listing)
{
@ -1320,8 +1288,7 @@ listing_source_line (line)
}
void
listing_source_file (file)
const char *file;
listing_source_file (const char *file)
{
if (listing)
listing_tail->hll_file = file_info (file);
@ -1332,71 +1299,61 @@ listing_source_file (file)
/* Dummy functions for when compiled without listing enabled. */
void
listing_flags (ignore)
int ignore;
listing_flags (int ignore)
{
s_ignore (0);
}
void
listing_list (on)
int on;
listing_list (int on)
{
s_ignore (0);
}
void
listing_eject (ignore)
int ignore;
listing_eject (int ignore)
{
s_ignore (0);
}
void
listing_psize (ignore)
int ignore;
listing_psize (int ignore)
{
s_ignore (0);
}
void
listing_nopage (ignore)
int ignore;
listing_nopage (int ignore)
{
s_ignore (0);
}
void
listing_title (depth)
int depth;
listing_title (int depth)
{
s_ignore (0);
}
void
listing_file (name)
const char *name;
listing_file (const char *name)
{
}
void
listing_newline (name)
char *name;
listing_newline (char *name)
{
}
void
listing_source_line (n)
unsigned int n;
listing_source_line (unsigned int n)
{
}
void
listing_source_file (n)
const char *n;
listing_source_file (const char *n)
{
}

View File

@ -41,21 +41,21 @@
#define LISTING_SKIP_COND() ((listing & LISTING_NOCOND) != 0)
void listing_eject PARAMS ((int));
void listing_error PARAMS ((const char *message));
void listing_file PARAMS ((const char *name));
void listing_flags PARAMS ((int));
void listing_list PARAMS ((int on));
void listing_newline PARAMS ((char *ps));
void listing_prev_line PARAMS ((void));
void listing_print PARAMS ((char *name));
void listing_psize PARAMS ((int));
void listing_nopage PARAMS ((int));
void listing_source_file PARAMS ((const char *));
void listing_source_line PARAMS ((unsigned int));
void listing_title PARAMS ((int depth));
void listing_warning PARAMS ((const char *message));
void listing_width PARAMS ((unsigned int x));
void listing_eject (int);
void listing_error (const char *message);
void listing_file (const char *name);
void listing_flags (int);
void listing_list (int on);
void listing_newline (char *ps);
void listing_prev_line (void);
void listing_print (char *name);
void listing_psize (int);
void listing_nopage (int);
void listing_source_file (const char *);
void listing_source_line (unsigned int);
void listing_title (int depth);
void listing_warning (const char *message);
void listing_width (unsigned int x);
extern int listing_lhs_width;
extern int listing_lhs_width_second;

View File

@ -67,16 +67,15 @@ extern void *alloca ();
/* Internal functions. */
static int get_token PARAMS ((int, sb *, sb *));
static int getstring PARAMS ((int, sb *, sb *));
static int get_any_string PARAMS ((int, sb *, sb *, int, int));
static int do_formals PARAMS ((macro_entry *, int, sb *));
static int get_apost_token PARAMS ((int, sb *, sb *, int));
static int sub_actual
PARAMS ((int, sb *, sb *, struct hash_control *, int, sb *, int));
static int get_token (int, sb *, sb *);
static int getstring (int, sb *, sb *);
static int get_any_string (int, sb *, sb *, int, int);
static int do_formals (macro_entry *, int, sb *);
static int get_apost_token (int, sb *, sb *, int);
static int sub_actual (int, sb *, sb *, struct hash_control *, int, sb *, int);
static const char *macro_expand_body
PARAMS ((sb *, sb *, formal_entry *, struct hash_control *, int));
static const char *macro_expand PARAMS ((int, sb *, macro_entry *, sb *));
(sb *, sb *, formal_entry *, struct hash_control *, int);
static const char *macro_expand (int, sb *, macro_entry *, sb *);
#define ISWHITE(x) ((x) == ' ' || (x) == '\t')
@ -113,7 +112,7 @@ static int macro_strip_at;
/* Function to use to parse an expression. */
static int (*macro_expr) PARAMS ((const char *, int, sb *, int *));
static int (*macro_expr) (const char *, int, sb *, int *);
/* Number of macro expansions that have been done. */
@ -122,11 +121,8 @@ static int macro_number;
/* Initialize macro processing. */
void
macro_init (alternate, mri, strip_at, expr)
int alternate;
int mri;
int strip_at;
int (*expr) PARAMS ((const char *, int, sb *, int *));
macro_init (int alternate, int mri, int strip_at,
int (*expr) (const char *, int, sb *, int *))
{
macro_hash = hash_new ();
macro_defined = 0;
@ -139,8 +135,7 @@ macro_init (alternate, mri, strip_at, expr)
/* Switch in and out of MRI mode on the fly. */
void
macro_mri_mode (mri)
int mri;
macro_mri_mode (int mri)
{
macro_mri = mri;
}
@ -152,11 +147,8 @@ macro_mri_mode (mri)
Return 1 on success, 0 on unexpected EOF. */
int
buffer_and_nest (from, to, ptr, get_line)
const char *from;
const char *to;
sb *ptr;
int (*get_line) PARAMS ((sb *));
buffer_and_nest (const char *from, const char *to, sb *ptr,
int (*get_line) (sb *))
{
int from_len = strlen (from);
int to_len = strlen (to);
@ -235,10 +227,7 @@ buffer_and_nest (from, to, ptr, get_line)
/* Pick up a token. */
static int
get_token (idx, in, name)
int idx;
sb *in;
sb *name;
get_token (int idx, sb *in, sb *name)
{
if (idx < in->len
&& (ISALPHA (in->ptr[idx])
@ -263,10 +252,7 @@ get_token (idx, in, name)
/* Pick up a string. */
static int
getstring (idx, in, acc)
int idx;
sb *in;
sb *acc;
getstring (int idx, sb *in, sb *acc)
{
idx = sb_skip_white (idx, in);
@ -354,12 +340,7 @@ getstring (idx, in, acc)
*/
static int
get_any_string (idx, in, out, expand, pretend_quoted)
int idx;
sb *in;
sb *out;
int expand;
int pretend_quoted;
get_any_string (int idx, sb *in, sb *out, int expand, int pretend_quoted)
{
sb_reset (out);
idx = sb_skip_white (idx, in);
@ -439,10 +420,7 @@ get_any_string (idx, in, out, expand, pretend_quoted)
/* Pick up the formal parameters of a macro definition. */
static int
do_formals (macro, idx, in)
macro_entry *macro;
int idx;
sb *in;
do_formals (macro_entry *macro, int idx, sb *in)
{
formal_entry **p = &macro->formals;
@ -522,12 +500,8 @@ do_formals (macro, idx, in)
the macro which was defined. */
const char *
define_macro (idx, in, label, get_line, namep)
int idx;
sb *in;
sb *label;
int (*get_line) PARAMS ((sb *));
const char **namep;
define_macro (int idx, sb *in, sb *label,
int (*get_line) (sb *), const char **namep)
{
macro_entry *macro;
sb name;
@ -583,11 +557,7 @@ define_macro (idx, in, label, get_line, namep)
/* Scan a token, and then skip KIND. */
static int
get_apost_token (idx, in, name, kind)
int idx;
sb *in;
sb *name;
int kind;
get_apost_token (int idx, sb *in, sb *name, int kind)
{
idx = get_token (idx, in, name);
if (idx < in->len
@ -601,14 +571,8 @@ get_apost_token (idx, in, name, kind)
/* Substitute the actual value for a formal parameter. */
static int
sub_actual (start, in, t, formal_hash, kind, out, copyifnotthere)
int start;
sb *in;
sb *t;
struct hash_control *formal_hash;
int kind;
sb *out;
int copyifnotthere;
sub_actual (int start, sb *in, sb *t, struct hash_control *formal_hash,
int kind, sb *out, int copyifnotthere)
{
int src;
formal_entry *ptr;
@ -654,12 +618,8 @@ sub_actual (start, in, t, formal_hash, kind, out, copyifnotthere)
/* Expand the body of a macro. */
static const char *
macro_expand_body (in, out, formals, formal_hash, locals)
sb *in;
sb *out;
formal_entry *formals;
struct hash_control *formal_hash;
int locals;
macro_expand_body (sb *in, sb *out, formal_entry *formals,
struct hash_control *formal_hash, int locals)
{
sb t;
int src = 0;
@ -881,11 +841,7 @@ macro_expand_body (in, out, formals, formal_hash, locals)
body. */
static const char *
macro_expand (idx, in, m, out)
int idx;
sb *in;
macro_entry *m;
sb *out;
macro_expand (int idx, sb *in, macro_entry *m, sb *out)
{
sb t;
formal_entry *ptr;
@ -1073,11 +1029,8 @@ macro_expand (idx, in, m, out)
*EXPAND. Return 1 if a macro is found, 0 otherwise. */
int
check_macro (line, expand, error, info)
const char *line;
sb *expand;
const char **error;
macro_entry **info;
check_macro (const char *line, sb *expand,
const char **error, macro_entry **info)
{
const char *s;
char *copy, *cs;
@ -1127,8 +1080,7 @@ check_macro (line, expand, error, info)
/* Delete a macro. */
void
delete_macro (name)
const char *name;
delete_macro (const char *name)
{
hash_delete (macro_hash, name);
}
@ -1138,12 +1090,7 @@ delete_macro (name)
success, or an error message otherwise. */
const char *
expand_irp (irpc, idx, in, out, get_line)
int irpc;
int idx;
sb *in;
sb *out;
int (*get_line) PARAMS ((sb *));
expand_irp (int irpc, int idx, sb *in, sb *out, int (*get_line) (sb *))
{
const char *mn;
sb sub;

View File

@ -70,19 +70,14 @@ extern int macro_defined;
extern int macro_nest;
extern int buffer_and_nest
PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *))));
extern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
extern void macro_init
PARAMS ((int, int, int, int (*) PARAMS ((const char *, int, sb *, int *))));
extern void macro_mri_mode
PARAMS ((int));
(int, int, int, int (*) (const char *, int, sb *, int *));
extern void macro_mri_mode (int);
extern const char *define_macro
PARAMS ((int, sb *, sb *, int (*) PARAMS ((sb *)), const char **));
extern int check_macro
PARAMS ((const char *, sb *, const char **, macro_entry **));
extern void delete_macro
PARAMS ((const char *));
extern const char *expand_irp
PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *))));
(int, sb *, sb *, int (*) (sb *), const char **);
extern int check_macro (const char *, sb *, const char **, macro_entry **);
extern void delete_macro (const char *);
extern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *));
#endif

View File

@ -42,10 +42,10 @@ typedef int * va_list;
#define va_end(ARGS)
#endif
static void identify PARAMS ((char *));
static void as_show_where PARAMS ((void));
static void as_warn_internal PARAMS ((char *, unsigned int, char *));
static void as_bad_internal PARAMS ((char *, unsigned int, char *));
static void identify (char *);
static void as_show_where (void);
static void as_warn_internal (char *, unsigned int, char *);
static void as_bad_internal (char *, unsigned int, char *);
/* Despite the rest of the comments in this file, (FIXME-SOON),
* here is the current scheme for error messages etc:
@ -85,8 +85,7 @@ static void as_bad_internal PARAMS ((char *, unsigned int, char *));
*/
static void
identify (file)
char *file;
identify (char *file)
{
static int identified;
if (identified)
@ -108,7 +107,7 @@ identify (file)
static int warning_count;
int
had_warnings ()
had_warnings (void)
{
return (warning_count);
}
@ -119,7 +118,7 @@ had_warnings ()
static int error_count;
int
had_errors ()
had_errors (void)
{
return (error_count);
}
@ -127,7 +126,7 @@ had_errors ()
/* Print the current location to stderr. */
static void
as_show_where ()
as_show_where (void)
{
char *file;
unsigned int line;
@ -141,9 +140,8 @@ as_show_where ()
/* Like perror(3), but with more info. */
void
as_perror (gripe, filename)
const char *gripe; /* Unpunctuated error theme. */
const char *filename;
as_perror (const char *gripe, /* Unpunctuated error theme. */
const char *filename)
{
const char *errtxt;
@ -198,10 +196,7 @@ as_tsktsk (format, va_alist)
/* The common portion of as_warn and as_warn_where. */
static void
as_warn_internal (file, line, buffer)
char *file;
unsigned int line;
char *buffer;
as_warn_internal (char *file, unsigned int line, char *buffer)
{
++warning_count;
@ -302,10 +297,7 @@ as_warn_where (file, line, format, va_alist)
/* The common portion of as_bad and as_bad_where. */
static void
as_bad_internal (file, line, buffer)
char *file;
unsigned int line;
char *buffer;
as_bad_internal (char *file, unsigned int line, char *buffer)
{
++error_count;
@ -442,9 +434,7 @@ as_fatal (format, va_alist)
Arguments: Filename, line number, optional function name. */
void
as_assert (file, line, fn)
const char *file, *fn;
int line;
as_assert (const char *file, int line, const char *fn)
{
as_show_where ();
fprintf (stderr, _("Internal error!\n"));
@ -461,9 +451,7 @@ as_assert (file, line, fn)
and exit without producing a core file. */
void
as_abort (file, line, fn)
const char *file, *fn;
int line;
as_abort (const char *file, int line, const char *fn)
{
as_show_where ();
if (fn)
@ -479,9 +467,7 @@ as_abort (file, line, fn)
/* Support routines. */
void
fprint_value (file, val)
FILE *file;
valueT val;
fprint_value (FILE *file, valueT val)
{
if (sizeof (val) <= sizeof (long))
{
@ -499,9 +485,7 @@ fprint_value (file, val)
}
void
sprint_value (buf, val)
char *buf;
valueT val;
sprint_value (char *buf, valueT val)
{
if (sizeof (val) <= sizeof (long))
{