summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-05 11:31:20 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-08-05 11:31:20 (GMT)
commit999b2b28f4245e7717bff024cefe87905644cfb1 (patch) (side-by-side diff)
treefcc057dfd0ba79a514294c9a203dba5a9b4132a7 /tests
parentdd6eb59eb0de0e8fe0482bbc9a4acb99e302c963 (diff)
downloadgdbm-999b2b28f4245e7717bff024cefe87905644cfb1.tar.gz
gdbm-999b2b28f4245e7717bff024cefe87905644cfb1.tar.bz2
Include progname.h instead of declaring canonical_progname.
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/gtdel.c16
-rw-r--r--tests/gtdump.c17
-rw-r--r--tests/gtfetch.c16
-rw-r--r--tests/gtload.c21
-rw-r--r--tests/gtver.c16
5 files changed, 10 insertions, 76 deletions
diff --git a/tests/gtdel.c b/tests/gtdel.c
index 6826532..ff9cdb9 100644
--- a/tests/gtdel.c
+++ b/tests/gtdel.c
@@ -16,27 +16,13 @@
*/
#include "autoconf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdbm.h"
-
-const char *
-canonical_progname (const char *str)
-{
- const char *p;
-
- p = strrchr (str, '/');
- if (p)
- p++;
- else
- p = str;
- if (strncmp (p, "lt-", 3) == 0)
- p += 3;
- return p;
-}
+#include "progname.h"
int
main (int argc, char **argv)
{
const char *progname = canonical_progname (argv[0]);
const char *dbname;
diff --git a/tests/gtdump.c b/tests/gtdump.c
index 7030cfd..927a47c 100644
--- a/tests/gtdump.c
+++ b/tests/gtdump.c
@@ -16,39 +16,24 @@
*/
#include "autoconf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdbm.h"
-
-const char *
-canonical_progname (const char *str)
-{
- const char *p;
-
- p = strrchr (str, '/');
- if (p)
- p++;
- else
- p = str;
- if (strncmp (p, "lt-", 3) == 0)
- p += 3;
- return p;
-}
+#include "progname.h"
int
main (int argc, char **argv)
{
const char *progname = canonical_progname (argv[0]);
const char *dbname;
datum key;
datum data;
int flags = 0;
GDBM_FILE dbf;
int delim = '\t';
- int data_z = 0;
while (--argc)
{
char *arg = *++argv;
if (strcmp (arg, "-h") == 0)
diff --git a/tests/gtfetch.c b/tests/gtfetch.c
index e7ff542..0c254b7 100644
--- a/tests/gtfetch.c
+++ b/tests/gtfetch.c
@@ -16,12 +16,13 @@
*/
#include "autoconf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdbm.h"
+#include "progname.h"
void
print_key (FILE *fp, datum key, int delim)
{
size_t i;
@@ -30,27 +31,12 @@ print_key (FILE *fp, datum key, int delim)
if (key.dptr[i] == delim || key.dptr[i] == '\\')
fputc ('\\', fp);
fputc (key.dptr[i], fp);
}
}
-const char *
-canonical_progname (const char *str)
-{
- const char *p;
-
- p = strrchr (str, '/');
- if (p)
- p++;
- else
- p = str;
- if (strncmp (p, "lt-", 3) == 0)
- p += 3;
- return p;
-}
-
int
main (int argc, char **argv)
{
const char *progname = canonical_progname (argv[0]);
const char *dbname;
datum key;
diff --git a/tests/gtload.c b/tests/gtload.c
index f75f671..550833f 100644
--- a/tests/gtload.c
+++ b/tests/gtload.c
@@ -16,27 +16,13 @@
*/
#include "autoconf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdbm.h"
-
-const char *
-canonical_progname (const char *str)
-{
- const char *p;
-
- p = strrchr (str, '/');
- if (p)
- p++;
- else
- p = str;
- if (strncmp (p, "lt-", 3) == 0)
- p += 3;
- return p;
-}
+#include "progname.h"
int
main (int argc, char **argv)
{
const char *progname = canonical_progname (argv[0]);
const char *dbname;
@@ -97,12 +83,17 @@ main (int argc, char **argv)
fprintf (stderr, "%s: wrong arguments\n", progname);
exit (1);
}
dbname = *argv;
dbf = gdbm_open (dbname, block_size, mode|flags, 00664, NULL);
+ if (!dbf)
+ {
+ fprintf (stderr, "gdbm_open failed: %s\n", gdbm_strerror (gdbm_errno));
+ exit (1);
+ }
while (fgets (buf, sizeof buf, stdin))
{
size_t i, j;
size_t len = strlen (buf);
diff --git a/tests/gtver.c b/tests/gtver.c
index 0865666..27fc0b9 100644
--- a/tests/gtver.c
+++ b/tests/gtver.c
@@ -16,27 +16,13 @@
*/
#include "autoconf.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gdbm.h"
-
-const char *
-canonical_progname (const char *str)
-{
- const char *p;
-
- p = strrchr (str, '/');
- if (p)
- p++;
- else
- p = str;
- if (strncmp (p, "lt-", 3) == 0)
- p += 3;
- return p;
-}
+#include "progname.h"
#define major_number(lib) ((lib) ? gdbm_version_number[0] : GDBM_VERSION_MAJOR)
#define minor_number(lib) ((lib) ? gdbm_version_number[1] : GDBM_VERSION_MINOR)
#define patch_number(lib) ((lib) ? gdbm_version_number[2] : GDBM_VERSION_PATCH)
int

Return to:

Send suggestions and report system problems to the System administrator.