From e6028806a0fc29ec8382a028eb627b796d776a43 Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 14:18:33 +0200 Subject: [PATCH 1/9] Fix libltdl workaround for NetBSD --- main/configure.ac | 2 +- main/gbc/gbi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/configure.ac b/main/configure.ac index ec8af9460..ee06a6cb0 100644 --- a/main/configure.ac +++ b/main/configure.ac @@ -97,7 +97,7 @@ GB_COMPONENT( dnl ---- We do not use libtool to load shared libraries anymore! AC_DEFINE(DONT_USE_LTDL, 1, [Do not use libtool to load shared libraries]) -if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD"; then +if test "$SYSTEM" != "OPENBSD" && test "$SYSTEM" != "FREEBSD" && test "$SYSTEM" != "NETBSD"; then DL_LIB="-ldl" else DL_LIB="" diff --git a/main/gbc/gbi.c b/main/gbc/gbi.c index 547260b26..a369872fc 100644 --- a/main/gbc/gbi.c +++ b/main/gbc/gbi.c @@ -45,7 +45,7 @@ #include -#if defined(OS_LINUX) || defined(OS_GNU) || defined(OS_OPENBSD) || defined(OS_FREEBSD) || defined(OS_CYGWIN) +#ifdef DONT_USE_LTDL #define lt_dlinit() (0) #define lt_dlhandle void * #define lt_dlopenext(_path) dlopen(_path, RTLD_LAZY) From a3df7692685b388df4886ae361b9b9e5ed7c2d61 Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 14:29:54 +0200 Subject: [PATCH 2/9] Use sys/ioctl.h instead of pty.h pty.h is not needed because its functions are not used. Use ioctl.h additionally to the already included termios.h to import the implicitly used functions/constants. --- main/gbx/gbx_c_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index 8845c7cf3..aeb3447e8 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include "gb_common.h" From e74adab7c5e32c9fb65ac7fa554fc0ee706667ac Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 15:36:25 +0200 Subject: [PATCH 3/9] Use FreeBSD exp10() fix for all BSDs [INTERPRETER] * BUG: The exp10() function works on all BSDs now --- main/gbx/gbx_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/gbx/gbx_math.h b/main/gbx/gbx_math.h index 10d7f1a1a..a01114850 100644 --- a/main/gbx/gbx_math.h +++ b/main/gbx/gbx_math.h @@ -26,7 +26,7 @@ #include "config.h" -#ifdef OS_FREEBSD +#ifdef OS_BSD #undef HAVE_EXP10 #endif From bb8106cebddaeb33dc61b10ad84a27e8684c4b06 Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 19:50:41 +0200 Subject: [PATCH 4/9] Fix local variable conflict for older compilers [GB.NCURSES] * Fix local variable conflict for older compilers --- gb.ncurses/src/c_input.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gb.ncurses/src/c_input.c b/gb.ncurses/src/c_input.c index 7d8b21de2..384fe0009 100644 --- a/gb.ncurses/src/c_input.c +++ b/gb.ncurses/src/c_input.c @@ -102,22 +102,22 @@ void INPUT_drain() flushinp(); } -static int INPUT_get_ncurses(int timeout) +static int INPUT_get_ncurses(int time_out) { int ret; - if (timeout >= 0) - timeout(timeout); + if (time_out >= 0) + timeout(time_out); ret = getch(); if (ret == ERR) { /* Had a timeout, the manual doesn't define any errors to happen for wgetch() besides NULL pointer arguments. The only source of ERR is timeout expired. */ - if (timeout >= 0) + if (time_out >= 0) ret = 0; } - if (timeout >= 0) + if (time_out >= 0) timeout(-1); return ret; } From 9e980453637e49675634cb1ac680a1cef52556c1 Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 23:22:44 +0200 Subject: [PATCH 5/9] [GB.PDF] Compile with C++ 11 [GB.PDF] * BUG: Compile with C++ 11 which is needed by current poppler versions --- gb.pdf/src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/gb.pdf/src/Makefile.am b/gb.pdf/src/Makefile.am index 418dbec86..f23192a43 100644 --- a/gb.pdf/src/Makefile.am +++ b/gb.pdf/src/Makefile.am @@ -5,6 +5,7 @@ gblib_LTLIBRARIES = gb.pdf.la gb_pdf_la_LIBADD = @POPPLER_LIB@ gb_pdf_la_LDFLAGS = -module @LD_FLAGS@ @POPPLER_LDFLAGS@ +gb_pdf_la_CXXFLAGS = $(AM_CXXFLAGS) -std=c++11 gb_pdf_la_CPPFLAGS = @POPPLER_INC@ gb_pdf_la_SOURCES = main.h main.cpp \ From b1a12236ade61dde06100db7693a46c5d3eb58a3 Mon Sep 17 00:00:00 2001 From: bgermann Date: Wed, 29 Aug 2018 23:59:11 +0200 Subject: [PATCH 6/9] Convert from statfs to more portable statvfs [INTERPRETER] * NEW: Convert from statfs to more portable statvfs --- main/gbx/gbx_c_file.c | 8 ++++---- main/gbx/gbx_stream.c | 4 ++-- main/gbx/gbx_stream.h | 6 +++--- main/gbx/gbx_stream_buffer.c | 4 ++-- main/gbx/gbx_stream_direct.c | 8 ++++---- main/gbx/gbx_stream_memory.c | 2 +- main/gbx/gbx_stream_pipe.c | 2 +- main/gbx/gbx_stream_string.c | 2 +- main/gbx/gbx_subr_file.c | 2 +- main/share/gb_file_temp.h | 10 +++------- 10 files changed, 22 insertions(+), 26 deletions(-) diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index aeb3447e8..a849e2102 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -98,7 +98,7 @@ static void watch_stream(CSTREAM *_object, int mode, bool on) if (mode & ST_READ) GB_Watch(fd, GB_WATCH_READ, (void *)(on ? callback_read : NULL), (intptr_t)THIS); - if (mode & ST_WRITE) + if (mode & ST_WRIT) GB_Watch(fd, GB_WATCH_WRITE, (void *)(on ? callback_write : NULL), (intptr_t)THIS); } @@ -143,8 +143,8 @@ static CFILE *create_default_stream(FILE *file, int mode) void CFILE_init(void) { CFILE_in = create_default_stream(stdin, ST_READ); - CFILE_out = create_default_stream(stdout, ST_WRITE); - CFILE_err = create_default_stream(stderr, ST_WRITE); + CFILE_out = create_default_stream(stdout, ST_WRIT); + CFILE_err = create_default_stream(stderr, ST_WRIT); } void CFILE_exit(void) @@ -860,7 +860,7 @@ BEGIN_METHOD(Stream_Watch, GB_INTEGER mode; GB_BOOLEAN on) if (mode == R_OK) mode = ST_READ; else if (mode == W_OK) - mode = ST_WRITE; + mode = ST_WRIT; else { GB_Error("Unknown watch"); diff --git a/main/gbx/gbx_stream.c b/main/gbx/gbx_stream.c index e2797eedd..8c014a3df 100644 --- a/main/gbx/gbx_stream.c +++ b/main/gbx/gbx_stream.c @@ -956,7 +956,7 @@ static STREAM *enter_temp_stream(STREAM *stream) _temp_level = 0; if (_temp_stream.type) STREAM_close(&_temp_stream); - STREAM_open(&_temp_stream, NULL, ST_STRING | ST_WRITE); + STREAM_open(&_temp_stream, NULL, ST_STRING | ST_WRIT); } _temp_level++; @@ -1807,7 +1807,7 @@ void STREAM_begin(STREAM *stream) if (!stream->common.redirect) { ALLOC_ZERO(&stream->common.redirect, sizeof(STREAM)); - STREAM_open(stream->common.redirect, NULL, ST_STRING | ST_WRITE); + STREAM_open(stream->common.redirect, NULL, ST_STRING | ST_WRIT); } stream->common.redirected = TRUE; diff --git a/main/gbx/gbx_stream.h b/main/gbx/gbx_stream.h index 679c1b76c..fa08eac1a 100644 --- a/main/gbx/gbx_stream.h +++ b/main/gbx/gbx_stream.h @@ -146,10 +146,10 @@ typedef enum { ST_READ = (1 << 0), - ST_WRITE = (1 << 1), - ST_READ_WRITE = ST_READ + ST_WRITE, + ST_WRIT = (1 << 1), + ST_READ_WRITE = ST_READ + ST_WRIT, ST_MODE = 0x3, - ST_APPEND = (1 << 2), + ST_APPENDING = (1 << 2), ST_CREATE = (1 << 3), ST_ACCESS = 0xF, ST_DIRECT = (1 << 4), diff --git a/main/gbx/gbx_stream_buffer.c b/main/gbx/gbx_stream_buffer.c index 3f702f13a..727c37d53 100644 --- a/main/gbx/gbx_stream_buffer.c +++ b/main/gbx/gbx_stream_buffer.c @@ -51,9 +51,9 @@ static int stream_open(STREAM *stream, const char *path, int mode) if (mode & ST_CREATE) fmode = "w+"; - else if (mode & ST_APPEND) + else if (mode & ST_APPENDING) fmode = "a+"; - else if (mode & ST_WRITE) + else if (mode & ST_WRIT) fmode = "r+"; else fmode = "r"; diff --git a/main/gbx/gbx_stream_direct.c b/main/gbx/gbx_stream_direct.c index c0ef4983d..a870280ea 100644 --- a/main/gbx/gbx_stream_direct.c +++ b/main/gbx/gbx_stream_direct.c @@ -51,7 +51,7 @@ static int stream_open(STREAM *stream, const char *path, int mode) if (mode & ST_CREATE) fmode = O_CREAT | O_TRUNC; // | O_EXCL; - else if (mode & ST_APPEND) + else if (mode & ST_APPENDING) fmode = O_APPEND | O_CREAT; else fmode = 0; @@ -59,14 +59,14 @@ static int stream_open(STREAM *stream, const char *path, int mode) switch (mode & ST_MODE) { case ST_READ: fmode |= O_RDONLY; break; - case ST_WRITE: fmode |= O_WRONLY; break; + case ST_WRIT: fmode |= O_WRONLY; break; case ST_READ_WRITE: fmode |= O_RDWR; break; default: fmode |= O_RDONLY; } if (path[0] == '.' && isdigit(path[1])) { - if ((mode & ST_CREATE) || (mode & ST_APPEND)) + if ((mode & ST_CREATE) || (mode & ST_APPENDING)) THROW(E_ACCESS); if (NUMBER_from_string(NB_READ_INTEGER, &path[1], strlen(path) - 1, &val) || val._integer.value < 0) @@ -81,7 +81,7 @@ static int stream_open(STREAM *stream, const char *path, int mode) return TRUE; if (((mode & ST_MODE) == ST_READ && (omode & O_ACCMODE) == O_WRONLY) - || ((mode & ST_MODE) == ST_WRITE && (omode & O_ACCMODE) == O_RDONLY) + || ((mode & ST_MODE) == ST_WRIT && (omode & O_ACCMODE) == O_RDONLY) || ((mode & ST_MODE) == ST_READ_WRITE && (omode & O_ACCMODE) != O_RDWR)) THROW(E_ACCESS); diff --git a/main/gbx/gbx_stream_memory.c b/main/gbx/gbx_stream_memory.c index 57d52e51e..ae7312c82 100644 --- a/main/gbx/gbx_stream_memory.c +++ b/main/gbx/gbx_stream_memory.c @@ -96,7 +96,7 @@ static int stream_read(STREAM *stream, char *buffer, int len) static int stream_write(STREAM *stream, char *buffer, int len) { - if ((stream->common.mode & ST_WRITE) == 0) + if ((stream->common.mode & ST_WRIT) == 0) THROW(E_ACCESS); CHECK_enter(); diff --git a/main/gbx/gbx_stream_pipe.c b/main/gbx/gbx_stream_pipe.c index f0db2c9f3..7cc475dbd 100644 --- a/main/gbx/gbx_stream_pipe.c +++ b/main/gbx/gbx_stream_pipe.c @@ -57,7 +57,7 @@ static int stream_open(STREAM *stream, const char *path, int mode) switch (mode & ST_MODE) { case ST_READ: fmode |= O_RDONLY; break; - case ST_WRITE: fmode |= O_WRONLY; break; + case ST_WRIT: fmode |= O_WRONLY; break; case ST_READ_WRITE: fmode |= O_RDWR; break; default: fmode |= O_RDONLY; } diff --git a/main/gbx/gbx_stream_string.c b/main/gbx/gbx_stream_string.c index f556955ca..e7ce1a0a7 100644 --- a/main/gbx/gbx_stream_string.c +++ b/main/gbx/gbx_stream_string.c @@ -81,7 +81,7 @@ static int stream_read(STREAM *stream, char *buffer, int len) static int stream_write(STREAM *stream, char *buffer, int len) { - if ((stream->common.mode & ST_WRITE) == 0) + if ((stream->common.mode & ST_WRIT) == 0) THROW(E_ACCESS); stream->string.buffer = STRING_add(stream->string.buffer, buffer, len); diff --git a/main/gbx/gbx_subr_file.c b/main/gbx/gbx_subr_file.c index 8f35a2b8c..14fb8a71c 100755 --- a/main/gbx/gbx_subr_file.c +++ b/main/gbx/gbx_subr_file.c @@ -225,7 +225,7 @@ void SUBR_open(ushort code) { str = SUBR_get_string(PARAM); - if (mode & ST_WRITE) + if (mode & ST_WRIT) { stream.string.buffer = STRING_new(str, STRING_length(str)); } diff --git a/main/share/gb_file_temp.h b/main/share/gb_file_temp.h index 72165a44d..d7edb01a8 100644 --- a/main/share/gb_file_temp.h +++ b/main/share/gb_file_temp.h @@ -39,11 +39,7 @@ #ifdef PROJECT_EXEC -#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -#include -#else -#include -#endif +#include #include #include @@ -1082,12 +1078,12 @@ void FILE_link(const char *src, const char *dst) int64_t FILE_free(const char *path) { - struct statfs info; + struct statvfs info; if (FILE_is_relative(path)) return 0; - statfs(path, &info); + statvfs(path, &info); return (int64_t)(getuid() == 0 ? info.f_bfree : info.f_bavail) * info.f_bsize; } From 3685f21cbf773fb04df2248b4c1791d88fffcd18 Mon Sep 17 00:00:00 2001 From: bgermann Date: Thu, 30 Aug 2018 09:35:44 +0200 Subject: [PATCH 7/9] [GB.TERM] Compatiblitity with NetBSD [GB.TERM] * NEW: Compatiblitity with NetBSD --- main/lib/term/cterm.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/main/lib/term/cterm.c b/main/lib/term/cterm.c index cd5039767..97444e52b 100644 --- a/main/lib/term/cterm.c +++ b/main/lib/term/cterm.c @@ -157,26 +157,30 @@ IMPLEMENT_TSP(ISTRIP, c_iflag) IMPLEMENT_TSP(INLCR, c_iflag) IMPLEMENT_TSP(IGNCR, c_iflag) IMPLEMENT_TSP(ICRNL, c_iflag) -IMPLEMENT_TSP(IUCLC, c_iflag) IMPLEMENT_TSP(IXON, c_iflag) IMPLEMENT_TSP(IXANY, c_iflag) IMPLEMENT_TSP(IXOFF, c_iflag) +#ifndef OS_BSD +IMPLEMENT_TSP(IUCLC, c_iflag) IMPLEMENT_TSP(IUTF8, c_iflag) -IMPLEMENT_TSP(OPOST, c_oflag) IMPLEMENT_TSP(OLCUC, c_oflag) +IMPLEMENT_TSP(OFILL, c_oflag) +#endif +IMPLEMENT_TSP(OPOST, c_oflag) IMPLEMENT_TSP(ONLCR, c_oflag) IMPLEMENT_TSP(OCRNL, c_oflag) IMPLEMENT_TSP(ONOCR, c_oflag) IMPLEMENT_TSP(ONLRET, c_oflag) -IMPLEMENT_TSP(OFILL, c_oflag) +#ifndef OS_BSD IMPLEMENT_TSP_I(NLDLY, c_oflag) IMPLEMENT_TSP_I(CRDLY, c_oflag) IMPLEMENT_TSP_I(TABDLY, c_oflag) IMPLEMENT_TSP_I(BSDLY, c_oflag) IMPLEMENT_TSP_I(VTDLY, c_oflag) IMPLEMENT_TSP_I(FFDLY, c_oflag) +#endif IMPLEMENT_TSP_I(CSIZE, c_cflag) IMPLEMENT_TSP(CSTOPB, c_cflag) @@ -200,9 +204,11 @@ IMPLEMENT_TSP(NOFLSH, c_lflag) IMPLEMENT_TSP(TOSTOP, c_lflag) IMPLEMENT_TSP(IEXTEN, c_lflag) -#ifndef OS_CYGWIN +#ifdef OS_LINUX IMPLEMENT_TSP(CMSPAR, c_cflag) IMPLEMENT_TSP(XCASE, c_lflag) +#endif +#ifndef OS_CYGWIN IMPLEMENT_TSP(ECHOPRT, c_lflag) IMPLEMENT_TSP(PENDIN, c_lflag) #endif @@ -327,15 +333,19 @@ GB_DESC TermDesc[] = __TC(TCIFLUSH), __TC(TCOFLUSH), __TC(TCIOFLUSH), __TC(TCIOFF), __TC(TCION), __TC(TCOOFF), __TC(TCOON), - +#ifndef OS_BSD __TC(NL0), __TC(NL1), __TC(CR0), __TC(CR1), __TC(CR2), __TC(CR3), __TC(TAB0), __TC(TAB1), __TC(TAB2), __TC(TAB3), __TC(XTABS), __TC(BS0), __TC(BS1), __TC(VT0), __TC(VT1), __TC(FF0), __TC(FF1), - +#endif __TC(CS5), __TC(CS6), __TC(CS7), __TC(CS8), GB_CONSTANT("VDISABLE", "i", _POSIX_VDISABLE), - __TC(B0), __TC(B50), __TC(B75), __TC(B110), __TC(B134), __TC(B150), __TC(B200), __TC(B300), __TC(B600), __TC(B1200), __TC(B1800), __TC(B2400), __TC(B4800), __TC(B9600), __TC(B19200), __TC(B38400), __TC(B57600), __TC(B115200), __TC(B230400), __TC(B460800), __TC(B500000), __TC(B576000), __TC(B921600), __TC(B1000000), __TC(B1152000), __TC(B1500000), __TC(B2000000), __TC(B2500000), __TC(B3000000), -#ifndef OS_CYGWIN + __TC(B0), __TC(B50), __TC(B75), __TC(B110), __TC(B134), __TC(B150), __TC(B200), __TC(B300), __TC(B600), __TC(B1200), __TC(B1800), __TC(B2400), __TC(B4800), __TC(B9600), __TC(B19200), __TC(B38400), __TC(B57600), __TC(B115200), __TC(B230400), __TC(B460800), + +#ifndef OS_BSD +__TC(B500000), __TC(B576000), __TC(B921600), __TC(B1000000), __TC(B1152000), __TC(B1500000), __TC(B2000000), __TC(B2500000), __TC(B3000000), +#endif +#ifdef OS_LINUX __TC(B3500000), __TC(B4000000), #endif @@ -359,26 +369,30 @@ GB_DESC TerminalSettingsDesc[] = __TSP(INLCR), __TSP(IGNCR), __TSP(ICRNL), - __TSP(IUCLC), __TSP(IXON), __TSP(IXANY), __TSP(IXOFF), +#ifndef OS_BSD + __TSP(IUCLC), __TSP(IUTF8), - - __TSP(OPOST), + __TSP(OLCUC), + __TSP(OFILL), +#endif + __TSP(OPOST), __TSP(ONLCR), __TSP(OCRNL), __TSP(ONOCR), __TSP(ONLRET), - __TSP(OFILL), +#ifndef OS_BSD __TSP_I(NLDLY), __TSP_I(CRDLY), __TSP_I(TABDLY), __TSP_I(BSDLY), __TSP_I(VTDLY), __TSP_I(FFDLY), +#endif __TSP_I(CSIZE), __TSP(CSTOPB), @@ -402,9 +416,11 @@ GB_DESC TerminalSettingsDesc[] = __TSP(TOSTOP), __TSP(IEXTEN), -#ifndef OS_CYGWIN +#ifdef OS_LINUX __TSP(CMSPAR), __TSP(XCASE), +#endif +#ifndef OS_CYGWIN __TSP(ECHOPRT), __TSP(PENDIN), #endif From 3e6d969613efb1aa4f7c0b1fb8c9a6a74fb7bc3c Mon Sep 17 00:00:00 2001 From: bgermann Date: Thu, 30 Aug 2018 13:33:13 +0200 Subject: [PATCH 8/9] Change enum prefix that collides with statvfs --- main/gbx/gbx_api.c | 4 ++-- main/gbx/gbx_c_file.c | 20 ++++++++++---------- main/gbx/gbx_stream.c | 34 +++++++++++++++++----------------- main/gbx/gbx_stream.h | 26 +++++++++++++------------- main/gbx/gbx_stream_arch.c | 2 +- main/gbx/gbx_stream_buffer.c | 6 +++--- main/gbx/gbx_stream_direct.c | 20 ++++++++++---------- main/gbx/gbx_stream_memory.c | 4 ++-- main/gbx/gbx_stream_pipe.c | 8 ++++---- main/gbx/gbx_stream_string.c | 2 +- main/gbx/gbx_subr_file.c | 10 +++++----- main/share/gb_file_temp.h | 4 ++-- 12 files changed, 70 insertions(+), 70 deletions(-) diff --git a/main/gbx/gbx_api.c b/main/gbx/gbx_api.c index 8358a4dcd..329c03f44 100644 --- a/main/gbx/gbx_api.c +++ b/main/gbx/gbx_api.c @@ -2437,7 +2437,7 @@ bool GB_Serialize(const char *path, GB_VALUE *value) CATCH_ERROR { - STREAM_open(&stream, path, ST_CREATE); + STREAM_open(&stream, path, STO_CREATE); STREAM_write_type(&stream, T_VARIANT, (VALUE *)value); STREAM_close(&stream); } @@ -2450,7 +2450,7 @@ bool GB_UnSerialize(const char *path, GB_VALUE *value) CATCH_ERROR { - STREAM_open(&stream, path, ST_READ); + STREAM_open(&stream, path, STO_READ); STREAM_read_type(&stream, T_VARIANT, (VALUE *)value); STREAM_close(&stream); } diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index a849e2102..9d404b4e8 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -95,10 +95,10 @@ static void watch_stream(CSTREAM *_object, int mode, bool on) STREAM *stream = &THIS_STREAM->stream; int fd = STREAM_handle(stream); - if (mode & ST_READ) + if (mode & STO_READ) GB_Watch(fd, GB_WATCH_READ, (void *)(on ? callback_read : NULL), (intptr_t)THIS); - if (mode & ST_WRIT) + if (mode & STO_WRITE) GB_Watch(fd, GB_WATCH_WRITE, (void *)(on ? callback_write : NULL), (intptr_t)THIS); } @@ -112,7 +112,7 @@ CFILE *CFILE_create(STREAM *stream, int mode) *CSTREAM_stream(file) = *stream; //file->watch_fd = -1; - if (mode & ST_WATCH) + if (mode & STO_WATCH) { watch_stream(&file->ob, mode, TRUE); OBJECT_attach((OBJECT *)file, OP ? (OBJECT *)OP : (OBJECT *)CP, "File"); @@ -142,9 +142,9 @@ static CFILE *create_default_stream(FILE *file, int mode) void CFILE_init(void) { - CFILE_in = create_default_stream(stdin, ST_READ); - CFILE_out = create_default_stream(stdout, ST_WRIT); - CFILE_err = create_default_stream(stderr, ST_WRIT); + CFILE_in = create_default_stream(stdin, STO_READ); + CFILE_out = create_default_stream(stdout, STO_WRITE); + CFILE_err = create_default_stream(stderr, STO_WRITE); } void CFILE_exit(void) @@ -621,7 +621,7 @@ BEGIN_METHOD(File_Load, GB_STRING path) int rlen; char *str = NULL; - STREAM_open(&stream, STRING_conv_file_name(STRING(path), LENGTH(path)), ST_READ); + STREAM_open(&stream, STRING_conv_file_name(STRING(path), LENGTH(path)), STO_READ); ON_ERROR_1(error_CFILE_load_save, &stream) { @@ -665,7 +665,7 @@ BEGIN_METHOD(File_Save, GB_STRING path; GB_STRING data) STREAM stream; - STREAM_open(&stream, STRING_conv_file_name(STRING(path), LENGTH(path)), ST_CREATE); + STREAM_open(&stream, STRING_conv_file_name(STRING(path), LENGTH(path)), STO_CREATE); ON_ERROR_1(error_CFILE_load_save, &stream) { @@ -858,9 +858,9 @@ BEGIN_METHOD(Stream_Watch, GB_INTEGER mode; GB_BOOLEAN on) int mode = VARG(mode); if (mode == R_OK) - mode = ST_READ; + mode = STO_READ; else if (mode == W_OK) - mode = ST_WRIT; + mode = STO_WRITE; else { GB_Error("Unknown watch"); diff --git a/main/gbx/gbx_stream.c b/main/gbx/gbx_stream.c index 8c014a3df..d5fc6cfa4 100644 --- a/main/gbx/gbx_stream.c +++ b/main/gbx/gbx_stream.c @@ -168,19 +168,19 @@ void STREAM_open(STREAM *stream, const char *path, int mode) stream->type = NULL; - if (mode & ST_PIPE) + if (mode & STO_PIPE) sclass = &STREAM_pipe; - else if (mode & ST_MEMORY) + else if (mode & STO_MEMORY) sclass = &STREAM_memory; - else if (mode & ST_STRING) + else if (mode & STO_STRING) sclass = &STREAM_string; - else if (mode & ST_LOCK) + else if (mode & STO_LOCK) sclass = &STREAM_lock; else { // ".99" is used for opening a file descriptor in direct mode - if (FILE_is_relative(path) && !((mode & ST_DIRECT) && path[0] == '.' && isdigit(path[1]))) + if (FILE_is_relative(path) && !((mode & STO_DIRECT) && path[0] == '.' && isdigit(path[1]))) { ARCHIVE *arch = NULL; const char *tpath = path; @@ -198,7 +198,7 @@ void STREAM_open(STREAM *stream, const char *path, int mode) goto _OPEN; }*/ - if ((mode & ST_ACCESS) != ST_READ || mode & ST_PIPE) + if ((mode & STO_ACCESS) != STO_READ || mode & STO_PIPE) THROW(E_ACCESS); if (!ARCHIVE_find_from_path(&arch, &tpath)) @@ -210,7 +210,7 @@ void STREAM_open(STREAM *stream, const char *path, int mode) path = tpath; } - if (mode & ST_DIRECT) + if (mode & STO_DIRECT) sclass = &STREAM_direct; else sclass = &STREAM_buffer; @@ -713,13 +713,13 @@ static char *input(STREAM *stream, bool line, char *escape) ec = escape ? *escape : 0; if (!line) - test = &&__TEST_INPUT; + test = &&__TESTO_INPUT; else { switch(stream->common.eol) { - case GB_EOL_WINDOWS: test = &&__TEST_WINDOWS; break; - case GB_EOL_MAC: test = &&__TEST_MAC; break; + case GB_EOL_WINDOWS: test = &&__TESTO_WINDOWS; break; + case GB_EOL_MAC: test = &&__TESTO_MAC; break; default: test = NULL; mode = ec ? 1 : 0; break; } } @@ -807,7 +807,7 @@ static char *input(STREAM *stream, bool line, char *escape) goto *test; - __TEST_INPUT: + __TESTO_INPUT: if (c <= ' ') { @@ -817,7 +817,7 @@ static char *input(STREAM *stream, bool line, char *escape) else continue; - __TEST_MAC: + __TESTO_MAC: if (c == '\r') { @@ -827,7 +827,7 @@ static char *input(STREAM *stream, bool line, char *escape) else continue; - __TEST_WINDOWS: + __TESTO_WINDOWS: if ((lc == '\r') && (c == '\n')) { @@ -956,7 +956,7 @@ static STREAM *enter_temp_stream(STREAM *stream) _temp_level = 0; if (_temp_stream.type) STREAM_close(&_temp_stream); - STREAM_open(&_temp_stream, NULL, ST_STRING | ST_WRIT); + STREAM_open(&_temp_stream, NULL, STO_STRING | STO_WRITE); } _temp_level++; @@ -1549,7 +1549,7 @@ void STREAM_load(const char *path, char **buffer, int *rlen) STREAM stream; int64_t len; - STREAM_open(&stream, path, ST_READ); + STREAM_open(&stream, path, STO_READ); STREAM_lof(&stream, &len); if (len >> 31) @@ -1573,7 +1573,7 @@ bool STREAM_map(const char *path, char **paddr, int *plen) size_t len; bool ret = TRUE; - STREAM_open(&stream, path, ST_READ + ST_DIRECT); + STREAM_open(&stream, path, STO_READ + STO_DIRECT); if (stream.type == &STREAM_arch) { @@ -1807,7 +1807,7 @@ void STREAM_begin(STREAM *stream) if (!stream->common.redirect) { ALLOC_ZERO(&stream->common.redirect, sizeof(STREAM)); - STREAM_open(stream->common.redirect, NULL, ST_STRING | ST_WRIT); + STREAM_open(stream->common.redirect, NULL, STO_STRING | STO_WRITE); } stream->common.redirected = TRUE; diff --git a/main/gbx/gbx_stream.h b/main/gbx/gbx_stream.h index fa08eac1a..691bc4a0d 100644 --- a/main/gbx/gbx_stream.h +++ b/main/gbx/gbx_stream.h @@ -145,19 +145,19 @@ typedef STREAM; enum { - ST_READ = (1 << 0), - ST_WRIT = (1 << 1), - ST_READ_WRITE = ST_READ + ST_WRIT, - ST_MODE = 0x3, - ST_APPENDING = (1 << 2), - ST_CREATE = (1 << 3), - ST_ACCESS = 0xF, - ST_DIRECT = (1 << 4), - ST_LOCK = (1 << 5), - ST_WATCH = (1 << 6), - ST_PIPE = (1 << 7), - ST_MEMORY = (1 << 8), - ST_STRING = (1 << 9) + STO_READ = (1 << 0), + STO_WRITE = (1 << 1), + STO_READ_WRITE = STO_READ + STO_WRITE, + STO_MODE = 0x3, + STO_APPEND = (1 << 2), + STO_CREATE = (1 << 3), + STO_ACCESS = 0xF, + STO_DIRECT = (1 << 4), + STO_LOCK = (1 << 5), + STO_WATCH = (1 << 6), + STO_PIPE = (1 << 7), + STO_MEMORY = (1 << 8), + STO_STRING = (1 << 9) }; enum { diff --git a/main/gbx/gbx_stream_arch.c b/main/gbx/gbx_stream_arch.c index 9aebc8aa8..296ed3bcc 100644 --- a/main/gbx/gbx_stream_arch.c +++ b/main/gbx/gbx_stream_arch.c @@ -55,7 +55,7 @@ static int stream_open(STREAM *stream, const char *path, int mode) return TRUE; } - if ((mode & ST_ACCESS) != ST_READ) + if ((mode & STO_ACCESS) != STO_READ) { errno = EACCES; return TRUE; diff --git a/main/gbx/gbx_stream_buffer.c b/main/gbx/gbx_stream_buffer.c index 727c37d53..5fbbdd8d9 100644 --- a/main/gbx/gbx_stream_buffer.c +++ b/main/gbx/gbx_stream_buffer.c @@ -49,11 +49,11 @@ static int stream_open(STREAM *stream, const char *path, int mode) struct stat info; int fd; - if (mode & ST_CREATE) + if (mode & STO_CREATE) fmode = "w+"; - else if (mode & ST_APPENDING) + else if (mode & STO_APPEND) fmode = "a+"; - else if (mode & ST_WRIT) + else if (mode & STO_WRITE) fmode = "r+"; else fmode = "r"; diff --git a/main/gbx/gbx_stream_direct.c b/main/gbx/gbx_stream_direct.c index a870280ea..ea6705f61 100644 --- a/main/gbx/gbx_stream_direct.c +++ b/main/gbx/gbx_stream_direct.c @@ -49,24 +49,24 @@ static int stream_open(STREAM *stream, const char *path, int mode) int fmode, omode; VALUE val; - if (mode & ST_CREATE) + if (mode & STO_CREATE) fmode = O_CREAT | O_TRUNC; // | O_EXCL; - else if (mode & ST_APPENDING) + else if (mode & STO_APPEND) fmode = O_APPEND | O_CREAT; else fmode = 0; - switch (mode & ST_MODE) + switch (mode & STO_MODE) { - case ST_READ: fmode |= O_RDONLY; break; - case ST_WRIT: fmode |= O_WRONLY; break; - case ST_READ_WRITE: fmode |= O_RDWR; break; + case STO_READ: fmode |= O_RDONLY; break; + case STO_WRITE: fmode |= O_WRONLY; break; + case STO_READ_WRITE: fmode |= O_RDWR; break; default: fmode |= O_RDONLY; } if (path[0] == '.' && isdigit(path[1])) { - if ((mode & ST_CREATE) || (mode & ST_APPENDING)) + if ((mode & STO_CREATE) || (mode & STO_APPEND)) THROW(E_ACCESS); if (NUMBER_from_string(NB_READ_INTEGER, &path[1], strlen(path) - 1, &val) || val._integer.value < 0) @@ -80,9 +80,9 @@ static int stream_open(STREAM *stream, const char *path, int mode) if (omode < 0) return TRUE; - if (((mode & ST_MODE) == ST_READ && (omode & O_ACCMODE) == O_WRONLY) - || ((mode & ST_MODE) == ST_WRIT && (omode & O_ACCMODE) == O_RDONLY) - || ((mode & ST_MODE) == ST_READ_WRITE && (omode & O_ACCMODE) != O_RDWR)) + if (((mode & STO_MODE) == STO_READ && (omode & O_ACCMODE) == O_WRONLY) + || ((mode & STO_MODE) == STO_WRITE && (omode & O_ACCMODE) == O_RDONLY) + || ((mode & STO_MODE) == STO_READ_WRITE && (omode & O_ACCMODE) != O_RDWR)) THROW(E_ACCESS); stream->direct.watch = TRUE; diff --git a/main/gbx/gbx_stream_memory.c b/main/gbx/gbx_stream_memory.c index ae7312c82..362bf279c 100644 --- a/main/gbx/gbx_stream_memory.c +++ b/main/gbx/gbx_stream_memory.c @@ -72,7 +72,7 @@ static int stream_close(STREAM *stream) static int stream_read(STREAM *stream, char *buffer, int len) { - /*if ((stream->common.mode & ST_READ) == 0) + /*if ((stream->common.mode & STO_READ) == 0) THROW(E_ACCESS);*/ CHECK_enter(); @@ -96,7 +96,7 @@ static int stream_read(STREAM *stream, char *buffer, int len) static int stream_write(STREAM *stream, char *buffer, int len) { - if ((stream->common.mode & ST_WRIT) == 0) + if ((stream->common.mode & STO_WRITE) == 0) THROW(E_ACCESS); CHECK_enter(); diff --git a/main/gbx/gbx_stream_pipe.c b/main/gbx/gbx_stream_pipe.c index 7cc475dbd..e117426bb 100644 --- a/main/gbx/gbx_stream_pipe.c +++ b/main/gbx/gbx_stream_pipe.c @@ -54,11 +54,11 @@ static int stream_open(STREAM *stream, const char *path, int mode) fmode = 0; - switch (mode & ST_MODE) + switch (mode & STO_MODE) { - case ST_READ: fmode |= O_RDONLY; break; - case ST_WRIT: fmode |= O_WRONLY; break; - case ST_READ_WRITE: fmode |= O_RDWR; break; + case STO_READ: fmode |= O_RDONLY; break; + case STO_WRITE: fmode |= O_WRONLY; break; + case STO_READ_WRITE: fmode |= O_RDWR; break; default: fmode |= O_RDONLY; } diff --git a/main/gbx/gbx_stream_string.c b/main/gbx/gbx_stream_string.c index e7ce1a0a7..20d58ad93 100644 --- a/main/gbx/gbx_stream_string.c +++ b/main/gbx/gbx_stream_string.c @@ -81,7 +81,7 @@ static int stream_read(STREAM *stream, char *buffer, int len) static int stream_write(STREAM *stream, char *buffer, int len) { - if ((stream->common.mode & ST_WRIT) == 0) + if ((stream->common.mode & STO_WRITE) == 0) THROW(E_ACCESS); stream->string.buffer = STRING_add(stream->string.buffer, buffer, len); diff --git a/main/gbx/gbx_subr_file.c b/main/gbx/gbx_subr_file.c index 14fb8a71c..2c0618625 100755 --- a/main/gbx/gbx_subr_file.c +++ b/main/gbx/gbx_subr_file.c @@ -213,9 +213,9 @@ void SUBR_open(ushort code) else THROW_TYPE(T_POINTER, PARAM->type); - STREAM_open(&stream, (char *)addr, mode | ST_MEMORY); + STREAM_open(&stream, (char *)addr, mode | STO_MEMORY); } - else if (mode & ST_STRING) + else if (mode & STO_STRING) { char *str; @@ -225,7 +225,7 @@ void SUBR_open(ushort code) { str = SUBR_get_string(PARAM); - if (mode & ST_WRIT) + if (mode & STO_WRITE) { stream.string.buffer = STRING_new(str, STRING_length(str)); } @@ -1035,7 +1035,7 @@ void SUBR_lock(ushort code) for(;;) { - STREAM_open(&stream, path, ST_LOCK); + STREAM_open(&stream, path, STO_LOCK); if (!STREAM_lock_all(&stream) && FILE_exist(path)) break; @@ -1055,7 +1055,7 @@ void SUBR_lock(ushort code) THROW(E_LOCK); } - file = CFILE_create(&stream, ST_LOCK); + file = CFILE_create(&stream, STO_LOCK); OBJECT_put(RETURN, file); SUBR_LEAVE(); } diff --git a/main/share/gb_file_temp.h b/main/share/gb_file_temp.h index d7edb01a8..c2357d9a8 100644 --- a/main/share/gb_file_temp.h +++ b/main/share/gb_file_temp.h @@ -999,8 +999,8 @@ void FILE_copy(const char *src, const char *dst) TRY { - STREAM_open(&stream_src, src, ST_READ); - STREAM_open(&stream_dst, dst, ST_CREATE); + STREAM_open(&stream_src, src, STO_READ); + STREAM_open(&stream_dst, dst, STO_CREATE); STREAM_lof(&stream_src, &len); From 1b7abb97b72fd54303e8854e61a1dcc9b6e9df49 Mon Sep 17 00:00:00 2001 From: bgermann Date: Thu, 30 Aug 2018 14:07:18 +0200 Subject: [PATCH 9/9] Correct 3e6d9696 --- main/gbx/gbx_stream.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/gbx/gbx_stream.c b/main/gbx/gbx_stream.c index d5fc6cfa4..ac78bdef8 100644 --- a/main/gbx/gbx_stream.c +++ b/main/gbx/gbx_stream.c @@ -713,13 +713,13 @@ static char *input(STREAM *stream, bool line, char *escape) ec = escape ? *escape : 0; if (!line) - test = &&__TESTO_INPUT; + test = &&__TEST_INPUT; else { switch(stream->common.eol) { - case GB_EOL_WINDOWS: test = &&__TESTO_WINDOWS; break; - case GB_EOL_MAC: test = &&__TESTO_MAC; break; + case GB_EOL_WINDOWS: test = &&__TEST_WINDOWS; break; + case GB_EOL_MAC: test = &&__TEST_MAC; break; default: test = NULL; mode = ec ? 1 : 0; break; } } @@ -807,7 +807,7 @@ static char *input(STREAM *stream, bool line, char *escape) goto *test; - __TESTO_INPUT: + __TEST_INPUT: if (c <= ' ') { @@ -817,7 +817,7 @@ static char *input(STREAM *stream, bool line, char *escape) else continue; - __TESTO_MAC: + __TEST_MAC: if (c == '\r') { @@ -827,7 +827,7 @@ static char *input(STREAM *stream, bool line, char *escape) else continue; - __TESTO_WINDOWS: + __TEST_WINDOWS: if ((lc == '\r') && (c == '\n')) {