From ec81194f386f35b0d914e0fc5c727cd217c62c91 Mon Sep 17 00:00:00 2001 From: AIDA Shinra Date: Mon, 14 Oct 2013 22:31:01 +0900 Subject: Workaround of GC crash on Cygwin64 Patch from , [w3m-dev:04469] on 2013-10-14. --- main.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index b421943..af6048e 100644 --- a/main.c +++ b/main.c @@ -11,6 +11,9 @@ #include #endif #include +#if defined(__CYGWIN__) && defined(USE_BINMODE_STREAM) +#include +#endif #include "terms.h" #include "myctype.h" #include "regex.h" @@ -397,6 +400,10 @@ main(int argc, char **argv, char **envp) wc_ces CodePage; #endif #endif +#if defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) + char **getimage_args = NULL; +#endif /* defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) */ + GC_INIT(); #if defined(ENABLE_NLS) || (defined(USE_M17N) && defined(HAVE_LANGINFO_CODESET)) setlocale(LC_ALL, ""); @@ -418,6 +425,10 @@ main(int argc, char **argv, char **envp) CurrentDir = currentdir(); CurrentPid = (int)getpid(); +#if defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) + if (argv[0] && *argv[0]) + MyProgramName = argv[0]; +#endif /* defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) */ BookmarkFile = NULL; config_file = NULL; @@ -735,6 +746,15 @@ main(int argc, char **argv, char **envp) else if (!strcmp("-reqlog",argv[i])) { w3m_reqlog=rcFile("request.log"); } +#if defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) + else if (!strcmp("-$$getimage", argv[i])) { + ++i; + getimage_args = argv + i; + i += 4; + if (i > argc) + usage(); + } +#endif /* defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) */ else { usage(); } @@ -823,6 +843,30 @@ main(int argc, char **argv, char **envp) if (w3m_backend) backend(); +#if defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) + if (getimage_args) { + char *image_url = conv_from_system(getimage_args[0]); + char *base_url = conv_from_system(getimage_args[1]); + ParsedURL base_pu; + + parseURL2(base_url, &base_pu, NULL); + image_source = getimage_args[2]; + newbuf = loadGeneralFile(image_url, &base_pu, NULL, 0, NULL); + if (!newbuf || !newbuf->real_type || + strncasecmp(newbuf->real_type, "image/", 6)) + unlink(getimage_args[2]); +#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) + symlink(getimage_args[2], getimage_args[3]); +#else + { + FILE *f = fopen(getimage_args[3], "w"); + if (f) + fclose(f); + } +#endif + w3m_exit(0); + } +#endif /* defined(DONT_CALL_GC_AFTER_FORK) && defined(USE_IMAGE) */ if (w3m_dump) mySignal(SIGINT, SIG_IGN); @@ -833,7 +877,13 @@ main(int argc, char **argv, char **envp) mySignal(SIGPIPE, SigPipe); #endif +#define HAVE_GC_GET_WARN_PROC +#ifdef HAVE_GC_GET_WARN_PROC + orig_GC_warn_proc = GC_get_warn_proc(); + GC_set_warn_proc(wrap_GC_warn_proc); +#else orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc); +#endif err_msg = Strnew(); if (load_argc == 0) { /* no URL specified */ -- cgit v1.2.3