From 72956b1c3b6da705161f1becea18af09d8d2815e Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 23 Sep 2002 16:03:11 +0000 Subject: [PATCH] cygwin/popen fix from kayvan git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5331 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/ChangeLog | 10 ++++++++++ src/support/filetools.C | 2 +- src/support/os.h | 4 +++- src/support/os_os2.C | 9 ++++++++- src/support/os_unix.C | 9 ++++++++- src/support/os_win32.C | 9 ++++++++- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/support/ChangeLog b/src/support/ChangeLog index cb07e736b0..d8437f17b8 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,13 @@ +2002-09-16 Kayvan A. Sylvan + + * os.h, os_os2.C, os_win32.C, os_unix.C: Added popen_read_mode(), + since at least for Cygwin, the "rb" read_mode acceptable for + fopen() is illegal for popen(), whose mode argument *must* be "r" + or "w". + + * filetools.C (RunCommand): Uses os::popen_read_mode() instead + of os::read_mode() + 2002-08-20 Lars Gullik Bjønnes * Makefile.am (libsupport_la_SOURCES): delete smart_ptr.h and diff --git a/src/support/filetools.C b/src/support/filetools.C index 82e9ce635c..fd938e7c8a 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -1294,7 +1294,7 @@ cmd_ret const RunCommand(string const & cmd) // pstream (process stream), with the // variants ipstream, opstream - FILE * inf = ::popen(cmd.c_str(), os::read_mode()); + FILE * inf = ::popen(cmd.c_str(), os::popen_read_mode()); // (Claus Hentschel) Check if popen was succesful ;-) if (!inf) diff --git a/src/support/os.h b/src/support/os.h index 9a7e48be7b..fef5345e06 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -52,9 +52,11 @@ public: static string internal_path(string const &p); // is path absolute? static bool is_absolute_path(string const & p); - // returns a string suitable to be passed to fopen/popen when + // returns a string suitable to be passed to fopen when // reading a file static char const * read_mode(); + // same for popen(). + static char const * popen_read_mode(); // static void warn(string mesg); private: diff --git a/src/support/os_os2.C b/src/support/os_os2.C index a16620dff8..bc05f319c2 100644 --- a/src/support/os_os2.C +++ b/src/support/os_os2.C @@ -174,9 +174,16 @@ bool os::is_absolute_path(string const & p) } -// returns a string suitable to be passed to fopen/popen when +// returns a string suitable to be passed to fopen when // reading a file char const * os::read_mode() { return "r"; } + +// returns a string suitable to be passed to popen when +// reading a pipe +char const * os::popen_read_mode() +{ + return "r"; +} diff --git a/src/support/os_unix.C b/src/support/os_unix.C index e5ccd430d9..26778e85df 100644 --- a/src/support/os_unix.C +++ b/src/support/os_unix.C @@ -77,9 +77,16 @@ bool os::is_absolute_path(string const & p) return (!p.empty() && p[0] == '/'); } -// returns a string suitable to be passed to fopen/popen when +// returns a string suitable to be passed to fopen when // reading a file char const * os::read_mode() { return "r"; } + +// returns a string suitable to be passed to popen when +// reading a pipe +char const * os::popen_read_mode() +{ + return "r"; +} diff --git a/src/support/os_win32.C b/src/support/os_win32.C index 8d2b848732..f3f8026c2b 100644 --- a/src/support/os_win32.C +++ b/src/support/os_win32.C @@ -119,9 +119,16 @@ bool os::is_absolute_path(string const & p) return isDosPath | isUnixPath; } -// returns a string suitable to be passed to fopen/popen when +// returns a string suitable to be passed to fopen when // reading a file char const * os::read_mode() { return "rb"; } + +// returns a string suitable to be passed to popen when +// reading a pipe +char const * os::popen_read_mode() +{ + return "r"; +} -- 2.39.5