summaryrefslogtreecommitdiff
path: root/bdb/common/db_getlong.c
diff options
context:
space:
mode:
Diffstat (limited to 'bdb/common/db_getlong.c')
-rw-r--r--bdb/common/db_getlong.c73
1 files changed, 34 insertions, 39 deletions
diff --git a/bdb/common/db_getlong.c b/bdb/common/db_getlong.c
index bead530cd94..6ba8ebfcdaa 100644
--- a/bdb/common/db_getlong.c
+++ b/bdb/common/db_getlong.c
@@ -1,14 +1,14 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997, 1998, 1999, 2000
+ * Copyright (c) 1996-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: db_getlong.c,v 11.11 2000/12/22 19:16:04 bostic Exp $";
+static const char revid[] = "$Id: db_getlong.c,v 11.18 2002/03/28 20:13:33 bostic Exp $";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -20,7 +20,6 @@ static const char revid[] = "$Id: db_getlong.c,v 11.11 2000/12/22 19:16:04 bosti
#endif
#include "db_int.h"
-#include "clib_ext.h"
/*
* __db_getlong --
@@ -43,42 +42,40 @@ __db_getlong(dbp, progname, p, min, max, storep)
val = strtol(p, &end, 10);
if ((val == LONG_MIN || val == LONG_MAX) &&
__os_get_errno() == ERANGE) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: %s\n", progname, p, strerror(ERANGE));
- exit(1);
- }
- dbp->err(dbp, ERANGE, "%s", p);
+ else
+ dbp->err(dbp, ERANGE, "%s", p);
return (1);
}
if (p[0] == '\0' || (end[0] != '\0' && end[0] != '\n')) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: Invalid numeric argument\n", progname, p);
- exit(1);
- }
- dbp->errx(dbp, "%s: Invalid numeric argument", p);
+ else
+ dbp->errx(dbp, "%s: Invalid numeric argument", p);
return (1);
}
if (val < min) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: Less than minimum value (%ld)\n",
progname, p, min);
- exit(1);
- }
- dbp->errx(dbp, "%s: Less than minimum value (%ld)", p, min);
+ else
+ dbp->errx(dbp,
+ "%s: Less than minimum value (%ld)", p, min);
return (1);
}
if (val > max) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: Greater than maximum value (%ld)\n",
progname, p, max);
- exit(1);
- }
- dbp->errx(dbp, "%s: Greater than maximum value (%ld)", p, max);
- exit(1);
+ else
+ dbp->errx(dbp,
+ "%s: Greater than maximum value (%ld)", p, max);
+ return (1);
}
*storep = val;
return (0);
@@ -109,31 +106,29 @@ __db_getulong(dbp, progname, p, min, max, storep)
__os_set_errno(0);
val = strtoul(p, &end, 10);
if (val == ULONG_MAX && __os_get_errno() == ERANGE) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: %s\n", progname, p, strerror(ERANGE));
- exit(1);
- }
- dbp->err(dbp, ERANGE, "%s", p);
+ else
+ dbp->err(dbp, ERANGE, "%s", p);
return (1);
}
if (p[0] == '\0' || (end[0] != '\0' && end[0] != '\n')) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
"%s: %s: Invalid numeric argument\n", progname, p);
- exit(1);
- }
- dbp->errx(dbp, "%s: Invalid numeric argument", p);
+ else
+ dbp->errx(dbp, "%s: Invalid numeric argument", p);
return (1);
}
if (val < min) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
- "%s: %s: Less than minimum value (%ld)\n",
+ "%s: %s: Less than minimum value (%lu)\n",
progname, p, min);
- exit(1);
- }
- dbp->errx(dbp, "%s: Less than minimum value (%ld)", p, min);
+ else
+ dbp->errx(dbp,
+ "%s: Less than minimum value (%lu)", p, min);
return (1);
}
@@ -144,14 +139,14 @@ __db_getulong(dbp, progname, p, min, max, storep)
* may not exist on all platforms.
*/
if (max != 0 && val > max) {
- if (dbp == NULL) {
+ if (dbp == NULL)
fprintf(stderr,
- "%s: %s: Greater than maximum value (%ld)\n",
+ "%s: %s: Greater than maximum value (%lu)\n",
progname, p, max);
- exit(1);
- }
- dbp->errx(dbp, "%s: Greater than maximum value (%ld)", p, max);
- exit(1);
+ else
+ dbp->errx(dbp,
+ "%s: Greater than maximum value (%lu)", p, max);
+ return (1);
}
*storep = val;
return (0);