Debian Codegraph @

src/_amiga.c

raw symbols SCIP
1 // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
2 // Copyright (C) 1998-2024 Marco Baye
3 // Have a look at "acme.c" for further info
4 //
5 // platform specific stuff (in this case, for AmigaOS)
6 #ifndef platform_C
7 #define platform_C
8
9
10 // convert UNIX-style path name to local platform style path name and decide
11 // whether path is absolute or relative. p points to the terminated input
12 // string, to be overwritten with the terminated output string.
13 // conversions done for AmigaOS:
14 // "/absolute/path" -> ":absolute/path"
15 // "../../twolevelsup" -> "//twolevelsup"
16 void platform_convert_path(boolean *is_absolute, char *readptr)
17 {
18 char *writeptr,
19 previous;
20
21 // init
22 *is_absolute = FALSE; // there are two ways for this to become true
23 writeptr = readptr; // good thing the string can only shrink, but not grow
24 previous = '/'; // make sure ".." substitution also works for the first component
25 // check for leading '/'
26 if (*readptr == '/') {
27 *is_absolute = TRUE;
28 ++readptr;
29 *(writeptr++) = ':';
30 }
31 // now scan remaining characters and convert all "../" components to "/"
32 while (*readptr) {
33 if ((previous == '/')
34 && (*readptr == '.')
35 && (readptr[1] == '.')
36 && (readptr[2] == '/')) {
37 readptr += 2;
38 }
39 previous = *readptr; // remember for next ".." check
40 // prefixes like "workbench:" also mean the path is absolute
41 if (*readptr == ':') {
42 *is_absolute = TRUE;
43 }
44 *writeptr = *readptr; // copy character
45 ++readptr;
46 ++writeptr;
47 }
48 *writeptr = *readptr; // copy terminator
49 }
50
51
52 #endif