1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-03 08:30:09 +00:00

Code cleanup for cygw32

This commit is contained in:
Daniel Colascione 2012-10-08 04:53:18 -08:00
parent c54ebba4e0
commit 501199a3db
18 changed files with 139 additions and 67 deletions

View File

@ -9,6 +9,59 @@
'const char *'.
(x_to_w32_color): Don't modify the argument, modify a copy instead.
2012-10-08 Daniel Colascione <dancol@dancol.org>
* w32term.h (WM_EMACS_BRINGTOTOP, WM_EMACS_INPUT_READY)
(WM_EMACS_END): Change WM_EMACS_BRINGTOTOP from 22 to 21 to close
accidental message numbering hole. Change other messages to
match.
* w32select.h (HAVE_W32SELECT): Remove.
* w32select.c, w32proc.c, w32menu.c, w32console.c, w32.c: Include
w32common.h instead of w32heap.h
* w32heap.h (ROUND_UP, ROUND_DOWN, get_page_size)
(get_allocation_unit, get_processor_type, get_w32_major_version)
(get_w32_minor_version, sysinfo_cache, osinfo_cache)
(w32_major_version, w32_minor_version, w32_build_number, OS_9X)
(OS_NT, os_subtype, cache_system_info): Move declarations to
w32common.
* w32heap.c: Include w32common.h.
(sysinfo_cache, syspage_mask, osinfo_cache, w32_major_version)
(w32_minor_version, w32_build_number, w32_subtype): Remove
duplicate definitions.
* w32fns.c: Include w32common.h; include w32heap.h only in
WINDOWSNT.
(Fx_file_dialog): Clarify comment on GetOpenFileName structure.
Use `report_file_error' instead of `error' in order to better
inform users of what went wrong. Increase NTGUI_UNICODE file
dialog box file name length to 32k, the maximum allowed by the NT
kernel.
* w32common.h: New file.
(ROUND_UP, ROUND_DOWN, get_page_size)
(get_allocation_unit, get_processor_type, get_w32_major_version)
(get_w32_minor_version, sysinfo_cache, osinfo_cache)
(w32_major_version, w32_minor_version, w32_build_number, OS_9X)
(OS_NT, os_subtype, cache_system_info): Move here.
* unexw32.c, unexcw.c: Include w32common.h.
* emacs.c (main): Use (defined (WINDOWSNT) || defined
HAVE_NTGUI) instead of removed HAVE_W32SELECT to decide whether
to call syms_of_w32select.
* cygw32.h: Remove obsolete EXFUN declarations.
* cygw32.c (Qutf_16_le): Rename to Qutf_16le.
* Makefile.in (SOME_MACHINE_OBJECTS): Reverse accidental removal
of w32inevt.o from SOME_MACHINE_OBJECTS.
2012-10-08 Daniel Colascione <dancol@dancol.org>
* image.c: Permanent fix for JPEG compilation issue --- limit

View File

@ -357,7 +357,7 @@ SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
fontset.o dbusbind.o cygw32.o \
nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
w32.o w32console.o w32fns.o w32heap.o \
w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
xsettings.o xgselect.o termcap.o

View File

@ -22,7 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "buffer.h"
#include <unistd.h>
#include <fcntl.h>
static Lisp_Object Qutf_16_le;
static Lisp_Object Qutf_16le;
static Lisp_Object
fchdir_unwind (Lisp_Object dir_fd)
@ -117,13 +117,13 @@ from_unicode (Lisp_Object str)
str = Fsubstring (str, make_number (0), make_number (-1));
}
return code_convert_string_norecord (str, Qutf_16_le, 0);
return code_convert_string_norecord (str, Qutf_16le, 0);
}
wchar_t *
to_unicode (Lisp_Object str, Lisp_Object *buf)
{
*buf = code_convert_string_norecord (str, Qutf_16_le, 1);
*buf = code_convert_string_norecord (str, Qutf_16le, 1);
/* We need to make a another copy (in addition to the one made by
code_convert_string_norecord) to ensure that the final string is
_doubly_ zero terminated --- that is, that the string is
@ -163,7 +163,7 @@ void
syms_of_cygw32 (void)
{
/* No, not utf-16-le: that one has a BOM. */
DEFSYM (Qutf_16_le, "utf-16le");
DEFSYM (Qutf_16le, "utf-16le");
defsubr (&Scygwin_convert_path_from_windows);
defsubr (&Scygwin_convert_path_to_windows);
}

View File

@ -46,11 +46,6 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
object, to a multi-byte Emacs string, and return it. */
extern Lisp_Object from_unicode (Lisp_Object str);
/* *** Path conversion. *** */
EXFUN (Fcygwin_convert_path_to_windows, 2);
EXFUN (Fcygwin_convert_path_from_windows, 2);
/* *** Misc *** */
extern void syms_of_cygw32 (void);
extern char * w32_strerror (int error_no);

View File

@ -1415,9 +1415,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_fontset ();
#endif /* HAVE_NTGUI */
#ifdef HAVE_W32SELECT
#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
syms_of_w32select ();
#endif /* HAVE_W32SELECT */
#endif /* WINDOWSNT || HAVE_NTGUI */
#ifdef MSDOS
syms_of_xmenu ();
@ -1465,9 +1465,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
globals_of_w32menu ();
#endif /* HAVE_NTGUI */
#ifdef HAVE_W32SELECT
#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
globals_of_w32select ();
#endif /* HAVE_W32SELECT */
#endif /* WINDOWSNT || HAVE_NTGUI */
}
init_charset ();

View File

@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "unexec.h"
#include "w32common.h"
#include <lisp.h>
#include <stdio.h>

View File

@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "unexec.h"
#include "w32common.h"
#include <stdio.h>
#include <fcntl.h>

View File

@ -173,6 +173,7 @@ typedef struct _REPARSE_DATA_BUFFER {
#include "w32.h"
#include "ndir.h"
#include "w32common.h"
#include "w32heap.h"
#include "systime.h"
#include "dispextern.h" /* for xstrcasecmp */

53
src/w32common.h Normal file
View File

@ -0,0 +1,53 @@
/* Common functions for Microsoft Windows builds of Emacs
Copyright (C) 2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs 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.
GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef W32COMMON_H
#define W32COMMON_H
#include <windows.h>
#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
#define get_page_size() sysinfo_cache.dwPageSize
#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
#define get_processor_type() sysinfo_cache.dwProcessorType
#define get_w32_major_version() w32_major_version
#define get_w32_minor_version() w32_minor_version
extern SYSTEM_INFO sysinfo_cache;
extern OSVERSIONINFO osinfo_cache;
extern unsigned long syspage_mask;
extern int w32_major_version;
extern int w32_minor_version;
extern int w32_build_number;
enum {
OS_9X = 1,
OS_NT
};
extern int os_subtype;
/* Cache system info, e.g., the NT page size. */
extern void cache_system_info (void);
#endif /* W32COMMON_H */

View File

@ -37,7 +37,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "termchar.h"
#include "dispextern.h"
#include "w32term.h"
#include "w32heap.h" /* for os_subtype */
#include "w32common.h" /* for os_subtype */
#include "w32inevt.h"
/* from window.c */

View File

@ -45,7 +45,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "systime.h"
#include "termhooks.h"
#include "w32common.h"
#ifdef WINDOWSNT
#include "w32heap.h"
#endif /* WINDOWSNT */
#if CYGWIN
#include "cygw32.h"
@ -6111,7 +6115,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
} new_file_details;
#ifdef NTGUI_UNICODE
wchar_t filename_buf[MAX_PATH + 1];
wchar_t filename_buf[32*1024 + 1]; // NT kernel maximum
OPENFILENAMEW * file_details = &new_file_details.details;
#else /* not NTGUI_UNICODE */
char filename_buf[MAX_PATH + 1];
@ -6173,11 +6177,12 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
unixtodos_filename (SDATA (filename));
#endif /* NTGUI_UNICODE */
/* Fill in the structure for the call to GetOpenFileName below. For
NTGUI_UNICODE builds (which run only on NT), we just use the
actual size of the structure. For non-NTGUI_UNICODE builds, we
tell the OS we're using an old version of the structure if it's not
new enough to support the newer version. */
/* Fill in the structure for the call to GetOpenFileName below.
For NTGUI_UNICODE builds (which run only on NT), we just use
the actual size of the structure. For non-NTGUI_UNICODE
builds, we tell the OS we're using an old version of the
structure if the OS isn't new enough to support the newer
version. */
memset (&new_file_details, 0, sizeof (new_file_details));
if (w32_major_version > 4 && w32_major_version < 95)
@ -6187,7 +6192,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
/* Set up the inout parameter for the selected file name. */
if (SBYTES (filename) + 1 > sizeof (filename_buf))
error ("filename too long");
report_file_error ("filename too long", default_filename);
memcpy (filename_buf, SDATA (filename), SBYTES (filename) + 1);
file_details->lpstrFile = filename_buf;

View File

@ -23,26 +23,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
#include "w32common.h"
#include "w32heap.h"
#include "lisp.h" /* for VALMASK */
#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
/* This gives us the page size and the size of the allocation unit on NT. */
SYSTEM_INFO sysinfo_cache;
/* This gives us version, build, and platform identification. */
extern unsigned long syspage_mask;
OSVERSIONINFO osinfo_cache;
/* The major and minor versions of NT. */
int w32_major_version;
int w32_minor_version;
int w32_build_number;
/* Distinguish between Windows NT and Windows 95. */
int os_subtype;
/* Emulate getpagesize. */
int
getpagesize (void)

View File

@ -24,9 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
#include <windows.h>
#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
/*
* Heap related stuff.
*/
@ -34,28 +31,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
#define get_committed_heap_size() (get_data_end () - get_data_start ())
#define get_heap_start() get_data_start ()
#define get_heap_end() get_data_end ()
#define get_page_size() sysinfo_cache.dwPageSize
#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
#define get_processor_type() sysinfo_cache.dwProcessorType
#define get_w32_major_version() w32_major_version
#define get_w32_minor_version() w32_minor_version
extern unsigned char *get_data_start (void);
extern unsigned char *get_data_end (void);
extern size_t reserved_heap_size;
extern SYSTEM_INFO sysinfo_cache;
extern OSVERSIONINFO osinfo_cache;
extern BOOL using_dynamic_heap;
extern int w32_major_version;
extern int w32_minor_version;
extern int w32_build_number;
enum {
OS_9X = 1,
OS_NT
};
extern int os_subtype;
/* Emulation of Unix sbrk(). */
extern void *sbrk (ptrdiff_t size);
@ -66,9 +46,6 @@ extern void init_heap (void);
/* Round the heap to this size. */
extern void round_heap (size_t size);
/* Cache system info, e.g., the NT page size. */
extern void cache_system_info (void);
/* ----------------------------------------------------------------- */
/* Useful routines for manipulating memory-mapped files. */

View File

@ -56,7 +56,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "dispextern.h"
#include "w32heap.h" /* for osinfo_cache */
#include "w32common.h" /* for osinfo_cache */
#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */

View File

@ -51,6 +51,7 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
#include "lisp.h"
#include "w32.h"
#include "w32common.h"
#include "w32heap.h"
#include "systime.h"
#include "syswait.h"

View File

@ -75,7 +75,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "lisp.h"
#include "w32term.h" /* for all of the w32 includes */
#include "w32heap.h" /* os_subtype */
#include "w32common.h" /* os_subtype */
#include "blockinput.h"
#include "charset.h"
#include "coding.h"

View File

@ -21,8 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define W32SELECT_H
#include <windows.h>
#define HAVE_W32SELECT 1
extern void syms_of_w32select (void);
extern void globals_of_w32select (void);
extern void term_w32select (void);

View File

@ -619,9 +619,9 @@ do { \
#define WM_EMACS_HIDE_CARET (WM_EMACS_START + 18)
#define WM_EMACS_SETCURSOR (WM_EMACS_START + 19)
#define WM_EMACS_PAINT (WM_EMACS_START + 20)
#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 22)
#define WM_EMACS_INPUT_READY (WM_EMACS_START + 23)
#define WM_EMACS_END (WM_EMACS_START + 24)
#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 21)
#define WM_EMACS_INPUT_READY (WM_EMACS_START + 22)
#define WM_EMACS_END (WM_EMACS_START + 23)
#define WND_FONTWIDTH_INDEX (0)
#define WND_LINEHEIGHT_INDEX (4)