From: Angus Leeming Date: Tue, 3 May 2005 20:32:55 +0000 (+0000) Subject: MSVC compiles out of the box. X-Git-Tag: 1.6.10~14328 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4db573abbed808469b56c9f521efd68f583b885e;p=features.git MSVC compiles out of the box. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9901 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 61a9c7eb14..3816fc8f63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-03 Angus Leeming + + * configure.ac: test for io.h and process.h. + Test the spelling of close(), getpid(), open(), pclose() and + popen(). Do they have a leading underscore or not? + 2005-05-02 Angus Leeming * configure.ac: test for utime.h and sys/utime.h diff --git a/configure.ac b/configure.ac index 7741e6d963..22f641f306 100644 --- a/configure.ac +++ b/configure.ac @@ -236,7 +236,7 @@ AC_LANG_POP(C) # some standard header files AC_HEADER_DIRENT AC_HEADER_MAJOR -AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h) +AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h) # some standard structures AC_HEADER_STAT @@ -282,7 +282,7 @@ dnl work correctly because of some conflict with stdlib.h with g++ 2.96 dnl We aim to remove this eventually, since we should test as much as dnl possible with the compiler which will use the functions (JMarc) AC_LANG_PUSH(C) -AC_CHECK_FUNCS(mkfifo mkstemp mktemp lstat readlink) +AC_CHECK_FUNCS(close _close getpid _getpid lstat mkfifo mkstemp mktemp open _open pclose _pclose popen _popen readlink) AC_LANG_POP(C) LYX_CHECK_SPELL_ENGINES diff --git a/development/Win32/config.h b/development/Win32/config.h index fc15d2afdd..f4cdb3d53a 100644 --- a/development/Win32/config.h +++ b/development/Win32/config.h @@ -96,6 +96,9 @@ /* Define to 1 if you have the `asprintf' function. */ /* #undef HAVE_ASPRINTF */ +/* Define to 1 if you have the `close' function. */ +/* #undef HAVE_CLOSE */ + /* Define if the GNU dcgettext() function is already present or preinstalled. */ /* #undef HAVE_DCGETTEXT */ @@ -160,6 +163,9 @@ /* Define to 1 if you have the `getpagesize' function. */ #define HAVE_GETPAGESIZE 1 +/* Define to 1 if you have the `getpid' function. */ +/* #undef HAVE_GETPID */ + /* Define if the GNU gettext() function is already present or preinstalled. */ /* #undef HAVE_GETTEXT */ @@ -182,6 +188,9 @@ /* Define to 1 if you have the header file. */ #define HAVE_IOS 1 +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_ISTREAM 1 @@ -237,7 +246,7 @@ /* #define HAVE_MKDIR */ /* Define to 1 if you have the `mkfifo' function. */ -/* #undef HAVE_MKFIFO 1 */ +/* #undef HAVE_MKFIFO */ /* Define to 1 if you have the `mkstemp' function. */ /* #undef HAVE_MKSTEMP */ @@ -257,12 +266,24 @@ /* Define to 1 if you have the header file. */ #define HAVE_NL_TYPES_H 1 +/* Define to 1 if you have the `open' function. */ +/* #undef HAVE_OPEN */ + /* Define to 1 if you have the header file. */ #define HAVE_OSTREAM 1 +/* Define to 1 if you have the `pclose' function. */ +/* #undef HAVE_PCLOSE */ + +/* Define to 1 if you have the `popen' function. */ +/* #undef HAVE_POPEN */ + /* Define if your printf() function supports format strings with positions. */ #define HAVE_POSIX_PRINTF 1 +/* Define to 1 if you have the header file. */ +#define HAVE_PROCESS_H 1 + /* Define to 1 if you have the header file. */ /* #undef HAVE_PSPELL_PSPELL_H */ @@ -381,9 +402,24 @@ /* Define to 1 if you have the header file. */ #define HAVE_ZLIB_H 1 +/* Define to 1 if you have the `_close' function. */ +#define HAVE__CLOSE 1 + +/* Define to 1 if you have the `_getpid' function. */ +#define HAVE__GETPID 1 + /* Define to 1 if you have the `_mkdir' function. */ #define HAVE__MKDIR 1 +/* Define to 1 if you have the `_open' function. */ +#define HAVE__OPEN 1 + +/* Define to 1 if you have the `_pclose' function. */ +#define HAVE__PCLOSE 1 + +/* Define to 1 if you have the `_popen' function. */ +#define HAVE__POPEN 1 + /* Define to 1 if you have the `__argz_count' function. */ /* #undef HAVE___ARGZ_COUNT */ diff --git a/development/Win32/readme.txt b/development/Win32/readme.txt index 1de92c00c3..0e8e3ae592 100644 --- a/development/Win32/readme.txt +++ b/development/Win32/readme.txt @@ -7,15 +7,9 @@ To compile using MicroSoft Visual Studio 2003.NET, do this: 2) Make sure QTDIR is set in your global environment, and QTDIR\bin is in your path. Control panel, system, advanced, environment - variables in your friend on Windows XP. + variables is your friend on Windows XP. -3) Apply the win32_kludge.diff using GNU patch. Download from - http://gnuwin32.sourceforge.net/packages/patch.htm - and type "patch -p0 < development\win32\win32_kludge.diff" - in cmd box with current working directory lyx-devel. - Make sure that patch is in your path. (c:\program files\gnuwin32\bin) - -4) Open the development\win32\lyx.sln file in Visual Studio, +3) Open the development\win32\lyx.sln file in Visual Studio, compile and run. You can probably also use the free version of Microsoft's compiler, but I haven't tried that. diff --git a/development/Win32/win32_kludge.diff b/development/Win32/win32_kludge.diff deleted file mode 100644 index e7fdb703d6..0000000000 --- a/development/Win32/win32_kludge.diff +++ /dev/null @@ -1,77 +0,0 @@ -Index: src/support/filetools.C -=================================================================== -RCS file: /cvs/lyx/lyx-devel/src/support/filetools.C,v -retrieving revision 1.209 -diff -u -r1.209 filetools.C ---- src/support/filetools.C 2005/04/21 14:03:30 1.209 -+++ src/support/filetools.C 2005/04/26 15:43:13 -@@ -1051,6 +1051,11 @@ - - cmd_ret const RunCommand(string const & cmd) - { -+#ifdef _WIN32 -+ // TODO: Implement this, or merge it into forkedcall. -+ // Used for lyx2lyx in buffer.C, echo in math_extern and kpse in this file -+ return make_pair(-1, string()); -+#else - // FIXME: replace all calls to RunCommand with ForkedCall - // (if the output is not needed) or the code in ispell.C - // (if the output is needed). -@@ -1080,6 +1085,7 @@ - perror("RunCommand:: could not terminate child process"); - - return make_pair(pret, ret); -+#endif - } - - -Index: src/support/tempname.C -=================================================================== -RCS file: /cvs/lyx/lyx-devel/src/support/tempname.C,v -retrieving revision 1.26 -diff -u -r1.26 tempname.C ---- src/support/tempname.C 2005/04/26 10:30:24 1.26 -+++ src/support/tempname.C 2005/04/26 15:51:22 -@@ -32,6 +32,10 @@ - # endif - #endif - -+#ifdef _WIN32 -+# include -+#endif -+ - using boost::scoped_array; - - using std::string; -@@ -44,6 +48,9 @@ - { - #if defined(HAVE_MKSTEMP) - return ::mkstemp(templ); -+#elif defined(_WIN32) -+ ::_mktemp(templ); -+ return (int) ::fopen(templ, "w"); - #elif defined(HAVE_MKTEMP) - // This probably just barely works... - ::mktemp(templ); -@@ -60,7 +67,9 @@ - { - string const tmpdir(dir.empty() ? package().temp_dir() : dir); - string tmpfl(AddName(tmpdir, mask)); -+#ifndef _WIN32 - tmpfl += convert(getpid()); -+#endif - tmpfl += "XXXXXX"; - - // The supposedly safe mkstemp version -@@ -71,7 +80,11 @@ - int const tmpf = make_tempfile(tmpl.get()); - if (tmpf != -1) { - string const t(tmpl.get()); -+#ifdef _WIN32 -+ ::fclose((FILE *) tmpf); -+#else - ::close(tmpf); -+#endif - lyxerr[Debug::FILES] << "Temporary file `" << t - << "' created." << endl; - return t; diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 6cc7349137..e12c034643 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,11 @@ +2005-05-03 Angus Leeming + + * filetools.C (RunCommand): protect calls to popen() and pclose() + with preprocessor guards. + + * tempname.C: protect calls to close(), getpid() and open() + with preprocessor guards. + 2005-05-02 Angus Leeming * socktools.C: make compilation dependent on HAVE_FCNTL rather diff --git a/src/support/filetools.C b/src/support/filetools.C index 6bdc9336ab..35609982ae 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -1061,7 +1061,13 @@ cmd_ret const RunCommand(string const & cmd) // pstream (process stream), with the // variants ipstream, opstream +#if defined (HAVE_POPEN) FILE * inf = ::popen(cmd.c_str(), os::popen_read_mode()); +#elif defined (HAVE__POPEN) + FILE * inf = ::_popen(cmd.c_str(), os::popen_read_mode()); +#else +#error No popen() function. +#endif // (Claus Hentschel) Check if popen was succesful ;-) if (!inf) { @@ -1075,7 +1081,15 @@ cmd_ret const RunCommand(string const & cmd) ret += static_cast(c); c = fgetc(inf); } + +#if defined (HAVE_PCLOSE) int const pret = pclose(inf); +#elif defined (HAVE__PCLOSE) + int const pret = _pclose(inf); +#else +#error No pclose() function. +#endif + if (pret == -1) perror("RunCommand:: could not terminate child process"); diff --git a/src/support/tempname.C b/src/support/tempname.C index 18699223a6..afad6dedcf 100644 --- a/src/support/tempname.C +++ b/src/support/tempname.C @@ -30,6 +30,12 @@ # ifdef HAVE_SYS_STAT_H # include # endif +# ifdef HAVE_IO_H +# include +# endif +# ifdef HAVE_PROCESS_H +# include +# endif #endif using boost::scoped_array; @@ -47,7 +53,15 @@ int make_tempfile(char * templ) #elif defined(HAVE_MKTEMP) // This probably just barely works... ::mktemp(templ); +# if defined (HAVE_OPEN) return ::open(templ, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); +# elif defined (HAVE__OPEN) + return ::_open(templ, + _O_RDWR | _O_CREAT | _O_EXCL, + _S_IREAD | _S_IWRITE); +# else +# error No open() function. +# endif #else #error FIX FIX FIX #endif @@ -60,7 +74,13 @@ string const lyx::support::tempName(string const & dir, string const & mask) { string const tmpdir(dir.empty() ? package().temp_dir() : dir); string tmpfl(AddName(tmpdir, mask)); +#if defined (HAVE_GETPID) tmpfl += convert(getpid()); +#elif defined (HAVE__GETPID) + tmpfl += convert(_getpid()); +#else +# error No getpid() function +#endif tmpfl += "XXXXXX"; // The supposedly safe mkstemp version @@ -71,7 +91,13 @@ string const lyx::support::tempName(string const & dir, string const & mask) int const tmpf = make_tempfile(tmpl.get()); if (tmpf != -1) { string const t(tmpl.get()); +#if defined (HAVE_CLOSE) ::close(tmpf); +#elif defined (HAVE__CLOSE) + ::_close(tmpf); +#else +# error No close() function. +#endif lyxerr[Debug::FILES] << "Temporary file `" << t << "' created." << endl; return t;