diff -uraN emacs-24.3.orig/lisp/international/w32-ime.elc emacs-24.3.new//lisp/international/w32-ime.elc
--- emacs-24.3.orig/lisp/international/w32-ime.elc	1970-01-01 09:00:00 +0900
+++ emacs-24.3.new//lisp/international/w32-ime.elc	2014-06-28 01:46:59 +0900
@@ -0,0 +1,54 @@
+;ELC
+;;; Compiled by kkatsuhisa@ADA on Fri Jun 27 14:27:31 2014
+;;; from file c:/MinGW/msys/1.0/home/kkatsuhisa/emacs-work/emacs-24.3/lisp/international/w32-ime.el
+;;; in Emacs version 22.3.1
+;;; with all optimizations.
+
+;;; This file uses dynamic docstrings, first added in Emacs 19.29.
+(if (and (boundp 'emacs-version)
+	 (< (aref emacs-version (1- (length emacs-version))) ?A)
+	 (or (and (boundp 'epoch::version) epoch::version)
+	     (string-lessp emacs-version "19.29")))
+    (error "`w32-ime.el' was compiled for Emacs 19.29 or later"))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(custom-declare-group 'W32-IME nil "w32-ime" :group 'emacs)
+#@40 It is stored the last data from Emacs.
+(defvar w32-last-selection nil (#$ . 675))
+#@119 Functions to eval when IME is turned on at least.
+Even if IME state is not changed, these functiona are maybe called.
+(defvar w32-ime-on-hook nil (#$ . 764))
+#@120 Functions to eval when IME is turned off at least.
+Even if IME state is not changed, these functiona are maybe called.
+(defvar w32-ime-off-hook nil (#$ . 929))
+#@75 If this variable is nil, IME control when buffer is switched is disabled.
+(defvar w32-ime-buffer-switch-p t (#$ . 1095))
+#@40 When t, mode line indicates IME state.
+(defvar w32-ime-show-mode-line t (#$ . 1222))
+#@65 This is shown at the mode line. It is regarded as state of ime.
+(defvar w32-ime-mode-line-state-indicator "[O]" (#$ . 1313))
+(byte-code "\300\301!\210\302\301\303\304#\207" [make-variable-buffer-local w32-ime-mode-line-state-indicator put permanent-local t] 4)
+#@37 List of IME state indicator string.
+(defvar w32-ime-mode-line-state-indicator-list '("-" "[|]" "[O]") (#$ . 1580))
+#@28 Original mode line format.
+(defvar w32-ime-mode-line-format-original nil (#$ . 1701))
+(byte-code "\300\301\302\"\210\300\303\302\"\207" [global-set-key [kanji] ignore [compend]] 3)
+#@181 Wrap FUNCTION, and IME control is enabled when FUNCTION is called.
+An original function is saved to FUNCTION-SUFFIX when suffix is string.
+If SUFFIX is nil, "-original" is added. 
+(defalias 'wrap-function-to-control-ime #[(function interactive-p interactive-arg &optional suffix) "\305\306!	\203\f	\202
\307P!\310\n!?\205A\nKM\210\311\312\205&\313\fD\314\315\316\317\320\321\nD\322BB\323BBE\324\320\321\nD\325BBDEFM)\207" [function suffix original-function interactive-p interactive-arg intern symbol-name "-original" fboundp lambda (&rest arguments) interactive cond (and (ime-get-mode) (equal current-input-method "W32-IME")) (ime-force-off) unwind-protect apply quote (arguments) ((when (and (not (ime-get-mode)) (equal current-input-method "W32-IME")) (ime-force-on))) t (arguments)] 11 (#$ . 1889)])
+#@76 * if this variable is string, toroku-region regard this value as yomigana.
+(defvar w32-ime-toroku-region-yomigana nil (#$ . -2709))
+(defalias 'w32-ime-toroku-region #[(begin end) "	{\306\n;\204\307\310!\210\311\312\313
\"\306\314#\315
\"+\207" [begin end w32-ime-toroku-region-yomigana reading w32-ime-buffer-switch-p string nil w32-set-ime-mode hiragana read-multilingual-string format "Input reading of \"%s\": " "W32-IME" w32-ime-register-word-dialog] 4 nil "r"])
+(defalias 'w32-ime-sync-state #[(window) "\2058r\305	!q\210\306	!\307 \211\204%\f\310\232\203%\311\312!\210\313\314!\2027\2057\f\310\232?\2057\315\312!\210\313\316!+\207" [w32-ime-buffer-switch-p window frame ime-state current-input-method window-buffer window-frame ime-get-mode "W32-IME" ime-force-on nil run-hooks w32-ime-on-hook ime-force-off w32-ime-off-hook] 3])
+(defalias 'w32-ime-set-selected-window-buffer-hook #[(oldbuf newwin newbuf) "\301!\207" [newwin w32-ime-sync-state] 2])
+(defalias 'w32-ime-select-window-hook #[(old new) "\301!\207" [new w32-ime-sync-state] 2])
+(defalias 'w32-ime-mode-line-update #[nil "\203\303\304 !\204\305 \203\306\202\307	8\202	@\310 \207" [w32-ime-show-mode-line w32-ime-mode-line-state-indicator-list w32-ime-mode-line-state-indicator window-minibuffer-p selected-window ime-get-mode 1 2 force-mode-line-update] 2])
+(defalias 'w32-ime-init-mode-line-display #[nil "\302\235?\2051\303\300!@;\203%@\304\230\203%\305\300\306\302ABB\"\210\202.\305\300\306\302BB\"\210\307\310!\207" [mode-line-format w32-ime-mode-line-format-original w32-ime-mode-line-state-indicator default-value "-" set-default "" force-mode-line-update t] 5])
+(defalias 'w32-ime-initialize #[nil "\303=\205'	\304=\205'\305\306!\205'\307 \210\310 \210\311\312\313\"\210\311\314\315\"\210\316\n\317\320#\207" [system-type window-system global-map windows-nt w32 featurep w32-ime w32-ime-init-mode-line-display w32-ime-mode-line-update add-hook select-window-functions w32-ime-select-window-hook set-selected-window-buffer-functions w32-ime-set-selected-window-buffer-hook define-key [kanji] toggle-input-method] 4])
+(defalias 'w32-ime-uninitialize #[nil "\304=\205*	\305=\205*\306\307!\205*\310\311\n\"\210\312\313!\210\314\315\316\"\210\314\317\320\"\210\321\322\323#\207" [system-type window-system w32-ime-mode-line-format-original global-map windows-nt w32 featurep w32-ime set-default mode-line-format force-mode-line-update t remove-hook select-window-functions w32-ime-select-window-hook set-selected-window-buffer-functions w32-ime-set-selected-window-buffer-hook define-key [kanji] ignore] 4])
+(defalias 'w32-ime-exit-from-minibuffer #[nil "\300 \210\301 \302X\205\303\304\305\"\207" [deactivate-input-method minibuffer-depth 1 remove-hook minibuffer-exit-hook w32-ime-exit-from-minibuffer] 3])
+(defalias 'w32-ime-state-switch #[(&optional arg) "\203#\304\305\306!\210\305\307!\210\310\311 \312 =\203\313\314\315\"\210\316 \210\2022\310\305\317!\210\305\320!\210\310\321 \210\322 \207" [arg deactivate-current-input-method-function describe-current-input-method-function current-input-method w32-ime-state-switch run-hooks input-method-activate-hook w32-ime-on-hook nil selected-window minibuffer-window add-hook minibuffer-exit-hook w32-ime-exit-from-minibuffer ime-force-on input-method-inactivate-hook w32-ime-off-hook ime-force-off w32-ime-mode-line-update] 3])
+(byte-code "\300\301\302\303\304\305%\210\306\307!\207" [register-input-method "W32-IME" "Japanese" w32-ime-state-switch "" "W32 System IME" provide w32-ime] 6)
diff -uraN emacs-24.3.orig/lisp/term/w32-win.el emacs-24.3.new//lisp/term/w32-win.el
--- emacs-24.3.orig/lisp/term/w32-win.el	2013-01-02 05:37:17 +0900
+++ emacs-24.3.new//lisp/term/w32-win.el	2014-06-29 00:24:17 +0900
@@ -211,15 +211,17 @@
        ;; earlier versions.  Set up the list of libraries according to
        ;; the version we were compiled against.  (If we were compiled
        ;; without PNG support, libpng-version's value is -1.)
-       (if (>= libpng-version 10400)
+       (if (>= libpng-version 10612)
+	     '(png "libpng16-16.dll")
+	 (if (>= libpng-version 10400)
 	   ;; libpng14-14.dll is libpng 1.4.3 from GTK+
 	   '(png "libpng14-14.dll" "libpng14.dll")
 	 '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
 	       ;; these are libpng 1.2.8 from GTK+
-	       "libpng13d.dll" "libpng13.dll"))
-       '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
-       '(tiff "libtiff3.dll" "libtiff.dll")
-       '(gif "giflib4.dll" "libungif4.dll" "libungif.dll")
+	       "libpng13d.dll" "libpng13.dll")))
+       '(jpeg "libjpeg-9.dll" "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
+       '(tiff "libtiff-5.dll" "libtiff3.dll" "libtiff.dll")
+       '(gif "libgif-7.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")
diff -uraN emacs-24.3.orig/lisp/term/w32-win.elc emacs-24.3.new//lisp/term/w32-win.elc
--- emacs-24.3.orig/lisp/term/w32-win.elc	2013-03-08 17:15:56 +0900
+++ emacs-24.3.new//lisp/term/w32-win.elc	2014-06-29 00:24:53 +0900
@@ -1,7 +1,7 @@
 ;ELC
-;;; Compiled by gm@skiddaw on Fri Mar  8 00:15:56 2013
-;;; from file /misc/emacs/bzr/emacs24-merge/lisp/term/w32-win.el
-;;; in Emacs version 24.3
+;;; Compiled by kkatsuhisa@WIRBELWIND on Sun Jun 29 00:24:53 2014
+;;; from file c:/MinGW/msys/1.0/home/kkatsuhisa/emacs-work/emacs-24.3.new/lisp/term/w32-win.el
+;;; in Emacs version 24.3.1
 ;;; with all optimizations.
 
 ;;; This file uses dynamic docstrings, first added in Emacs 19.29.
@@ -19,13 +19,13 @@
 Switch to a buffer editing the last file dropped.
 
 (fn EVENT &optional NEW-FRAME)
-(defalias 'w32-drag-n-drop #[513 "\212\301!\211@)\301!\3028)\211@A\303V\203%\211\303V\203%\304\305\"\210\203.\306\307 !\210\310 \210\311 \262\312\313\314\"AA@\"\266\204)\207" [position event-start 2 0 set-frame-selected-window nil select-frame make-frame raise-frame selected-window mapc apply-partially w32-handle-dropped-file] 11 (#$ . 1430) "e"])
+(defalias 'w32-drag-n-drop #[513 "\212\301!\211@)\301!\3028)\211@A\303V\203%\211\303V\203%\304\305\"\210\203.\306\307 !\210\310 \210\311 \262\312\313\314\"AA@\"\266\204)\207" [position event-start 2 0 set-frame-selected-window nil select-frame make-frame raise-frame selected-window mapc apply-partially w32-handle-dropped-file] 11 (#$ . 1473) "e"])
 #@179 Edit the files listed in the drag-n-drop EVENT, in other frames.
 May create new frames, or reuse existing ones.  The frame editing
 the last file dropped is selected.
 
 (fn EVENT)
-(defalias 'w32-drag-n-drop-other-frame #[257 "\300\301\"\207" [w32-drag-n-drop t] 4 (#$ . 1934) "e"])
+(defalias 'w32-drag-n-drop-other-frame #[257 "\300\301\"\207" [w32-drag-n-drop t] 4 (#$ . 1977) "e"])
 (byte-code "\300\301\302\"\210\300\303\304\"\210\300\305\306\"\207" [global-set-key [drag-n-drop] w32-drag-n-drop [C-drag-n-drop] w32-drag-n-drop-other-frame [language-change] ignore] 3)
 #@435 Start key navigation of the menu bar in FRAME.
 
@@ -38,23 +38,23 @@
 `tmm-menubar'.
 
 (fn &optional FRAME)
-(defalias 'w32-menu-bar-open #[256 "\203	\301\302\"\207\303 p\304\305\306\307\310\311\"\312\"\313\314%DC\216\315\206&\303 \316\"\210\317 )\207" [menu-bar-mode w32-send-sys-command 61696 selected-frame funcall make-byte-code 0 "\302\300!\203\303\300\304\"\210\305\301!\205\301q\207" vconcat vector [frame-live-p select-frame norecord buffer-live-p] 3 "\n\n(fn)" select-frame norecord tmm-menubar] 11 (#$ . 2409) "i"])
+(defalias 'w32-menu-bar-open #[256 "\203	\301\302\"\207\303 p\304\305\306\307\310\311\"\312\"\313\314%DC\216\315\206&\303 \316\"\210\317 )\207" [menu-bar-mode w32-send-sys-command 61696 selected-frame funcall make-byte-code 0 "\302\300!\203\303\300\304\"\210\305\301!\205\301q\207" vconcat vector [frame-live-p select-frame norecord buffer-live-p] 3 "\n\n(fn)" select-frame norecord tmm-menubar] 11 (#$ . 2452) "i"])
 #@276 String of fontset spec of the standard fontset.
 This defines a fontset consisting of the Courier New variations for
 European languages which are distributed with Windows as
 "Multilanguage Support".
 
 See the documentation of `create-fontset-from-fontset-spec' for the format.
-(defvar w32-standard-fontset-spec "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard" (#$ . 3280))
+(defvar w32-standard-fontset-spec "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard" (#$ . 3323))
 #@52 Report an error when a suspend is attempted.
 
 (fn)
-(defalias 'x-win-suspend-error #[0 "\300\301!\207" [error "Suspending an Emacs running under W32 makes no sense"] 2 (#$ . 3668)])
-(byte-code "\302\303Y\203\304\202\f\305\306\307\310\311\312\313\314\315\316\257\303\207" [libpng-version dynamic-library-alist (xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") 10400 (png "libpng14-14.dll" "libpng14.dll") (png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll" "libpng13d.dll" "libpng13.dll") (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") (tiff "libtiff3.dll" "libtiff.dll") (gif "giflib4.dll" "libungif4.dll" "libungif.dll") (svg "librsvg-2-2.dll") (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") (glib "libglib-2.0-0.dll") (gobject "libgobject-2.0-0.dll") (gnutls "libgnutls-28.dll" "libgnutls-26.dll") (libxml2 "libxml2-2.dll" "libxml2.dll")] 11)
+(defalias 'x-win-suspend-error #[0 "\300\301!\207" [error "Suspending an Emacs running under W32 makes no sense"] 2 (#$ . 3711)])
+(byte-code "\302\303Y\203\304\202\305Y\203\306\202\307\310\311\312\313\314\315\316\317\320\257\303\207" [libpng-version dynamic-library-alist (xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") 10612 (png "libpng16-16.dll") 10400 (png "libpng14-14.dll" "libpng14.dll") (png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll" "libpng13d.dll" "libpng13.dll") (jpeg "libjpeg-9.dll" "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") (tiff "libtiff-5.dll" "libtiff3.dll" "libtiff.dll") (gif "libgif-7.dll" "giflib4.dll" "libungif4.dll" "libungif.dll") (svg "librsvg-2-2.dll") (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") (glib "libglib-2.0-0.dll") (gobject "libgobject-2.0-0.dll") (gnutls "libgnutls-28.dll" "libgnutls-26.dll") (libxml2 "libxml2-2.dll" "libxml2.dll")] 11)
 #@56 Non-nil if the w32 window system has been initialized.
-(defvar w32-initialized nil (#$ . 4537))
+(defvar w32-initialized nil (#$ . 4678))
 #@44 Initialize Emacs for W32 GUI frames.
 
 (fn)
-(defalias 'w32-initialize-window-system #[0 "\203\n\306\307\310C\"\210\311	!\n;\204\312\313\314\315 #\316\317\f\320=#\210\321 \210\322\323\324D\325\323\326\322EDC\217\210\327 \210\330\331\332\"\333\203\216\334!\262\335\236\204O\336\236\203V\337\340BB\262\341
\"\342\236\203v\3424\236\204v\342\211\236AB4B4\202\216\343\236\203\216\3434\236\204\216\343\211\236AB4B4\266\3445\330\345\346\"\211\203\250\347\350\"\203\250\3514B4\210)\352\353\354\"\210\3446\355 \210\356\357\360\"\210\361\362!\210\363 \210\344\211\207" [w32-initialized command-line-args x-resource-name x-command-line-resources initial-window-system initial-frame-alist signal cl-assertion-failed (not w32-initialized) x-handle-args replace-regexp-in-string "[.*]" "-" invocation-name x-open-connection "w32" w32 create-default-fontset #1=#:err funcall #[0 "\301\302\"\207" [w32-standard-fontset-spec create-fontset-from-fontset-spec t] 3 "\n\n(fn)"] error #[257 "\300\301\302\303\"\304#\207" [display-warning initialization format "Creation of the standard fontset failed: %s" :error] 6 "\n\n(fn ERR)"] create-fontset-from-x-resource x-get-resource "geometry" "Geometry" nil x-parse-geometry top left (user-position . t) (user-size . t) append height width t "reverseVideo" "ReverseVideo" string-match "^\\(true\\|yes\\|on\\)$" (reverse . t) add-hook suspend-hook x-win-suspend-error menu-bar-enable-clipboard set-default mode-line-frame-identification "  " set-message-beep ok x-apply-session-resources default-frame-alist case-fold-search split-window-keep-point] 6 (#$ . 4639)])
+(defalias 'w32-initialize-window-system #[0 "\203\n\306\307\310C\"\210\311	!\n;\204\312\313\314\315 #\316\317\f\320=#\210\321 \210\322\323\324D\325\323\326\322EDC\217\210\327 \210\330\331\332\"\333\203\216\334!\262\335\236\204O\336\236\203V\337\340BB\262\341
\"\342\236\203v\3424\236\204v\342\211\236AB4B4\202\216\343\236\203\216\3434\236\204\216\343\211\236AB4B4\266\3445\330\345\346\"\211\203\250\347\350\"\203\250\3514B4\210)\352\353\354\"\210\3446\355 \210\356\357\360\"\210\361\362!\210\363 \210\344\211\207" [w32-initialized command-line-args x-resource-name x-command-line-resources initial-window-system initial-frame-alist signal cl-assertion-failed (not w32-initialized) x-handle-args replace-regexp-in-string "[.*]" "-" invocation-name x-open-connection "w32" w32 create-default-fontset #1=#:err funcall #[0 "\301\302\"\207" [w32-standard-fontset-spec create-fontset-from-fontset-spec t] 3 "\n\n(fn)"] error #[257 "\300\301\302\303\"\304#\207" [display-warning initialization format "Creation of the standard fontset failed: %s" :error] 6 "\n\n(fn ERR)"] create-fontset-from-x-resource x-get-resource "geometry" "Geometry" nil x-parse-geometry top left (user-position . t) (user-size . t) append height width t "reverseVideo" "ReverseVideo" string-match "^\\(true\\|yes\\|on\\)$" (reverse . t) add-hook suspend-hook x-win-suspend-error menu-bar-enable-clipboard set-default mode-line-frame-identification "  " set-message-beep ok x-apply-session-resources default-frame-alist case-fold-search split-window-keep-point] 6 (#$ . 4780)])
 (byte-code "\300\301\302\"\210\300\303\304\"\210\300\305\306\"\210\300\307\310\"\210\311\312!\207" [add-to-list display-format-alist ("\\`w32\\'" . w32) handle-args-function-alist (w32 . x-handle-args) frame-creation-function-alist (w32 . x-create-frame-with-faces) window-system-initialization-alist (w32 . w32-initialize-window-system) provide w32-win] 3)
diff -uraN emacs-24.3.orig/src/image.c emacs-24.3.new//src/image.c
--- emacs-24.3.orig/src/image.c	2014-08-17 21:45:23 +0900
+++ emacs-24.3.new//src/image.c	2014-08-17 21:42:48 +0900
@@ -5489,6 +5489,9 @@
 DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t));
 #endif /* libpng version >= 1.5 */
 
+HMODULE libpng_handle = NULL;
+extern void unload_libpng();
+
 static bool
 init_png_functions (void)
 {
@@ -5496,6 +5499,9 @@
 
   if (!(library = w32_delayed_load (Qpng)))
     return 0;
+  
+  libpng_handle = library;
+  atexit(unload_libpng);
 
   LOAD_IMGLIB_FN (library, png_get_io_ptr);
   LOAD_IMGLIB_FN (library, png_sig_cmp);
@@ -6778,6 +6784,9 @@
 DEF_IMGLIB_FN (void, TIFFClose, (TIFF *));
 DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t));
 
+HANDLE libtiff_handle = NULL;
+extern void unload_libtiff();
+
 static bool
 init_tiff_functions (void)
 {
@@ -6786,6 +6795,9 @@
   if (!(library = w32_delayed_load (Qtiff)))
     return 0;
 
+  libtiff_handle = library;
+  atexit(unload_libtiff);
+
   LOAD_IMGLIB_FN (library, TIFFSetErrorHandler);
   LOAD_IMGLIB_FN (library, TIFFSetWarningHandler);
   LOAD_IMGLIB_FN (library, TIFFOpen);
diff -uraN emacs-24.3.orig/src/w32.c emacs-24.3.new//src/w32.c
--- emacs-24.3.orig/src/w32.c	2014-08-17 21:45:23 +0900
+++ emacs-24.3.new//src/w32.c	2014-06-29 00:39:56 +0900
@@ -7332,4 +7332,22 @@
 }
 #endif /* HAVE_GNUTLS */
 
+extern HMODULE libpng_handle;
+void unload_libpng()
+{
+  if(libpng_handle != NULL)
+    {
+      FreeLibrary(libpng_handle);
+    }
+}
+
+extern HMODULE libtiff_handle;
+void unload_libtiff()
+{
+  if(libtiff_handle != NULL)
+    {
+      FreeLibrary(libtiff_handle);
+    }
+}
+
 /* end of w32.c */
diff -uraN emacs-24.3.orig/src/w32fns.c emacs-24.3.new//src/w32fns.c
--- emacs-24.3.orig/src/w32fns.c	2014-08-17 21:45:23 +0900
+++ emacs-24.3.new//src/w32fns.c	2014-06-28 01:47:00 +0900
@@ -21,6 +21,13 @@
 
 #include <config.h>
 
+#define WM_IME_REQUEST 0x0288
+#define IMR_DOCUMENTFEED 0x0007
+#define IME_PROP_COMPLETE_ON_UNSELECT   0x00100000
+#define SCS_CAP_SETRECONVERTSTRING      0x00000004
+#define RECONVERSION 1
+#define DOCUMENTFEED 1
+
 #include <signal.h>
 #include <stdio.h>
 #include <stddef.h>
