I'm in the process of updating the pkgsrc (multi-OS multi-cpu packaging
system originated at NetBSD) entry for opensc from 0.11.13 to 0.12.2.
I'm having a few unrelated issues, and will send separate notes.

In src/common/compat_getopt.{h,c}, replacements are provided for getopt,
getopt_long and getopt_long_only unless all three are found at configure
time.  NetBSD has getopt (which is originally from 4.3BSD) and
getopt_long, but not getopt_long_only, which as far as I can tell is
only found on GNU/Linux.   The replacement has a type clash with the
builtin declaration.

I believe that getopt_long_only is not actually used.  So I have created
a packaging patch to drop the test for getopt_long_only, so that the
replacements are not selected if the system has getopt and getopt_long.
(As a hack, I also changed the test program to use getopt_long so that
it would build.

So if opensc doesn't have a good reason to use getopt_long_only, it
would simplify things and improve portability to remove compat support
for it.

    Thanks,
    Greg

$NetBSD$

--- src/common/compat_getopt.c.orig     2011-07-05 11:28:53.000000000 +0000
+++ src/common/compat_getopt.c
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#if ! ( defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG) && 
defined(HAVE_GETOPT_LONG_ONLY) )
+#if ! ( defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG) )
 
 #include <sys/types.h>
 #include <stdlib.h>
$NetBSD$

--- src/common/compat_getopt.h.orig     2011-07-05 11:28:53.000000000 +0000
+++ src/common/compat_getopt.h
@@ -30,7 +30,7 @@
 #include "config.h"
 #endif
 
-#if defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG) && 
defined(HAVE_GETOPT_LONG_ONLY)
+#if defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG)
 #include <getopt.h>
 #else
 
@@ -43,7 +43,6 @@ extern "C" {
 
 #define getopt my_getopt
 #define getopt_long my_getopt_long
-#define getopt_long_only my_getopt_long_only
 #define _getopt_internal _my_getopt_internal
 #define opterr my_opterr
 #define optind my_optind
@@ -86,6 +85,6 @@ extern int _my_getopt_internal(int argc,
 }
 #endif
 
-#endif /* HAVE_GETOPT_H && HAVE_GETOPT_LONG && HAVE_GETOPT_LONG_ONLY */
+#endif /* HAVE_GETOPT_H && HAVE_GETOPT_LONG */
 
 #endif /* MY_GETOPT_H_INCLUDED */
$NetBSD$

--- src/common/compat_getopt_main.c.orig        2011-07-05 11:28:53.000000000 
+0000
+++ src/common/compat_getopt_main.c
@@ -173,6 +173,8 @@ main(int argc, char * argv[])
               progname);
     }
 
+#define getopt_long_only getopt_long
+
   /* parse all options from the command line */
   while ((opt =
           getopt_long_only(argc, argv, shortopts, longopts, &longind)) != -1)

Attachment: pgp9TZVnEqosO.pgp
Description: PGP signature

_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to