diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-01 18:03:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-06 20:28:20 +0200 |
| commit | f09e17c3c564e8310125a10c03397cbf473ff643 (patch) | |
| tree | 8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /src/filename_absolute.cxx | |
| parent | b0e0c355edaa2e23148cb0260ada907aec930f05 (diff) | |
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files
The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
Diffstat (limited to 'src/filename_absolute.cxx')
| -rw-r--r-- | src/filename_absolute.cxx | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index 19c1d97a6..67beb50c3 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -1,6 +1,4 @@ // -// "$Id$" -// // Filename expansion routines for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2017 by Bill Spitzak and others. @@ -9,11 +7,11 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems on the following page: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // /* expand a file name by prepending current directory, deleting . and @@ -40,7 +38,7 @@ inline int isdirsep(char c) {return c == '/';} fl_filename_absolute(out, sizeof(out), "../log/messages"); // out="/var/log/messages" \endcode \param[out] to resulting absolute filename - \param[in] tolen size of the absolute filename buffer + \param[in] tolen size of the absolute filename buffer \param[in] from relative filename \return 0 if no change, non zero otherwise */ @@ -114,16 +112,16 @@ int Fl_System_Driver::filename_absolute(char *to, int tolen, const char *from) { fl_filename_relative(out, sizeof(out), "../foo.txt"); // out="../foo.txt", return=0 (no change) \endcode \param[out] to resulting relative filename - \param[in] tolen size of the relative filename buffer + \param[in] tolen size of the relative filename buffer \param[in] from absolute filename \return 0 if no change, non zero otherwise */ -int // O - 0 if no change, 1 if changed -fl_filename_relative(char *to, // O - Relative filename - int tolen, // I - Size of "to" buffer +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 { - char cwd_buf[FL_PATH_MAX]; // Current directory + char cwd_buf[FL_PATH_MAX]; // Current directory // get the current directory and return if we can't if (!fl_getcwd(cwd_buf, sizeof(cwd_buf))) { strlcpy(to, from, tolen); @@ -135,14 +133,14 @@ fl_filename_relative(char *to, // O - Relative filename /** Makes a filename relative to any other directory. \param[out] to resulting relative filename - \param[in] tolen size of the relative filename buffer + \param[in] tolen size of the relative filename buffer \param[in] from absolute filename \param[in] base relative to this absolute path \return 0 if no change, non zero otherwise */ -int // O - 0 if no change, 1 if changed -fl_filename_relative(char *to, // O - Relative filename - int tolen, // I - Size of "to" buffer +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 const char *base) { // I - Find path relative to this path return Fl::system_driver()->filename_relative(to, tolen, from, base); @@ -156,72 +154,72 @@ fl_filename_relative(char *to, // O - Relative filename */ int // O - 0 if no change, 1 if changed -Fl_System_Driver::filename_relative(char *to, // O - Relative filename +Fl_System_Driver::filename_relative(char *to, // O - Relative filename int tolen, // I - Size of "to" buffer const char *from, // I - Absolute filename const char *base) // I - Find path relative to this path { - char *newslash; // Directory separator - const char *slash; // Directory separator + char *newslash; // Directory separator + const char *slash; // Directory separator char *cwd = 0L, *cwd_buf = 0L; if (base) cwd = cwd_buf = strdup(base); - + // return if "from" is not an absolute path if (from[0] == '\0' || !isdirsep(*from)) { strlcpy(to, from, tolen); if (cwd_buf) free(cwd_buf); return 0; } - + // return if "cwd" is not an absolute path if (!cwd || cwd[0] == '\0' || !isdirsep(*cwd)) { strlcpy(to, from, tolen); if (cwd_buf) free(cwd_buf); return 0; } - + // test for the exact same string and return "." if so if (!strcmp(from, cwd)) { strlcpy(to, ".", tolen); free(cwd_buf); return (1); } - + // compare both path names until we find a difference for (slash = from, newslash = cwd; *slash != '\0' && *newslash != '\0'; slash ++, newslash ++) if (isdirsep(*slash) && isdirsep(*newslash)) continue; else if (*slash != *newslash) break; - + // skip over trailing slashes if ( *newslash == '\0' && *slash != '\0' && !isdirsep(*slash) &&(newslash==cwd || !isdirsep(newslash[-1])) ) newslash--; - + // now go back to the first character of the first differing paths segment while (!isdirsep(*slash) && slash > from) slash --; if (isdirsep(*slash)) slash ++; - + // do the same for the current dir if (isdirsep(*newslash)) newslash --; if (*newslash != '\0') while (!isdirsep(*newslash) && newslash > cwd) newslash --; - + // prepare the destination buffer to[0] = '\0'; to[tolen - 1] = '\0'; - + // now add a "previous dir" sequence for every following slash in the cwd while (*newslash != '\0') { if (isdirsep(*newslash)) strlcat(to, "../", tolen); - + newslash ++; } - + // finally add the differing path from "from" strlcat(to, slash, tolen); - + free(cwd_buf); return 1; } @@ -230,7 +228,3 @@ Fl_System_Driver::filename_relative(char *to, // O - Relative filename \} \endcond */ - -// -// End of "$Id$". -// |
