diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-14 13:16:37 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-14 13:16:37 +0000 |
commit | c3df0bf5f64241cb7ea00c1894da7f81e055a2aa (patch) | |
tree | 2a698dae997c076077b1ad7476d6576c0f89db12 /src/datconv.c | |
parent | 60f99611aee975bcd0710c59e32e8c2a13154603 (diff) | |
download | gdbm-c3df0bf5f64241cb7ea00c1894da7f81e055a2aa.tar.gz gdbm-c3df0bf5f64241cb7ea00c1894da7f81e055a2aa.tar.bz2 |
Provide "open" and "close" commands; implement new variables.
* src/datconv.c (datum_format): Don't print field delimiter
after the last field.
(dsprint): Bugfix.
* src/gdbmload.c (gdbm_load_from_file): Return GDBM_NO_DBNAME
when loading from bdb dump and the database pointer is NULL.
* src/gdbmtool.c (opendb, checkdb): New auxiliary functions.
(begin handlers): call checkdb.
(import_handler): Special handling for GDBM_NO_DBNAME.
(status_handler): Print more info.
(command_tab): Call checkdb prior to handlers that expect an
open database.
New commands: open, close
(gdbmarg_string, gdbmarg_datum)
(gdbmarg_kvpair): Take pointer to locus as the 2nd argument.
All uses changed.
(coerce): Include locus info in the diagnostic message.
(main): Don't open database right away.
* src/gdbmtool.h (GDBMTOOL_DEFFILE): New define.
(gdbmarg) <loc>: New member.
(VART_INT): New variable typ.e
(VAR_ERR_FAILURE): New error code.
(variable_is_set, varible_mode_name): New protos.
* src/gram.y: Provide printable token names for error messages.
Pass locus to gdbmarg initialization functions.
* src/lex.l (vparse_error): Fix output.
* src/var.c (variable) <v.num, hook, hook_data>: New members.
(vartab): Define more variables.
(variable_set): Accept value of any valid datatype.
(variable_mode_name, variable_is_set): New functions.
Diffstat (limited to 'src/datconv.c')
-rw-r--r-- | src/datconv.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/datconv.c b/src/datconv.c index cf17011..0178f41 100644 --- a/src/datconv.c +++ b/src/datconv.c @@ -211,7 +211,8 @@ datum_format (FILE *fp, datum const *dat, struct dsegm *ds) { int off = 0; char *delim[2]; - + int first_field = 1; + if (!ds) { fprintf (fp, "%.*s\n", dat->dsize, dat->dptr); @@ -228,6 +229,8 @@ datum_format (FILE *fp, datum const *dat, struct dsegm *ds) switch (ds->type) { case FDEF_FLD: + if (!first_field) + fwrite (delim[1], strlen (delim[1]), 1, fp); if (ds->v.field.name) fprintf (fp, "%s=", ds->v.field.name); if (ds->v.field.dim > 1) @@ -259,7 +262,7 @@ datum_format (FILE *fp, datum const *dat, struct dsegm *ds) } if (ds->v.field.dim > 1) fprintf (fp, " }"); - fwrite (delim[1], strlen (delim[1]), 1, fp); + first_field = 0; break; case FDEF_OFF: @@ -403,7 +406,7 @@ dsprint (FILE *fp, int what, struct dsegm *ds) case FDEF_FLD: fprintf (fp, "\t%s", ds->v.field.type->name); if (ds->v.field.name) - fprintf (fp, " %s", ds->v.field.type->name); + fprintf (fp, " %s", ds->v.field.name); if (ds->v.field.dim > 1) fprintf (fp, "[%d]", ds->v.field.dim); fprintf (fp, ",\n"); |