mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-01-10 21:30:30 +00:00
"!warn" and friends now support list and string symbols
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@191 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
98ae73381d
commit
bc0cd5b8ea
27
src/alu.c
27
src/alu.c
@ -392,8 +392,8 @@ static void string_init_string(struct object *self, const char *data, int len)
|
||||
self->type = &type_string;
|
||||
self->u.string = safe_malloc(sizeof(*(self->u.string)) + len);
|
||||
memcpy(self->u.string->payload, data, len);
|
||||
self->u.string->payload[len] = 0; // terminate (just for easier printf-debugging)
|
||||
self->u.string->length = len;
|
||||
self->u.string->payload[len] = 0; // terminate, to facilitate string_print()
|
||||
self->u.string->length = len; // length does not include the added terminator
|
||||
self->u.string->refs = 1;
|
||||
}
|
||||
// parse string or character
|
||||
@ -1744,20 +1744,29 @@ static void float_print(struct object *self, struct dynabuf *db)
|
||||
// print value for user message
|
||||
static void list_print(struct object *self, struct dynabuf *db)
|
||||
{
|
||||
char buffer[64]; // 20 + 2*20 for 64-bit numbers, 64 bytes should be enough for anybody
|
||||
struct listitem *item;
|
||||
int length;
|
||||
struct object *obj;
|
||||
const char *prefix = ""; // first item does not get a prefix
|
||||
|
||||
sprintf(buffer, "<LIST (len %ld, refs %ld)>", (long) self->u.listhead->length, (long) self->u.listhead->refs);
|
||||
DynaBuf_add_string(db, buffer);
|
||||
DynaBuf_append(db, '[');
|
||||
length = self->u.listhead->length;
|
||||
item = self->u.listhead->next;
|
||||
while (length--) {
|
||||
obj = &item->payload;
|
||||
DynaBuf_add_string(db, prefix);
|
||||
obj->type->print(obj, db);
|
||||
item = item->next;
|
||||
prefix = ", "; // following items are prefixed
|
||||
}
|
||||
DynaBuf_append(db, ']');
|
||||
}
|
||||
|
||||
// string:
|
||||
// print value for user message
|
||||
static void string_print(struct object *self, struct dynabuf *db)
|
||||
{
|
||||
char buffer[64]; // 20 + 2*20 for 64-bit numbers, 64 bytes should be enough for anybody
|
||||
|
||||
sprintf(buffer, "<STRING (len %ld, refs %ld)>", (long) self->u.string->length, (long) self->u.string->refs);
|
||||
DynaBuf_add_string(db, buffer);
|
||||
DynaBuf_add_string(db, self->u.string->payload); // there is a terminator after the actual payload, so this works
|
||||
}
|
||||
|
||||
struct type type_int = {
|
||||
|
17
src/input.c
17
src/input.c
@ -341,7 +341,7 @@ void Input_ensure_EOS(void) // Now GotByte = first char to test
|
||||
char quote; // character before and after
|
||||
|
||||
quote = (GotByte == '\'') ? '"' : '\''; // use single quotes, unless byte is a single quote (then use double quotes)
|
||||
sprintf(buf, "Garbage data at end of statement (unexpected %c%c%c).", quote, GotByte, quote); // FIXME - change in docs!
|
||||
sprintf(buf, "Garbage data at end of statement (unexpected %c%c%c).", quote, GotByte, quote);
|
||||
Throw_error(buf);
|
||||
Input_skip_remainder();
|
||||
}
|
||||
@ -556,8 +556,8 @@ int Input_read_filename(boolean allow_library, boolean *uses_lib)
|
||||
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
SKIPSPACE();
|
||||
// check for library access
|
||||
if (GotByte == '<') {
|
||||
switch (GotByte) {
|
||||
case '<': // library access
|
||||
if (uses_lib)
|
||||
*uses_lib = TRUE;
|
||||
// if library access forbidden, complain
|
||||
@ -578,14 +578,15 @@ int Input_read_filename(boolean allow_library, boolean *uses_lib)
|
||||
// copy lib path and set quoting char
|
||||
DynaBuf_add_string(GlobalDynaBuf, lib_prefix);
|
||||
terminator = '>';
|
||||
} else {
|
||||
break;
|
||||
case '"': // normal access
|
||||
if (uses_lib)
|
||||
*uses_lib = FALSE;
|
||||
if (GotByte != '"') {
|
||||
Throw_error("File name quotes not found (\"\" or <>).");
|
||||
return 1; // error
|
||||
}
|
||||
terminator = '"';
|
||||
break;
|
||||
default: // none of the above
|
||||
Throw_error("File name quotes not found (\"\" or <>).");
|
||||
return 1; // error
|
||||
}
|
||||
// remember border between optional library prefix and string from assembler source file
|
||||
start_of_string = GlobalDynaBuf->size;
|
||||
|
@ -356,13 +356,14 @@ static enum eos po_convtab(void)
|
||||
FILE *stream;
|
||||
|
||||
if ((GotByte == '<') || (GotByte == '"')) {
|
||||
// if file name is missing, don't bother continuing
|
||||
// encoding table from file
|
||||
if (Input_read_filename(TRUE, &uses_lib))
|
||||
return SKIP_REMAINDER;
|
||||
return SKIP_REMAINDER; // missing or unterminated file name
|
||||
|
||||
stream = includepaths_open_ro(uses_lib);
|
||||
return user_defined_encoding(stream);
|
||||
} else {
|
||||
// one of the pre-defined encodings
|
||||
return predefined_encoding();
|
||||
}
|
||||
}
|
||||
@ -376,7 +377,7 @@ static enum eos encode_string(const struct encoder *inner_encoder, char xor)
|
||||
// make given encoder the current one (for ALU-parsed values)
|
||||
encoder_current = inner_encoder;
|
||||
do {
|
||||
if (GotByte == '"') {
|
||||
if (GotByte == '"') { // FIXME - add "&& !config.backslash_escaping", otherwise stuff like "string"[index] will not work
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
if (Input_quoted_to_dynabuf('"'))
|
||||
return SKIP_REMAINDER; // unterminated or escaping error
|
||||
@ -396,6 +397,9 @@ static enum eos encode_string(const struct encoder *inner_encoder, char xor)
|
||||
// temporarily set to the given one.
|
||||
ALU_any_int(&value);
|
||||
output_8(value);
|
||||
// FIXME - call ALU_any_result(FLOAT2INT) instead and support lists and strings:
|
||||
// for lists, call some list_iter() fn to handle components
|
||||
// for strings, do not forget to XOR!
|
||||
}
|
||||
} while (Input_accept_comma());
|
||||
encoder_current = outer_encoder; // reactivate buffered encoder
|
||||
@ -1170,7 +1174,7 @@ static enum eos throw_string(const char prefix[], void (*fn)(const char *))
|
||||
DYNABUF_CLEAR(user_message);
|
||||
DynaBuf_add_string(user_message, prefix);
|
||||
do {
|
||||
if (GotByte == '"') {
|
||||
if ((GotByte == '"') && !config.backslash_escaping) {
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
if (Input_quoted_to_dynabuf('"'))
|
||||
return SKIP_REMAINDER; // unterminated or escaping error
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.96.5" // update before release FIXME
|
||||
#define CODENAME "Fenchurch" // update before release
|
||||
#define CHANGE_DATE "24 May" // update before release FIXME
|
||||
#define CHANGE_DATE "26 May" // update before release FIXME
|
||||
#define CHANGE_YEAR "2020" // 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