finalize VC++ port

This commit is contained in:
David Rose 2002-05-23 22:32:37 +00:00
parent 916bf7d0e5
commit 2ed8641380
7 changed files with 33 additions and 87 deletions

View File

@ -20,8 +20,8 @@
/* Define if the C++ iostream library supports ios::binary. */
#undef HAVE_IOS_BINARY
/* Define if we're compiling for Cygwin. */
#undef PLATFORM_CYGWIN
/* Define if we're compiling with Cygwin. */
#undef HAVE_CYGWIN
/* Define if we're compiling using Windows Microsoft Visual C++. */
#undef WIN32_VC

View File

@ -12,8 +12,8 @@
/* Define if the C++ iostream library supports ios::binary. */
/* #undef HAVE_IOS_BINARY */
/* Define if we're compiling for Cygwin. */
/* #undef PLATFORM_CYGWIN */
/* Define if we're compiling with Cygwin. */
/* #undef HAVE_CYGWIN */
/* Define if we're compiling using Windows Microsoft Visual C++. */
#define WIN32_VC 1

View File

@ -74,7 +74,7 @@ else
fi
if test "$PLATFORM" = "Cygwin"; then
AC_DEFINE(PLATFORM_CYGWIN)
AC_DEFINE(HAVE_CYGWIN)
fi
AC_DEFINE_UNQUOTED(PLATFORM, "$PLATFORM")

View File

@ -52,6 +52,16 @@
#include <windows.h>
#endif
// We might have been linked with the Cygwin dll. This is ideal if it
// is available, because it allows Panda to access all the Cygwin
// mount definitions if they are in use. If the Cygwin dll is not
// available, we fall back to our own convention for converting
// pathnames.
#ifdef HAVE_CYGWIN
extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32);
//extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix);
#endif
static string
front_to_back_slash(const string &str) {
string result = str;
@ -85,10 +95,6 @@ get_panda_root() {
if (!got_panda_root) {
const char *envvar = getenv("PANDA_ROOT");
if (envvar == (const char *)NULL) {
envvar = getenv("CYGWIN_ROOT");
}
if (envvar != (const char *)NULL) {
panda_root = front_to_back_slash(envvar);
}
@ -145,10 +151,18 @@ convert_pathname(const string &unix_style_pathname) {
} else {
// It starts with a slash, but the first part is not a single
// letter, so prefix $PANDA_ROOT.
// letter.
#ifdef HAVE_CYGWIN
// Use Cygwin to convert it if possible.
char result[4096] = "";
cygwin_conv_to_win32_path(unix_style_pathname.c_str(), result);
windows_pathname = result;
#else // HAVE_CYGWIN
// Without Cygwin, just prefix $PANDA_ROOT.
windows_pathname =
get_panda_root() + front_to_back_slash(unix_style_pathname.substr(1));
#endif // HAVE_CYGWIN
}
return windows_pathname;
@ -250,7 +264,7 @@ Filename(const Filename &dirname, const Filename &basename) {
////////////////////////////////////////////////////////////////////
Filename Filename::
from_os_specific(const string &os_specific, Filename::Type type) {
#if defined(WIN32)
#ifdef WIN32
string result = back_to_front_slash(os_specific);
const string &panda_root = get_panda_root();
@ -291,13 +305,12 @@ from_os_specific(const string &os_specific, Filename::Type type) {
Filename filename(result);
filename.set_type(type);
return filename;
#else
#else // WIN32
// Generic Unix-style filenames--no conversion necessary.
Filename filename(os_specific);
filename.set_type(type);
return filename;
#endif
#endif // WIN32
}
////////////////////////////////////////////////////////////////////

View File

@ -1694,7 +1694,7 @@ compare_output(const string &new_contents, Filename filename,
diff_ok = true;
}
out_b.close();
string command = "diff -u '" + filename.get_fullpath() + "' '" +
string command = "diff -ub '" + filename.get_fullpath() + "' '" +
temp_filename.get_fullpath() + "'";
int sys_result = system(command.c_str());
if (sys_result < 0) {

View File

@ -47,11 +47,6 @@ PPScope::MapVariableDefinition PPScope::_null_map_def;
PPScope::ScopeStack PPScope::_scope_stack;
#ifdef PLATFORM_CYGWIN
extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32);
extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix);
#endif
////////////////////////////////////////////////////////////////////
// Function: PPScope::Constructor
// Access: Public
@ -895,9 +890,11 @@ r_expand_variable(const string &str, size_t &vp,
} else if (funcname == "unixfilename") {
return expand_unixfilename(params);
} else if (funcname == "cygpath_w") {
return expand_cygpath_w(params);
// This maps to osfilename for historical reasons.
return expand_osfilename(params);
} else if (funcname == "cygpath_p") {
return expand_cygpath_p(params);
// This maps to unixfilename for historical reasons.
return expand_unixfilename(params);
} else if (funcname == "wildcard") {
return expand_wildcard(params);
} else if (funcname == "isdir") {
@ -1205,70 +1202,6 @@ expand_unixfilename(const string &params) {
return result;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_cygpath_w
// Access: Private
// Description: Expands the "cygpath_w" function variable.
//
// This converts the Unix-style filename to a Windows
// filename using the Cygwin rules when ppremake has
// been compiled with Cygwin; it is thus equivalent to
// the result of the cygpath -w command.
//
// When Cygwin is not available, this returns the same
// as the "osfilename" variable.
////////////////////////////////////////////////////////////////////
string PPScope::
expand_cygpath_w(const string &params) {
string filename = trim_blanks(expand_string(params));
#ifdef PLATFORM_CYGWIN
char result[4096];
// In Win32, we're either running Cygwin, in which case this
// function is statically linked in and definitely non-NULL, or
// we're running native Win32, in which case this function may or
// may not have been dynamically linked in. In either case, use it
// if we've got it.
cygwin_conv_to_win32_path(filename.c_str(), result);
filename = result;
#else
Filename fn(filename);
filename = fn.to_os_specific();
#endif // PLATFORM_CYGWIN
return filename;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_cygpath_p
// Access: Private
// Description: Expands the "cygpath_p" function variable.
//
// This converts the Windows filename to a Unix-style
// filename using the Cygwin rules when ppremake has
// been compiled with Cygwin; it is thus equivalent to
// the result of the cygpath -p command.
//
// When Cygwin is not available, this returns the same
// as the "unixfilename" variable.
////////////////////////////////////////////////////////////////////
string PPScope::
expand_cygpath_p(const string &params) {
string filename = trim_blanks(expand_string(params));
#ifdef PLATFORM_CYGWIN
char result[4096];
cygwin_conv_to_posix_path(filename.c_str(), result);
filename = result;
#else
filename = Filename::from_os_specific(filename);
#endif // PLATFORM_CYGWIN
return filename;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_wildcard
// Access: Private

View File

@ -27,7 +27,7 @@
#include <strstream.h>
#endif
#if defined(PLATFORM_CYGWIN) || defined(WIN32_VC)
#if defined(HAVE_CYGWIN) || defined(WIN32_VC)
// Either Cygwin or Visual C++ is a Win32 environment.
#define WIN32
#endif