diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-13 06:27:44 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-13 06:27:44 +0000 |
commit | 1638ed6202b77b521214128189dc4aacdb5fe098 (patch) | |
tree | 2e82fd4a16bef6f4d29bf11b4b4b62e7fa9de28f /tests | |
parent | 4785154fda6411a384a4ead5abb18c22bb77a8f0 (diff) | |
download | gdbm-1638ed6202b77b521214128189dc4aacdb5fe098.tar.gz gdbm-1638ed6202b77b521214128189dc4aacdb5fe098.tar.bz2 |
Handle structured key and content data in gdbmtool.
* src/datconv.c: New file.
* src/Makefile.am (gdbmtool_SOURCES): Add datconv.c.
* src/gdbmtool.h (slist, kvpair): New structures.
(gdbmarg): Keep various types of data depending on the
value of the type member.
(slist_new, slist_free)
(kvpair_string, kvpair_list): New protos.
(gdbmarg_new): Remove.
(gdbmarg_string, gdbmarg_datum)
(gdbmarg_kvpair, gdbmarg_free)
(gdbmarg_destroy): New protos.
(xd_expand, xd_store, datadef_locate): New protos.
(field, dsegm): New structs.
(dsegm_new, dsegm_new_field, dsegm_free_list): New protos.
* src/gdbmtool.c: Rewrite.
* src/gram.y: Change grammar to allow for defining key and
content structure and for supplying structured data as arguments
to fetch, store and similar functions.
* src/lex.l: Handle new token types.
* tests/dtload.c (main): Fix parser.
* tests/gtload.c: Likewise.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dtload.c | 7 | ||||
-rw-r--r-- | tests/gtload.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/tests/dtload.c b/tests/dtload.c index 6ebd638..a02b36c 100644 --- a/tests/dtload.c +++ b/tests/dtload.c @@ -134,11 +134,12 @@ main (int argc, char **argv) progname, line); continue; } - + buf[j] = 0; + key.dptr = buf; key.dsize = j + data_z; - data.dptr = buf + j + 1; - data.dsize = strlen (buf + j + 1) + data_z; + data.dptr = buf + i + 1; + data.dsize = strlen (data.dptr) + data_z; if (store (key, data) != 0) { fprintf (stderr, "%s: %d: item not inserted\n", diff --git a/tests/gtload.c b/tests/gtload.c index b89ae1f..2920463 100644 --- a/tests/gtload.c +++ b/tests/gtload.c @@ -157,11 +157,12 @@ main (int argc, char **argv) progname, line); continue; } - + buf[j] = 0; + key.dptr = buf; key.dsize = j + data_z; - data.dptr = buf + j + 1; - data.dsize = strlen (buf + j + 1) + data_z; + data.dptr = buf + i + 1; + data.dsize = strlen (data.dptr) + data_z; if (gdbm_store (dbf, key, data, replace) != 0) { fprintf (stderr, "%s: %d: item not inserted\n", |