shithub: sox

Download patch

ref: a1e803f1053d488bcd2f625181e81b130d4aed75
parent: eb49e872741878d031997e7d3e8dcc5133d30c0b
author: cbagwell <cbagwell>
date: Wed Nov 5 09:31:44 EST 2008

Rename external symbols to avoid conflicts.  getopt wasn't being used before now on GNU systems either.  Fix that.

--- a/src/getopt.c
+++ b/src/getopt.c
@@ -1,4 +1,3 @@
-#include "soxconfig.h"
 /* Getopt for GNU.
    NOTE: getopt is now part of the C library, so if you don't know what
    "Keep this file name-space clean" means, talk to drepper@gnu.org
@@ -58,6 +57,11 @@
 # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
 #  define ELIDE_CODE
 # endif
+#endif
+
+/* For SoX, always compile this */
+#if defined ELIDE_CODE
+#undef ELIDE_CODE
 #endif
 
 #ifndef ELIDE_CODE
--- a/src/getopt.h
+++ b/src/getopt.h
@@ -42,10 +42,17 @@
 # include <ctype.h>
 #endif
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 extern "C" {
 #endif
 
+/* Create aliases to prevent collisions with c libraries versions of
+ * these.
+ */
+#define optind lsx_optind
+#define optarg lsx_optarg
+#define getopt lsx_getopt
+
 /* For communication from `getopt' to the caller.
    When `getopt' finds an option that takes an argument,
    the argument value is returned here.
@@ -84,9 +91,9 @@
    zero.
 
    The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
+   no_argument          (or 0) if the option does not take an argument,
+   required_argument    (or 1) if the option requires an argument,
+   optional_argument    (or 2) if the option takes an optional argument.
 
    If the field `flag' is not NULL, it points to a variable that is set
    to the value given in the field `val' when the option is found, but
@@ -115,10 +122,10 @@
 
 /* Names for the values of the `has_arg' field of `struct option'.  */
 
-# define no_argument		0
-# define required_argument	1
-# define optional_argument	2
-#endif	/* need getopt */
+# define no_argument            0
+# define required_argument      1
+# define optional_argument      2
+#endif  /* need getopt */
 
 
 /* Get definitions and prototypes for functions to process the
@@ -157,17 +164,17 @@
 
 # ifndef __need_getopt
 extern int getopt_long (int ___argc, char *const *___argv,
-			const char *__shortopts,
-		        const struct option *__longopts, int *__longind);
+                        const char *__shortopts,
+                        const struct option *__longopts, int *__longind);
 extern int getopt_long_only (int ___argc, char *const *___argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind);
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind);
 
 /* Internal only.  Users should not call this directly.  */
 extern int _getopt_internal (int ___argc, char *const *___argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind,
-			     int __long_only);
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind,
+                             int __long_only);
 # endif
 #else /* not __STDC__ */
 extern int getopt ();
@@ -179,7 +186,7 @@
 # endif
 #endif /* __STDC__ */
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 }
 #endif
 
--- a/src/getopt1.c
+++ b/src/getopt1.c
@@ -56,6 +56,11 @@
 #endif
 #endif
 
+/* Always compile for SoX */
+#if defined ELIDE_CODE
+#undef ELIDE_CODE
+#endif
+
 #ifndef ELIDE_CODE