/* sb.c - string buffer manipulation routines
- Copyright 1994, 1995, 2000 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 2000, 2003 Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
#define dsize 5
-static void sb_check PARAMS ((sb *, int));
+static void sb_check (sb *, int);
/* Statistics of sb structures. */
/* initializes an sb. */
void
-sb_build (ptr, size)
- sb *ptr;
- int size;
+sb_build (sb *ptr, int size)
{
/* see if we can find one to allocate */
sb_element *e;
}
void
-sb_new (ptr)
- sb *ptr;
+sb_new (sb *ptr)
{
sb_build (ptr, dsize);
}
/* deallocate the sb at ptr */
void
-sb_kill (ptr)
- sb *ptr;
+sb_kill (sb *ptr)
{
/* return item to free list */
ptr->item->next = free_list.size[ptr->pot];
/* add the sb at s to the end of the sb at ptr */
void
-sb_add_sb (ptr, s)
- sb *ptr;
- sb *s;
+sb_add_sb (sb *ptr, sb *s)
{
sb_check (ptr, s->len);
memcpy (ptr->ptr + ptr->len, s->ptr, s->len);
and grow it if it doesn't. */
static void
-sb_check (ptr, len)
- sb *ptr;
- int len;
+sb_check (sb *ptr, int len)
{
if (ptr->len + len >= 1 << ptr->pot)
{
/* make the sb at ptr point back to the beginning. */
void
-sb_reset (ptr)
- sb *ptr;
+sb_reset (sb *ptr)
{
ptr->len = 0;
}
/* add character c to the end of the sb at ptr. */
void
-sb_add_char (ptr, c)
- sb *ptr;
- int c;
+sb_add_char (sb *ptr, int c)
{
sb_check (ptr, 1);
ptr->ptr[ptr->len++] = c;
/* add null terminated string s to the end of sb at ptr. */
void
-sb_add_string (ptr, s)
- sb *ptr;
- const char *s;
+sb_add_string (sb *ptr, const char *s)
{
int len = strlen (s);
sb_check (ptr, len);
/* add string at s of length len to sb at ptr */
void
-sb_add_buffer (ptr, s, len)
- sb *ptr;
- const char *s;
- int len;
+sb_add_buffer (sb *ptr, const char *s, int len)
{
sb_check (ptr, len);
memcpy (ptr->ptr + ptr->len, s, len);
/* print the sb at ptr to the output file */
void
-sb_print (outfile, ptr)
- FILE *outfile;
- sb *ptr;
+sb_print (FILE *outfile, sb *ptr)
{
int i;
int nc = 0;
}
void
-sb_print_at (outfile, idx, ptr)
- FILE *outfile;
- int idx;
- sb *ptr;
+sb_print_at (FILE *outfile, int idx, sb *ptr)
{
int i;
for (i = idx; i < ptr->len; i++)
string, so that it can be used as an arg to printf %s. */
char *
-sb_name (in)
- sb *in;
+sb_name (sb *in)
{
/* stick a null on the end of the string */
sb_add_char (in, 0);
/* like sb_name, but don't include the null byte in the string. */
char *
-sb_terminate (in)
- sb *in;
+sb_terminate (sb *in)
{
sb_add_char (in, 0);
--in->len;
whitespace. return the index of the first non whitespace character */
int
-sb_skip_white (idx, ptr)
- int idx;
- sb *ptr;
+sb_skip_white (int idx, sb *ptr)
{
while (idx < ptr->len
&& (ptr->ptr[idx] == ' '
next character. */
int
-sb_skip_comma (idx, ptr)
- int idx;
- sb *ptr;
+sb_skip_comma (int idx, sb *ptr)
{
while (idx < ptr->len
&& (ptr->ptr[idx] == ' '