1*fae548d3Szrj /* sb.h - header file for string buffer manipulation routines 2*fae548d3Szrj Copyright (C) 1994-2020 Free Software Foundation, Inc. 3*fae548d3Szrj 4*fae548d3Szrj Written by Steve and Judy Chamberlain of Cygnus Support, 5*fae548d3Szrj sac@cygnus.com 6*fae548d3Szrj 7*fae548d3Szrj This file is part of GAS, the GNU Assembler. 8*fae548d3Szrj 9*fae548d3Szrj GAS is free software; you can redistribute it and/or modify 10*fae548d3Szrj it under the terms of the GNU General Public License as published by 11*fae548d3Szrj the Free Software Foundation; either version 3, or (at your option) 12*fae548d3Szrj any later version. 13*fae548d3Szrj 14*fae548d3Szrj GAS is distributed in the hope that it will be useful, 15*fae548d3Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 16*fae548d3Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*fae548d3Szrj GNU General Public License for more details. 18*fae548d3Szrj 19*fae548d3Szrj You should have received a copy of the GNU General Public License 20*fae548d3Szrj along with GAS; see the file COPYING. If not, write to the Free 21*fae548d3Szrj Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 22*fae548d3Szrj 02110-1301, USA. */ 23*fae548d3Szrj 24*fae548d3Szrj #ifndef SB_H 25*fae548d3Szrj 26*fae548d3Szrj #define SB_H 27*fae548d3Szrj 28*fae548d3Szrj /* String blocks 29*fae548d3Szrj 30*fae548d3Szrj I had a couple of choices when deciding upon this data structure. 31*fae548d3Szrj gas uses null terminated strings for all its internal work. This 32*fae548d3Szrj often means that parts of the program that want to examine 33*fae548d3Szrj substrings have to manipulate the data in the string to do the 34*fae548d3Szrj right thing (a common operation is to single out a bit of text by 35*fae548d3Szrj saving away the character after it, nulling it out, operating on 36*fae548d3Szrj the substring and then replacing the character which was under the 37*fae548d3Szrj null). This is a pain and I remember a load of problems that I had with 38*fae548d3Szrj code in gas which almost got this right. Also, it's harder to grow and 39*fae548d3Szrj allocate null terminated strings efficiently. 40*fae548d3Szrj 41*fae548d3Szrj Obstacks provide all the functionality needed, but are too 42*fae548d3Szrj complicated, hence the sb. 43*fae548d3Szrj 44*fae548d3Szrj An sb is allocated by the caller. */ 45*fae548d3Szrj 46*fae548d3Szrj typedef struct sb 47*fae548d3Szrj { 48*fae548d3Szrj char *ptr; /* Points to the current block. */ 49*fae548d3Szrj size_t len; /* How much is used. */ 50*fae548d3Szrj size_t max; /* The maximum length. */ 51*fae548d3Szrj } 52*fae548d3Szrj sb; 53*fae548d3Szrj 54*fae548d3Szrj extern void sb_new (sb *); 55*fae548d3Szrj extern void sb_build (sb *, size_t); 56*fae548d3Szrj extern void sb_kill (sb *); 57*fae548d3Szrj extern void sb_add_sb (sb *, sb *); 58*fae548d3Szrj extern void sb_scrub_and_add_sb (sb *, sb *); 59*fae548d3Szrj extern void sb_reset (sb *); 60*fae548d3Szrj extern void sb_add_char (sb *, size_t); 61*fae548d3Szrj extern void sb_add_string (sb *, const char *); 62*fae548d3Szrj extern void sb_add_buffer (sb *, const char *, size_t); 63*fae548d3Szrj extern char *sb_terminate (sb *); 64*fae548d3Szrj extern size_t sb_skip_white (size_t, sb *); 65*fae548d3Szrj extern size_t sb_skip_comma (size_t, sb *); 66*fae548d3Szrj 67*fae548d3Szrj /* Actually in input-scrub.c. */ 68*fae548d3Szrj extern void input_scrub_include_sb (sb *, char *, int); 69*fae548d3Szrj 70*fae548d3Szrj #endif /* SB_H */ 71