|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62472 - in trunk/tools/quickbook: detail doc
From: daniel_james_at_[hidden]
Date: 2010-06-06 03:24:12
Author: danieljames
Date: 2010-06-06 03:24:10 EDT (Sun, 06 Jun 2010)
New Revision: 62472
URL: http://svn.boost.org/trac/boost/changeset/62472
Log:
Use cygwin 1.7 path API.
Text files modified:
trunk/tools/quickbook/detail/input_path.cpp | 79 +++++++++++++++++++++++++++++++++++----
trunk/tools/quickbook/doc/quickbook.qbk | 1
2 files changed, 72 insertions(+), 8 deletions(-)
Modified: trunk/tools/quickbook/detail/input_path.cpp
==============================================================================
--- trunk/tools/quickbook/detail/input_path.cpp (original)
+++ trunk/tools/quickbook/detail/input_path.cpp 2010-06-06 03:24:10 EDT (Sun, 06 Jun 2010)
@@ -9,12 +9,30 @@
#include <boost/program_options.hpp>
#include "./input_path.hpp"
-#if defined(__cygwin__) || defined(__CYGWIN__)
+#if !(defined(__cygwin__) || defined(__CYGWIN__))
+
+// Everything but cygwin
+
+namespace quickbook { namespace detail
+{
+ void validate(boost::any& v,
+ const std::vector<std::string>& values,
+ input_path*, int)
+ {
+ std::string path
+ = boost::program_options::validators::get_single_string(values);
+
+ v = input_path(path);
+ }
+}}
+
+#elif defined(QUICKBOOK_CYGWIN_1_5)
+
+// Cygwin 1.5.x
+
#include <boost/filesystem/config.hpp>
#include <windows.h>
#include <sys/cygwin.h>
-#endif
-
namespace quickbook { namespace detail
{
@@ -25,18 +43,63 @@
std::string path
= boost::program_options::validators::get_single_string(values);
-#if !(defined(__cygwin__) || defined(__CYGWIN__))
- v = input_path(path);
-#elif defined(BOOST_WINDOWS_PATH)
char result[MAX_PATH + 1];
+
+#if defined(BOOST_WINDOWS_PATH)
cygwin_conv_to_win32_path(path.c_str(), result);
- v = input_path(result);
#elif defined(BOOST_POSIX_PATH)
- char result[MAX_PATH + 1];
cygwin_conv_to_posix_path(path.c_str(), result);
+#else
+# error "Bosot filesystem path type doesn't seem to be set."
+#endif
+
v = input_path(result);
+ }
+}}
+
+#else
+
+// Cygwin 1.7.x
+
+#include <boost/filesystem/config.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/program_options/errors.hpp>
+#include <windows.h>
+#include <sys/cygwin.h>
+
+namespace quickbook { namespace detail
+{
+ void validate(boost::any& v,
+ const std::vector<std::string>& values,
+ input_path*, int)
+ {
+ std::string path
+ = boost::program_options::validators::get_single_string(values);
+
+#if defined(BOOST_WINDOWS_PATH)
+ cygwin_conv_path_t flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
+#elif defined(BOOST_POSIX_PATH)
+ cygwin_conv_path_t flags = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
#else
# error "Bosot filesystem path type doesn't seem to be set."
#endif
+
+ ssize_t size = cygwin_conv_path(flags, path.c_str(), NULL, 0);
+
+ if (size < 0) {
+ throw boost::program_options::validation_error(
+ boost::program_options::validation_error::invalid_option_value);
+ }
+
+ boost::scoped_array<char> result(new char[size]);
+
+ if(cygwin_conv_path(flags, path.c_str(), result.get(), size)) {
+ throw boost::program_options::validation_error(
+ boost::program_options::validation_error::invalid_option_value);
+ }
+
+ v = input_path(result.get());
}
}}
+
+#endif
Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2010-06-06 03:24:10 EDT (Sun, 06 Jun 2010)
@@ -197,6 +197,7 @@
* Generate more valid boostbook (still invalid in a few places).
* Warn about invalid doc_info members.
* Support multiple categories in library doc_info.
+* Use the cygwin 1.7 API for better path handling.
[endsect]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk