diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-10-10 19:33:22 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2002-10-10 19:33:22 +0000 |
| commit | 77c3efad19f1fd47a26cfaec43d47667ec2661d9 (patch) | |
| tree | af69bba464db1802e76462f759f60575df517811 | |
| parent | 8e0ec8482e9922153a95c98c98e1747a6c63517d (diff) | |
Matthias's fl_filename_relative() fixes.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2663 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | src/filename_absolute.cxx | 30 |
2 files changed, 23 insertions, 11 deletions
@@ -1,5 +1,9 @@ CHANGES IN FLTK 1.1.1 + - fl_filename_relative() didn't check that the path was + absolute under WIN32. + - fl_filename_relative() didn't check that the path was + on the current drive under WIN32. - The Fl_BMP_Image class now handles 16-bit BMP files and BMP files with a transparency mask. - The fltk-config script didn't add the required include diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index 3f0f76bb8..1a795f1a7 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_absolute.cxx,v 1.5.2.4.2.8 2002/05/16 12:47:43 easysw Exp $" +// "$Id: filename_absolute.cxx,v 1.5.2.4.2.9 2002/10/10 19:33:22 easysw Exp $" // // Filename expansion routines for the Fast Light Tool Kit (FLTK). // @@ -108,14 +108,20 @@ int fl_filename_absolute(char *to, int tolen, const char *from) { int // O - 0 if no change, 1 if changed fl_filename_relative(char *to, // O - Relative filename - int tolen, // I - Size of "to" buffer - const char *from) { // I - Absolute filename + int tolen, // I - Size of "to" buffer + const char *from) {// I - Absolute filename const char *newslash; // Directory separator const char *slash; // Directory separator char cwd[1024]; // Current directory +#if defined(WIN32) || defined(__EMX__) + if (from[0] == '\0' || + (!isdirsep(*from) && !isalpha(*from) && from[1] != ':' && + !isdirsep(from[2]))) { +#else if (from[0] == '\0' || !isdirsep(*from)) { +#endif // WIN32 || __EMX__ strlcpy(to, from, tolen); return 0; } @@ -125,7 +131,16 @@ fl_filename_relative(char *to, // O - Relative filename return 0; } +#if defined(WIN32) || defined(__EMX__) + if (*from != *cwd) { + // Not the same drive... + strlcpy(to, from, tolen); + return 0; + } + for (slash = from + 2, newslash = cwd + 2; +#else for (slash = from, newslash = cwd; +#endif // WIN32 || __EMX__ *slash != '\0' && *newslash != '\0'; slash ++, newslash ++) if (isdirsep(*slash) && isdirsep(*newslash)) continue; @@ -142,13 +157,6 @@ fl_filename_relative(char *to, // O - Relative filename if (isdirsep(*slash)) slash ++; -#if defined(WIN32) || defined(__EMX__) - if (isalpha(slash[0]) && slash[1] == ':') { - strlcpy(to, from, tolen); - return 0; /* Different drive letter... */ - } -#endif /* WIN32 || __EMX__ */ - if (*newslash != '\0') while (!isdirsep(*newslash) && newslash > cwd) newslash --; @@ -168,5 +176,5 @@ fl_filename_relative(char *to, // O - Relative filename // -// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.8 2002/05/16 12:47:43 easysw Exp $". +// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.9 2002/10/10 19:33:22 easysw Exp $". // |
