diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-04-12 05:53:44 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-04-12 05:53:44 +0800 |
commit | 48182f64e86638a5420b3768c13a8ae4d0dbd249 (patch) | |
tree | 2b9d50448d7b0253a233227a1ac465b3d4b70b3d | |
parent | 2175169690175866675a79081b37158877b79d31 (diff) | |
download | gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar.gz gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar.bz2 gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar.lz gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar.xz gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.tar.zst gsoc2013-evolution-48182f64e86638a5420b3768c13a8ae4d0dbd249.zip |
Handle parsing negative integers.
2002-04-11 Jeffrey Stedfast <fejj@ximian.com>
* e-sexp.c (parse_value): Handle parsing negative integers.
svn path=/trunk/; revision=16441
-rw-r--r-- | e-util/ChangeLog | 4 | ||||
-rw-r--r-- | e-util/e-sexp.c | 26 |
2 files changed, 23 insertions, 7 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 375de2f381..d9973f512b 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,7 @@ +2002-04-11 Jeffrey Stedfast <fejj@ximian.com> + + * e-sexp.c (parse_value): Handle parsing negative integers. + 2002-03-29 JP Rosevear <jpr@ximian.com> * e-dialog-utils.c (e_file_dialog_save): open a file selection diff --git a/e-util/e-sexp.c b/e-util/e-sexp.c index 3a2a37d5fb..9dce281465 100644 --- a/e-util/e-sexp.c +++ b/e-util/e-sexp.c @@ -822,13 +822,13 @@ parse_values(ESExp *f, int *len) static struct _ESExpTerm * parse_value(ESExp *f) { - int token; + int token, negative = FALSE; struct _ESExpTerm *t = NULL; GScanner *gs = f->scanner; struct _ESExpSymbol *s; - + p(printf("parsing value\n")); - + token = g_scanner_get_next_token(gs); switch(token) { case G_TOKEN_LEFT_PAREN: @@ -839,29 +839,41 @@ parse_value(ESExp *f) t = parse_term_new(f, ESEXP_TERM_STRING); t->value.string = g_strdup(g_scanner_cur_value(gs).v_string); break; + case '-': + p(printf ("got negative int?\n")); + token = g_scanner_get_next_token (gs); + if (token != G_TOKEN_INT) { + e_sexp_fatal_error (f, "Invalid format for a integer value"); + return NULL; + } + + negative = TRUE; + /* fall through... */ case G_TOKEN_INT: t = parse_term_new(f, ESEXP_TERM_INT); t->value.number = g_scanner_cur_value(gs).v_int; + if (negative) + t->value.number = -t->value.number; p(printf("got int\n")); break; case '#': { char *str; - + p(printf("got bool?\n")); token = g_scanner_get_next_token(gs); if (token != G_TOKEN_IDENTIFIER) { e_sexp_fatal_error (f, "Invalid format for a boolean value"); return NULL; } - + str = g_scanner_cur_value (gs).v_identifier; - + g_assert (str != NULL); if (!(strlen (str) == 1 && (str[0] == 't' || str[0] == 'f'))) { e_sexp_fatal_error (f, "Invalid format for a boolean value"); return NULL; } - + t = parse_term_new(f, ESEXP_TERM_BOOL); t->value.bool = (str[0] == 't'); break; } |