summaryrefslogtreecommitdiffabout
path: root/src/txtacc.c
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:33:34 (GMT)
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch) (unidiff)
tree65356dd7b5a9010499550c468e960c93515a7e15 /src/txtacc.c
parentf569a6f2628b9ddef4dfb4424aff2dad644a8f19 (diff)
downloadwydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.gz
wydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.bz2
Drop gnulib.
* bootstrap: Rewrite. * bootstrap.conf: Remove. * configure.ac: Remove gl_EARLY/gl_INIT * src/backup.c: New file. * src/txtacc.c (txtacc_finish): Make sure a new entry is appended only once to the list. * (all sources): Use grecs memory allocation functions. * src/wydawca.h" Include fnmatch.h and regex.h (backup_type): New enum. (simple_backup_suffix): New extern. (find_backup_file_name): New proto. * tests/bkupname.c: New file. * tests/backup00.at: New file. * tests/backup01.at: New file. * tests/backup02.at: New file. * tests/backup03.at: New file. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * grecs: Update.
Diffstat (limited to 'src/txtacc.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/txtacc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -31,14 +31,14 @@ struct txtacc
31 struct grecs_list *mem; /* List of already allocated elements */ 31 struct grecs_list *mem; /* List of already allocated elements */
32}; 32};
33 33
34static struct txtacc_entry * 34static struct txtacc_entry *
35txtacc_alloc_entry (struct grecs_list *list, size_t size) 35txtacc_alloc_entry (struct grecs_list *list, size_t size)
36{ 36{
37 struct txtacc_entry *p = xmalloc (sizeof (*p)); 37 struct txtacc_entry *p = grecs_malloc (sizeof (*p));
38 p->buf = xmalloc (size); 38 p->buf = grecs_malloc (size);
39 p->size = size; 39 p->size = size;
40 p->len = 0; 40 p->len = 0;
41 grecs_list_append (list, p); 41 grecs_list_append (list, p);
42 return p; 42 return p;
43} 43}
44 44
@@ -86,13 +86,13 @@ txtacc_entry_free (void *p)
86 } 86 }
87} 87}
88 88
89struct txtacc * 89struct txtacc *
90txtacc_create () 90txtacc_create ()
91{ 91{
92 struct txtacc *acc = xmalloc (sizeof (*acc)); 92 struct txtacc *acc = grecs_malloc (sizeof (*acc));
93 acc->cur = grecs_list_create (); 93 acc->cur = grecs_list_create ();
94 acc->cur->free_entry = txtacc_entry_free; 94 acc->cur->free_entry = txtacc_entry_free;
95 acc->mem = grecs_list_create (); 95 acc->mem = grecs_list_create ();
96 acc->mem->free_entry = txtacc_entry_free; 96 acc->mem->free_entry = txtacc_entry_free;
97 return acc; 97 return acc;
98} 98}
@@ -134,12 +134,13 @@ txtacc_finish (struct txtacc *acc, int steal)
134 return NULL; 134 return NULL;
135 135
136 case 1: 136 case 1:
137 txtent = acc->cur->head->data; 137 txtent = acc->cur->head->data;
138 acc->cur->head->data = NULL; 138 acc->cur->head->data = NULL;
139 txtacc_entry_tailor (txtent); 139 txtacc_entry_tailor (txtent);
140 grecs_list_append (acc->mem, txtent);
140 break; 141 break;
141 142
142 default: 143 default:
143 size = 0; 144 size = 0;
144 for (ep = acc->cur->head; ep; ep = ep->next) 145 for (ep = acc->cur->head; ep; ep = ep->next)
145 { 146 {
@@ -155,28 +156,29 @@ txtacc_finish (struct txtacc *acc, int steal)
155 } 156 }
156 } 157 }
157 158
158 grecs_list_clear (acc->cur); 159 grecs_list_clear (acc->cur);
159 p = txtent->buf; 160 p = txtent->buf;
160 if (steal) 161 if (steal)
161 free (txtent); 162 {
162 else 163 grecs_list_remove_tail (acc->mem);
163 grecs_list_append (acc->mem, txtent); 164 free (txtent);
165 }
164 return p; 166 return p;
165} 167}
166 168
167void 169void
168txtacc_free_string (struct txtacc *acc, char *str) 170txtacc_free_string (struct txtacc *acc, char *str)
169{ 171{
170 struct grecs_list_entry *ep; 172 struct grecs_list_entry *ep;
171 for (ep = acc->mem->head; ep; ep = ep->next) 173 for (ep = acc->mem->head; ep; ep = ep->next)
172 { 174 {
173 struct txtacc_entry *tp = ep->data; 175 struct txtacc_entry *tp = ep->data;
174 if (tp->buf == str) 176 if (tp->buf == str)
175 { 177 {
176 grecs_list_remove_entry(acc->mem, ep); 178 grecs_list_remove_entry (acc->mem, ep);
177 free (tp->buf); 179 free (tp->buf);
178 return; 180 return;
179 } 181 }
180 } 182 }
181} 183}
182 184

Return to:

Send suggestions and report system problems to the System administrator.