Subject: Re: textproc/nbsed broken on non-NetBSD systems
To: Robert Lillack <lillack@mis.mpg.de>
From: Robert Lillack <lillack@mis.mpg.de>
List: tech-pkg
Date: 04/29/2005 22:29:35
This is a multi-part message in MIME format.
--------------080905000807050504060605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Robert Lillack wrote:

> I think at least a switch to force building getopt, when SunOS <=5.8
> is detected in libnbcompat's autoconf script is the badly needed.

Actually I got to revoke this. nbsed did use libnbcompat's getopt.
And that's the broken one (correct me, if I'm wrong, it's late here):

% gcc -o getopt-test getopt-test.c libnbcompat-20041024/libnbcompat.a
% ./getopt-test abc --x && echo "ok" || echo "nono"
nono

% gcc -o getopt-test getopt-test.c
% ./getopt-test abc --x && echo "ok" || echo "nono"
ok

Both tests done on the Solaris 8 box I was referring to, before.
getopt-test.c is attached. (For this tiny test I don't even consider the
GNU way broken, but changing the defines you should have a good starting
point for autoconf magic)

What do I overlook?

Cheers, Rob.
-- 
   +- Robert Lillack ------------------ lillack@mis.mpg.de -+
  /  Max Planck Institute for Mathematics in the Sciences  /
+- Leipzig, Germany ----------- phone: +49-341-9959-693 -+

--------------080905000807050504060605
Content-Type: text/plain;
 name="getopt-test.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="getopt-test.c"

/* call like this: ./getopt abc --x */
#include <unistd.h>

#define GETOPT_POSIX		0
#define GETOPT_GNUSTYLE		0
#define GETOPT_BROKEN		1

extern int optind;

int main(int argc, char **argv) {
  if (getopt(argc, argv, "x") != -1) {
    exit(GETOPT_GNUSTYLE);
  }

  argc -= optind;
  if (argc < 2) {
    exit(GETOPT_BROKEN);
  }

  exit(GETOPT_POSIX);
}

--------------080905000807050504060605--