aboutsummaryrefslogtreecommitdiff
path: root/src/datconv.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-17 08:38:57 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2013-05-17 08:38:57 +0000
commitc7f543a57fc4feb9abb8ce97ff857db9f20026c7 (patch)
treec4e2feb455f46bd456ef84d8c40700edc0f8680c /src/datconv.c
parent78c8bbc4157d577c291b289602794ecd1ff24c42 (diff)
downloadgdbm-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.c33
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);
}

Return to:

Send suggestions and report system problems to the System administrator.