]> granicus.if.org Git - file/commitdiff
more fixes for ancient systems
authorChristos Zoulas <christos@zoulas.com>
Thu, 3 Jul 2008 15:48:18 +0000 (15:48 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 3 Jul 2008 15:48:18 +0000 (15:48 +0000)
configure.ac
src/file.c
src/funcs.c
src/getopt_long.c
src/mygetopt.h [new file with mode: 0644]

index d79cad48aae283405b5fea6de5223aefb147a916..9fd15bdefcabadacddf8ef8cb3eebef005ad06df 100644 (file)
@@ -62,6 +62,7 @@ AC_HEADER_MAJOR
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
 AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
+AC_CHECK_HEADERS(getopt.h err.h)
 AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
 AC_CHECK_HEADERS(zlib.h)
 
index 5496a64d4a6ff3850cc8fb2b9d6fb6cbd1a31420..7dcc7447f7f5dae3776b43e5d81dd98f4e813d1d 100644 (file)
 #include <wchar.h>
 #endif
 
+#ifdef HAVE_GETOPT_H
 #include <getopt.h>
+#else
+#include "mygetopt.h"
+#endif
 #ifndef HAVE_GETOPT_LONG
 int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex);
 #endif
@@ -70,7 +74,7 @@ int getopt_long(int argc, char * const *argv, const char *optstring, const struc
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: file.c,v 1.119 2008/02/07 00:58:52 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.120 2008/05/18 23:21:17 christos Exp $")
 #endif /* lint */
 
 
index 600c9b117f2ce9c6d4a57987e041ad1e320cc37f..c32b7825afabec243933366abf18b78956ec874c 100644 (file)
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.40 2008/05/09 14:20:28 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.41 2008/05/16 14:25:01 christos Exp $")
 #endif /* lint */
 
+#ifndef SIZE_MAX
+#define SIZE_MAX       ((size_t)~0)
+#endif
+
 /*
  * Like printf, only we append to a buffer.
  */
index e6efd0f58462bed2cfcb47a322c0aee13f35e0c7..4d9c8788c2bb5ce4963122405b058bd9b735780b 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <assert.h>
+#ifdef HAVE_ERR_H
 #include <err.h>
+#else
+#include <stdio.h>
+#define warnx printf
+#endif
 #include <errno.h>
+#ifdef HAVE_GETOPT_H
 #include <getopt.h>
+#else
+#include "mygetopt.h"
+#endif
 #include <stdlib.h>
 #include <string.h>
 
 #define REPLACE_GETOPT
 
+#ifndef _DIAGASSERT
 #define _DIAGASSERT assert
+#endif
 
 #ifdef REPLACE_GETOPT
 #ifdef __weak_alias
diff --git a/src/mygetopt.h b/src/mygetopt.h
new file mode 100644 (file)
index 0000000..63bb69b
--- /dev/null
@@ -0,0 +1,71 @@
+/*     $NetBSD: getopt.h,v 1.8 2007/11/06 19:21:18 christos Exp $      */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GETOPT_H_
+#define _GETOPT_H_
+
+#include <sys/cdefs.h>
+#include <unistd.h>
+
+/*
+ * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
+ */
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+struct option {
+       /* name of long option */
+       const char *name;
+       /*
+        * one of no_argument, required_argument, and optional_argument:
+        * whether option takes an argument
+        */
+       int has_arg;
+       /* if not NULL, set *flag to val when option found */
+       int *flag;
+       /* if flag not NULL, value to set *flag to; else return value */
+       int val;
+};
+
+__BEGIN_DECLS
+int getopt_long(int, char * const *, const char *,
+    const struct option *, int *);
+__END_DECLS
+#endif /* !_GETOPT_H_ */