Skip to content

Commit

Permalink
PR gas/14201
Browse files Browse the repository at this point in the history
	* sb.h (sb_max_power_two): Delete.
	(struct sb): Delete "item" and "pot".  Make "len" a size_t.  Add "max".
	(sb_element): Delete.
	(sb_add_char, sb_add_buffer, sb_skip_comma, sb_skip_write): Update
	prototypes.
	* sb.c (string_count, free_list): Delete.
	(sb_build, sb_kill, sb_check): Rewrite.
	(scrub_from_sb, sb_add_char, sb_add_string, sb_add_buffer,
	sb_skip_white, sb_skip_comma): Replace assorted int params,
	vars and return types with size_t.
	* input-scrub.c: Likewise.
	* macro.c: Likewise.
	* macro.h: Likewise.
	* as.c: Likewise.
	* as.h: Likewise.
	* input-file.h: Likewise.
	* input-file.c: Likewise.
	* read.c: Likewise.
	* app.c: ..or ptrdiff_t.
	* input-file.c (input_file_get): Use ferror.
	(input_file_give_next_buffer): Use input_file_get.
  • Loading branch information
Alan Modra committed Jun 7, 2012
1 parent f55e92d commit 125b192
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 180 deletions.
25 changes: 25 additions & 0 deletions gas/ChangeLog
@@ -1,3 +1,28 @@
2012-06-07 Alan Modra <amodra@gmail.com>

PR gas/14201
* sb.h (sb_max_power_two): Delete.
(struct sb): Delete "item" and "pot". Make "len" a size_t. Add "max".
(sb_element): Delete.
(sb_add_char, sb_add_buffer, sb_skip_comma, sb_skip_write): Update
prototypes.
* sb.c (string_count, free_list): Delete.
(sb_build, sb_kill, sb_check): Rewrite.
(scrub_from_sb, sb_add_char, sb_add_string, sb_add_buffer,
sb_skip_white, sb_skip_comma): Replace assorted int params,
vars and return types with size_t.
* input-scrub.c: Likewise.
* macro.c: Likewise.
* macro.h: Likewise.
* as.c: Likewise.
* as.h: Likewise.
* input-file.h: Likewise.
* input-file.c: Likewise.
* read.c: Likewise.
* app.c: ..or ptrdiff_t.
* input-file.c (input_file_get): Use ferror.
(input_file_give_next_buffer): Use input_file_get.

2012-05-29 Roland McGrath <mcgrathr@google.com>

* read.c [HANDLE_BUNDLE] (bundle_lock_depth): New variable.
Expand Down
18 changes: 9 additions & 9 deletions gas/app.c
@@ -1,6 +1,6 @@
/* This is the Assembler Pre-Processor
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010
1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2012
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Expand Down Expand Up @@ -214,7 +214,7 @@ static char *out_string;
static char out_buf[20];
static int add_newlines;
static char *saved_input;
static int saved_input_len;
static size_t saved_input_len;
static char input_buffer[32 * 1024];
static const char *mri_state;
static char mri_last_ch;
Expand All @@ -232,7 +232,7 @@ struct app_save
char out_buf[sizeof (out_buf)];
int add_newlines;
char * saved_input;
int saved_input_len;
size_t saved_input_len;
#ifdef TC_M68K
int scrub_m68k_mri;
#endif
Expand Down Expand Up @@ -295,7 +295,7 @@ app_pop (char *arg)
saved_input = NULL;
else
{
gas_assert (saved->saved_input_len <= (int) (sizeof input_buffer));
gas_assert (saved->saved_input_len <= sizeof (input_buffer));
memcpy (input_buffer, saved->saved_input, saved->saved_input_len);
saved_input = input_buffer;
saved_input_len = saved->saved_input_len;
Expand Down Expand Up @@ -351,14 +351,14 @@ process_escape (int ch)
machine, and saves its state so that it may return at any point.
This is the way the old code used to work. */

int
do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
size_t
do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen)
{
char *to = tostart;
char *toend = tostart + tolen;
char *from;
char *fromend;
int fromlen;
size_t fromlen;
register int ch, ch2 = 0;
/* Character that started the string we're working on. */
static char quotechar;
Expand Down Expand Up @@ -548,7 +548,7 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
GET and PUT macros. */
{
char *s;
int len;
ptrdiff_t len;

for (s = from; s < fromend; s++)
{
Expand Down Expand Up @@ -1366,7 +1366,7 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
)
{
char *s;
int len;
ptrdiff_t len;

for (s = from; s < fromend; s++)
{
Expand Down
6 changes: 3 additions & 3 deletions gas/as.c
Expand Up @@ -1002,8 +1002,8 @@ close_output_file (void)

/* The interface between the macro code and gas expression handling. */

static int
macro_expr (const char *emsg, int idx, sb *in, int *val)
static size_t
macro_expr (const char *emsg, size_t idx, sb *in, offsetT *val)
{
char *hold;
expressionS ex;
Expand All @@ -1019,7 +1019,7 @@ macro_expr (const char *emsg, int idx, sb *in, int *val)
if (ex.X_op != O_constant)
as_bad ("%s", emsg);

*val = (int) ex.X_add_number;
*val = ex.X_add_number;

return idx;
}
Expand Down
2 changes: 1 addition & 1 deletion gas/as.h
Expand Up @@ -490,7 +490,7 @@ void input_scrub_insert_line (const char *);
void input_scrub_insert_file (char *);
char * input_scrub_new_file (char *);
char * input_scrub_next_buffer (char **bufp);
int do_scrub_chars (int (*get) (char *, int), char *, int);
size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t);
int gen_to_words (LITTLENUM_TYPE *, int, long);
int had_err (void);
int ignore_input (void);
Expand Down
33 changes: 9 additions & 24 deletions gas/input-file.c
@@ -1,6 +1,6 @@
/* input_file.c - Deal with Input Files -
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001,
2002, 2003, 2005, 2006, 2007, 2009
2002, 2003, 2005, 2006, 2007, 2009, 2012
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Expand Down Expand Up @@ -29,8 +29,6 @@
#include "input-file.h"
#include "safe-ctype.h"

static int input_file_get (char *, int);

/* This variable is non-zero if the file currently being read should be
preprocessed by app. It is zero if the file can be read straight in. */
int preprocess = 0;
Expand Down Expand Up @@ -71,7 +69,7 @@ input_file_end (void)
}

/* Return BUFFER_SIZE. */
unsigned int
size_t
input_file_buffer_size (void)
{
return (BUFFER_SIZE);
Expand Down Expand Up @@ -213,20 +211,17 @@ input_file_close (void)

/* This function is passed to do_scrub_chars. */

static int
input_file_get (char *buf, int buflen)
static size_t
input_file_get (char *buf, size_t buflen)
{
int size;
size_t size;

if (feof (f_in))
return 0;

size = fread (buf, sizeof (char), buflen, f_in);
if (size < 0)
{
as_bad (_("can't read from %s: %s"), file_name, xstrerror (errno));
size = 0;
}
if (ferror (f_in))
as_bad (_("can't read from %s: %s"), file_name, xstrerror (errno));
return size;
}

Expand All @@ -236,7 +231,7 @@ char *
input_file_give_next_buffer (char *where /* Where to place 1st character of new buffer. */)
{
char *return_value; /* -> Last char of what we read, + 1. */
int size;
size_t size;

if (f_in == (FILE *) 0)
return 0;
Expand All @@ -247,18 +242,8 @@ input_file_give_next_buffer (char *where /* Where to place 1st character of new
if (preprocess)
size = do_scrub_chars (input_file_get, where, BUFFER_SIZE);
else
{
if (feof (f_in))
size = 0;
else
size = fread (where, sizeof (char), BUFFER_SIZE, f_in);
}
size = input_file_get (where, BUFFER_SIZE);

if (size < 0)
{
as_bad (_("can't read from %s: %s"), file_name, xstrerror (errno));
size = 0;
}
if (size)
return_value = where + size;
else
Expand Down
4 changes: 2 additions & 2 deletions gas/input-file.h
@@ -1,5 +1,5 @@
/* input_file.h header for input-file.c
Copyright 1987, 1992, 1993, 2000, 2003, 2005, 2006, 2007
Copyright 1987, 1992, 1993, 2000, 2003, 2005, 2006, 2007, 2012
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Expand Down Expand Up @@ -58,7 +58,7 @@

char *input_file_give_next_buffer (char *where);
char *input_file_push (void);
unsigned int input_file_buffer_size (void);
size_t input_file_buffer_size (void);
void input_file_begin (void);
void input_file_close (void);
void input_file_end (void);
Expand Down
15 changes: 7 additions & 8 deletions gas/input-scrub.c
@@ -1,6 +1,6 @@
/* input_scrub.c - Break up input buffers into whole numbers of lines.
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011
2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Expand Down Expand Up @@ -75,7 +75,7 @@ static char save_source[AFTER_SIZE];
static unsigned int buffer_length;

/* The index into an sb structure we are reading from. -1 if none. */
static int sb_index = -1;
static size_t sb_index = -1;

/* If we are reading from an sb structure, this is it. */
static sb from_sb;
Expand Down Expand Up @@ -111,12 +111,12 @@ struct input_save {
char * partial_where;
int partial_size;
char save_source[AFTER_SIZE];
unsigned int buffer_length;
size_t buffer_length;
char * physical_input_file;
char * logical_input_file;
unsigned int physical_input_line;
int logical_input_line;
int sb_index;
size_t sb_index;
sb from_sb;
int from_sb_is_expansion; /* Should we do a conditional check? */
struct input_save * next_saved_file; /* Chain of input_saves. */
Expand Down Expand Up @@ -312,13 +312,12 @@ input_scrub_next_buffer (char **bufp)
{
register char *limit; /*->just after last char of buffer. */

if (sb_index >= 0)
if (sb_index != (size_t) -1)
{
if (sb_index >= from_sb.len)
{
sb_kill (&from_sb);
if (from_sb_is_expansion
)
if (from_sb_is_expansion)
{
cond_finish_check (macro_nest);
#ifdef md_macro_end
Expand Down Expand Up @@ -428,7 +427,7 @@ seen_at_least_1_file (void)
void
bump_line_counters (void)
{
if (sb_index < 0)
if (sb_index == (size_t) -1)
{
++physical_input_line;
if (logical_input_line >= 0)
Expand Down

0 comments on commit 125b192

Please sign in to comment.