aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-11 12:13:09 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-11 12:13:09 +0300
commit590e208c40797206fd6a93651fc59e0b68eeb545 (patch)
treed7abd0ca33b3355b1a27760bf9850e445fafd607 /src
parentdb81e378576dcc5510032c72060e48e562f208c9 (diff)
downloadwydawca-590e208c40797206fd6a93651fc59e0b68eeb545.tar.gz
wydawca-590e208c40797206fd6a93651fc59e0b68eeb545.tar.bz2
Remove obstack.
* src/txtacc.c: New file. * gnulib.modules: Remove obstack. * src/wydawca.h (txtacc_create, txtacc_free) (txtacc_free_string, txtacc_grow) (txtacc_finish): New functions. (txtacc_1grow): New macro.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/builtin.c16
-rw-r--r--src/cmdline.opt24
-rw-r--r--src/directive.c6
-rw-r--r--src/lock.c2
-rw-r--r--src/meta.c26
-rw-r--r--src/report.c17
-rw-r--r--src/triplet.c8
-rw-r--r--src/txtacc.c177
-rw-r--r--src/verify.c6
-rw-r--r--src/wydawca.c1
-rw-r--r--src/wydawca.h18
12 files changed, 242 insertions, 60 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8fd7d94..8139849 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,7 @@ wydawca_SOURCES=\
46 vtab.c\ 46 vtab.c\
47 null.c\ 47 null.c\
48 timer.c\ 48 timer.c\
49 txtacc.c\
49 report.c 50 report.c
50 51
51BUILT_SOURCES=cmdline.h 52BUILT_SOURCES=cmdline.h
diff --git a/src/builtin.c b/src/builtin.c
index 412a2e7..0a76738 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -149,7 +149,7 @@ parse_cmp_type (const char *pat, strcmp_fn *cmpfn, int *rf)
149 149
150struct builtin_data_storage 150struct builtin_data_storage
151{ 151{
152 struct obstack stk; 152 struct txtacc *acc;
153 char **wp; 153 char **wp;
154}; 154};
155 155
@@ -164,7 +164,7 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
164 int i; 164 int i;
165 int rc; 165 int rc;
166 size_t count = 0; 166 size_t count = 0;
167 struct obstack stk; 167 struct txtacc *acc;
168 int flags = 0; 168 int flags = 0;
169 strcmp_fn cmpfn = cmp_exact; 169 strcmp_fn cmpfn = cmp_exact;
170 struct builtin_data_storage *bds; 170 struct builtin_data_storage *bds;
@@ -176,7 +176,7 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
176 return 0; 176 return 0;
177 } 177 }
178 178
179 obstack_init (&stk); 179 acc = txtacc_create ();
180 180
181 for (i = 0; i < dict->parmc; i++) 181 for (i = 0; i < dict->parmc; i++)
182 { 182 {
@@ -198,7 +198,7 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
198 for (j = 1; j <= ncol; j++) 198 for (j = 1; j <= ncol; j++)
199 { 199 {
200 char *val = dict->parmv[i + j]; 200 char *val = dict->parmv[i + j];
201 obstack_grow (&stk, val, strlen (val) + 1); 201 txtacc_grow (acc, val, strlen (val) + 1);
202 } 202 }
203 count++; 203 count++;
204 } 204 }
@@ -211,7 +211,7 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
211 211
212 if (count == 0) 212 if (count == 0)
213 { 213 {
214 obstack_free (&stk, NULL); 214 txtacc_free (acc);
215 bds = NULL; 215 bds = NULL;
216 rc = 1; 216 rc = 1;
217 } 217 }
@@ -223,8 +223,8 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
223 bds = xmalloc (sizeof (*bds)); 223 bds = xmalloc (sizeof (*bds));
224 count *= ncol; 224 count *= ncol;
225 bds->wp = xcalloc (count, sizeof (bds->wp[0])); 225 bds->wp = xcalloc (count, sizeof (bds->wp[0]));
226 bds->stk = stk; 226 bds->acc = acc;
227 p = obstack_finish (&stk); 227 p = txtacc_finish (acc);
228 228
229 for (i = 0; i < count; i++) 229 for (i = 0; i < count; i++)
230 { 230 {
@@ -245,7 +245,7 @@ builtin_free_result (struct dictionary *dict, void *handle)
245 if (dict->storage) 245 if (dict->storage)
246 { 246 {
247 struct builtin_data_storage *bds = dict->storage; 247 struct builtin_data_storage *bds = dict->storage;
248 obstack_free (&bds->stk, NULL); 248 txtacc_free (bds->acc);
249 free (bds->wp); 249 free (bds->wp);
250 free (bds); 250 free (bds);
251 dict->storage = NULL; 251 dict->storage = NULL;
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 4c3d22f..afa1949 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -14,8 +14,7 @@
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with wydawca. If not, see <http://www.gnu.org/licenses/>. */ 15 with wydawca. If not, see <http://www.gnu.org/licenses/>. */
16 16
17static struct obstack pp_cmd_stack; 17static struct txtacc *pp_cmd_acc;
18static int pp_cmd_stack_init;
19 18
20static struct grecs_list *source_list; 19static struct grecs_list *source_list;
21static struct grecs_list *tag_list; 20static struct grecs_list *tag_list;
@@ -152,19 +151,16 @@ OPTION(define,D,SYMBOL[=VALUE],
152BEGIN 151BEGIN
153 char *p; 152 char *p;
154 153
155 if (!pp_cmd_stack_init) 154 if (!pp_cmd_acc)
156 { 155 pp_cmd_acc = txtacc_create ();
157 obstack_init (&pp_cmd_stack); 156 txtacc_grow (pp_cmd_acc, " \"-D", 4);
158 pp_cmd_stack_init = 1;
159 }
160 obstack_grow (&pp_cmd_stack, " \"-D", 4);
161 for (p = optarg; *p; p++) 157 for (p = optarg; *p; p++)
162 { 158 {
163 if (*p == '\\' || *p == '"') 159 if (*p == '\\' || *p == '"')
164 obstack_1grow (&pp_cmd_stack, '\\'); 160 txtacc_1grow (pp_cmd_acc, '\\');
165 obstack_1grow (&pp_cmd_stack, *p); 161 txtacc_1grow (pp_cmd_acc, *p);
166 } 162 }
167 obstack_1grow (&pp_cmd_stack, '"'); 163 txtacc_1grow (pp_cmd_acc, '"');
168END 164END
169 165
170OPTION(preprocessor,,COMMAND, 166OPTION(preprocessor,,COMMAND,
@@ -213,13 +209,13 @@ void
213parse_options(int argc, char *argv[]) 209parse_options(int argc, char *argv[])
214{ 210{
215 GETOPT(argc, argv) 211 GETOPT(argc, argv)
216 if (pp_cmd_stack_init && grecs_preprocessor) 212 if (pp_cmd_acc && grecs_preprocessor)
217 { 213 {
218 char *defs = obstack_finish (&pp_cmd_stack); 214 char *defs = txtacc_finish (pp_cmd_acc);
219 char *cmd = xmalloc (strlen (grecs_preprocessor) + strlen (defs) + 1); 215 char *cmd = xmalloc (strlen (grecs_preprocessor) + strlen (defs) + 1);
220 strcpy (cmd, grecs_preprocessor); 216 strcpy (cmd, grecs_preprocessor);
221 strcat (cmd, defs); 217 strcat (cmd, defs);
222 grecs_preprocessor = cmd; 218 grecs_preprocessor = cmd;
223 obstack_free (&pp_cmd_stack, NULL); 219 txtacc_free (pp_cmd_acc);
224 } 220 }
225} 221}
diff --git a/src/directive.c b/src/directive.c
index 34e5feb..1f11d77 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -498,10 +498,10 @@ run_check_script (const char *script, struct file_triplet *trp,
498 size_t len = strlen (buf); 498 size_t len = strlen (buf);
499 if (debug_level > 2) 499 if (debug_level > 2)
500 logmsg (LOG_DEBUG, _("read: %s"), buf); 500 logmsg (LOG_DEBUG, _("read: %s"), buf);
501 obstack_grow (&trp->obstk, buf, len); 501 txtacc_grow (trp->acc, buf, len);
502 total += size; 502 total += size;
503 } 503 }
504 obstack_1grow (&trp->obstk, 0); 504 txtacc_1grow (trp->acc, 0);
505 if (debug_level > 2) 505 if (debug_level > 2)
506 logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total); 506 logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total);
507 507
@@ -511,7 +511,7 @@ run_check_script (const char *script, struct file_triplet *trp,
511 signal (SIGCHLD, oldsig); 511 signal (SIGCHLD, oldsig);
512 512
513 if (total) 513 if (total)
514 trp->check_diag = obstack_finish (&trp->obstk); 514 trp->check_diag = txtacc_finish (trp->acc);
515 515
516 trp->check_result = status; 516 trp->check_result = status;
517 if (WIFEXITED (status)) 517 if (WIFEXITED (status))
diff --git a/src/lock.c b/src/lock.c
index 9e73463..32367de 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -176,7 +176,7 @@ static char *
176host_name () 176host_name ()
177{ 177{
178 static char *hostbuf = NULL; 178 static char *hostbuf = NULL;
179 size_t size; 179 size_t size = 0;
180 int rc; 180 int rc;
181 181
182 if (hostbuf) 182 if (hostbuf)
diff --git a/src/meta.c b/src/meta.c
index 30d3041..61dc334 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -54,26 +54,26 @@ meta_expand_string (const char *string, struct metadef *def, void *data,
54{ 54{
55 const char *p, *s; 55 const char *p, *s;
56 char *res; 56 char *res;
57 struct obstack stk; 57 struct txtacc *acc;
58 58
59 if (!string) 59 if (!string)
60 return NULL; 60 return NULL;
61 61
62 obstack_init (&stk); 62 acc = txtacc_create ();
63 63