diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-05 14:09:48 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-05 14:39:29 +0300 |
commit | 6c3f6c1b02dd5f9ac343c713bdae4aa83bafc328 (patch) | |
tree | 49bc8df1cff7157c711c63447c3e272ebc67cd4c /src/format.c | |
parent | a60eb4b18345626a84e23784d77ca231812e1dff (diff) | |
download | grecs-6c3f6c1b02dd5f9ac343c713bdae4aa83bafc328.tar.gz grecs-6c3f6c1b02dd5f9ac343c713bdae4aa83bafc328.tar.bz2 |
Improve node formatting. Add version comparasion functions.
* am/grecs.m4 (GRECS_SETUP): New option: shared.
* doc/GRECS_SETUP.3: Document new options.
* doc/grecs_format_locus.3: Update.
* doc/grecs_format_node.3: Document new flags.
* src/.gitignore: Update.
* src/version.c: New file.
* src/Make.am (GRECS_SRC): Add version.c
(EXTRA_DIST): Update.
* src/diag.c (default_print_diag): Flush stdout as per the docs.
* src/format.c (grecs_format_locus): Don't print trailing semicolon.
(grecs_format_value): Handle GRECS_NODE_FLAG_NOQUOTE flag.
(grecs_format_node): Print delimiters when needed.
* src/grecs.h (grecs_version_info): New struct.
(grecs_version, grecs_version_cmp): New protos.
(GRECS_NODE_FLAG_NOQUOTE): New flag.
* tests/gcfver.c: New file.
* tests/vercmp.at: New file.
* tests/.gitignore: Update.
* tests/Makefile.am: Define GRECS_VERCMP_AT in package.m4
(TESTSUITE_AT): Add vercmp.at (conditionally).
(noinst_PROGRAMS): Add gcfver.
* tests/testsuite.at: Conditionally include vercmp.at.
Diffstat (limited to 'src/format.c')
-rw-r--r-- | src/format.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/format.c b/src/format.c index 2c97b72..6e33521 100644 --- a/src/format.c +++ b/src/format.c @@ -188,7 +188,7 @@ void grecs_format_locus(grecs_locus_t *locus, FILE *fp) { if (locus) - fprintf(fp, "%s:%d:", locus->file, locus->line); + fprintf(fp, "%s:%d", locus->file, locus->line); } void @@ -222,6 +222,8 @@ grecs_format_value(struct grecs_value *val, int flags, FILE *fp) &need_quote); if (flags & GRECS_NODE_FLAG_QUOTE) need_quote = 1; + else if (flags & GRECS_NODE_FLAG_NOQUOTE) + need_quote = 0; if (need_quote) { char *cbuf = grecs_malloc(clen + 1); wordsplit_c_quote_copy(cbuf, val->v.string, @@ -257,6 +259,8 @@ grecs_format_value(struct grecs_value *val, int flags, FILE *fp) void grecs_format_node(struct grecs_node *node, int flags, FILE *fp) { + const char *delim_str = NULL; + if (!flags) flags = GRECS_NODE_FLAG_DEFAULT; switch (node->type) { @@ -271,15 +275,19 @@ grecs_format_node(struct grecs_node *node, int flags, FILE *fp) case grecs_node_stmt: if (flags & GRECS_NODE_FLAG_LOCUS) { grecs_format_locus(&node->locus, fp); - fputc(' ', fp); + delim_str = ": "; } if (flags & GRECS_NODE_FLAG_PATH) { + if (delim_str) + fprintf(fp, "%s", delim_str); grecs_format_node_path(node, flags, fp); - fputc(':', fp); - fputc(' ', fp); + delim_str = ": "; } - if (flags & GRECS_NODE_FLAG_VALUE) + if (flags & GRECS_NODE_FLAG_VALUE) { + if (delim_str) + fprintf(fp, "%s", delim_str); grecs_format_value(&node->value, flags, fp); + } } } |