mirror of
https://github.com/uffejakobsen/acme.git
synced 2026-04-24 01:18:54 +00:00
file names can now be specified via string symbols
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@429 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
+11
-3
@@ -279,9 +279,17 @@ Expression did not return a number.
|
||||
An expression returned a string or a list but a number (integer or
|
||||
float) was expected.
|
||||
|
||||
File name quotes not found ("" or <>).
|
||||
File names have to be given in quotes. Either "" quoting for files
|
||||
located in the current directory or <> quoting for library files.
|
||||
Expression did not return a string.
|
||||
An expression returned a list or a number but a string was
|
||||
expected (for example a file name).
|
||||
|
||||
Quotes not found.
|
||||
In older versions, file names could not be specified via symbols,
|
||||
but had to be given as string literals in quotes:
|
||||
Either as "path/to/file" for lookups in the current directory or
|
||||
as <path/to/file> for lookups in the library.
|
||||
So if the first character is neither '<' nor '"' this error was
|
||||
generated.
|
||||
|
||||
Force bits can only be given to counters, not when iterating over string/list contents.
|
||||
You used a force bit with a "!for" loop counter, but then used the
|
||||
|
||||
+37
-26
@@ -929,6 +929,34 @@ static int read_filename_shared_end(boolean *absolute)
|
||||
return 0; // ok
|
||||
}
|
||||
|
||||
// parse string and return in GlobalDynaBuf
|
||||
static int get_string(void)
|
||||
{
|
||||
struct object object;
|
||||
|
||||
if (config.dialect >= V0_97__BACKSLASH_ESCAPING) {
|
||||
// since v0.97 the expression parser supports string objects:
|
||||
ALU_any_result(&object);
|
||||
if (object.type == &type_string) {
|
||||
dynabuf_clear(GlobalDynaBuf);
|
||||
dynabuf_add_bytes(GlobalDynaBuf, object.u.string->payload, object.u.string->length);
|
||||
} else {
|
||||
throw_error("Expression did not return a string.");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
// in older versions, strings could only be given as literals:
|
||||
if (GotByte != '"') {
|
||||
throw_error("Quotes not found.");
|
||||
return 1;
|
||||
}
|
||||
if (input_read_string_literal('"')) {
|
||||
return 1; // unterminated or escaping error
|
||||
}
|
||||
}
|
||||
return 0; // ok
|
||||
}
|
||||
|
||||
// try to read a file name for an input file.
|
||||
// library access by using <...> quoting is allowed.
|
||||
// flags for "library access" and "absolute path" will be set accordingly.
|
||||
@@ -942,30 +970,16 @@ int input_read_input_filename(struct filespecflags *flags)
|
||||
{
|
||||
SKIPSPACE();
|
||||
if (GotByte == '<') {
|
||||
// library access:
|
||||
// <path/to/file> means library access:
|
||||
flags->uses_lib = TRUE;
|
||||
// read file name string (must be a single string <literal>)
|
||||
if (input_read_string_literal('>'))
|
||||
return 1; // unterminated or escaping error
|
||||
|
||||
} else {
|
||||
// "normal", non-library access:
|
||||
// "path/to/file" or SOME_STRING_SYMBOL means non-library access:
|
||||
flags->uses_lib = FALSE;
|
||||
// old algo (do not merge with similar parts from "if" block!):
|
||||
if (GotByte != '"') {
|
||||
throw_error("File name quotes not found (\"\" or <>).");
|
||||
return 1; // error
|
||||
}
|
||||
// read file name string
|
||||
if (input_read_string_literal('"'))
|
||||
return 1; // unterminated or escaping error
|
||||
|
||||
// new algo: (FIXME)
|
||||
// it should be possible to construct the name of input file from symbols, so
|
||||
// build environments can define a name at one place and use it at another.
|
||||
// FIXME - use expression parser to read filename string!
|
||||
if (get_string())
|
||||
return 1; // unterminated, escaping error or not a string
|
||||
}
|
||||
|
||||
// check length, remember abs/rel, terminate, do platform conversion
|
||||
return read_filename_shared_end(&flags->absolute);
|
||||
}
|
||||
@@ -1075,20 +1089,17 @@ int input_read_output_filename(void)
|
||||
|
||||
SKIPSPACE();
|
||||
if (GotByte == '<') {
|
||||
// <path/to/file> means library access:
|
||||
throw_error("Writing to library not supported.");
|
||||
return 1; // error
|
||||
}
|
||||
if (GotByte != '"') {
|
||||
throw_error("File name quotes not found (\"\").");
|
||||
return 1; // error
|
||||
}
|
||||
// we expect "path/to/file" or SOME_STRING_SYMBOL:
|
||||
// in the past, output filenames had to be given as literals and could not be
|
||||
// created dynamically at runtime. because this "security feature" can now be
|
||||
// circumvented using the symbol expansion mechanism, it does not make sense to
|
||||
// keep it: it would only add complexity.
|
||||
// FIXME!
|
||||
if (input_read_string_literal('"'))
|
||||
return 1; // unterminated or escaping error
|
||||
// keep it, it would only add complexity.
|
||||
if (get_string())
|
||||
return 1; // unterminated, escaping error or not a string
|
||||
|
||||
// check length, remember abs/rel, terminate, do platform conversion:
|
||||
if (read_filename_shared_end(&absolute))
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.97" // update before release FIXME
|
||||
#define CODENAME "Zem" // update before release
|
||||
#define CHANGE_DATE "22 Oct" // update before release FIXME
|
||||
#define CHANGE_DATE "26 Oct" // 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
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
*=$1000
|
||||
!fill 3, [0] ; -> "Expression did not return a number."
|
||||
@@ -0,0 +1,2 @@
|
||||
*=$1000
|
||||
!sl 3 ; -> "Expression did not return a string."
|
||||
@@ -0,0 +1,2 @@
|
||||
*=$1000
|
||||
!sl 4.5 ; -> "Expression did not return a string."
|
||||
@@ -0,0 +1,2 @@
|
||||
*=$1000
|
||||
!sl [0] ; -> "Expression did not return a string."
|
||||
Reference in New Issue
Block a user