bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] Autoconf and differences between GNU getopt and OpenBSD get


From: Alexander Taler
Subject: [Bug-gnulib] Autoconf and differences between GNU getopt and OpenBSD getopt
Date: Sun, 10 Oct 2004 10:38:33 -0400

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, in building the feature branch of CVS on OpenBSD 3.5 sparc64,
I've uncovered a problem with getopt.  autoconf detects that
getopt is present and usable:

checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking for getopt_long_only... yes

However, the CVS tests fail because getopt doesn't behave quite
as it expects.  I've identified two differences:

They emit different messages if an option is not recognized:
GNU getopt emits argv[0] and "invalid option":
   admin: invalid option -- H
OpenBSD getopt emits the program's name and "unknown option":
   cvs: unknown option -- H

They handle a double colon and a space between the option and the
argument differently.  For example, with an option string of
"r::", and argv of "-r", "foo", GNU getopt will return NULL in
optarg, while OpenBSD will return "foo".  Here's some code that
illustrates the difference:

#include <stdio.h>
#include "getopt.h"

int main(int argc, char **argv) {

  int c = 3;
  char *v[3] = {"test", "-r", "foo"};
  getopt(c, v, "r::");

  if (optarg == NULL) {
    printf("GNU getopt\n");
  } else {
    printf("OpenBSD getopt\n");
  }
}


Since this behaviour has shipped in OpenBSD 3.5, I guess adding a
test to autoconf is the correct thing to do.  My knowledge of
autoconf and m4 is too weak to allow me to do it myself.

Thanks for your trouble,
Alex

- -- 
http://libcvs.cvshome.org/    Access CVS through a library. 
PGP:  ID: 0x23DC453B  FPR: 42D0 66C2 9FF8 553A 373A  B819 4C34 93BA 23DC 453B
The purpose of the minutes is not to record events, it is to protect people.
                -- Sir Humphrey Appleby
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (OpenBSD)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFBaUkkTDSTuiPcRTsRAg8qAJkBRBuVlPShyRrQd+hD5ampm46HagCcCiqT
fku6NcWpBZWP51o2i2l/lAM=
=9Sx0
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]