summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5354a56)
raw | patch | inline | side by side (parent: 5354a56)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 30 Jul 2008 19:53:45 +0000 (12:53 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 30 Jul 2008 19:53:45 +0000 (12:53 -0700) |
OPT_INTEGER() works on an integer, not on an unsigned long. On a big
endian architecture with long larger than int, integer test gives bogus
results because of this bug.
Reported by H.Merijn Brand in HP-UX 64-bit environment.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
endian architecture with long larger than int, integer test gives bogus
results because of this bug.
Reported by H.Merijn Brand in HP-UX 64-bit environment.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0040-parse-options.sh | patch | blob | history | |
test-parse-options.c | patch | blob | history |
index 03dbe00102626e05c37e45d8a3b1364b99644942..e38241c80a6625c9b5b89340b9d0c5a2667bf345 100755 (executable)
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 123
abbrev: 7
verbose: 2
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 321
abbrev: 10
verbose: 2
cat > expect << EOF
boolean: 1
integer: 13
+timestamp: 0
string: 123
abbrev: 7
verbose: 0
cat > expect << EOF
boolean: 0
integer: 2
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect << EOF
boolean: 0
integer: 0
+timestamp: 0
string: 123
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 0
integer: 0
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 0
-integer: 1
+integer: 0
+timestamp: 1
string: default
abbrev: 7
verbose: 0
Callback: "four", 0
boolean: 5
integer: 4
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 1
integer: 23
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
diff --git a/test-parse-options.c b/test-parse-options.c
index 2a79e729a4018ddb2da9ff633f4bf3b102fa8f88..6e18083a7d1655e9eabef197c58d92a910d2f67b 100644 (file)
--- a/test-parse-options.c
+++ b/test-parse-options.c
#include "parse-options.h"
static int boolean = 0;
-static unsigned long integer = 0;
+static int integer = 0;
+static unsigned long timestamp;
static int abbrev = 7;
static int verbose = 0, dry_run = 0, quiet = 0;
static char *string = NULL;
OPT_INTEGER('i', "integer", &integer, "get a integer"),
OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
- OPT_DATE('t', NULL, &integer, "get timestamp of <time>"),
+ OPT_DATE('t', NULL, ×tamp, "get timestamp of <time>"),
OPT_CALLBACK('L', "length", &integer, "str",
"get length of <str>", length_callback),
OPT_GROUP("String options"),
argc = parse_options(argc, argv, options, usage, 0);
printf("boolean: %d\n", boolean);
- printf("integer: %lu\n", integer);
+ printf("integer: %u\n", integer);
+ printf("timestamp: %lu\n", timestamp);
printf("string: %s\n", string ? string : "(not set)");
printf("abbrev: %d\n", abbrev);
printf("verbose: %d\n", verbose);