USE_UTF32 define removed; deprecated code paths for non UTF8<->UTF32 removed from nga-c

FossilOrigin-Name: c401c458e2d74e9c142437055363f89bfff2056cada15dc6e5dde3856ce5b0cb
This commit is contained in:
crc 2024-01-10 22:10:12 +00:00
parent 374434eb40
commit 1632155687
4 changed files with 2 additions and 52 deletions

View file

@ -28,7 +28,6 @@ LIBDL ?=
# -------------------------------------------------------------
OPTIONS ?=
OPTIONS += -DUSE_UTF32
OPTIONS += -DBIT64
# This helps improve performance on some systems.

View file

@ -26,13 +26,8 @@
- nga-c
- use UTF32 internally (translating to/from UTF8 externally)
Future Notes
In 2023.9 the nga-c implementation added support (enabled by
default) for using UTF32 (translating incoming source and output
between UTF8 and UTF32 transparently). The fallback option (to
just read raw 8-bit values) is now considered deprecated and
will be removed in the future (assuming no bug reports relating
to the UTF32 conversions are reported).
================================================================

View file

@ -240,7 +240,6 @@ V file_write_bytes(NgaState *vm) {
}
V file_read_character(NgaState *vm) {
#ifdef USE_UTF32
CELL c;
CELL slot = stack_pop(vm);
if (slot <= 0 || slot > MAX_OPEN_FILES || vm->OpenFileHandles[slot] == 0) {
@ -249,13 +248,9 @@ V file_read_character(NgaState *vm) {
}
c = fread_character(vm->OpenFileHandles[slot]);
stack_push(vm, feof(vm->OpenFileHandles[slot]) ? 0 : c);
#else
file_read(vm);
#endif
}
V file_write_character(NgaState *vm) {
#ifdef USE_UTF32
unsigned char utf8_bytes[4];
int num_bytes;
CELL slot, c, r;
@ -266,9 +261,6 @@ V file_write_character(NgaState *vm) {
exit(1);
}
r = fwrite(&utf8_bytes, num_bytes, 1, vm->OpenFileHandles[slot]);
#else
file_write(vm);
#endif
}
V file_read_line(NgaState *vm) {
@ -279,7 +271,6 @@ V file_read_line(NgaState *vm) {
printf("\nERROR (nga/file_read): Invalid file handle\n");
exit(1);
}
#ifdef USE_UTF32
c = fread_character(vm->OpenFileHandles[slot]);
vm->memory[targ] = c;
targ++;
@ -289,17 +280,6 @@ V file_read_line(NgaState *vm) {
targ++;
}
vm->memory[targ - 1] = 0;
#else
c = fgetc(vm->OpenFileHandles[slot]);
vm->memory[targ] = c;
targ++;
while (c != 10 && c != 13 && c != 0) {
c = fgetc(vm->OpenFileHandles[slot]);
vm->memory[targ] = c;
targ++;
}
vm->memory[targ - 1] = 0;
#endif
}
V file_write_line(NgaState *vm) {

View file

@ -330,7 +330,6 @@ V guard(NgaState *vm, int n, int m, int diff) {
/*---------------------------------------------------------------------
Now on to I/O and extensions!
---------------------------------------------------------------------*/
#ifdef USE_UTF32
V display_utf8(const unsigned char* utf8_bytes, int num_bytes) {
if (write(STDOUT_FILENO, utf8_bytes, num_bytes) == -1) {
perror("Error writing to /dev/stdout");
@ -360,17 +359,12 @@ V utf32_to_utf8(uint32_t utf32_char, unsigned char* utf8_bytes, int* num_bytes)
*num_bytes = 0;
}
}
#endif
V io_output(NgaState *vm) {
#ifdef USE_UTF32
unsigned char utf8_bytes[4];
int num_bytes;
utf32_to_utf8(stack_pop(vm), utf8_bytes, &num_bytes);
display_utf8(utf8_bytes, num_bytes);
#else
putc(stack_pop(vm), stdout);
#endif
fflush(stdout);
}
@ -382,7 +376,6 @@ V query_output(NgaState *vm) {
/*=====================================================================*/
#ifdef USE_UTF32
int read_character(int from) {
unsigned char utf8_bytes[4] = { 0 };
int utf32_char, i, num_bytes;
@ -468,14 +461,9 @@ int fread_character(FILE *from) {
}
return utf32_char;
}
#endif
V io_keyboard(NgaState *vm) {
#ifdef USE_UTF32
stack_push(vm, read_character(STDIN_FILENO));
#else
stack_push(vm, getc(stdin));
#endif
if (TOS == 127) TOS = 8;
}
@ -714,11 +702,7 @@ int not_eol(int c) {
}
V read_token(FILE *file, char *token_buffer) {
#ifdef USE_UTF32
int ch = fread_character(file);
#else
int ch = getc(file);
#endif
int count = 0;
while (not_eol(ch)) {
if ((ch == 8 || ch == 127) && count > 0) {
@ -726,11 +710,7 @@ V read_token(FILE *file, char *token_buffer) {
} else {
token_buffer[count++] = ch;
}
#ifdef USE_UTF32
ch = fread_character(file);
#else
ch = getc(file);
#endif
}
token_buffer[count] = '\0';
}
@ -820,11 +800,7 @@ V read_line(NgaState *vm, FILE *file, char *token_buffer) {
token_buffer[0] = '\0';
while ((ch != 10) && (ch != 13) && (ch != EOF) && (ch != 0)) {
token_buffer[count++] = ch;
#ifdef USE_UTF32
ch = fread_character(file);
#else
ch = getc(file);
#endif
}
token_buffer[count] = '\0';
}