From db020f6607bd3751bfdb5748eaf2ba230e4b42bb Mon Sep 17 00:00:00 2001 From: marcobaye Date: Thu, 19 Jun 2025 15:55:22 +0000 Subject: [PATCH] small cleanup in src and docs concerning ACME library git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@440 4df02467-bbd4-4a76-a152-e7ce94205b78 --- docs/Errors.txt | 13 ++++++++----- docs/Lib.txt | 14 +++++++++++++- src/_amiga.h | 3 ++- src/_dos.h | 3 ++- src/_riscos.h | 3 ++- src/_std.h | 9 +++++++-- src/acme.c | 5 ++++- src/global.c | 3 ++- src/global.h | 3 ++- src/input.c | 6 +++--- src/platform.c | 20 ++++++++++++++++---- src/platform.h | 5 ++++- src/version.h | 2 +- 13 files changed, 66 insertions(+), 23 deletions(-) diff --git a/docs/Errors.txt b/docs/Errors.txt index 6d5a0ae..b22f4a4 100644 --- a/docs/Errors.txt +++ b/docs/Errors.txt @@ -184,11 +184,6 @@ Zeropage pointer wraps around from $ff to $00 Section: Errors during assembly ---------------------------------------------------------------------- -"ACME" environment variable not found. - This will be shown if the source code references any files from - the library, but the library location variable wasn't set. This - can only be given on systems using the said variable. - "!cbm" is obsolete; use "!ct pet" instead. This is given when the now obsolete "!cbm" pseudo opcode is encountered. @@ -332,6 +327,14 @@ Invalid hex digit after \x, expected 0-9/a-f. by two hex digits. If the next two chars are not [0-9a-fA-F], this error will be generated. +Library path not set. Use --libpath or create an environment variable. + This will be shown if the source code references a file from the + library but ACME does not know where the library is located. + If the ACME binary was compiled with a default path, you will not + see this error. + See the file "Lib.txt" in this directory for info on how to setup + the library path. + Macro already defined. Macros can only be defined once. If you define a macro twice, ACME will give an error for the new definition and then output an info diff --git a/docs/Lib.txt b/docs/Lib.txt index fcf8b07..bb35a5c 100644 --- a/docs/Lib.txt +++ b/docs/Lib.txt @@ -14,7 +14,19 @@ within ACME sources when using the pseudo opcodes "!source" or If the file names are given using "..." quoting, ACME will look for the files in the current directory. If the file names are given using <...> quoting, ACME will look for -them in the ACME_Lib directory tree however. +them in the library directory. + +The actual location of the library directory can be given in several +different ways: + 1. a default can be given when compiling the ACME binary. + 2. an environment variable called "ACME" overrides this. + 3. and the CLI switch "--libpath" overrides even that. + +Setting up an environment variable is OS-specific, so for example on +Linux, put this in your .bashrc file: + export ACME="$HOME/.acme/ACME_Lib" +...and of course you will then have to copy the library tree to that +location. All files in the ACME_Lib directory tree are in the public domain. They are *NOT* covered by the GNU General Public License, under which diff --git a/src/_amiga.h b/src/_amiga.h index d6fbe82..db49a25 100644 --- a/src/_amiga.h +++ b/src/_amiga.h @@ -17,8 +17,9 @@ #define ALTERNATIVE_DIR_SEP ':' // string containing the prefix for accessing files from the library tree +// (use "--libpath" cli switch to override) #define PLATFORM_LIBPREFIX "progdir:acme_lib/" -#define PLATFORM_NEEDS_ENV_VAR 0 // no "ACME" environment variable needed +#define PLATFORM_USE_ENV_VAR 0 // no "ACME" environment variable needed/supported // setting file types of created files #define PLATFORM_SETFILETYPE_APPLE(a) diff --git a/src/_dos.h b/src/_dos.h index 3afa917..98f44e3 100644 --- a/src/_dos.h +++ b/src/_dos.h @@ -17,8 +17,9 @@ #define ALTERNATIVE_DIR_SEP '\\' // dummy // string containing the prefix for accessing files from the library tree +// (use "--libpath" cli switch or "ACME" environment variable to set this) #define PLATFORM_LIBPREFIX NULL -#define PLATFORM_NEEDS_ENV_VAR 1 // library access needs "ACME" environment variable +#define PLATFORM_USE_ENV_VAR 1 // library access needs "ACME" environment variable // setting file types of created files #define PLATFORM_SETFILETYPE_APPLE(a) diff --git a/src/_riscos.h b/src/_riscos.h index 74fdcee..ab73089 100644 --- a/src/_riscos.h +++ b/src/_riscos.h @@ -20,8 +20,9 @@ #define ALTERNATIVE_DIR_SEP ':' // string containing the prefix for accessing files from the library tree +// (use "--libpath" cli switch to override) #define PLATFORM_LIBPREFIX "ACME_Lib:" -#define PLATFORM_NEEDS_ENV_VAR 0 // no "ACME" environment variable needed +#define PLATFORM_USE_ENV_VAR 0 // no "ACME" environment variable needed/supported // setting file types of created files #define PLATFORM_SETFILETYPE_APPLE(a) RISCOS_set_filetype(a, 0xffd) // FIXME - wrong value! diff --git a/src/_std.h b/src/_std.h index 9c3383f..15bacbd 100644 --- a/src/_std.h +++ b/src/_std.h @@ -17,8 +17,13 @@ #define ALTERNATIVE_DIR_SEP '/' // dummy // string containing the prefix for accessing files from the library tree -#define PLATFORM_LIBPREFIX NULL // TODO: package maintainers could use sth like "/usr/share/acme/lib/" here (and put the library files there) -#define PLATFORM_NEEDS_ENV_VAR 1 // library access needs "ACME" environment variable +// (use "--libpath" cli switch or "ACME" environment variable to set this) +#define PLATFORM_LIBPREFIX NULL +#define PLATFORM_USE_ENV_VAR 1 // library access needs "ACME" environment variable +// if you are building an "ACME" package for a linux or bsd distribution, you +// could put the library files at /usr/share/acme/lib/ and use that path instead +// of "NULL" above. the user then only needs the "ACME" environment variable if +// they want to override the default path given here. // setting the created files' types #define PLATFORM_SETFILETYPE_APPLE(a) diff --git a/src/acme.c b/src/acme.c index fb9f569..62aa263 100644 --- a/src/acme.c +++ b/src/acme.c @@ -69,6 +69,7 @@ static const char arg_vicelabels[] = "VICE labels filename"; #define OPTION_STRICT "strict" #define OPTION_LIBPATH "libpath" #define OPTION_DIALECT "dialect" +#define OPTION_PLEASE "please" #define OPTION_DEBUGLEVEL "debuglevel" #define OPTION_TEST "test" // options for "-W" @@ -728,9 +729,11 @@ static const char *long_option(const char *string) else if (strcmp(string, OPTION_STRICT) == 0) config.all_warnings_are_errors = TRUE; else if (strcmp(string, OPTION_LIBPATH) == 0) - config.platform_lib_prefix = cliargs_safe_get_next("path to library"); + platform_set_lib_path(cliargs_safe_get_next("path to library")); else if (strcmp(string, OPTION_DIALECT) == 0) set_dialect(cliargs_get_next()); // NULL is ok (handled like unknown) + else if (strcmp(string, OPTION_PLEASE) == 0) + ++config.politeness; else if (strcmp(string, OPTION_DEBUGLEVEL) == 0) config.debuglevel = string_to_number(cliargs_safe_get_next("debug level")); else if (strcmp(string, OPTION_TEST) == 0) { diff --git a/src/global.c b/src/global.c index a78e633..8346276 100644 --- a/src/global.c +++ b/src/global.c @@ -122,6 +122,7 @@ void config_default(struct config *conf) conf->all_warnings_are_errors = FALSE; // enabled by --strict conf->test_new_features = FALSE; // enabled by --test conf->dialect = V__CURRENT_VERSION; // changed by --dialect + conf->politeness = 0; // changed by --please conf->debuglevel = DEBUGLEVEL_DEBUG; // changed by --debuglevel, used by "!debug" conf->platform_lib_prefix = PLATFORM_LIBPREFIX; conf->initial_cpu_type = NULL; @@ -600,7 +601,7 @@ void throw_warning(const char msg[]) // output an error (something is wrong, no output file will be generated). // the assembler will try to go on with the assembly, so the user gets to know -// about more than one of his typos at a time. +// about more than one of their typos at a time. void throw_error(const char msg[]) { if (error_is_in_cli_args) diff --git a/src/global.h b/src/global.h index f0b9f2b..0cbabf6 100644 --- a/src/global.h +++ b/src/global.h @@ -89,6 +89,7 @@ struct config { boolean all_warnings_are_errors; // FALSE, enabled by --strict boolean test_new_features; // FALSE, enabled by --test enum dialect dialect; // set by --dialect (and --test --test) + int politeness; // incremented by --please int debuglevel; // set by --debuglevel, used by "!debug" const char *platform_lib_prefix; // default value depends on platform const struct cpu_type *initial_cpu_type; @@ -223,7 +224,7 @@ extern void throw_warning(const char msg[]); // output an error (something is wrong, no output file will be generated). // the assembler will try to go on with the assembly, so the user gets to know -// about more than one of his typos at a time. +// about more than one of their typos at a time. extern void throw_error(const char msg[]); // output a serious error (assembly stops, for example if outbuffer overruns). diff --git a/src/input.c b/src/input.c index a2f7bee..91fa9d7 100644 --- a/src/input.c +++ b/src/input.c @@ -1104,9 +1104,9 @@ static void library_path_to_pathbuf(void) dynabuf_clear(pathbuf); // CAUTION: the second part of the condition below implies the first part, // so the first part seems useless. but the first part allows for the - // compiler removing the check completely on some platforms. - if ((PLATFORM_NEEDS_ENV_VAR) && (config.platform_lib_prefix == NULL)) { - throw_error("\"ACME\" environment variable not found."); // FIXME - change to sth like "library path not set, use --libpath or set ACME env var" + // compiler to remove the check completely on some platforms. + if ((PLATFORM_USE_ENV_VAR) && (config.platform_lib_prefix == NULL)) { + throw_error("Library path not set. Use --libpath or create an environment variable."); } else { dynabuf_add_string(pathbuf, config.platform_lib_prefix); } diff --git a/src/platform.c b/src/platform.c index 274c943..7550c23 100644 --- a/src/platform.c +++ b/src/platform.c @@ -4,6 +4,7 @@ // // Platform specific stuff #include "platform.h" +#include "global.h" // for config // Amiga @@ -29,19 +30,30 @@ #endif +// set or change library path +void platform_set_lib_path(const char new_path[]) +{ + if (config.platform_lib_prefix) { + // this is mostly for debugging so people can check if their env var setup works: + printf("Changing library path from \"%s\" to \"%s\".\n", config.platform_lib_prefix, new_path); + fflush(stdout); // force output before any subsequent errors + } + config.platform_lib_prefix = new_path; +} + + // stuff shared by some, but not all platforms: -#if PLATFORM_NEEDS_ENV_VAR +#if PLATFORM_USE_ENV_VAR #include // for getenv() #include "dynabuf.h" -#include "global.h" // for config // function to setup pointer to library tree from env var void platform_read_env_var(void) { char *env_var; - // Find out the path of ACME's library + // find out the path of ACME's library env_var = getenv("ACME"); // if environment variable was found, make a copy if (env_var) { @@ -49,7 +61,7 @@ void platform_read_env_var(void) // copy environment variable to global dynamic buffer dynabuf_add_string(GlobalDynaBuf, env_var); dynabuf_append(GlobalDynaBuf, '\0'); // add terminator - config.platform_lib_prefix = dynabuf_get_copy(GlobalDynaBuf); + platform_set_lib_path(dynabuf_get_copy(GlobalDynaBuf)); } } diff --git a/src/platform.h b/src/platform.h index 3a4ac97..88cf1f2 100644 --- a/src/platform.h +++ b/src/platform.h @@ -42,8 +42,11 @@ // longer than the input string! extern void platform_convert_path(boolean *is_absolute, char *p); +// set or change library path +extern void platform_set_lib_path(const char new_path[]); + // stuff shared by some, but not all platforms: -#if PLATFORM_NEEDS_ENV_VAR +#if PLATFORM_USE_ENV_VAR // function to setup pointer to library tree from env var extern void platform_read_env_var(void); diff --git a/src/version.h b/src/version.h index ce10e0b..72d868c 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ #define RELEASE "0.97" // update before release FIXME #define CODENAME "Zem" // update before release -#define CHANGE_DATE "16 Jun" // update before release FIXME +#define CHANGE_DATE "17 Jun" // update before release FIXME #define CHANGE_YEAR "2025" // update before release //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME