aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-11-27 00:01:52 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-11-27 00:01:52 +0200
commit690ec7913002d28537dbfc04532b17a10ee56ab3 (patch)
treedc090af5bf705a8a0e7a47d42159048a1979f770 /src
parent83a06bbc6b3796a0b8646816da34c6672488cbf0 (diff)
downloadgrecs-690ec7913002d28537dbfc04532b17a10ee56ab3.tar.gz
grecs-690ec7913002d28537dbfc04532b17a10ee56ab3.tar.bz2
New text formatting functions.
* src/txtacc.c (grecs_txtacc_grow_string) (grecs_txtacc_grow_string_escape): New functions. * src/grecs.hin: Ditto
Diffstat (limited to 'src')
-rw-r--r--src/grecs.hin3
-rw-r--r--src/txtacc.c22
2 files changed, 22 insertions, 3 deletions
diff --git a/src/grecs.hin b/src/grecs.hin
index e83b855..1a591d3 100644
--- a/src/grecs.hin
+++ b/src/grecs.hin
@@ -409,6 +409,9 @@ int grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...);
409struct grecs_txtacc *grecs_txtacc_create(void); 409struct grecs_txtacc *grecs_txtacc_create(void);
410void grecs_txtacc_free(struct grecs_txtacc *acc); 410void grecs_txtacc_free(struct grecs_txtacc *acc);
411void grecs_txtacc_grow(struct grecs_txtacc *acc, const char *buf, size_t size); 411void grecs_txtacc_grow(struct grecs_txtacc *acc, const char *buf, size_t size);
412void grecs_txtacc_grow_string(struct grecs_txtacc *acc, const char *buf);
413void grecs_txtacc_grow_string_escape(struct grecs_txtacc *acc,
414 const char *buf);
412#define grecs_txtacc_grow_char(acc,c) \ 415#define grecs_txtacc_grow_char(acc,c) \
413 do { \ 416 do { \
414 char __ch = c; \ 417 char __ch = c; \
diff --git a/src/txtacc.c b/src/txtacc.c
index a8fa002..f416006 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -106,9 +106,9 @@ void
106grecs_txtacc_free(struct grecs_txtacc *acc) 106grecs_txtacc_free(struct grecs_txtacc *acc)
107{ 107{
108 if (acc) { 108 if (acc) {
109 grecs_list_free (acc->cur); 109 grecs_list_free(acc->cur);
110 grecs_list_free (acc->mem); 110 grecs_list_free(acc->mem);
111 free (acc); 111 free(acc);
112 } 112 }
113} 113}
114 114
@@ -126,6 +126,22 @@ grecs_txtacc_grow(struct grecs_txtacc *acc, const char *buf, size_t size)
126 } 126 }
127} 127}
128 128
129void
130grecs_txtacc_grow_string(struct grecs_txtacc *acc, const char *buf)
131{
132 grecs_txtacc_grow(acc, buf, strlen(buf));
133}
134
135void
136grecs_txtacc_grow_string_escape(struct grecs_txtacc *acc, const char *buf)
137{
138 for (; *buf; buf++) {
139 if (strchr(" \t\n\"\'\\", *buf))
140 grecs_txtacc_grow_char(acc, '\\');
141 grecs_txtacc_grow_char(acc, *buf);
142 }
143}
144
129char * 145char *
130grecs_txtacc_finish(struct grecs_txtacc *acc, int steal) 146grecs_txtacc_finish(struct grecs_txtacc *acc, int steal)
131{ 147{

Return to:

Send suggestions and report system problems to the System administrator.