mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-02-10 11:31:49 +00:00
tweaked pathname parsing for Amiga, DOS and RISC OS
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@363 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
7a94c67990
commit
daefa72aea
49
src/_amiga.c
Normal file
49
src/_amiga.c
Normal file
@ -0,0 +1,49 @@
|
||||
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
|
||||
// Copyright (C) 1998-2024 Marco Baye
|
||||
// Have a look at "acme.c" for further info
|
||||
//
|
||||
// platform specific stuff (in this case, for AmigaOS)
|
||||
#ifndef platform_C
|
||||
#define platform_C
|
||||
|
||||
|
||||
// convert UNIX-style path name to AmigaOS-style path name:
|
||||
// "/absolute/path" -> ":absolute/path"
|
||||
// "../../twolevelsup" -> "//twolevelsup"
|
||||
void platform_convert_path(boolean *is_absolute, char *readptr)
|
||||
{
|
||||
char *writeptr,
|
||||
previous;
|
||||
|
||||
// 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 '/'
|
||||
if (*readptr == '/') {
|
||||
*is_absolute = TRUE;
|
||||
++readptr;
|
||||
*(writeptr++) = ':';
|
||||
}
|
||||
// now scan remaining characters and convert all "../" components to "/"
|
||||
while (*readptr) {
|
||||
if ((previous == '/')
|
||||
&& (*readptr == '.')
|
||||
&& (readptr[1] == '.')
|
||||
&& (readptr[2] == '/')) {
|
||||
readptr += 2;
|
||||
}
|
||||
previous = *readptr; // remember for next ".." check
|
||||
// prefixes like "workbench:" also mean the path is absolute
|
||||
if (*readptr == ':') {
|
||||
*is_absolute = TRUE;
|
||||
}
|
||||
*writeptr = *readptr; // copy character
|
||||
++readptr;
|
||||
++writeptr;
|
||||
}
|
||||
*writeptr = *readptr; // copy terminator
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -12,9 +12,6 @@
|
||||
// called once on program startup (could register exit handler, if needed)
|
||||
#define PLATFORM_INIT
|
||||
|
||||
// convert UNIX-style pathname to Amiga-style pathname (no change)
|
||||
//#define PLATFORM_CONVERTPATH(p)
|
||||
|
||||
// directory separators for search paths
|
||||
#define DIRECTORY_SEPARATOR '/'
|
||||
#define ALTERNATIVE_DIR_SEP ':'
|
||||
|
11
src/_dos.c
11
src/_dos.c
@ -7,9 +7,16 @@
|
||||
#define platform_C
|
||||
|
||||
|
||||
// convert UNIX-style pathname to DOS-style pathname
|
||||
void DOS_convert_path(char *p)
|
||||
// convert UNIX-style path name to DOS-style path name:
|
||||
// "path/file" -> "path\file"
|
||||
void platform_convert_path(boolean *is_absolute, char *p)
|
||||
{
|
||||
// leading '/' means absolute path
|
||||
*is_absolute = (*p == '/');
|
||||
// stuff like "C:" also means absolute
|
||||
if ((*p) && (p[1] == ':'))
|
||||
*is_absolute = TRUE;
|
||||
// exchange forward and backward slashes
|
||||
while (*p) {
|
||||
if (*p == '/') {
|
||||
*p = '\\';
|
||||
|
10
src/_dos.h
10
src/_dos.h
@ -7,17 +7,11 @@
|
||||
#define platform_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// symbolic constants and macros
|
||||
|
||||
// called once on program startup (could register exit handler, if needed)
|
||||
#define PLATFORM_INIT platform_read_env_var()
|
||||
|
||||
// convert UNIX-style pathname to DOS-style pathname
|
||||
#define PLATFORM_CONVERTPATH(p) DOS_convert_path(p)
|
||||
|
||||
// directory separators for search paths
|
||||
#define DIRECTORY_SEPARATOR '\\'
|
||||
#define ALTERNATIVE_DIR_SEP '\\' // dummy
|
||||
@ -53,8 +47,4 @@ do { \
|
||||
#define PLATFORM_LONGOPTION_CODE
|
||||
|
||||
|
||||
// Convert UNIX-style pathname to DOS-style pathname
|
||||
extern void DOS_convert_path(char *p);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <kernel.h>
|
||||
#include "input.h"
|
||||
#include "input.h" // for input_now->location.plat_filename
|
||||
|
||||
|
||||
// constants
|
||||
@ -44,21 +44,61 @@ void RISCOS_entry(void)
|
||||
}
|
||||
|
||||
|
||||
// convert UNIX-style pathname to RISC OS-style pathname
|
||||
void RISCOS_convert_path(char *p)
|
||||
// convert UNIX-style path name to RISC OS-style path name:
|
||||
// "path/to/file.ext" -> "path.to.file/ext"
|
||||
// "../../twolevelsup" -> "^.^.twolevelsup"
|
||||
void platform_convert_path(boolean *is_absolute, char *readptr)
|
||||
{
|
||||
while (*p) {
|
||||
if (*p == '.') {
|
||||
*p = '/';
|
||||
} else if (*p == '/') {
|
||||
*p = '.';
|
||||
} else if (*p == '?') {
|
||||
*p = '#';
|
||||
} else if (*p == '#') {
|
||||
*p = '?';
|
||||
}
|
||||
++p;
|
||||
char *writeptr,
|
||||
previous;
|
||||
|
||||
// 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)
|
||||
if (*readptr == '/') {
|
||||
*is_absolute = TRUE;
|
||||
++readptr;
|
||||
*(writeptr++) = '$';
|
||||
*(writeptr++) = '.';
|
||||
}
|
||||
*/
|
||||
// now scan remaining characters and convert all "../" components to "^."
|
||||
while (*readptr) {
|
||||
if ((previous == '/')
|
||||
&& (*readptr == '.')
|
||||
&& (readptr[1] == '.')
|
||||
&& (readptr[2] == '/')) {
|
||||
readptr += 2;
|
||||
*(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;
|
||||
}
|
||||
// convert characters
|
||||
if (*readptr == '.') {
|
||||
*writeptr = '/';
|
||||
} else if (*readptr == '/') {
|
||||
*writeptr = '.';
|
||||
} else if (*readptr == '?') {
|
||||
*writeptr = '#';
|
||||
} else if (*readptr == '#') {
|
||||
*writeptr = '?';
|
||||
} else {
|
||||
*writeptr = *readptr; // copy character
|
||||
}
|
||||
++readptr;
|
||||
++writeptr;
|
||||
}
|
||||
*writeptr = *readptr; // copy terminator
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define platform_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "config.h" // for "bits"
|
||||
|
||||
|
||||
// symbolic constants and macros
|
||||
@ -15,9 +15,6 @@
|
||||
// called once on program startup (could register exit handler, if needed)
|
||||
#define PLATFORM_INIT RISCOS_entry()
|
||||
|
||||
// convert UNIX-style pathname to RISC OS-style pathname
|
||||
#define PLATFORM_CONVERTPATH(path) RISCOS_convert_path(path)
|
||||
|
||||
// directory separators for search paths
|
||||
#define DIRECTORY_SEPARATOR '.'
|
||||
#define ALTERNATIVE_DIR_SEP ':'
|
||||
@ -68,9 +65,6 @@ extern bits RISCOS_flags; // Holds platform-specific flags
|
||||
// used as PLATFORM_INIT: registers exit handler
|
||||
extern void RISCOS_entry(void);
|
||||
|
||||
// convert UNIX-style pathname to RISC OS-style pathname
|
||||
extern void RISCOS_convert_path(char *path);
|
||||
|
||||
// setting the created files' types
|
||||
extern void RISCOS_set_filetype(const char *filename, int type);
|
||||
|
||||
|
@ -7,4 +7,12 @@
|
||||
#define platform_C
|
||||
|
||||
|
||||
// convert UNIX-style path name to local platform-style path name:
|
||||
void platform_convert_path(boolean *is_absolute, char *p)
|
||||
{
|
||||
*is_absolute = (*p == '/');
|
||||
// ...no need to really "convert" anything...
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -12,9 +12,6 @@
|
||||
// called once on program startup (could register exit handler, if needed)
|
||||
#define PLATFORM_INIT platform_read_env_var()
|
||||
|
||||
// convert UNIX-style pathname to platform-style pathname (no change)
|
||||
//#define PLATFORM_CONVERTPATH(p)
|
||||
|
||||
// directory separator for search paths
|
||||
#define DIRECTORY_SEPARATOR '/'
|
||||
#define ALTERNATIVE_DIR_SEP '/' // dummy
|
||||
|
10
src/input.c
10
src/input.c
@ -651,19 +651,17 @@ static int read_filename_shared_end(boolean *absolute)
|
||||
return 1; // error
|
||||
}
|
||||
|
||||
// check if absolute and remember
|
||||
*absolute = GlobalDynaBuf->buffer[0] == '/';
|
||||
|
||||
// resolve backslash escapes
|
||||
if (input_unescape_dynabuf())
|
||||
return 1; // escaping error
|
||||
|
||||
// terminate string
|
||||
dynabuf_append(GlobalDynaBuf, '\0');
|
||||
#ifdef PLATFORM_CONVERTPATH
|
||||
|
||||
// platform-specific path name conversion
|
||||
PLATFORM_CONVERTPATH(GLOBALDYNABUF_CURRENT);
|
||||
#endif
|
||||
// (and tell absolute/relative paths apart)
|
||||
platform_convert_path(absolute, GLOBALDYNABUF_CURRENT);
|
||||
|
||||
return 0; // ok
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,11 @@
|
||||
//
|
||||
// Platform specific stuff
|
||||
#include "platform.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
// Amiga
|
||||
#ifdef _AMIGA
|
||||
#ifndef platform_C
|
||||
#define platform_C
|
||||
// Nothing here - Amigas don't need no stinkin' platform-specific stuff!
|
||||
#endif
|
||||
#include "_amiga.c"
|
||||
#endif
|
||||
|
||||
// DOS, OS/2 and Windows
|
||||
|
@ -5,6 +5,9 @@
|
||||
// Platform specific stuff
|
||||
|
||||
|
||||
#include "config.h" // for "boolean"
|
||||
|
||||
|
||||
// Amiga
|
||||
#ifdef _AMIGA
|
||||
#define PLATFORM_VERSION "Ported to AmigaOS by Christoph Mammitzsch."
|
||||
@ -32,6 +35,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
// convert UNIX-style path name to local platform style path name
|
||||
extern void platform_convert_path(boolean *is_absolute, char *p);
|
||||
|
||||
// stuff shared by some, but not all platforms:
|
||||
#if PLATFORM_NEEDS_ENV_VAR
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.97" // update before release FIXME
|
||||
#define CODENAME "Zem" // update before release
|
||||
#define CHANGE_DATE "5 Mar" // update before release FIXME
|
||||
#define CHANGE_DATE "6 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user