OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src Date: 23-May-2008 13:40:29
Branch: HEAD Handle: 2008052312402800
Modified files:
openpkg-src/file file.patch file.spec
Log:
fix portability issues related to getopt, SIZE_MAX and [v]asprintf
Summary:
Revision Changes Path
1.11 +203 -16 openpkg-src/file/file.patch
1.79 +1 -1 openpkg-src/file/file.spec
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/file/file.patch
============================================================================
$ cvs diff -u -r1.10 -r1.11 file.patch
--- openpkg-src/file/file.patch 31 Mar 2008 18:52:52 -0000 1.10
+++ openpkg-src/file/file.patch 23 May 2008 11:40:28 -0000 1.11
@@ -1,7 +1,7 @@
Index: src/apprentice.c
---- src/apprentice.c.orig 2007-12-27 21:52:36 +0100
-+++ src/apprentice.c 2008-03-31 20:50:08 +0200
-@@ -549,6 +549,7 @@
+--- src/apprentice.c.orig 2008-03-28 19:19:30 +0100
++++ src/apprentice.c 2008-05-23 13:35:47 +0200
+@@ -633,6 +633,7 @@
file_oomem(ms, maxmagic * sizeof(*marray));
return -1;
}
@@ -10,8 +10,8 @@
/* print silly verbose header for USG compat. */
Index: src/compress.c
---- src/compress.c.orig 2007-12-02 18:32:23 +0100
-+++ src/compress.c 2008-03-31 20:50:08 +0200
+--- src/compress.c.orig 2008-02-07 01:58:52 +0100
++++ src/compress.c 2008-05-23 13:35:47 +0200
@@ -167,7 +167,7 @@
* `safe' read for sockets and pipes.
*/
@@ -30,7 +30,7 @@
if (swrite(tfd, buf, (size_t)r) != r)
break;
}
-@@ -462,7 +462,7 @@
+@@ -463,7 +463,7 @@
n = 0;
goto err;
}
@@ -39,22 +39,209 @@
#ifdef DEBUG
(void)fprintf(stderr, "Read failed (%s)\n",
strerror(errno));
+Index: src/file.c
+--- src/file.c.orig 2008-02-07 01:58:52 +0100
++++ src/file.c 2008-05-23 13:36:38 +0200
+@@ -60,9 +60,20 @@
+ #include <wchar.h>
+ #endif
+
+-#include <getopt.h>
+ #ifndef HAVE_GETOPT_LONG
++struct option {
++ const char *name;
++ int has_arg;
++ int *flag;
++ int val;
++};
++#define no_argument 0
++#define required_argument 1
++#define optional_argument 2
+ int getopt_long(int argc, char * const *argv, const char *optstring, const
struct option *longopts, int *longindex);
++#include "src/getopt_long.c"
++#else
++#include <getopt.h>
+ #endif
+
+ #include <netinet/in.h> /* for byte swapping */
Index: src/file.h
---- src/file.h.orig 2007-11-08 01:31:37 +0100
-+++ src/file.h 2008-03-31 20:50:08 +0200
-@@ -333,7 +333,7 @@
+--- src/file.h.orig 2008-03-07 16:00:07 +0100
++++ src/file.h 2008-05-23 13:35:47 +0200
+@@ -346,7 +346,7 @@
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
-protected ssize_t sread(int, void *, size_t, int);
+protected ssize_t file_sread(int, void *, size_t, int);
protected int file_check_mem(struct magic_set *, unsigned int);
+ protected int file_looks_utf8(const unsigned char *, size_t, unichar *,
size_t *);
+
+@@ -367,9 +367,11 @@
+ #endif
+
+ #ifndef HAVE_VASPRINTF
++#define vasprintf file_vasprintf
+ int vasprintf(char **ptr, const char *format_string, va_list vargs);
+ #endif
+ #ifndef HAVE_ASPRINTF
++#define asprintf file_asprintf
+ int asprintf(char **ptr, const char *format_string, ...);
+ #endif
+
+Index: src/funcs.c
+--- src/funcs.c.orig 2008-03-07 16:00:07 +0100
++++ src/funcs.c 2008-05-23 13:35:47 +0200
+@@ -29,6 +29,7 @@
+ #include <stdarg.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <limits.h>
+ #include <ctype.h>
+ #if defined(HAVE_WCHAR_H)
+ #include <wchar.h>
+@@ -329,3 +330,108 @@
+ #endif /* ENABLE_CONDITIONALS */
+ return 0;
+ }
++
++/*
++ * From bsd-asprintf.c in OpenSSH:
++ * Copyright (c) 2004 Darren Tucker.
++ *
++ * Based originally on asprintf.c from OpenBSD:
++ * Copyright (c) 1997 Todd C. Miller <[EMAIL PROTECTED]>
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#ifndef HAVE_ASPRINTF
++int asprintf(char **str, const char *fmt, ...)
++{
++ va_list ap;
++ int ret;
++
++ *str = NULL;
++ va_start(ap, fmt);
++ ret = vasprintf(str, fmt, ap);
++ va_end(ap);
++
++ return ret;
++}
++#endif
++
++#ifndef HAVE_VASPRINTF
++
++#ifdef HAVE_LIMITS_H
++#include <limits.h>
++#endif
++
++#include <errno.h>
++#include <stdarg.h>
++#include <stdlib.h>
++
++#ifndef VA_COPY
++# ifdef HAVE_VA_COPY
++# define VA_COPY(dest, src) va_copy(dest, src)
++# else
++# ifdef HAVE___VA_COPY
++# define VA_COPY(dest, src) __va_copy(dest, src)
++# else
++# define VA_COPY(dest, src) (dest) = (src)
++# endif
++# endif
++#endif
++
++#define INIT_SZ 128
++
++int vasprintf(char **str, const char *fmt, va_list ap)
++{
++ int ret = -1;
++ va_list ap2;
++ char *string, *newstr;
++ size_t len;
++
++ VA_COPY(ap2, ap);
++ if ((string = malloc(INIT_SZ)) == NULL)
++ goto fail;
++
++ ret = vsnprintf(string, INIT_SZ, fmt, ap2);
++ if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */
++ *str = string;
++ } else if (ret == INT_MAX || ret < 0) { /* Bad length */
++ free(string);
++ goto fail;
++ } else { /* bigger than initial, realloc allowing for nul */
++ len = (size_t)ret + 1;
++ if ((newstr = realloc(string, len)) == NULL) {
++ free(string);
++ goto fail;
++ } else {
++ va_end(ap2);
++ VA_COPY(ap2, ap);
++ ret = vsnprintf(newstr, len, fmt, ap2);
++ if (ret >= 0 && (size_t)ret < len) {
++ *str = newstr;
++ } else { /* failed with realloc'ed string, give up */
++ free(newstr);
++ goto fail;
++ }
++ }
++ }
++ va_end(ap2);
++ return (ret);
++
++fail:
++ *str = NULL;
++ errno = ENOMEM;
++ va_end(ap2);
++ return (-1);
++}
++#endif
++
+Index: src/getopt_long.c
+--- src/getopt_long.c.orig 2008-02-07 01:50:10 +0100
++++ src/getopt_long.c 2008-05-23 13:35:47 +0200
+@@ -30,9 +30,7 @@
+ */
+
+ #include <assert.h>
+-#include <err.h>
+ #include <errno.h>
+-#include <getopt.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+@@ -73,6 +71,16 @@
+
+ #define EMSG ""
- #ifndef COMPILE_ONLY
++#define __P(x) x
++#define warnx file_warnx
++void warnx(const char *fmt, ...)
++{
++ va_list ap;
++ va_start(ap, fmt);
++ vfprintf(stderr, "WARNING: %s\n", ap);
++ va_end(ap);
++}
++
+ static int getopt_internal __P((int, char **, const char *));
+ static int gcd __P((int, int));
+ static void permute_args __P((int, int, int, char **));
Index: src/magic.c
---- src/magic.c.orig 2007-12-27 17:35:59 +0100
-+++ src/magic.c 2008-03-31 20:50:08 +0200
-@@ -322,7 +322,7 @@
+--- src/magic.c.orig 2008-02-19 16:16:38 +0100
++++ src/magic.c 2008-05-23 13:35:47 +0200
+@@ -325,7 +325,7 @@
if (ispipe) {
ssize_t r = 0;
@@ -64,9 +251,9 @@
nbytes += r;
if (r < PIPE_BUF) break;
Index: src/softmagic.c
---- src/softmagic.c.orig 2007-12-27 17:35:59 +0100
-+++ src/softmagic.c 2008-03-31 20:50:08 +0200
-@@ -288,10 +288,9 @@
+--- src/softmagic.c.orig 2008-03-07 16:00:07 +0100
++++ src/softmagic.c 2008-05-23 13:35:47 +0200
+@@ -302,10 +302,9 @@
}
#ifndef HAVE_STRNDUP
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/file/file.spec
============================================================================
$ cvs diff -u -r1.78 -r1.79 file.spec
--- openpkg-src/file/file.spec 19 May 2008 05:27:24 -0000 1.78
+++ openpkg-src/file/file.spec 23 May 2008 11:40:28 -0000 1.79
@@ -36,7 +36,7 @@
Group: Filesystem
License: BSD
Version: %{V_api_c}
-Release: 20080519
+Release: 20080523
# package options
%option with_perl no
@@ .
______________________________________________________________________
OpenPKG http://openpkg.org
CVS Repository Commit List [email protected]