-
-
Save Amar1729/36843d3bbca0ef16ab9dc5845d71be17 to your computer and use it in GitHub Desktop.
PATCH: libguestfs gnulib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure b/configure | |
index 65f1145..068f21f 100755 | |
--- a/configure | |
+++ b/configure | |
@@ -24432,9 +24432,9 @@ if ${gl_cv_func_getcwd_abort_bug+:} false; then : | |
$as_echo_n "(cached) " >&6 | |
else | |
# Remove any remnants of a previous test. | |
- rm -rf confdir-14B--- | |
+ # rm -rf confdir-14B--- | |
# Arrange for deletion of the temporary directory this test creates. | |
- ac_clean_files="$ac_clean_files confdir-14B---" | |
+ # ac_clean_files="$ac_clean_files confdir-14B---" | |
if test "$cross_compiling" = yes; then : | |
gl_cv_func_getcwd_abort_bug=yes | |
else | |
@@ -24516,7 +24516,7 @@ main () | |
if (1) | |
{ | |
- static char const dir_name[] = "confdir-14B---"; | |
+ /* static char const dir_name[] = "confdir-14B---"; */ | |
size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) | |
/ sizeof dir_name); | |
size_t d; | |
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am | |
index f5dbcf7..bd71549 100644 | |
--- a/gnulib/lib/Makefile.am | |
+++ b/gnulib/lib/Makefile.am | |
@@ -1415,6 +1415,8 @@ EXTRA_libgnu_la_SOURCES += open.c | |
## end gnulib module open | |
+libgnu_la_SOURCES += open_memstream.c | |
+ | |
## begin gnulib module openat | |
diff --git a/gnulib/lib/error.c b/gnulib/lib/error.c | |
index 0ac7695..176856d 100644 | |
--- a/gnulib/lib/error.c | |
+++ b/gnulib/lib/error.c | |
@@ -113,9 +113,13 @@ int strerror_r (); | |
# endif | |
# endif | |
+#if defined __APPLE__ && defined __MACH__ | |
+#define program_name (((char **)*_NSGetArgv())[0]) | |
+#else | |
/* The calling program should define program_name and set it to the | |
name of the executing program. */ | |
extern char *program_name; | |
+#endif | |
# if HAVE_STRERROR_R || defined strerror_r | |
# define __strerror_r strerror_r | |
diff --git a/gnulib/lib/open_memstream.c b/gnulib/lib/open_memstream.c | |
index e69de29..f1b4338 100644 | |
--- /dev/null | |
+++ b/gnulib/lib/open_memstream.c | |
@@ -0,0 +1,186 @@ | |
+/* Open a write stream around a malloc'd string. | |
+ Copyright (C) 2010 Free Software Foundation, Inc. | |
+ | |
+ This program is free software: you can redistribute it and/or modify | |
+ it under the terms of the GNU General Public License as published by | |
+ the Free Software Foundation; either version 3 of the License, or | |
+ (at your option) any later version. | |
+ | |
+ This program is distributed in the hope that it will be useful, | |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+ GNU General Public License for more details. | |
+ | |
+ You should have received a copy of the GNU General Public License | |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
+ | |
+/* Written by Eric Blake <address@hidden>, 2010. */ | |
+ | |
+#include <config.h> | |
+ | |
+/* Specification. */ | |
+#include <stdio.h> | |
+ | |
+#include <assert.h> | |
+#include <errno.h> | |
+#include <stdlib.h> | |
+#include <string.h> | |
+ | |
+#include "verify.h" | |
+ | |
+# define INITIAL_ALLOC 64 | |
+ | |
+struct data | |
+{ | |
+ char **buf; /* User's argument. */ | |
+ size_t *len; /* User's argument. Smaller of pos or eof. */ | |
+ size_t pos; /* Current position. */ | |
+ size_t eof; /* End-of-file position. */ | |
+ size_t allocated; /* Allocated size of *buf, always > eof. */ | |
+ char c; /* Temporary storage for byte overwritten by NUL, if pos < eof. */ | |
+}; | |
+typedef struct data data; | |
+ | |
+/* Stupid BSD interface uses int/int instead of ssize_t/size_t. */ | |
+verify (sizeof (int) <= sizeof (size_t)); | |
+verify (sizeof (int) <= sizeof (ssize_t)); | |
+ | |
+static int | |
+mem_write (void *c, const char *buf, int n) | |
+{ | |
+ data *cookie = c; | |
+ char *cbuf = *cookie->buf; | |
+ | |
+ /* Be sure we don't overflow. */ | |
+ if ((ssize_t) (cookie->pos + n) < 0) | |
+ { | |
+ errno = EFBIG; | |
+ return EOF; | |
+ } | |
+ /* Grow the buffer, if necessary. Use geometric growth to avoid | |
+ quadratic realloc behavior. Overallocate, to accomodate the | |
+ requirement to always place a trailing NUL not counted by length. | |
+ Thus, we want max(prev_size*1.5, cookie->pos+n+1). */ | |
+ if (cookie->allocated <= cookie->pos + n) | |
+ { | |
+ size_t newsize = cookie->allocated * 3 / 2; | |
+ if (newsize < cookie->pos + n + 1) | |
+ newsize = cookie->pos + n + 1; | |
+ cbuf = realloc (cbuf, newsize); | |
+ if (!cbuf) | |
+ return EOF; | |
+ *cookie->buf = cbuf; | |
+ cookie->allocated = newsize; | |
+ } | |
+ /* If we have previously done a seek beyond eof, ensure all | |
+ intermediate bytges are NUL. */ | |
+ if (cookie->eof < cookie->pos) | |
+ memset (cbuf + cookie->eof, '\0', cookie->pos - cookie->eof); | |
+ memcpy (cbuf + cookie->pos, buf, n); | |
+ cookie->pos += n; | |
+ /* If the user has previously written beyond the current position, | |
+ remember what the trailing NUL is overwriting. Otherwise, | |
+ extend the stream. */ | |
+ if (cookie->eof < cookie->pos) | |
+ cookie->eof = cookie->pos; | |
+ else | |
+ cookie->c = cbuf[cookie->pos]; | |
+ cbuf[cookie->pos] = '\0'; | |
+ *cookie->len = cookie->pos; | |
+ return n; | |
+} | |
+ | |
+static fpos_t | |
+mem_seek (void *c, fpos_t pos, int whence) | |
+{ | |
+ data *cookie = c; | |
+ off_t offset = pos; | |
+ | |
+ if (whence == SEEK_CUR) | |
+ offset += cookie->pos; | |
+ else if (whence == SEEK_END) | |
+ offset += cookie->eof; | |
+ if (offset < 0) | |
+ { | |
+ errno = EINVAL; | |
+ offset = -1; | |
+ } | |
+ else if ((size_t) offset != offset) | |
+ { | |
+ errno = ENOSPC; | |
+ offset = -1; | |
+ } | |
+ else | |
+ { | |
+ if (cookie->pos < cookie->eof) | |
+ { | |
+ (*cookie->buf)[cookie->pos] = cookie->c; | |
+ cookie->c = '\0'; | |
+ } | |
+ cookie->pos = offset; | |
+ if (cookie->pos < cookie->eof) | |
+ { | |
+ cookie->c = (*cookie->buf)[cookie->pos]; | |
+ (*cookie->buf)[cookie->pos] = '\0'; | |
+ *cookie->len = cookie->pos; | |
+ } | |
+ else | |
+ *cookie->len = cookie->eof; | |
+ } | |
+ return offset; | |
+} | |
+ | |
+static int | |
+mem_close (void *c) | |
+{ | |
+ data *cookie = c; | |
+ char *buf; | |
+ | |
+ /* Be nice and try to reduce excess memory. */ | |
+ buf = realloc (*cookie->buf, *cookie->len + 1); | |
+ if (buf) | |
+ *cookie->buf = buf; | |
+ free (cookie); | |
+ return 0; | |
+} | |
+ | |
+FILE * | |
+open_memstream (char **buf, size_t *len) | |
+{ | |
+ FILE *f; | |
+ data *cookie; | |
+ | |
+ if (!buf || !len) | |
+ { | |
+ errno = EINVAL; | |
+ return NULL; | |
+ } | |
+ if (!(cookie = malloc (sizeof *cookie))) | |
+ return NULL; | |
+ if (!(*buf = malloc (INITIAL_ALLOC))) | |
+ { | |
+ free (cookie); | |
+ errno = ENOMEM; | |
+ return NULL; | |
+ } | |
+ **buf = '\0'; | |
+ *len = 0; | |
+ | |
+ f = funopen (cookie, NULL, mem_write, mem_seek, mem_close); | |
+ if (!f) | |
+ { | |
+ int saved_errno = errno; | |
+ free (cookie); | |
+ errno = saved_errno; | |
+ } | |
+ else | |
+ { | |
+ cookie->buf = buf; | |
+ cookie->len = len; | |
+ cookie->pos = 0; | |
+ cookie->eof = 0; | |
+ cookie->c = '\0'; | |
+ cookie->allocated = INITIAL_ALLOC; | |
+ } | |
+ return f; | |
+} | |
diff --git a/gnulib/lib/stdio.in.h b/gnulib/lib/stdio.in.h | |
index ec43874..32e779d 100644 | |
--- a/gnulib/lib/stdio.in.h | |
+++ b/gnulib/lib/stdio.in.h | |
@@ -778,6 +778,8 @@ _GL_CXXALIAS_SYS (obstack_vprintf, int, | |
_GL_CXXALIASWARN (obstack_vprintf); | |
#endif | |
+_GL_FUNCDECL_SYS (open_memstream, FILE *, (char **, size_t *)); | |
+ | |
#if @GNULIB_PCLOSE@ | |
# if !@HAVE_PCLOSE@ | |
_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | |
diff --git a/gnulib/tests/test-getcwd.c b/gnulib/tests/test-getcwd.c | |
index 756f932..47f9843 100644 | |
--- a/gnulib/tests/test-getcwd.c | |
+++ b/gnulib/tests/test-getcwd.c | |
@@ -71,7 +71,7 @@ test_abort_bug (void) | |
if (HAVE_OPENAT_SUPPORT) | |
{ | |
- static char const dir_name[] = "confdir-14B---"; | |
+ /* static char const dir_name[] = "confdir-14B---"; */ | |
size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) | |
/ sizeof dir_name); | |
size_t d; | |
diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4 | |
index 1a023cc..c02d0f3 100644 | |
--- a/m4/getcwd-abort-bug.m4 | |
+++ b/m4/getcwd-abort-bug.m4 | |
@@ -20,9 +20,9 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], | |
AC_CACHE_CHECK([whether getcwd aborts when 4k < cwd_length < 16k], | |
gl_cv_func_getcwd_abort_bug, | |
[# Remove any remnants of a previous test. | |
- rm -rf confdir-14B--- | |
+ # rm -rf confdir-14B--- | |
# Arrange for deletion of the temporary directory this test creates. | |
- ac_clean_files="$ac_clean_files confdir-14B---" | |
+ # ac_clean_files="$ac_clean_files confdir-14B---" | |
dnl Please keep this in sync with tests/test-getcwd.c. | |
AC_RUN_IFELSE( | |
[AC_LANG_SOURCE( | |
@@ -82,7 +82,7 @@ main () | |
if (1) | |
{ | |
- static char const dir_name[] = "confdir-14B---"; | |
+ /* static char const dir_name[] = "confdir-14B---"; */ | |
size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) | |
/ sizeof dir_name); | |
size_t d; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fix GOROOT to GOPATH | |
diff --git a/configure b/configure | |
index 068f21f..ce9176a 100755 | |
--- a/configure | |
+++ b/configure | |
@@ -689,7 +689,7 @@ HAVE_TOOLS_FALSE | |
HAVE_TOOLS_TRUE | |
HAVE_GOLANG_FALSE | |
HAVE_GOLANG_TRUE | |
-GOROOT | |
+GOPATH | |
GOARCH | |
GOOS | |
GOLANG | |
@@ -64195,7 +64195,7 @@ $as_echo "yes" >&6; } | |
# Substitute some golang environment. | |
GOOS=`$GOLANG env GOOS` | |
GOARCH=`$GOLANG env GOARCH` | |
- GOROOT=`$GOLANG env GOROOT` | |
+ GOPATH=`$GOLANG env GOPATH` | |
diff --git a/golang/Makefile.am b/golang/Makefile.am | |
index 58cafc6..4075bb0 100644 | |
--- a/golang/Makefile.am | |
+++ b/golang/Makefile.am | |
@@ -42,8 +42,8 @@ if ENABLE_APPLIANCE | |
GOFLAGS += -tags appliance | |
endif | |
-golangpkgdir = $(GOROOT)/pkg/$(GOOS)_$(GOARCH)/$(pkg) | |
-golangsrcdir = $(GOROOT)/src/pkg/$(pkg) | |
+golangpkgdir = $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(pkg) | |
+golangsrcdir = $(GOPATH)/src/$(pkg) | |
golangpkg_DATA = \ | |
pkg/$(GOOS)_$(GOARCH)/$(pkg).a | |
diff --git a/golang/Makefile.in b/golang/Makefile.in | |
index a336c02..6a426a8 100644 | |
--- a/golang/Makefile.in | |
+++ b/golang/Makefile.in | |
@@ -736,7 +736,7 @@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ | |
GOBJECT_LIBS = @GOBJECT_LIBS@ | |
GOLANG = @GOLANG@ | |
GOOS = @GOOS@ | |
-GOROOT = @GOROOT@ | |
+GOPATH = @GOPATH@ | |
GPERF = @GPERF@ | |
GREP = @GREP@ | |
GTK2_CFLAGS = @GTK2_CFLAGS@ | |
@@ -1496,8 +1496,8 @@ EXTRA_DIST = \ | |
run-tests | |
@HAVE_GOLANG_TRUE@GOFLAGS = $(am__append_1) | |
-@HAVE_GOLANG_TRUE@golangpkgdir = $(GOROOT)/pkg/$(GOOS)_$(GOARCH)/$(pkg) | |
-@HAVE_GOLANG_TRUE@golangsrcdir = $(GOROOT)/src/pkg/$(pkg) | |
+@HAVE_GOLANG_TRUE@golangpkgdir = $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(pkg) | |
+@HAVE_GOLANG_TRUE@golangsrcdir = $(GOPATH)/src/$(pkg) | |
@HAVE_GOLANG_TRUE@golangpkg_DATA = \ | |
@HAVE_GOLANG_TRUE@ pkg/$(GOOS)_$(GOARCH)/$(pkg).a | |
diff --git a/golang/examples/Makefile.in b/golang/examples/Makefile.in | |
index 2fa748b..afb9062 100644 | |
--- a/golang/examples/Makefile.in | |
+++ b/golang/examples/Makefile.in | |
@@ -715,7 +715,7 @@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ | |
GOBJECT_LIBS = @GOBJECT_LIBS@ | |
GOLANG = @GOLANG@ | |
GOOS = @GOOS@ | |
-GOROOT = @GOROOT@ | |
+GOPATH = @GOPATH@ | |
GPERF = @GPERF@ | |
GREP = @GREP@ | |
GTK2_CFLAGS = @GTK2_CFLAGS@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gnulib/lib/msvc-nothrow.c b/gnulib/lib/msvc-nothrow.c | |
index 90cf801..05fd688 100644 | |
--- a/gnulib/lib/msvc-nothrow.c | |
+++ b/gnulib/lib/msvc-nothrow.c | |
@@ -21,6 +21,8 @@ | |
#include "msvc-nothrow.h" | |
/* Get declarations of the native Windows API functions. */ | |
+#if defined __APPLE__ && defined __MACH__ | |
+#else | |
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
@@ -47,3 +49,4 @@ _gl_nothrow_get_osfhandle (int fd) | |
return result; | |
} | |
#endif | |
+#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment