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.
This commit is contained in:
Alan Modra 2012-06-07 12:47:23 +00:00
parent fb1b895daa
commit 39a45edc07
12 changed files with 143 additions and 180 deletions

View File

@ -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.

View File

@ -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.
@ -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;
@ -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
@ -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;
@ -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;
@ -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++)
{
@ -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++)
{

View File

@ -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;
@ -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;
}

View File

@ -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);

View File

@ -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.
@ -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;
@ -71,7 +69,7 @@ input_file_end (void)
}
/* Return BUFFER_SIZE. */
unsigned int
size_t
input_file_buffer_size (void)
{
return (BUFFER_SIZE);
@ -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;
}
@ -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;
@ -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

View File

@ -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.
@ -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);

View File

@ -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.
@ -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;
@ -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. */
@ -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
@ -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)

View File

@ -1,6 +1,6 @@
/* macro.c - macro support for gas
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc.
2004, 2005, 2006, 2007, 2008, 2011, 2012 Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
@ -65,7 +65,7 @@ static int macro_strip_at;
/* Function to use to parse an expression. */
static int (*macro_expr) (const char *, int, sb *, int *);
static size_t (*macro_expr) (const char *, size_t, sb *, offsetT *);
/* Number of macro expansions that have been done. */
@ -75,7 +75,7 @@ static int macro_number;
void
macro_init (int alternate, int mri, int strip_at,
int (*exp) (const char *, int, sb *, int *))
size_t (*exp) (const char *, size_t, sb *, offsetT *))
{
macro_hash = hash_new ();
macro_defined = 0;
@ -110,14 +110,13 @@ macro_mri_mode (int mri)
int
buffer_and_nest (const char *from, const char *to, sb *ptr,
int (*get_line) (sb *))
size_t (*get_line) (sb *))
{
int from_len;
int to_len = strlen (to);
size_t from_len;
size_t to_len = strlen (to);
int depth = 1;
int line_start = ptr->len;
int more = get_line (ptr);
size_t line_start = ptr->len;
size_t more = get_line (ptr);
if (to_len == 4 && strcasecmp (to, "ENDR") == 0)
{
@ -130,7 +129,7 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
while (more)
{
/* Try to find the first pseudo op on the line. */
int i = line_start;
size_t i = line_start;
bfd_boolean had_colon = FALSE;
/* With normal syntax we can suck what we want till we get
@ -227,8 +226,8 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
/* Pick up a token. */
static int
get_token (int idx, sb *in, sb *name)
static size_t
get_token (size_t idx, sb *in, sb *name)
{
if (idx < in->len
&& is_name_beginner (in->ptr[idx]))
@ -253,8 +252,8 @@ get_token (int idx, sb *in, sb *name)
/* Pick up a string. */
static int
getstring (int idx, sb *in, sb *acc)
static size_t
getstring (size_t idx, sb *in, sb *acc)
{
while (idx < in->len
&& (in->ptr[idx] == '"'
@ -339,8 +338,8 @@ getstring (int idx, sb *in, sb *acc)
(string) -> return (string-including-whitespaces)
xyx<whitespace> -> return xyz. */
static int
get_any_string (int idx, sb *in, sb *out)
static size_t
get_any_string (size_t idx, sb *in, sb *out)
{
sb_reset (out);
idx = sb_skip_white (idx, in);
@ -354,7 +353,7 @@ get_any_string (int idx, sb *in, sb *out)
}
else if (in->ptr[idx] == '%' && macro_alternate)
{
int val;
offsetT val;
char buf[20];
/* Turns the next expression into a string. */
@ -363,7 +362,7 @@ get_any_string (int idx, sb *in, sb *out)
idx + 1,
in,
&val);
sprintf (buf, "%d", val);
sprintf (buf, "%" BFD_VMA_FMT "d", val);
sb_add_string (out, buf);
}
else if (in->ptr[idx] == '"'
@ -474,8 +473,8 @@ del_formal (formal_entry *formal)
/* Pick up the formal parameters of a macro definition. */
static int
do_formals (macro_entry *macro, int idx, sb *in)
static size_t
do_formals (macro_entry *macro, size_t idx, sb *in)
{
formal_entry **p = &macro->formals;
const char *name;
@ -484,7 +483,7 @@ do_formals (macro_entry *macro, int idx, sb *in)
while (idx < in->len)
{
formal_entry *formal = new_formal ();
int cidx;
size_t cidx;
idx = get_token (idx, in, &formal->name);
if (formal->name.len == 0)
@ -626,8 +625,8 @@ free_macro (macro_entry *macro)
the macro which was defined. */
const char *
define_macro (int idx, sb *in, sb *label,
int (*get_line) (sb *),
define_macro (size_t idx, sb *in, sb *label,
size_t (*get_line) (sb *),
char *file, unsigned int line,
const char **namep)
{
@ -669,7 +668,7 @@ define_macro (int idx, sb *in, sb *label,
}
else
{
int cidx;
size_t cidx;
idx = get_token (idx, in, &name);
macro->name = sb_terminate (&name);
@ -706,8 +705,8 @@ define_macro (int idx, sb *in, sb *label,
/* Scan a token, and then skip KIND. */
static int
get_apost_token (int idx, sb *in, sb *name, int kind)
static size_t
get_apost_token (size_t idx, sb *in, sb *name, int kind)
{
idx = get_token (idx, in, name);
if (idx < in->len
@ -720,11 +719,11 @@ get_apost_token (int idx, sb *in, sb *name, int kind)
/* Substitute the actual value for a formal parameter. */
static int
sub_actual (int start, sb *in, sb *t, struct hash_control *formal_hash,
static size_t
sub_actual (size_t start, sb *in, sb *t, struct hash_control *formal_hash,
int kind, sb *out, int copyifnotthere)
{
int src;
size_t src;
formal_entry *ptr;
src = get_apost_token (start, in, t, kind);
@ -774,7 +773,8 @@ macro_expand_body (sb *in, sb *out, formal_entry *formals,
struct hash_control *formal_hash, const macro_entry *macro)
{
sb t;
int src = 0, inquote = 0, macro_line = 0;
size_t src = 0;
int inquote = 0, macro_line = 0;
formal_entry *loclist = NULL;
const char *err = NULL;
@ -1002,7 +1002,7 @@ macro_expand_body (sb *in, sb *out, formal_entry *formals,
body. */
static const char *
macro_expand (int idx, sb *in, macro_entry *m, sb *out)
macro_expand (size_t idx, sb *in, macro_entry *m, sb *out)
{
sb t;
formal_entry *ptr;
@ -1049,7 +1049,7 @@ macro_expand (int idx, sb *in, macro_entry *m, sb *out)
idx = sb_skip_white (idx, in);
while (idx < in->len)
{
int scan;
size_t scan;
/* Look and see if it's a positional or keyword arg. */
scan = idx;
@ -1289,7 +1289,7 @@ delete_macro (const char *name)
success, or an error message otherwise. */
const char *
expand_irp (int irpc, int idx, sb *in, sb *out, int (*get_line) (sb *))
expand_irp (int irpc, size_t idx, sb *in, sb *out, size_t (*get_line) (sb *))
{
sb sub;
formal_entry f;
@ -1345,7 +1345,7 @@ expand_irp (int irpc, int idx, sb *in, sb *out, int (*get_line) (sb *))
{
if (in->ptr[idx] == '"')
{
int nxt;
size_t nxt;
if (irpc)
in_quotes = ! in_quotes;

View File

@ -1,6 +1,6 @@
/* macro.h - header file for macro support for gas
Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006,
2007 Free Software Foundation, Inc.
2007, 2012 Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
@ -82,15 +82,16 @@ extern int macro_nest;
extern struct hash_control *macro_hash;
extern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
extern void macro_init
(int, int, int, int (*) (const char *, int, sb *, int *));
extern int buffer_and_nest (const char *, const char *, sb *,
size_t (*) (sb *));
extern void macro_init (int, int, int,
size_t (*) (const char *, size_t, sb *, offsetT *));
extern void macro_set_alternate (int);
extern void macro_mri_mode (int);
extern const char *define_macro
(int, sb *, sb *, int (*) (sb *), char *, unsigned int, const char **);
extern const char *define_macro (size_t, sb *, sb *, size_t (*) (sb *),
char *, unsigned int, 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 *));
extern const char *expand_irp (int, size_t, sb *, sb *, size_t (*) (sb *));
#endif

View File

@ -251,7 +251,7 @@ static void s_reloc (int);
static int hex_float (int, char *);
static segT get_known_segmented_expression (expressionS * expP);
static void pobegin (void);
static int get_non_macro_line_sb (sb *);
static size_t get_non_macro_line_sb (sb *);
static void generate_file_debug (void);
static char *_find_end_of_line (char *, int, int, int);
@ -579,10 +579,10 @@ pobegin (void)
static char *scrub_string;
static char *scrub_string_end;
static int
scrub_from_string (char *buf, int buflen)
static size_t
scrub_from_string (char *buf, size_t buflen)
{
int copy;
size_t copy;
copy = scrub_string_end - scrub_string;
if (copy > buflen)
@ -1235,8 +1235,8 @@ read_a_source_file (char *name)
new_tmp = new_buf;
for (;;)
{
int space;
int size;
size_t space;
size_t size;
space = (new_buf + new_length) - new_tmp;
size = do_scrub_chars (scrub_from_string, new_tmp, space);
@ -2748,13 +2748,13 @@ get_line_sb (sb *line, int in_macro)
return *input_line_pointer++;
}
static int
static size_t
get_non_macro_line_sb (sb *line)
{
return get_line_sb (line, 0);
}
static int
static size_t
get_macro_line_sb (sb *line)
{
return get_line_sb (line, 1);

View File

@ -1,5 +1,5 @@
/* sb.c - string buffer manipulation routines
Copyright 1994, 1995, 2000, 2003, 2005, 2006, 2007, 2009
Copyright 1994, 1995, 2000, 2003, 2005, 2006, 2007, 2009, 2012
Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
@ -39,47 +39,17 @@
use foo->ptr[*];
sb_kill (&foo); */
static int dsize = 5;
static void sb_check (sb *, int);
/* Statistics of sb structures. */
static int string_count[sb_max_power_two];
/* Free list of sb structures. */
static struct
{
sb_element *size[sb_max_power_two];
} free_list;
static size_t dsize = 32;
static void sb_check (sb *, size_t);
/* Initializes an sb. */
static void
sb_build (sb *ptr, int size)
sb_build (sb *ptr, size_t size)
{
/* See if we can find one to allocate. */
sb_element *e;
gas_assert (size < sb_max_power_two);
e = free_list.size[size];
if (!e)
{
/* Nothing there, allocate one and stick into the free list. */
e = (sb_element *) xmalloc (sizeof (sb_element) + (1 << size));
e->next = free_list.size[size];
e->size = 1 << size;
free_list.size[size] = e;
string_count[size]++;
}
/* Remove from free list. */
free_list.size[size] = e->next;
/* Copy into callers world. */
ptr->ptr = e->data;
ptr->pot = size;
ptr->ptr = xmalloc (size + 1);
ptr->max = size;
ptr->len = 0;
ptr->item = e;
}
void
@ -93,9 +63,7 @@ sb_new (sb *ptr)
void
sb_kill (sb *ptr)
{
/* Return item to free list. */
ptr->item->next = free_list.size[ptr->pot];
free_list.size[ptr->pot] = ptr->item;
free (ptr->ptr);
}
/* Add the sb at s to the end of the sb at ptr. */
@ -112,10 +80,10 @@ sb_add_sb (sb *ptr, sb *s)
static sb *sb_to_scrub;
static char *scrub_position;
static int
scrub_from_sb (char *buf, int buflen)
static size_t
scrub_from_sb (char *buf, size_t buflen)
{
int copy;
size_t copy;
copy = sb_to_scrub->len - (scrub_position - sb_to_scrub->ptr);
if (copy > buflen)
copy = buflen;
@ -144,19 +112,20 @@ sb_scrub_and_add_sb (sb *ptr, sb *s)
and grow it if it doesn't. */
static void
sb_check (sb *ptr, int len)
sb_check (sb *ptr, size_t len)
{
if (ptr->len + len >= 1 << ptr->pot)
{
sb tmp;
int pot = ptr->pot;
size_t max = ptr->max;
while (ptr->len + len >= 1 << pot)
pot++;
sb_build (&tmp, pot);
sb_add_sb (&tmp, ptr);
sb_kill (ptr);
*ptr = tmp;
while (ptr->len + len >= max)
{
max <<= 1;
if (max == 0)
as_fatal ("string buffer overflow");
}
if (max != ptr->max)
{
ptr->max = max;
ptr->ptr = xrealloc (ptr->ptr, max + 1);
}
}
@ -171,7 +140,7 @@ sb_reset (sb *ptr)
/* Add character c to the end of the sb at ptr. */
void
sb_add_char (sb *ptr, int c)
sb_add_char (sb *ptr, size_t c)
{
sb_check (ptr, 1);
ptr->ptr[ptr->len++] = c;
@ -182,7 +151,7 @@ sb_add_char (sb *ptr, int c)
void
sb_add_string (sb *ptr, const char *s)
{
int len = strlen (s);
size_t len = strlen (s);
sb_check (ptr, len);
memcpy (ptr->ptr + ptr->len, s, len);
ptr->len += len;
@ -191,7 +160,7 @@ sb_add_string (sb *ptr, const char *s)
/* Add string at s of length len to sb at ptr */
void
sb_add_buffer (sb *ptr, const char *s, int len)
sb_add_buffer (sb *ptr, const char *s, size_t len)
{
sb_check (ptr, len);
memcpy (ptr->ptr + ptr->len, s, len);
@ -211,8 +180,8 @@ sb_terminate (sb *in)
/* Start at the index idx into the string in sb at ptr and skip
whitespace. return the index of the first non whitespace character. */
int
sb_skip_white (int idx, sb *ptr)
size_t
sb_skip_white (size_t idx, sb *ptr)
{
while (idx < ptr->len
&& (ptr->ptr[idx] == ' '
@ -225,8 +194,8 @@ sb_skip_white (int idx, sb *ptr)
a comma and any following whitespace. returns the index of the
next character. */
int
sb_skip_comma (int idx, sb *ptr)
size_t
sb_skip_comma (size_t idx, sb *ptr)
{
while (idx < ptr->len
&& (ptr->ptr[idx] == ' '

View File

@ -1,5 +1,5 @@
/* sb.h - header file for string buffer manipulation routines
Copyright 1994, 1995, 2000, 2003, 2005, 2006, 2007
Copyright 1994, 1995, 2000, 2003, 2005, 2006, 2007, 2012
Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
@ -42,43 +42,27 @@
Obstacks provide all the functionality needed, but are too
complicated, hence the sb.
An sb is allocated by the caller, and is initialized to point to an
sb_element. sb_elements are kept on a free lists, and used when
needed, replaced onto the free list when unused. */
#define sb_max_power_two 30 /* Don't allow strings more than
2^sb_max_power_two long. */
An sb is allocated by the caller. */
typedef struct sb
{
char *ptr; /* Points to the current block. */
int len; /* How much is used. */
int pot; /* The maximum length is 1<<pot. */
struct le *item;
size_t len; /* How much is used. */
size_t max; /* The maximum length. */
}
sb;
/* Structure of the free list object of a string block. */
typedef struct le
{
struct le *next;
int size;
char data[1];
}
sb_element;
extern void sb_new (sb *);
extern void sb_kill (sb *);
extern void sb_add_sb (sb *, sb *);
extern void sb_scrub_and_add_sb (sb *, sb *);
extern void sb_reset (sb *);
extern void sb_add_char (sb *, int);
extern void sb_add_char (sb *, size_t);
extern void sb_add_string (sb *, const char *);
extern void sb_add_buffer (sb *, const char *, int);
extern void sb_add_buffer (sb *, const char *, size_t);
extern char *sb_terminate (sb *);
extern int sb_skip_white (int, sb *);
extern int sb_skip_comma (int, sb *);
extern size_t sb_skip_white (size_t, sb *);
extern size_t sb_skip_comma (size_t, sb *);
/* Actually in input-scrub.c. */
extern void input_scrub_include_sb (sb *, char *, int);