From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
To: Junio C Hamano <gitster@pobox.com>
Cc: Pierre Habouzit <madcoder@debian.org>, git@vger.kernel.org
Subject: Re: [PATCH] 64bit issue in test-parse-options.c
Date: Wed, 30 Jul 2008 21:55:00 +0200 [thread overview]
Message-ID: <20080730215500.5b4ec69e@pc09.procura.nl> (raw)
In-Reply-To: <7vej5b5grc.fsf@gitster.siamese.dyndns.org>
On Wed, 30 Jul 2008 12:11:35 -0700, Junio C Hamano <gitster@pobox.com>
wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
>
> > The proper fix is to let integer be an *INT* (long integer is bogus
> > anyways) and to put the date in a long using static unsigned long date,
> > and make OPT_DATE use this long.
>
> I am still puzzled by the original report of the breakage, as H. Merijn
> cannot be the first person to ever ran test-parse-options on 64-bit
> machine. Maybe there is a bytesex issue involved as well?
Itanium 2 / 64, and endianness indeed
> In any case, this should work.
Yes, that was what I was thinking too, but I had no time to go for the
test cases too. I had it to get to work ASAP.
> test-parse-options.c | 8 +++++---
> t/t0040-parse-options.sh | 11 ++++++++++-
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/test-parse-options.c b/test-parse-options.c
> index 2a79e72..6e18083 100644
> --- a/test-parse-options.c
> +++ b/test-parse-options.c
> @@ -2,7 +2,8 @@
> #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;
> @@ -32,7 +33,7 @@ int main(int argc, const char **argv)
> 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"),
> @@ -56,7 +57,8 @@ int main(int argc, const char **argv)
> 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);
>
>
> diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
> index 03dbe00..e38241c 100755
> --- a/t/t0040-parse-options.sh
> +++ b/t/t0040-parse-options.sh
> @@ -47,6 +47,7 @@ test_expect_success 'test help' '
> cat > expect << EOF
> boolean: 2
> integer: 1729
> +timestamp: 0
> string: 123
> abbrev: 7
> verbose: 2
> @@ -63,6 +64,7 @@ test_expect_success 'short options' '
> cat > expect << EOF
> boolean: 2
> integer: 1729
> +timestamp: 0
> string: 321
> abbrev: 10
> verbose: 2
> @@ -88,6 +90,7 @@ test_expect_success 'missing required value' '
> cat > expect << EOF
> boolean: 1
> integer: 13
> +timestamp: 0
> string: 123
> abbrev: 7
> verbose: 0
> @@ -108,6 +111,7 @@ test_expect_success 'intermingled arguments' '
> cat > expect << EOF
> boolean: 0
> integer: 2
> +timestamp: 0
> string: (not set)
> abbrev: 7
> verbose: 0
> @@ -135,6 +139,7 @@ test_expect_success 'ambiguously abbreviated option' '
> cat > expect << EOF
> boolean: 0
> integer: 0
> +timestamp: 0
> string: 123
> abbrev: 7
> verbose: 0
> @@ -161,6 +166,7 @@ test_expect_success 'detect possible typos' '
> cat > expect <<EOF
> boolean: 0
> integer: 0
> +timestamp: 0
> string: (not set)
> abbrev: 7
> verbose: 0
> @@ -177,7 +183,8 @@ test_expect_success 'keep some options as arguments' '
>
> cat > expect <<EOF
> boolean: 0
> -integer: 1
> +integer: 0
> +timestamp: 1
> string: default
> abbrev: 7
> verbose: 0
> @@ -197,6 +204,7 @@ cat > expect <<EOF
> Callback: "four", 0
> boolean: 5
> integer: 4
> +timestamp: 0
> string: (not set)
> abbrev: 7
> verbose: 0
> @@ -223,6 +231,7 @@ test_expect_success 'OPT_CALLBACK() and callback errors work' '
> cat > expect <<EOF
> boolean: 1
> integer: 23
> +timestamp: 0
> string: (not set)
> abbrev: 7
> verbose: 0
--
H.Merijn Brand Amsterdam Perl Mongers http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, SuSE 10.1, 10.2, and 10.3, AIX 5.2, and Cygwin.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
next prev parent reply other threads:[~2008-07-30 19:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-30 12:16 [PATCH] 64bit issue in test-parse-options.c H.Merijn Brand
2008-07-30 12:37 ` Pierre Habouzit
2008-07-30 12:44 ` H.Merijn Brand
2008-07-30 14:05 ` Pierre Habouzit
2008-07-30 19:11 ` Junio C Hamano
2008-07-30 19:35 ` Pierre Habouzit
2008-07-30 19:55 ` H.Merijn Brand [this message]
2008-07-31 11:07 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080730215500.5b4ec69e@pc09.procura.nl \
--to=h.m.brand@xs4all.nl \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).