From 048e55666ff371c81ad38fa08e26c7eb3793e544 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Tue, 9 Jul 2002 14:12:39 +0000 Subject: [PATCH] Detect getopt_long correctly. Fix gcc'ism. --- Makefile.in | 4 ++-- config.h.in | 3 +++ configure | 2 +- configure.in | 2 +- src/file.c | 14 +++++++------- src/file.h | 6 +++++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index f61dafcd..19d74b75 100644 --- a/Makefile.in +++ b/Makefile.in @@ -122,7 +122,7 @@ missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(file_SOURCES) OBJECTS = $(file_OBJECTS) @@ -416,7 +416,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/config.h.in b/config.h.in index aa058242..9963fbf7 100644 --- a/config.h.in +++ b/config.h.in @@ -67,6 +67,9 @@ /* The number of bytes in a uint64_t. */ #define SIZEOF_UINT64_T 0 +/* Define if you have the getopt_long function. */ +#undef HAVE_GETOPT_LONG + /* Define if you have the mkstemp function. */ #undef HAVE_MKSTEMP diff --git a/configure b/configure index a258ab34..d4149dfc 100755 --- a/configure +++ b/configure @@ -2740,7 +2740,7 @@ EOF -for ac_func in mmap strerror strtoul mkstemp +for ac_func in mmap strerror strtoul mkstemp getopt_long do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2747: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 2cd216ed..7c5536bc 100644 --- a/configure.in +++ b/configure.in @@ -91,7 +91,7 @@ AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0) AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0) dnl Checks for functions -AC_CHECK_FUNCS(mmap strerror strtoul mkstemp) +AC_CHECK_FUNCS(mmap strerror strtoul mkstemp getopt_long) dnl Checks for libraries AC_CHECK_LIB(z,gzopen) diff --git a/src/file.c b/src/file.c index 4779938c..39625f25 100644 --- a/src/file.c +++ b/src/file.c @@ -58,7 +58,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$Id: file.c,v 1.66 2002/07/03 19:00:41 christos Exp $") +FILE_RCSID("@(#)$Id: file.c,v 1.67 2002/07/09 14:12:40 christos Exp $") #endif /* lint */ @@ -105,7 +105,7 @@ int lineno; /* line number in the magic file */ static void unwrap(char *fn); static void usage(void); -#ifdef HAVE_GETOPT_H +#ifdef HAVE_GETOPT_LONG static void help(void); #endif #if 0 @@ -126,7 +126,7 @@ main(int argc, char **argv) char *mime, *home, *usermagic; struct stat sb; #define OPTSTRING "bcdf:ikm:nsvzCL" -#ifdef HAVE_GETOPT_H +#ifdef HAVE_GETOPT_LONG int longindex; static struct option long_options[] = { @@ -179,14 +179,14 @@ main(int argc, char **argv) } } -#ifndef HAVE_GETOPT_H +#ifndef HAVE_GETOPT_LONG while ((c = getopt(argc, argv, OPTSTRING)) != -1) #else while ((c = getopt_long(argc, argv, OPTSTRING, long_options, &longindex)) != -1) #endif switch (c) { -#ifdef HAVE_GETOPT_H +#ifdef HAVE_GETOPT_LONG case 0 : if (longindex == 1) help(); @@ -523,13 +523,13 @@ usage(void) { (void)fprintf(stderr, USAGE, progname); (void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname); -#ifdef HAVE_GETOPT_H +#ifdef HAVE_GETOPT_LONG (void)fputs("Try `file --help' for more information.\n", stderr); #endif exit(1); } -#ifdef HAVE_GETOPT_H +#ifdef HAVE_GETOPT_LONG static void help(void) { diff --git a/src/file.h b/src/file.h index 76bf8064..d31f6e21 100644 --- a/src/file.h +++ b/src/file.h @@ -1,6 +1,6 @@ /* * file.h - definitions for file(1) program - * @(#)$Id: file.h,v 1.43 2002/07/03 18:57:52 christos Exp $ + * @(#)$Id: file.h,v 1.44 2002/07/09 14:12:40 christos Exp $ * * Copyright (c) Ian F. Darwin, 1987. * Written by Ian F. Darwin. @@ -60,6 +60,10 @@ #define CHECK 1 #define COMPILE 2 +#ifndef __GNUC__ +#define __attribute__(a) +#endif + struct magic { uint16_t cont_level; /* level of ">" */ uint8_t nospflag; /* supress space character */ -- 2.40.0