added ugly kluge to fix ugly limitation in RISC OS version

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@366 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-03-17 23:47:04 +00:00
parent 538db084b5
commit 1d7fa761d9
7 changed files with 54 additions and 24 deletions

View File

@ -7,7 +7,10 @@
#define platform_C
// convert UNIX-style path name to AmigaOS-style path name:
// convert UNIX-style path name to local platform style path name and decide
// whether path is absolute or relative. p points to the terminated input
// string, to be overwritten with the terminated output string.
// conversions done for AmigaOS:
// "/absolute/path" -> ":absolute/path"
// "../../twolevelsup" -> "//twolevelsup"
void platform_convert_path(boolean *is_absolute, char *readptr)

View File

@ -7,13 +7,16 @@
#define platform_C
// convert UNIX-style path name to DOS-style path name:
// "path/file" -> "path\file"
// convert UNIX-style path name to local platform style path name and decide
// whether path is absolute or relative. p points to the terminated input
// string, to be overwritten with the terminated output string.
// conversions done for DOS:
// "path/to/file" -> "path\to\file"
void platform_convert_path(boolean *is_absolute, char *p)
{
// leading '/' means absolute path
*is_absolute = (*p == '/');
// stuff like "C:" also means absolute
// stuff like "c:whatever" also means absolute
if ((*p) && (p[1] == ':'))
*is_absolute = TRUE;
// exchange forward and backward slashes

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h> // for strlen and memmove
#include <kernel.h>
#include "input.h" // for input_now->location.plat_filename
@ -44,28 +45,35 @@ void RISCOS_entry(void)
}
// convert UNIX-style path name to RISC OS-style path name:
// convert UNIX-style path name to local platform style path name and decide
// whether path is absolute or relative. p points to the terminated input
// string, to be overwritten with the terminated output string.
// there is enough space allocated for the output string to be _one_(1!) byte
// longer than the input string!
// conversions done for RISC OS:
// "path/to/file.ext" -> "path.to.file/ext"
// "/absolute/path" -> "$.absolute.path" (this needs the one extra byte!)
// "../../twolevelsup" -> "^.^.twolevelsup"
void platform_convert_path(boolean *is_absolute, char *readptr)
{
char *writeptr,
previous;
size_t bytes;
// init
*is_absolute = FALSE; // there are two ways for this to become true
writeptr = readptr; // good thing the string can only shrink, but not grow
previous = '/'; // make sure ".." substitution also works for the first component
// check for leading '/'
/* FIXME - this cannot work because "$." is longer than "/"
(there is a bogus workaround further down)
*is_absolute = FALSE; // there are several ways for this to become true
// check for leading '/' and add '$' prefix:
if (*readptr == '/') {
// this is the extremely unlikely situation where an extra byte
// is needed, so let's get it done:
*is_absolute = TRUE;
++readptr;
*(writeptr++) = '$';
*(writeptr++) = '.';
bytes = strlen(readptr) + 1; // count terminator as well
memmove(readptr + 1, readptr, bytes); // "/path\0\0" -> "//path\0"
*(readptr++) = '$'; // "//path\0" -> "$/path\0"
}
*/
writeptr = readptr;
previous = '/'; // make sure ".." substitution also works for the first component
// now scan remaining characters and convert all "../" components to "^."
while (*readptr) {
if ((previous == '/')
@ -76,12 +84,11 @@ void platform_convert_path(boolean *is_absolute, char *readptr)
*(writeptr++) = '^';
}
previous = *readptr; // remember for next ".." check
if (*readptr == ':') {
// prefixes like "myproject:" mean the path is absolute
*is_absolute = TRUE;
} else if (*readptr == '$') {
// bogus workaround: user needs to use "$/whatever" for root dir
*is_absolute = TRUE;
if ((*readptr == ':') // path prefixes like "myproject:"...
|| (*readptr == '$') // ... or root directory indicator '$'...
|| (*readptr == '&') // ... or "user root directory" indicator '&'...
|| (*readptr == '%')) { // ... or "user library directory" indicator '%'...
*is_absolute = TRUE; // ...mean path is absolute
}
// convert characters
if (*readptr == '.') {

View File

@ -7,7 +7,11 @@
#define platform_C
// convert UNIX-style path name to local platform-style path name:
// convert UNIX-style path name to local platform style path name and decide
// whether path is absolute or relative. p points to the terminated input
// string, to be overwritten with the terminated output string.
// conversions done:
// (none, really)
void platform_convert_path(boolean *is_absolute, char *p)
{
*is_absolute = (*p == '/');

View File

@ -657,6 +657,12 @@ static int read_filename_shared_end(boolean *absolute)
// terminate string
dynabuf_append(GlobalDynaBuf, '\0');
// add another zero byte to make sure the buffer is large enough so the
// string could grow another byte:
dynabuf_append(GlobalDynaBuf, '\0');
// (this is an extremely ugly kluge for an extremely unlikely situation,
// but still less ugly than all other workarounds I could think of. see
// _riscos.c for the extremely unlikely situation where this is needed)
// platform-specific path name conversion
// (and tell absolute/relative paths apart)
@ -914,6 +920,9 @@ FILE *includepaths_open_ro(struct filespecflags *flags)
stream = combine_and_open_ro();
if (stream == NULL) {
// default prefix failed, so try list entries:
// (does not seem to make much sense for absolute paths,
// but maybe some windows user used search paths like
// "D:" or "E:" - oh well...)
for (ipi = ipi_head.next; ipi != &ipi_head; ipi = ipi->next) {
dynabuf_clear(pathbuf);
dynabuf_add_string(pathbuf, ipi->path);

View File

@ -35,7 +35,11 @@
#endif
// convert UNIX-style path name to local platform style path name
// convert UNIX-style path name to local platform style path name and decide
// whether path is absolute or relative. p points to the terminated input
// string, to be overwritten with the terminated output string.
// there is enough space allocated for the output string to be _one_(1!) byte
// longer than the input string!
extern void platform_convert_path(boolean *is_absolute, char *p);
// stuff shared by some, but not all platforms:

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "8 Mar" // update before release FIXME
#define CHANGE_DATE "9 Mar" // update before release FIXME
#define CHANGE_YEAR "2024" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME