From 3534b428629be185e096be99e3bd5fdfe32d5544 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 18 Sep 2014 18:55:44 +0000 Subject: initial commit with rc for skalibs-2.0.0.0 --- src/libstddjb/string_quote.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/libstddjb/string_quote.c (limited to 'src/libstddjb/string_quote.c') diff --git a/src/libstddjb/string_quote.c b/src/libstddjb/string_quote.c new file mode 100644 index 0000000..ed00402 --- /dev/null +++ b/src/libstddjb/string_quote.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +#include +#include + +int string_quote (stralloc *sa, char const *s, unsigned int len) +{ + unsigned int base = sa->len ; + int wasnull = !sa->s ; + if (!stralloc_catb(sa, "\"", 1)) return 0 ; + if (!string_quote_nodelim(sa, s, len) || !stralloc_catb(sa, "\"", 1)) + { + if (wasnull) stralloc_free(sa) ; else sa->len = base ; + return 0 ; + } + return 1 ; +} -- cgit v1.2.3