diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-17 08:38:57 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-17 08:38:57 +0000 |
commit | c7f543a57fc4feb9abb8ce97ff857db9f20026c7 (patch) | |
tree | c4e2feb455f46bd456ef84d8c40700edc0f8680c /src/datconv.c | |
parent | 78c8bbc4157d577c291b289602794ecd1ff24c42 (diff) | |
download | gdbm-c7f543a57fc4feb9abb8ce97ff857db9f20026c7.tar.gz gdbm-c7f543a57fc4feb9abb8ce97ff857db9f20026c7.tar.bz2 |
Update the docs.
* NEWS: Update.
* doc/gdbm.texinfo: Update.
* doc/gdbmtool.1: Document the "define" statement.
* src/datconv.c: Rename string datatypes to reflect their
meaning.
(dsprint): Improve output presentation.
Diffstat (limited to 'src/datconv.c')
-rw-r--r-- | src/datconv.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/datconv.c b/src/datconv.c index c8f63e0..c4adfa4 100644 --- a/src/datconv.c +++ b/src/datconv.c @@ -38,7 +38,7 @@ DEFFMT (f_float, float, "%f") DEFFMT (f_double, double, "%e") static int -f_string (FILE *fp, void *ptr, int size) +f_stringz (FILE *fp, void *ptr, int size) { int sz; char *s; @@ -58,7 +58,7 @@ f_string (FILE *fp, void *ptr, int size) } static int -f_zstring (FILE *fp, void *ptr, int size) +f_string (FILE *fp, void *ptr, int size) { int sz; char *s; @@ -140,14 +140,14 @@ s_float (struct xdatum *xd, char *str) } int -s_string (struct xdatum *xd, char *str) +s_stringz (struct xdatum *xd, char *str) { xd_store (xd, str, strlen (str) + 1); return 0; } int -s_zstring (struct xdatum *xd, char *str) +s_string (struct xdatum *xd, char *str) { xd_store (xd, str, strlen (str)); return 0; @@ -166,8 +166,8 @@ static struct datadef datatab[] = { { "ullong", sizeof(unsigned long long), f_ullong, s_ullong }, { "float", sizeof(float), f_float, s_float }, { "double", sizeof(double), f_double, s_double }, + { "stringz", 0, f_stringz, s_stringz }, { "string", 0, f_string, s_string }, - { "zstring", 0, f_zstring, s_zstring }, { NULL } }; @@ -403,29 +403,40 @@ void dsprint (FILE *fp, int what, struct dsegm *ds) { static char *dsstr[] = { "key", "content" }; + int delim; - fprintf (fp, "define %s {\n", dsstr[what]); + fprintf (fp, "define %s", dsstr[what]); + if (ds->next) + { + fprintf (fp, " {\n"); + delim = '\t'; + } + else + delim = ' '; for (; ds; ds = ds->next) { switch (ds->type) { case FDEF_FLD: - fprintf (fp, "\t%s", ds->v.field.type->name); + fprintf (fp, "%c%s", delim, ds->v.field.type->name); if (ds->v.field.name) fprintf (fp, " %s", ds->v.field.name); if (ds->v.field.dim > 1) fprintf (fp, "[%d]", ds->v.field.dim); - fprintf (fp, ",\n"); break; case FDEF_OFF: - fprintf (fp, "\toffset %d,\n", ds->v.n); + fprintf (fp, "%coffset %d", delim, ds->v.n); break; case FDEF_PAD: - fprintf (fp, "\tpad %d,\n", ds->v.n); + fprintf (fp, "%cpad %d", delim, ds->v.n); break; } + if (ds->next) + fputc (',', fp); + fputc ('\n', fp); } - fprintf (fp, "}\n"); + if (delim == '\t') + fputs ("}\n", fp); } |