aboutsummaryrefslogtreecommitdiff
path: root/src/meta.c
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/meta.c
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/meta.c')
-rw-r--r--src/meta.c26
1 files changed, 13 insertions, 13 deletions
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
64 for (p = string; *p;) 64 for (p = string; *p;)
65 { 65 {
66 char *e; 66 char *e;
67 size_t len = strcspn (p, "$"); 67 size_t len = strcspn (p, "$");
68 68
69 obstack_grow (&stk, p, len); 69 txtacc_grow (acc, p, len);
70 p += len; 70 p += len;
71 if (*p == '$') 71 if (*p == '$')
72 { 72 {
73 switch (*++p) 73 switch (*++p)
74 { 74 {
75 case '$': 75 case '$':
76 obstack_grow (&stk, p, 1); 76 txtacc_grow (acc, p, 1);
77 p++; 77 p++;
78 break; 78 break;
79 79
@@ -92,16 +92,16 @@ meta_expand_string (const char *string, struct metadef *def, void *data,
92 size_t len; 92 size_t len;
93 /* FIXME: Return value? */ 93 /* FIXME: Return value? */
94 dictionary_quote_string (dict, handle, s, &newval, &len); 94 dictionary_quote_string (dict, handle, s, &newval, &len);
95 obstack_grow (&stk, newval, len); 95 txtacc_grow (acc, newval, len);
96 free (newval); 96 free (newval);
97 } 97 }
98 else 98 else
99 obstack_grow (&stk, s, strlen (s)); 99 txtacc_grow (acc, s, strlen (s));
100 p = e + 1; 100 p = e + 1;
101 } 101 }
102 else 102 else
103 { 103 {
104 obstack_grow (&stk, p - 1, 2); 104 txtacc_grow (acc, p - 1, 2);
105 p++; 105 p++;
106 } 106 }
107 break; 107 break;
@@ -121,20 +121,20 @@ meta_expand_string (const char *string, struct metadef *def, void *data,
121 size_t len; 121 size_t len;
122 /* FIXME: Return value? */ 122 /* FIXME: Return value? */
123 dictionary_quote_string (dict, handle, s, &newval, &len); 123 dictionary_quote_string (dict, handle, s, &newval, &len);
124 obstack_grow (&stk, newval, len); 124 txtacc_grow (acc, newval, len);
125 free (newval); 125 free (newval);
126 } 126 }
127 else 127 else
128 obstack_grow (&stk, s, len); 128 txtacc_grow (acc, s, len);
129 p++; 129 p++;
130 } 130 }
131 } 131 }
132 else 132 else
133 obstack_grow (&stk, p, 1); 133 txtacc_grow (acc, p, 1);
134 } 134 }
135 obstack_1grow (&stk, 0); 135 txtacc_1grow (acc, 0);
136 res = xstrdup (obstack_finish (&stk)); 136 res = xstrdup (txtacc_finish (acc));
137 obstack_free (&stk, NULL); 137 txtacc_free (acc);
138 return res; 138 return res;
139} 139}
140 140

Return to:

Send suggestions and report system problems to the System administrator.