From e30e5af8554b875b0db081b626f628bf7bf75fdd Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 25 Nov 1999 17:50:10 +0000 Subject: [PATCH] r113: Added a check for getopt_long() functions. Uses short options only if it's not found. --- ROX-Filer/src/config.h.in | 1 + ROX-Filer/src/configure.in | 2 +- ROX-Filer/src/main.c | 31 +++++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ROX-Filer/src/config.h.in b/ROX-Filer/src/config.h.in index 4e7f3acf..572f14ce 100644 --- a/ROX-Filer/src/config.h.in +++ b/ROX-Filer/src/config.h.in @@ -2,3 +2,4 @@ #undef HAVE_SYS_UCRED_H #undef HAVE_MNTENT_H +#undef HAVE_GETOPT_LONG diff --git a/ROX-Filer/src/configure.in b/ROX-Filer/src/configure.in index 9a2f5d7f..caa43053 100644 --- a/ROX-Filer/src/configure.in +++ b/ROX-Filer/src/configure.in @@ -28,6 +28,6 @@ AC_TYPE_UID_T AC_TYPE_SIZE_T dnl Checks for library functions. -AC_CHECK_FUNCS(gethostname mkdir rmdir strdup strtol) +AC_CHECK_FUNCS(gethostname mkdir rmdir strdup strtol getopt_long) AC_OUTPUT(Makefile) diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index 1703ea3c..1720c362 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -17,8 +17,12 @@ * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA + * + * The getopt stuff is from glibc. */ +#include "config.h" + #include #include #include @@ -26,7 +30,10 @@ #include #include #include -#include + +#ifdef HAVE_GETOPT_LONG +# include +#endif #include #include "collection.h" @@ -45,8 +52,6 @@ int number_of_windows = 0; /* Quit when this reaches 0 again... */ int to_error_log = -1; /* Write here to log errors */ -#define USAGE "Try `ROX-Filer/AppRun --help' for more information.\n" - #define VERSION "ROX-Filer 0.1.4\n" \ "Copyright (C) 1999 Thomas Leonard.\n" \ "ROX-Filer comes with ABSOLUTELY NO WARRANTY,\n" \ @@ -56,6 +61,15 @@ int to_error_log = -1; /* Write here to log errors */ "For more information about these matters, " \ "see the file named COPYING.\n" +#ifdef HAVE_GETOPT_LONG +# define USAGE "Try `ROX-Filer/AppRun --help' for more information.\n" +# define SHORT_ONLY_WARNING "" +#else +# define USAGE "Try `ROX-Filer/AppRun -h' for more information.\n" +# define SHORT_ONLY_WARNING "NOTE: Your system does not support long options - \n" \ + "you must use the short versions instead.\n\n" +#endif \ + #define HELP "Usage: ROX-Filer/AppRun [OPTION]... [DIR]...\n" \ "Open filer windows showing each directory listed, or $HOME \n" \ "if no directories are given.\n\n" \ @@ -66,9 +80,10 @@ int to_error_log = -1; /* Write here to log errors */ " -l, --left [DIR] open DIR as a left-edge panel\n" \ " -r, --right [DIR] open DIR as a right-edge panel\n" \ " -o, --override override window manager control of panels\n" \ - "\n" \ + "\n" SHORT_ONLY_WARNING \ "Report bugs to .\n" +#ifdef HAVE_GETOPT_LONG static struct option long_opts[] = { {"top", 1, NULL, 't'}, @@ -80,6 +95,7 @@ static struct option long_opts[] = {"version", 0, NULL, 'v'}, {NULL, 0, NULL, 0}, }; +#endif /* Take control of panels away from WM? */ gboolean override_redirect = FALSE; @@ -141,11 +157,14 @@ int main(int argc, char **argv) while (1) { - int long_index; int c; - +#ifdef HAVE_GETOPT_LONG + int long_index; c = getopt_long(argc, argv, "t:b:l:r:ohv", long_opts, &long_index); +#else + c = getopt(argc, argv, "t:b:l:r:ohv"); +#endif if (c == EOF) break; /* No more options */ -- 2.11.4.GIT