diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-05-31 06:53:59 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-05-31 06:53:59 +0800 |
commit | 75353e0bff2661faf013f87aed65fbc58bb0ab68 (patch) | |
tree | 7c7c85ad7dc79b3d371ef0247a4fa5df8588a66d /e-util/e-sexp.c | |
parent | 7b37caa73423f9d8278892a72869c52432c2156e (diff) | |
download | gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar.gz gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar.bz2 gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar.lz gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar.xz gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.tar.zst gsoc2013-evolution-75353e0bff2661faf013f87aed65fbc58bb0ab68.zip |
Utility function to build a bool as part of an expression string.
2000-05-30 Not Zed <NotZed@HelixCode.com>
* e-sexp.c (e_sexp_encode_bool): Utility function to build a bool
as part of an expression string.
(e_sexp_encode_string): Likewise for strings.
svn path=/trunk/; revision=3300
Diffstat (limited to 'e-util/e-sexp.c')
-rw-r--r-- | e-util/e-sexp.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/e-util/e-sexp.c b/e-util/e-sexp.c index 7d7b5f5f0f..22727f22c2 100644 --- a/e-util/e-sexp.c +++ b/e-util/e-sexp.c @@ -1089,6 +1089,48 @@ e_sexp_eval(ESExp *f) return e_sexp_term_eval(f, f->tree); } +/** + * e_sexp_encode_bool: + * @s: + * @state: + * + * Encode a bool into an s-expression @s. Bools are + * encoded using #t #f syntax. + **/ +void +e_sexp_encode_bool(GString *s, gboolean state) +{ + if (state) + g_string_append(s, " #t"); + else + g_string_append(s, " #f"); +} + +/** + * e_sexp_encode_string: + * @s: Destination string. + * @string: String expression. + * + * Add a c string @string to the s-expression stored in + * the gstring @s. Quotes are added, and special characters + * are escaped appropriately. + **/ +void +e_sexp_encode_string(GString *s, const char *string) +{ + char c; + const char *p; + + p = string; + g_string_append(s, " \""); + while ( (c = *p++) ) { + if (c=='\\' || c=='\"' || c=='\'') + g_string_append_c(s, '\\'); + g_string_append_c(s, c); + } + g_string_append(s, "\""); +} + #ifdef TESTER int main(int argc, char **argv) { |