Subversion Repositories Kolibri OS

Rev

Rev 5222 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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