summaryrefslogtreecommitdiff
path: root/src/filename_absolute.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-12-11 16:03:13 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-12-11 16:03:13 +0000
commitfdcdc8fd46547a7cd77010db6b57f9cc9f4f51d1 (patch)
treee7cfd7b774e59fe9b2092ede165e3dd058a20955 /src/filename_absolute.cxx
parent6905f61c2c00bd2e6777b0ab9d843fbe1a46dcc4 (diff)
Multiple fixes from Sebastien.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1833 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/filename_absolute.cxx')
-rw-r--r--src/filename_absolute.cxx26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx
index 8e316294e..2eeca49e3 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.2 2001/11/26 19:41:57 easysw Exp $"
+// "$Id: filename_absolute.cxx,v 1.5.2.4.2.3 2001/12/11 16:03:12 easysw Exp $"
//
// Filename expansion routines for the Fast Light Tool Kit (FLTK).
//
@@ -110,13 +110,12 @@ int filename_absolute(char *to, int tolen, const char *from) {
*/
int // O - 0 if no change, 1 if changed
-filename_relative(char *to, // O - Relative filename
- int tolen, // I - Size of "to" buffer
- const char *from) { // I - Absolute filename
+filename_relative(char *to, // O - Relative filename
+ int tolen, // I - Size of "to" buffer
+ const char *from) { // I - Absolute filename
const char *newslash; // Directory separator
- char *slash; // Directory separator
+ const char *slash; // Directory separator
char cwd[1024]; // Current directory
- char *temp = new char[tolen];// Temporary pathname
if (from[0] == '\0' || !isdirsep(*from)) {
@@ -131,16 +130,13 @@ filename_relative(char *to, // O - Relative filename
return 0;
}
- strncpy(temp, from, tolen - 1);
- temp[tolen - 1] = '\0';
-
- for (slash = temp, newslash = cwd;
+ for (slash = from, newslash = cwd;
*slash != '\0' && *newslash != '\0';
slash ++, newslash ++)
if (isdirsep(*slash) && isdirsep(*newslash)) continue;
else if (*slash != *newslash) break;
- while (!isdirsep(*slash) && slash > temp) slash --;
+ while (!isdirsep(*slash) && slash > from) slash --;
if (isdirsep(*slash)) slash ++;
@@ -158,10 +154,8 @@ filename_relative(char *to, // O - Relative filename
to[0] = '\0';
to[tolen - 1] = '\0';
- while (*newslash != '\0')
- {
- if (*newslash == '/' || *newslash == '\\')
- strncat(to, "../", tolen - 1);
+ while (*newslash != '\0') {
+ if (isdirsep(*newslash)) strncat(to, "../", tolen - 1);
newslash ++;
}
@@ -173,5 +167,5 @@ filename_relative(char *to, // O - Relative filename
//
-// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.2 2001/11/26 19:41:57 easysw Exp $".
+// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.3 2001/12/11 16:03:12 easysw Exp $".
//