diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2024-08-12 01:27:13 +0100 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2024-08-12 01:27:13 +0100 |
commit | 9f3b5c2314239e1d3b6e1722e676ea1935bc2836 (patch) | |
tree | b44a86d3b6ae0cdf3eb1546ccf87ca33d26cd171 | |
parent | f09be22d7725e512d2bee67530181c42378fd792 (diff) | |
download | gcc-9f3b5c2314239e1d3b6e1722e676ea1935bc2836.zip gcc-9f3b5c2314239e1d3b6e1722e676ea1935bc2836.tar.gz gcc-9f3b5c2314239e1d3b6e1722e676ea1935bc2836.tar.bz2 |
PR modula2/116181 fix ODR warnings for C/m2 interface library modules
This patch fixes many ODR warnings which appear when compiling the
interface files found in gcc/m2/*-ch/ and gcc/m2/{pge,mc}-boot
directories.
gcc/m2/ChangeLog:
PR modula2/116181
* gm2-compiler/ppg.mod (FindStr): Initialize j.
* gm2-libs-ch/UnixArgs.cc (_M2_UnixArgs_ctor): Replace
M2RTS_RegisterModule with M2RTS_RegisterModule_Cstr.
* gm2-libs-ch/dtoa.cc (_M2_dtoa_ctor): Ditto.
* gm2-libs-ch/ldtoa.cc (ldtoa_strtold): Cast parameter s
for strtod.
(_M2_ldtoa_ctor): Replace M2RTS_RegisterModule with
M2RTS_RegisterModule_Cstr.
* gm2-libs-ch/m2rts.h (M2RTS_RegisterModule_Cstr): New
define.
(M2RTS_RegisterModule): Remove const.
* mc-boot-ch/GSelective.c (Selective_FdIsSet): Return bool
rather than int.
* mc-boot-ch/Gldtoa.cc (ldtoa_strtold): Change const char to
void.
Cast s before passing as a parameter to strtod.
* mc-boot-ch/Glibc.c (tracedb_open): Replace const char with const
void.
(libc_perror): Replace char with const char.
(libc_printf): Replace char with void.
(libc_snprintf): Replace char with void.
Add const_cast for parameter to index.
Add reinterpret_cast for parameter to vsnprintf.
(libc_open): Replace first paramter type char with void.
Add vararg for the third parameter.
* mc-boot-ch/Gm2rtsdummy.cc (M2RTS_RequestDependant): Remove #if 0 code.
(m2pim_M2RTS_RegisterModule): Change const char parameters to void
(M2RTS_RegisterModule): Ditto.
(_M2_M2RTS_init): Remove #if 0 code.
(M2RTS_ConstructModules): Ditto.
(M2RTS_Terminate): Ditto.
(M2RTS_DeconstructModules): Ditto.
(M2RTS_Halt): Ditto.
* mc-boot-ch/Gtermios.cc (SetFlag): Return bool.
* mc-boot-ch/m2rts.h (M2RTS_RegisterModule_Cstr): New define.
(M2RTS_RegisterModule): Change const char parameters to void.
* mc-boot/Gdecl.cc: Regenerate.
* mc/decl.mod (getNextConstExp): Reimplement.
* pge-boot/GDynamicStrings.cc: Regenerate.
* pge-boot/GDynamicStrings.h: Ditto.
* pge-boot/GM2RTS.h (M2RTS_RegisterModule_Cstr): New function.
(M2RTS_RegisterModule): Reformat.
* pge-boot/GSymbolKey.cc: Regenerate.
* pge-boot/GSysExceptions.cc (_M2_SysExceptions_init): Add correct parameters.
(_M2_SysExceptions_fini): Ditto.
* pge-boot/GUnixArgs.cc (_M2_UnixArgs_ctor::_M2_UnixArgs_ctor):
Replace call to M2RTS_RegisterModule with M2RTS_RegisterModuleCstr.
* pge-boot/Gerrno.cc (_M2_errno_init): Add correct parameters.
(_M2_errno_fini): Ditto.
* pge-boot/Gldtoa.cc (ldtoa_strtold): Replace const char with
void.
Use reinterpret_cast when passing s to strtod.
Replace true with TRUE.
* pge-boot/Gldtoa.h (ldtoa_strtold): Tidy up.
* pge-boot/Glibc.cc (libc_read): Use size_t as the return type.
(libc_write): Ditto.
(libc_strlen): Ditto.
(libc_perror): Replace char with const char.
(libc_printf): Replace char to const char.
Cast parameter to index using const_cast.
(libc_snprintf): Replace char with void.
Cast parameter to index using const_cast.
(libc_malloc): Replace parameter type with size_t.
(libc_memcpy): Replace third parameter type with size_t.
(libc_open): Use varargs.
* pge-boot/Glibc.h (libc_perror): Add _string_high parameter.
* pge-boot/Gpge.cc: Regenerate.
* pge-boot/Gtermios.cc (SetFlag): Replace return type with bool.
(_M2_termios_init): Add correct parameters.
(_M2_termios_fini): Ditto.
* pge-boot/m2rts.h (M2RTS_RegisterModule_Cstr): New define.
(M2RTS_RegisterModule): Replace const char with void.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
27 files changed, 742 insertions, 663 deletions
diff --git a/gcc/m2/gm2-compiler/ppg.mod b/gcc/m2/gm2-compiler/ppg.mod index fdb5f43..a82c901 100644 --- a/gcc/m2/gm2-compiler/ppg.mod +++ b/gcc/m2/gm2-compiler/ppg.mod @@ -3678,6 +3678,7 @@ VAR BEGIN t := code ; k := StrLen(code^.codetext)+1 ; + j := StrLen(str) ; WHILE t#NIL DO REPEAT WHILE (k>0) AND IsWhite(t^.codetext[k-1]) DO diff --git a/gcc/m2/gm2-libs-ch/UnixArgs.cc b/gcc/m2/gm2-libs-ch/UnixArgs.cc index 574ca58..67a0c99 100644 --- a/gcc/m2/gm2-libs-ch/UnixArgs.cc +++ b/gcc/m2/gm2-libs-ch/UnixArgs.cc @@ -86,6 +86,6 @@ _M2_UnixArgs_dep (void) extern "C" void __attribute__((__constructor__)) _M2_UnixArgs_ctor (void) { - M2RTS_RegisterModule ("UnixArgs", LIBNAME, _M2_UnixArgs_init, _M2_UnixArgs_finish, - _M2_UnixArgs_dep); + M2RTS_RegisterModule_Cstr ("UnixArgs", LIBNAME, _M2_UnixArgs_init, + _M2_UnixArgs_finish, _M2_UnixArgs_dep); } diff --git a/gcc/m2/gm2-libs-ch/dtoa.cc b/gcc/m2/gm2-libs-ch/dtoa.cc index 68e57cf..306e70d 100644 --- a/gcc/m2/gm2-libs-ch/dtoa.cc +++ b/gcc/m2/gm2-libs-ch/dtoa.cc @@ -194,8 +194,8 @@ _M2_dtoa_dep (void) extern "C" void __attribute__((__constructor__)) _M2_dtoa_ctor (void) { - M2RTS_RegisterModule ("dtoa", LIBNAME, _M2_dtoa_init, _M2_dtoa_finish, - _M2_dtoa_dep); + M2RTS_RegisterModule_Cstr ("dtoa", LIBNAME, _M2_dtoa_init, + _M2_dtoa_finish, _M2_dtoa_dep); } #else diff --git a/gcc/m2/gm2-libs-ch/ldtoa.cc b/gcc/m2/gm2-libs-ch/ldtoa.cc index 2da7a0d..9111de1 100644 --- a/gcc/m2/gm2-libs-ch/ldtoa.cc +++ b/gcc/m2/gm2-libs-ch/ldtoa.cc @@ -52,17 +52,17 @@ extern bool dtoa_calcsign (char *p, int str_size); (ndigits may be negative). */ long double -ldtoa_strtold (const char *s, bool *error) +ldtoa_strtold (void *s, bool *error) { char *endp; long double d; errno = 0; #if defined(HAVE_STRTOLD) - d = strtold (s, &endp); + d = strtold (reinterpret_cast <char *> (s), &endp); #else /* fall back to using strtod. */ - d = (long double)strtod (s, &endp); + d = (long double)strtod (reinterpret_cast <char *> (s), &endp); #endif if (endp != NULL && (*endp == '\0')) *error = (errno != 0); @@ -123,8 +123,8 @@ _M2_ldtoa_dep (void) extern "C" void __attribute__((__constructor__)) _M2_ldtoa_ctor (void) { - M2RTS_RegisterModule ("ldtoa", LIBNAME, _M2_ldtoa_init, _M2_ldtoa_finish, - _M2_ldtoa_dep); + M2RTS_RegisterModule_Cstr ("ldtoa", LIBNAME, _M2_ldtoa_init, + _M2_ldtoa_finish, _M2_ldtoa_dep); } #else diff --git a/gcc/m2/gm2-libs-ch/m2rts.h b/gcc/m2/gm2-libs-ch/m2rts.h index b6da7cc..83e463a 100644 --- a/gcc/m2/gm2-libs-ch/m2rts.h +++ b/gcc/m2/gm2-libs-ch/m2rts.h @@ -28,8 +28,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef void (*proc_con) (int, char **, char **); typedef void (*proc_dep) (void); +#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \ + M2RTS_RegisterModule (reinterpret_cast <void *> (const_cast <char *> (MODNAME)), \ + reinterpret_cast <void *> (const_cast <char *> (LIBNAME)), \ + init, fini, dep) + extern "C" void M2RTS_RequestDependant (const void *modulename, const void *dependancy); -extern "C" void M2RTS_RegisterModule (const void *modulename, const void *libname, +extern "C" void M2RTS_RegisterModule (void *modulename, void *libname, proc_con init, proc_con fini, proc_dep dependencies); extern "C" void _M2_M2RTS_init (void); diff --git a/gcc/m2/mc-boot-ch/GSelective.c b/gcc/m2/mc-boot-ch/GSelective.c index 6f30bde..26c135b 100644 --- a/gcc/m2/mc-boot-ch/GSelective.c +++ b/gcc/m2/mc-boot-ch/GSelective.c @@ -145,7 +145,7 @@ Selective_FdClr (int fd, fd_set *s) /* PROCEDURE FdIsSet (fd: INTEGER; SetOfFd) : BOOLEAN ; */ EXTERN -int +bool Selective_FdIsSet (int fd, fd_set *s) { return FD_ISSET (fd, s); diff --git a/gcc/m2/mc-boot-ch/Gldtoa.cc b/gcc/m2/mc-boot-ch/Gldtoa.cc index 1e7acb7..ce66fb7 100644 --- a/gcc/m2/mc-boot-ch/Gldtoa.cc +++ b/gcc/m2/mc-boot-ch/Gldtoa.cc @@ -43,22 +43,22 @@ extern bool dtoa_calcsign (char *p, int str_size); (ndigits may be negative). */ long double -ldtoa_strtold (const char *s, int *error) +ldtoa_strtold (void *s, bool *error) { char *endp; long double d; errno = 0; #if defined(HAVE_STRTOLD) - d = strtold (s, &endp); + d = strtold (reinterpret_cast <char *> (s), &endp); #else /* fall back to using strtod. */ - d = (long double)strtod (s, &endp); + d = (long double)strtod (reinterpret_cast <char *> (s), &endp); #endif if (endp != NULL && (*endp == '\0')) *error = (errno != 0); else - *error = TRUE; + *error = true; return d; } diff --git a/gcc/m2/mc-boot-ch/Glibc.c b/gcc/m2/mc-boot-ch/Glibc.c index e53a76a..492f17f 100644 --- a/gcc/m2/mc-boot-ch/Glibc.c +++ b/gcc/m2/mc-boot-ch/Glibc.c @@ -67,7 +67,7 @@ tracedb (const char *format, ...) static void -tracedb_open (const char *p, int flags, mode_t mode) +tracedb_open (const void *p, int flags, mode_t mode) { #if defined(BUILD_MC_LIBC_TRACE) bool item_written = false; @@ -161,7 +161,7 @@ libc_exit (int code) EXTERN void -libc_perror (char *s) +libc_perror (const char *s, unsigned int length) { perror (s); } @@ -207,7 +207,7 @@ libc_printf (const char *_format, unsigned int _format_high, ...) do { - c = index (&_format[i], '\\'); + c = index (&const_cast <char *> (_format)[i], '\\'); if (c == NULL) strcpy (&format[j], &_format[i]); else @@ -233,7 +233,7 @@ libc_printf (const char *_format, unsigned int _format_high, ...) EXTERN int -libc_snprintf (char *dest, size_t length, const char *_format, unsigned int _format_high, ...) +libc_snprintf (void *dest, size_t length, const char *_format, unsigned int _format_high, ...) { va_list arg; int done; @@ -244,7 +244,7 @@ libc_snprintf (char *dest, size_t length, const char *_format, unsigned int _for do { - c = index (&_format[i], '\\'); + c = index (&const_cast <char *> (_format)[i], '\\'); if (c == NULL) strcpy (&format[j], &_format[i]); else @@ -263,7 +263,7 @@ libc_snprintf (char *dest, size_t length, const char *_format, unsigned int _for while (c != NULL); va_start (arg, _format_high); - done = vsnprintf (dest, length, format, arg); + done = vsnprintf (reinterpret_cast<char *> (dest), length, format, arg); va_end (arg); return done; } @@ -343,11 +343,15 @@ libc_creat (char *p, mode_t mode) EXTERN int -libc_open (char *p, int flags, mode_t mode) +libc_open (void *p, int oflag, ...) { - tracedb_open (p, flags, mode); - int result = open (p, flags, mode); + va_list arg; + va_start (arg, oflag); + mode_t mode = va_arg (arg, mode_t); + tracedb_open (p, oflag, mode); + int result = open (reinterpret_cast <char *> (p), oflag, mode); tracedb_result (result); + va_end (arg); return result; } diff --git a/gcc/m2/mc-boot-ch/Gm2rtsdummy.cc b/gcc/m2/mc-boot-ch/Gm2rtsdummy.cc index f845a31..9b431f7 100644 --- a/gcc/m2/mc-boot-ch/Gm2rtsdummy.cc +++ b/gcc/m2/mc-boot-ch/Gm2rtsdummy.cc @@ -31,32 +31,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef void (*proc_con) (int, char **, char **); typedef void (*proc_dep) (void); -#if 0 -/* Used if -fscaffold-dynamic were selected. */ -extern "C" void M2RTS_RequestDependant (const char *modulename, const char *libname, - const char *dependancy, const char *deplib); -#endif - -extern "C" void m2pim_M2RTS_RegisterModule (const char *modulename, const char *libname, +extern "C" void m2pim_M2RTS_RegisterModule (void *modulename, void *libname, proc_con init, proc_con fini, proc_dep dependencies); /* Fixup references, the code will not be used though, as it is only used if -fscaffold-dynamic is selected (and mc uses -fscaffold-static). */ extern "C" -void M2RTS_RegisterModule (const char *modulename, const char *libname, +void M2RTS_RegisterModule (char *modulename, char *libname, proc_con init, proc_con fini, proc_dep dependencies) { - m2pim_M2RTS_RegisterModule (modulename, libname, init, fini, dependencies); + m2pim_M2RTS_RegisterModule (reinterpret_cast <void *> (modulename), + reinterpret_cast <void *> (libname), + init, fini, dependencies); } - -#if 0 -extern "C" void _M2_M2RTS_init (void); - -extern "C" void M2RTS_ConstructModules (const char *, - int argc, char *argv[], char *envp[]); -extern "C" void M2RTS_Terminate (void); -extern "C" void M2RTS_DeconstructModules (void); - -extern "C" void M2RTS_Halt (const char *, int, const char *, const char *) __attribute__ ((noreturn)); -#endif diff --git a/gcc/m2/mc-boot-ch/Gtermios.cc b/gcc/m2/mc-boot-ch/Gtermios.cc index 0ef5c8b..99f003f 100644 --- a/gcc/m2/mc-boot-ch/Gtermios.cc +++ b/gcc/m2/mc-boot-ch/Gtermios.cc @@ -1081,8 +1081,8 @@ EXPORT (GetFlag) (struct termios *t, Flag f, int *b) /* SetFlag - sets a flag value in, t, to, b, and returns TRUE if this flag value is supported. */ -int -EXPORT (SetFlag) (struct termios *t, Flag f, int b) +bool +EXPORT (SetFlag) (struct termios *t, Flag f, bool b) { switch (f) { diff --git a/gcc/m2/mc-boot-ch/m2rts.h b/gcc/m2/mc-boot-ch/m2rts.h index ef09bd7..bfd2d9f 100644 --- a/gcc/m2/mc-boot-ch/m2rts.h +++ b/gcc/m2/mc-boot-ch/m2rts.h @@ -28,9 +28,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef void (*proc_con) (int, char **, char **); typedef void (*proc_dep) (void); +#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \ + M2RTS_RegisterModule (const_cast <void *> (MODNAME), \ + const_cast <void *> (LIBNAME), \ + init, fini, dep) + extern "C" void M2RTS_RequestDependant (const char *modulename, const char *libname, const char *dependancy, const char *deplib); -extern "C" void M2RTS_RegisterModule (const char *modulename, const char *libname, +extern "C" void M2RTS_RegisterModule (void *modulename, void *libname, proc_con init, proc_con fini, proc_dep dependencies); extern "C" void _M2_M2RTS_init (void); diff --git a/gcc/m2/mc-boot/Gdecl.cc b/gcc/m2/mc-boot/Gdecl.cc index 183d671..defe0b2 100644 --- a/gcc/m2/mc-boot/Gdecl.cc +++ b/gcc/m2/mc-boot/Gdecl.cc @@ -6453,7 +6453,7 @@ static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, n->recordfieldF.tag = false; n->recordfieldF.scope = static_cast<decl_node__opaque> (NULL); initCname (&n->recordfieldF.cname); - /* + /* IF r^.kind=record THEN doRecordM2 (doP, r) @@ -6866,7 +6866,7 @@ static decl_node__opaque makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, d { decl_node__opaque f; - /* + /* makeIntrisicProc - create an intrinsic node. */ f = newNode (k); @@ -10084,7 +10084,7 @@ static void doString (mcPretty_pretty p, decl_node__opaque n) s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast<decl_node> (n)))); outTextS (p, s); s = DynamicStrings_KillString (s); - /* + /* IF DynamicStrings.Index (s, '"', 0)=-1 THEN outText (p, '"') ; @@ -10244,7 +10244,7 @@ static void doStringC (mcPretty_pretty p, decl_node__opaque n) DynamicStrings_String s; mcDebug_assert (isString (n)); - /* + /* s := InitStringCharStar (keyToCharStar (getSymName (n))) ; IF DynamicStrings.Length (s)>3 THEN @@ -10792,7 +10792,7 @@ static void doParamTypeEmit (mcPretty_pretty p, decl_node__opaque paramnode, dec doTypeNameC (p, paramtype); doOpaqueModifier (p, paramnode); } - /* + /* IF nodeUsesOpaque (paramnode) AND (NOT getNodeOpaqueVoidStar (paramnode)) THEN outText (p, '__opaque') @@ -13326,7 +13326,7 @@ static void doExternCP (mcPretty_pretty p) static void doProcedureCommentText (mcPretty_pretty p, DynamicStrings_String s) { - /* remove + /* remove from the start of the comment. */ while (((DynamicStrings_Length (s)) > 0) && ((DynamicStrings_char (s, 0)) == ASCII_lf)) { @@ -13392,7 +13392,7 @@ static void doProcedureHeadingC (decl_node__opaque n, bool prototype) } q = static_cast<decl_node__opaque> (NULL); doTypeC (doP, n->procedureF.returnType, &q); - /* + /* IF NOT isExported (n) THEN doTypeNameModifier (doP, n^.procedureF.returnType) @@ -14063,7 +14063,7 @@ static void includeDefVarProcedure (decl_node__opaque n) defModule = static_cast<decl_node__opaque> (decl_lookupDef (decl_getSymName (static_cast<decl_node> (n)))); if (defModule != NULL) { - /* + /* includeVar (defModule^.defF.decls) ; simplifyTypes (defModule^.defF.decls) ; */ @@ -25814,7 +25814,7 @@ extern "C" decl_node decl_makeComponentRef (decl_node rec, decl_node field) decl_node__opaque n; decl_node__opaque a; - /* + /* n := getLastOp (rec) ; IF (n#NIL) AND (isDeref (n) OR isPointerRef (n)) AND (skipType (getType (rec)) = skipType (getType (n))) @@ -26194,8 +26194,6 @@ extern "C" decl_node decl_makeConstExp (void) extern "C" decl_node decl_getNextConstExp (void) { - decl_node__opaque n; - mcDebug_assert (((decl_isDef (static_cast<decl_node> (currentModule))) || (decl_isImp (static_cast<decl_node> (currentModule)))) || (decl_isModule (static_cast<decl_node> (currentModule)))); if (decl_isDef (static_cast<decl_node> (currentModule))) { @@ -26206,12 +26204,12 @@ extern "C" decl_node decl_getNextConstExp (void) /* avoid dangling else. */ return static_cast<decl_node> (getNextFixup (¤tModule->impF.constFixup)); } - else if (decl_isModule (static_cast<decl_node> (currentModule))) + else { /* avoid dangling else. */ + mcDebug_assert (decl_isModule (static_cast<decl_node> (currentModule))); return static_cast<decl_node> (getNextFixup (¤tModule->moduleF.constFixup)); } - return static_cast<decl_node> (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } diff --git a/gcc/m2/mc/decl.mod b/gcc/m2/mc/decl.mod index 37fc396..8293c7f 100644 --- a/gcc/m2/mc/decl.mod +++ b/gcc/m2/mc/decl.mod @@ -3545,8 +3545,6 @@ END setConstExpComplete ; *) PROCEDURE getNextConstExp () : node ; -VAR - n: node ; BEGIN assert (isDef (currentModule) OR isImp (currentModule) OR isModule (currentModule)) ; WITH currentModule^ DO @@ -3556,12 +3554,11 @@ BEGIN ELSIF isImp (currentModule) THEN RETURN getNextFixup (impF.constFixup) - ELSIF isModule (currentModule) - THEN + ELSE + assert (isModule (currentModule)) RETURN getNextFixup (moduleF.constFixup) END - END ; - RETURN n + END END getNextConstExp ; diff --git a/gcc/m2/pge-boot/GDynamicStrings.cc b/gcc/m2/pge-boot/GDynamicStrings.cc index 997802b..3296969 100644 --- a/gcc/m2/pge-boot/GDynamicStrings.cc +++ b/gcc/m2/pge-boot/GDynamicStrings.cc @@ -25,6 +25,8 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +#include "config.h" +#include "system.h" #include <stdbool.h> # if !defined (PROC_D) # define PROC_D @@ -40,19 +42,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#include <stddef.h> -#include <string.h> -#include <limits.h> -#include <stdlib.h> # include "GStorage.h" -#include <unistd.h> #if defined(__cplusplus) # undef NULL # define NULL 0 #endif -#define _DynamicStrings_H #define _DynamicStrings_C +#include "GDynamicStrings.h" # include "Glibc.h" # include "GStrLib.h" # include "GStorage.h" @@ -84,27 +81,27 @@ typedef struct DynamicStrings__T3_a DynamicStrings__T3; typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState; -typedef DynamicStrings_stringRecord *DynamicStrings_String; +typedef DynamicStrings_stringRecord *DynamicStrings_String__opaque; struct DynamicStrings_DebugInfo_r { - DynamicStrings_String next; - void *file; + DynamicStrings_String__opaque next; + void * file; unsigned int line; - void *proc; + void * proc; }; struct DynamicStrings_descriptor_r { bool charStarUsed; - void *charStar; + void * charStar; unsigned int charStarSize; bool charStarValid; DynamicStrings_desState state; - DynamicStrings_String garbage; + DynamicStrings_String__opaque garbage; }; struct DynamicStrings_frameRec_r { - DynamicStrings_String alloc; - DynamicStrings_String dealloc; + DynamicStrings_String__opaque alloc; + DynamicStrings_String__opaque dealloc; DynamicStrings_frame next; }; @@ -112,7 +109,7 @@ struct DynamicStrings__T3_a { char array[(MaxBuf-1)+1]; }; struct DynamicStrings_Contents_r { DynamicStrings__T3 buf; unsigned int len; - DynamicStrings_String next; + DynamicStrings_String__opaque next; }; struct DynamicStrings_stringRecord_r { @@ -123,7 +120,7 @@ struct DynamicStrings_stringRecord_r { static bool Initialized; static DynamicStrings_frame frameHead; -static DynamicStrings_String captured; +static DynamicStrings_String__opaque captured; /* InitString - creates and returns a String type object. @@ -258,13 +255,26 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned /* RIndex - returns the indice of the last occurance of, ch, - in String, s. The search starts at position, o. - -1 is returned if, ch, is not found. + in String, s. The search starts at position, o. + -1 is returned if, ch, is not found. The search + is performed left to right. */ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o); /* + ReverseIndex - returns the indice of the last occurance of ch + in String s. The search starts at position o + and searches from right to left. The start position + may be indexed negatively from the right (-1 is the + last index). + The return value if ch is found will always be positive. + -1 is returned if ch is not found. +*/ + +extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o); + +/* RemoveComment - assuming that, comment, is a comment delimiter which indicates anything to its right is a comment then strip off the comment and also any white space @@ -390,7 +400,7 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal /* writeStringDesc write out debugging information about string, s. */ -static void writeStringDesc (DynamicStrings_String s); +static void writeStringDesc (DynamicStrings_String__opaque s); /* writeNspace - @@ -402,7 +412,7 @@ static void writeNspace (unsigned int n); DumpStringInfo - */ -static void DumpStringInfo (DynamicStrings_String s, unsigned int i); +static void DumpStringInfo (DynamicStrings_String__opaque s, unsigned int i); /* DumpStringInfo - @@ -420,7 +430,7 @@ static void doDSdbEnter (void); doDSdbExit - */ -static void doDSdbExit (DynamicStrings_String s); +static void doDSdbExit (DynamicStrings_String__opaque s); /* DSdbEnter - @@ -432,8 +442,8 @@ static void DSdbEnter (void); DSdbExit - */ -static void DSdbExit (DynamicStrings_String s); -static unsigned int Capture (DynamicStrings_String s); +static void DSdbExit (DynamicStrings_String__opaque s); +static unsigned int Capture (DynamicStrings_String__opaque s); /* Min - @@ -487,73 +497,73 @@ static void writeLn (void); AssignDebug - assigns, file, and, line, information to string, s. */ -static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high); +static DynamicStrings_String__opaque AssignDebug (DynamicStrings_String__opaque s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high); /* IsOn - returns TRUE if, s, is on one of the debug lists. */ -static bool IsOn (DynamicStrings_String list, DynamicStrings_String s); +static bool IsOn (DynamicStrings_String__opaque list, DynamicStrings_String__opaque s); /* AddTo - adds string, s, to, list. */ -static void AddTo (DynamicStrings_String *list, DynamicStrings_String s); +static void AddTo (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s); /* SubFrom - removes string, s, from, list. */ -static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s); +static void SubFrom (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s); /* AddAllocated - adds string, s, to the head of the allocated list. */ -static void AddAllocated (DynamicStrings_String s); +static void AddAllocated (DynamicStrings_String__opaque s); /* AddDeallocated - adds string, s, to the head of the deallocated list. */ -static void AddDeallocated (DynamicStrings_String s); +static void AddDeallocated (DynamicStrings_String__opaque s); /* IsOnAllocated - returns TRUE if the string, s, has ever been allocated. */ -static bool IsOnAllocated (DynamicStrings_String s); +static bool IsOnAllocated (DynamicStrings_String__opaque s); /* IsOnDeallocated - returns TRUE if the string, s, has ever been deallocated. */ -static bool IsOnDeallocated (DynamicStrings_String s); +static bool IsOnDeallocated (DynamicStrings_String__opaque s); /* SubAllocated - removes string, s, from the list of allocated strings. */ -static void SubAllocated (DynamicStrings_String s); +static void SubAllocated (DynamicStrings_String__opaque s); /* SubDeallocated - removes string, s, from the list of deallocated strings. */ -static void SubDeallocated (DynamicStrings_String s); +static void SubDeallocated (DynamicStrings_String__opaque s); /* SubDebugInfo - removes string, s, from the list of allocated strings. */ -static void SubDebugInfo (DynamicStrings_String s); +static void SubDebugInfo (DynamicStrings_String__opaque s); /* AddDebugInfo - adds string, s, to the list of allocated strings. */ -static void AddDebugInfo (DynamicStrings_String s); +static void AddDebugInfo (DynamicStrings_String__opaque s); /* ConcatContents - add the contents of string, a, where, h, is the @@ -566,19 +576,19 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned DeallocateCharStar - deallocates any charStar. */ -static void DeallocateCharStar (DynamicStrings_String s); +static void DeallocateCharStar (DynamicStrings_String__opaque s); /* CheckPoisoned - checks for a poisoned string, s. */ -static DynamicStrings_String CheckPoisoned (DynamicStrings_String s); +static DynamicStrings_String__opaque CheckPoisoned (DynamicStrings_String__opaque s); /* MarkInvalid - marks the char * version of String, s, as invalid. */ -static void MarkInvalid (DynamicStrings_String s); +static void MarkInvalid (DynamicStrings_String__opaque s); /* ConcatContentsAddress - concatenate the string, a, where, h, is the @@ -593,13 +603,13 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne onlist. String, a, is returned. */ -static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrings_String b); +static DynamicStrings_String__opaque AddToGarbage (DynamicStrings_String__opaque a, DynamicStrings_String__opaque b); /* IsOnGarbage - returns TRUE if, s, is on string, e, garbage list. */ -static bool IsOnGarbage (DynamicStrings_String e, DynamicStrings_String s); +static bool IsOnGarbage (DynamicStrings_String__opaque e, DynamicStrings_String__opaque s); /* IsWhite - returns TRUE if, ch, is a space or a tab. @@ -611,19 +621,19 @@ static bool IsWhite (char ch); DumpState - */ -static void DumpState (DynamicStrings_String s); +static void DumpState (DynamicStrings_String__opaque s); /* DumpStringSynopsis - */ -static void DumpStringSynopsis (DynamicStrings_String s); +static void DumpStringSynopsis (DynamicStrings_String__opaque s); /* DumpString - displays the contents of string, s. */ -static void DumpString (DynamicStrings_String s); +static void DumpString (DynamicStrings_String__opaque s); /* Init - initialize the module. @@ -635,7 +645,7 @@ static void Init (void); /* writeStringDesc write out debugging information about string, s. */ -static void writeStringDesc (DynamicStrings_String s) +static void writeStringDesc (DynamicStrings_String__opaque s) { writeCstring (s->debug.file); writeString ((const char *) ":", 1); @@ -691,7 +701,7 @@ static void writeNspace (unsigned int n) DumpStringInfo - */ -static void DumpStringInfo (DynamicStrings_String s, unsigned int i) +static void DumpStringInfo (DynamicStrings_String__opaque s, unsigned int i) { if (s != NULL) { @@ -739,11 +749,11 @@ static void doDSdbEnter (void) doDSdbExit - */ -static void doDSdbExit (DynamicStrings_String s) +static void doDSdbExit (DynamicStrings_String__opaque s) { if (CheckOn) { - s = DynamicStrings_PopAllocationExemption (true, s); + s = static_cast<DynamicStrings_String__opaque> (DynamicStrings_PopAllocationExemption (true, static_cast<DynamicStrings_String> (s))); } } @@ -761,11 +771,11 @@ static void DSdbEnter (void) DSdbExit - */ -static void DSdbExit (DynamicStrings_String s) +static void DSdbExit (DynamicStrings_String__opaque s) { } -static unsigned int Capture (DynamicStrings_String s) +static unsigned int Capture (DynamicStrings_String__opaque s) { /* * #undef GM2_DEBUG_DYNAMICSTINGS @@ -833,7 +843,7 @@ static void writeString (const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - i = static_cast<int> (libc_write (1, &a, static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high)))); + i = static_cast<int> (libc_write (1, const_cast<void*> (static_cast<const void*>(a)), static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high)))); } @@ -941,7 +951,7 @@ static void writeLn (void) AssignDebug - assigns, file, and, line, information to string, s. */ -static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high) +static DynamicStrings_String__opaque AssignDebug (DynamicStrings_String__opaque s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high) { void * f; void * p; @@ -952,8 +962,8 @@ static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *f memcpy (file, file_, _file_high+1); memcpy (proc, proc_, _proc_high+1); - f = &file; - p = &proc; + f = const_cast<void*> (static_cast<const void*>(file)); + p = const_cast<void*> (static_cast<const void*>(proc)); Storage_ALLOCATE (&s->debug.file, (StrLib_StrLen ((const char *) file, _file_high))+1); if ((libc_strncpy (s->debug.file, f, (StrLib_StrLen ((const char *) file, _file_high))+1)) == NULL) {} /* empty. */ @@ -971,7 +981,7 @@ static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *f IsOn - returns TRUE if, s, is on one of the debug lists. */ -static bool IsOn (DynamicStrings_String list, DynamicStrings_String s) +static bool IsOn (DynamicStrings_String__opaque list, DynamicStrings_String__opaque s) { while ((list != s) && (list != NULL)) { @@ -987,12 +997,12 @@ static bool IsOn (DynamicStrings_String list, DynamicStrings_String s) AddTo - adds string, s, to, list. */ -static void AddTo (DynamicStrings_String *list, DynamicStrings_String s) +static void AddTo (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s) { if ((*list) == NULL) { (*list) = s; - s->debug.next = NULL; + s->debug.next = static_cast<DynamicStrings_String__opaque> (NULL); } else { @@ -1006,9 +1016,9 @@ static void AddTo (DynamicStrings_String *list, DynamicStrings_String s) SubFrom - removes string, s, from, list. */ -static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) +static void SubFrom (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s) { - DynamicStrings_String p; + DynamicStrings_String__opaque p; if ((*list) == s) { @@ -1028,10 +1038,10 @@ static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) else { /* not found, quit */ - return ; + return; } } - s->debug.next = NULL; + s->debug.next = static_cast<DynamicStrings_String__opaque> (NULL); } @@ -1039,7 +1049,7 @@ static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) AddAllocated - adds string, s, to the head of the allocated list. */ -static void AddAllocated (DynamicStrings_String s) +static void AddAllocated (DynamicStrings_String__opaque s) { Init (); AddTo (&frameHead->alloc, s); @@ -1050,7 +1060,7 @@ static void AddAllocated (DynamicStrings_String s) AddDeallocated - adds string, s, to the head of the deallocated list. */ -static void AddDeallocated (DynamicStrings_String s) +static void AddDeallocated (DynamicStrings_String__opaque s) { Init (); AddTo (&frameHead->dealloc, s); @@ -1061,7 +1071,7 @@ static void AddDeallocated (DynamicStrings_String s) IsOnAllocated - returns TRUE if the string, s, has ever been allocated. */ -static bool IsOnAllocated (DynamicStrings_String s) +static bool IsOnAllocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1087,7 +1097,7 @@ static bool IsOnAllocated (DynamicStrings_String s) IsOnDeallocated - returns TRUE if the string, s, has ever been deallocated. */ -static bool IsOnDeallocated (DynamicStrings_String s) +static bool IsOnDeallocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1113,7 +1123,7 @@ static bool IsOnDeallocated (DynamicStrings_String s) SubAllocated - removes string, s, from the list of allocated strings. */ -static void SubAllocated (DynamicStrings_String s) +static void SubAllocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1123,7 +1133,7 @@ static void SubAllocated (DynamicStrings_String s) if (IsOn (f->alloc, s)) { SubFrom (&f->alloc, s); - return ; + return; } else { @@ -1137,7 +1147,7 @@ static void SubAllocated (DynamicStrings_String s) SubDeallocated - removes string, s, from the list of deallocated strings. */ -static void SubDeallocated (DynamicStrings_String s) +static void SubDeallocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1147,7 +1157,7 @@ static void SubDeallocated (DynamicStrings_String s) if (IsOn (f->dealloc, s)) { SubFrom (&f->dealloc, s); - return ; + return; } else { @@ -1161,13 +1171,13 @@ static void SubDeallocated (DynamicStrings_String s) SubDebugInfo - removes string, s, from the list of allocated strings. */ -static void SubDebugInfo (DynamicStrings_String s) +static void SubDebugInfo (DynamicStrings_String__opaque s) { if (IsOnDeallocated (s)) { Assertion_Assert (! DebugOn); /* string has already been deallocated */ - return ; + return; } if (IsOnAllocated (s)) { @@ -1186,9 +1196,9 @@ static void SubDebugInfo (DynamicStrings_String s) AddDebugInfo - adds string, s, to the list of allocated strings. */ -static void AddDebugInfo (DynamicStrings_String s) +static void AddDebugInfo (DynamicStrings_String__opaque s) { - s->debug.next = NULL; + s->debug.next = static_cast<DynamicStrings_String__opaque> (NULL); s->debug.file = NULL; s->debug.line = 0; s->debug.proc = NULL; @@ -1225,7 +1235,7 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned Storage_ALLOCATE ((void **) &(*c).next, sizeof (DynamicStrings_stringRecord)); (*c).next->head = NULL; (*c).next->contents.len = 0; - (*c).next->contents.next = NULL; + (*c).next->contents.next = static_cast<DynamicStrings_String__opaque> (NULL); ConcatContents (&(*c).next->contents, (const char *) a, _a_high, h, o); AddDebugInfo ((*c).next); (*c).next = AssignDebug ((*c).next, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 722, (const char *) "ConcatContents", 14); @@ -1241,7 +1251,7 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned DeallocateCharStar - deallocates any charStar. */ -static void DeallocateCharStar (DynamicStrings_String s) +static void DeallocateCharStar (DynamicStrings_String__opaque s) { if ((s != NULL) && (s->head != NULL)) { @@ -1261,7 +1271,7 @@ static void DeallocateCharStar (DynamicStrings_String s) CheckPoisoned - checks for a poisoned string, s. */ -static DynamicStrings_String CheckPoisoned (DynamicStrings_String s) +static DynamicStrings_String__opaque CheckPoisoned (DynamicStrings_String__opaque s) { if (((PoisonOn && (s != NULL)) && (s->head != NULL)) && (s->head->state == DynamicStrings_poisoned)) { @@ -1278,7 +1288,7 @@ static DynamicStrings_String CheckPoisoned (DynamicStrings_String s) MarkInvalid - marks the char * version of String, s, as invalid. */ -static void MarkInvalid (DynamicStrings_String s) +static void MarkInvalid (DynamicStrings_String__opaque s) { if (PoisonOn) { @@ -1321,7 +1331,7 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne Storage_ALLOCATE ((void **) &(*c).next, sizeof (DynamicStrings_stringRecord)); (*c).next->head = NULL; (*c).next->contents.len = 0; - (*c).next->contents.next = NULL; + (*c).next->contents.next = static_cast<DynamicStrings_String__opaque> (NULL); ConcatContentsAddress (&(*c).next->contents, reinterpret_cast<void *> (p), h-j); AddDebugInfo ((*c).next); if (TraceOn) @@ -1332,7 +1342,7 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne else { (*c).len = i; - (*c).next = NULL; + (*c).next = static_cast<DynamicStrings_String__opaque> (NULL); } } @@ -1343,9 +1353,9 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne onlist. String, a, is returned. */ -static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrings_String b) +static DynamicStrings_String__opaque AddToGarbage (DynamicStrings_String__opaque a, DynamicStrings_String__opaque b) { - DynamicStrings_String c; + DynamicStrings_String__opaque c; if (PoisonOn) { @@ -1382,7 +1392,7 @@ static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrin IsOnGarbage - returns TRUE if, s, is on string, e, garbage list. */ -static bool IsOnGarbage (DynamicStrings_String e, DynamicStrings_String s) +static bool IsOnGarbage (DynamicStrings_String__opaque e, DynamicStrings_String__opaque s) { if ((e != NULL) && (s != NULL)) { @@ -1420,7 +1430,7 @@ static bool IsWhite (char ch) DumpState - */ -static void DumpState (DynamicStrings_String s) +static void DumpState (DynamicStrings_String__opaque s) { switch (s->head->state) { @@ -1454,7 +1464,7 @@ static void DumpState (DynamicStrings_String s) DumpStringSynopsis - */ -static void DumpStringSynopsis (DynamicStrings_String s) +static void DumpStringSynopsis (DynamicStrings_String__opaque s) { writeCstring (s->debug.file); writeString ((const char *) ":", 1); @@ -1487,9 +1497,9 @@ static void DumpStringSynopsis (DynamicStrings_String s) DumpString - displays the contents of string, s. */ -static void DumpString (DynamicStrings_String s) +static void DumpString (DynamicStrings_String__opaque s) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { @@ -1531,7 +1541,7 @@ static void Init (void) extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -1539,21 +1549,21 @@ extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsi Storage_ALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); s->contents.len = 0; - s->contents.next = NULL; + s->contents.next = static_cast<DynamicStrings_String__opaque> (NULL); ConcatContents (&s->contents, (const char *) a, _a_high, StrLib_StrLen ((const char *) a, _a_high), 0); Storage_ALLOCATE ((void **) &s->head, sizeof (DynamicStrings_descriptor)); s->head->charStarUsed = false; s->head->charStar = NULL; s->head->charStarSize = 0; s->head->charStarValid = false; - s->head->garbage = NULL; + s->head->garbage = static_cast<DynamicStrings_String__opaque> (NULL); s->head->state = DynamicStrings_inuse; AddDebugInfo (s); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 758, (const char *) "InitString", 10); } - return s; + return static_cast<DynamicStrings_String> (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1566,48 +1576,48 @@ extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsi extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } if (s != NULL) { if (CheckOn) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (IsOnAllocated (s)) + if (IsOnAllocated (static_cast<DynamicStrings_String__opaque> (s))) { - SubAllocated (s); + SubAllocated (static_cast<DynamicStrings_String__opaque> (s)); } - else if (IsOnDeallocated (s)) + else if (IsOnDeallocated (static_cast<DynamicStrings_String__opaque> (s))) { /* avoid dangling else. */ - SubDeallocated (s); + SubDeallocated (static_cast<DynamicStrings_String__opaque> (s)); } } - if (s->head != NULL) + if (static_cast<DynamicStrings_String__opaque> (s)->head != NULL) { - s->head->state = DynamicStrings_poisoned; - s->head->garbage = DynamicStrings_KillString (s->head->garbage); + static_cast<DynamicStrings_String__opaque> (s)->head->state = DynamicStrings_poisoned; + static_cast<DynamicStrings_String__opaque> (s)->head->garbage = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->head->garbage))); if (! PoisonOn) { - DeallocateCharStar (s); + DeallocateCharStar (static_cast<DynamicStrings_String__opaque> (s)); } if (! PoisonOn) { - Storage_DEALLOCATE ((void **) &s->head, sizeof (DynamicStrings_descriptor)); - s->head = NULL; + Storage_DEALLOCATE ((void **) &static_cast<DynamicStrings_String__opaque> (s)->head, sizeof (DynamicStrings_descriptor)); + static_cast<DynamicStrings_String__opaque> (s)->head = NULL; } } - t = DynamicStrings_KillString (s->contents.next); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next))); if (! PoisonOn) { Storage_DEALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); } } - return NULL; + return static_cast<DynamicStrings_String> (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1635,11 +1645,11 @@ extern "C" void DynamicStrings_Fin (DynamicStrings_String s) extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; Storage_ALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); s->contents.len = 0; - s->contents.next = NULL; + s->contents.next = static_cast<DynamicStrings_String__opaque> (NULL); if (a != NULL) { ConcatContentsAddress (&s->contents, a, static_cast<unsigned int> (libc_strlen (a))); @@ -1649,14 +1659,14 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a) s->head->charStar = NULL; s->head->charStarSize = 0; s->head->charStarValid = false; - s->head->garbage = NULL; + s->head->garbage = static_cast<DynamicStrings_String__opaque> (NULL); s->head->state = DynamicStrings_inuse; AddDebugInfo (s); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 957, (const char *) "InitStringCharStar", 18); } - return s; + return static_cast<DynamicStrings_String> (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1672,16 +1682,16 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch) struct InitStringChar__T5_a { char array[1+1]; }; InitStringChar__T5 a; - DynamicStrings_String s; + DynamicStrings_String__opaque s; a.array[0] = ch; a.array[1] = ASCII_nul; - s = DynamicStrings_InitString ((const char *) &a.array[0], 1); + s = static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitString ((const char *) &a.array[0], 1)); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 977, (const char *) "InitStringChar", 14); } - return s; + return static_cast<DynamicStrings_String> (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1695,11 +1705,11 @@ extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s) { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } - if ((s != NULL) && (s->head->state == DynamicStrings_inuse)) + if ((s != NULL) && (static_cast<DynamicStrings_String__opaque> (s)->head->state == DynamicStrings_inuse)) { - s->head->state = DynamicStrings_marked; + static_cast<DynamicStrings_String__opaque> (s)->head->state = DynamicStrings_marked; } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1719,7 +1729,7 @@ extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s) } else { - return s->contents.len+(DynamicStrings_Length (s->contents.next)); + return static_cast<DynamicStrings_String__opaque> (s)->contents.len+(DynamicStrings_Length (static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next))); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -1732,12 +1742,12 @@ extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s) extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (a))); + b = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (b))); } if (a == b) { @@ -1746,17 +1756,17 @@ extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, else if (a != NULL) { /* avoid dangling else. */ - a = AddToGarbage (a, b); - MarkInvalid (a); - t = a; + a = static_cast<DynamicStrings_String> (AddToGarbage (static_cast<DynamicStrings_String__opaque> (a), static_cast<DynamicStrings_String__opaque> (b))); + MarkInvalid (static_cast<DynamicStrings_String__opaque> (a)); + t = static_cast<DynamicStrings_String__opaque> (a); while (b != NULL) { while ((t->contents.len == MaxBuf) && (t->contents.next != NULL)) { t = t->contents.next; } - ConcatContents (&t->contents, (const char *) &b->contents.buf.array[0], (MaxBuf-1), b->contents.len, 0); - b = b->contents.next; + ConcatContents (&t->contents, (const char *) &static_cast<DynamicStrings_String__opaque> (b)->contents.buf.array[0], (MaxBuf-1), static_cast<DynamicStrings_String__opaque> (b)->contents.len, 0); + b = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (b)->contents.next); } } if ((a == NULL) && (b != NULL)) @@ -1780,16 +1790,16 @@ extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_Strin struct ConCatChar__T6_a { char array[1+1]; }; ConCatChar__T6 b; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - a = CheckPoisoned (a); + a = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (a))); } b.array[0] = ch; b.array[1] = ASCII_nul; - t = a; - MarkInvalid (a); + t = static_cast<DynamicStrings_String__opaque> (a); + MarkInvalid (static_cast<DynamicStrings_String__opaque> (a)); while ((t->contents.len == MaxBuf) && (t->contents.next != NULL)) { t = t->contents.next; @@ -1810,13 +1820,13 @@ extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, { if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (a))); + b = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (b))); } if ((a != NULL) && (b != NULL)) { - a->contents.next = DynamicStrings_KillString (a->contents.next); - a->contents.len = 0; + static_cast<DynamicStrings_String__opaque> (a)->contents.next = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (a)->contents.next))); + static_cast<DynamicStrings_String__opaque> (a)->contents.len = 0; } return DynamicStrings_ConCat (a, b); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1830,10 +1840,10 @@ extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; unsigned int i; - t = s; + t = static_cast<DynamicStrings_String__opaque> (s); while (t != NULL) { i = 0; @@ -1861,12 +1871,12 @@ extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s) { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } s = DynamicStrings_Assign (DynamicStrings_InitString ((const char *) "", 0), s); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1198, (const char *) "Dup", 3); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1198, (const char *) "Dup", 3)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1882,13 +1892,13 @@ extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, Dy { if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (a))); + b = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (b))); } a = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "", 0), a), b); if (TraceOn) { - a = AssignDebug (a, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1218, (const char *) "Add", 3); + a = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (a), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1218, (const char *) "Add", 3)); } return a; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1906,25 +1916,25 @@ extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_St if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (a))); + b = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (b))); } if ((DynamicStrings_Length (a)) == (DynamicStrings_Length (b))) { while ((a != NULL) && (b != NULL)) { i = 0; - Assertion_Assert (a->contents.len == b->contents.len); - while (i < a->contents.len) + Assertion_Assert (static_cast<DynamicStrings_String__opaque> (a)->contents.len == static_cast<DynamicStrings_String__opaque> (b)->contents.len); + while (i < static_cast<DynamicStrings_String__opaque> (a)->contents.len) { - if (a->contents.buf.array[i] != b->contents.buf.array[i]) + if (static_cast<DynamicStrings_String__opaque> (a)->contents.buf.array[i] != static_cast<DynamicStrings_String__opaque> (b)->contents.buf.array[i]) { return false; } i += 1; } - a = a->contents.next; - b = b->contents.next; + a = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (a)->contents.next); + b = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (b)->contents.next); } return true; } @@ -1944,26 +1954,26 @@ extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_St extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } - t = DynamicStrings_InitStringCharStar (a); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitStringCharStar (a)); if (TraceOn) { t = AssignDebug (t, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1275, (const char *) "EqualCharStar", 13); } - t = AddToGarbage (t, s); - if (DynamicStrings_Equal (t, s)) + t = AddToGarbage (t, static_cast<DynamicStrings_String__opaque> (s)); + if (DynamicStrings_Equal (static_cast<DynamicStrings_String> (t), s)) { - t = DynamicStrings_KillString (t); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (t))); return true; } else { - t = DynamicStrings_KillString (t); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (t))); return false; } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1978,7 +1988,7 @@ extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a) extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -1986,22 +1996,22 @@ extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char * if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } - t = DynamicStrings_InitString ((const char *) a, _a_high); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitString ((const char *) a, _a_high)); if (TraceOn) { t = AssignDebug (t, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1305, (const char *) "EqualArray", 10); } - t = AddToGarbage (t, s); - if (DynamicStrings_Equal (t, s)) + t = AddToGarbage (t, static_cast<DynamicStrings_String__opaque> (s)); + if (DynamicStrings_Equal (static_cast<DynamicStrings_String> (t), s)) { - t = DynamicStrings_KillString (t); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (t))); return true; } else { - t = DynamicStrings_KillString (t); + t = static_cast<DynamicStrings_String__opaque> (DynamicStrings_KillString (static_cast<DynamicStrings_String> (t))); return false; } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2017,11 +2027,11 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } if (n <= 0) { - s = AddToGarbage (DynamicStrings_InitString ((const char *) "", 0), s); + s = static_cast<DynamicStrings_String> (AddToGarbage (static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitString ((const char *) "", 0)), static_cast<DynamicStrings_String__opaque> (s))); } else { @@ -2029,7 +2039,7 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u } if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1337, (const char *) "Mult", 4); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1337, (const char *) "Mult", 4)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2051,15 +2061,15 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high) { - DynamicStrings_String d; - DynamicStrings_String t; + DynamicStrings_String__opaque d; + DynamicStrings_String__opaque t; int start; int end; int o; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } if (low < 0) { @@ -2074,17 +2084,17 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, /* make sure high is <= Length (s) */ high = Min (DynamicStrings_Length (s), static_cast<unsigned int> (high)); } - d = DynamicStrings_InitString ((const char *) "", 0); - d = AddToGarbage (d, s); + d = static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitString ((const char *) "", 0)); + d = AddToGarbage (d, static_cast<DynamicStrings_String__opaque> (s)); o = 0; t = d; while (s != NULL) { - if (low < (o+((int ) (s->contents.len)))) + if (low < (o+((int ) (static_cast<DynamicStrings_String__opaque> (s)->contents.len)))) { if (o > high) { - s = NULL; + s = static_cast<DynamicStrings_String> (NULL); } else { @@ -2113,22 +2123,22 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, } t = t->contents.next; } - ConcatContentsAddress (&t->contents, &s->contents.buf.array[start], static_cast<unsigned int> (end-start)); - o += s->contents.len; - s = s->contents.next; + ConcatContentsAddress (&t->contents, &static_cast<DynamicStrings_String__opaque> (s)->contents.buf.array[start], static_cast<unsigned int> (end-start)); + o += static_cast<DynamicStrings_String__opaque> (s)->contents.len; + s = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next); } } else { - o += s->contents.len; - s = s->contents.next; + o += static_cast<DynamicStrings_String__opaque> (s)->contents.len; + s = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next); } } if (TraceOn) { d = AssignDebug (d, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1422, (const char *) "Slice", 5); } - return d; + return static_cast<DynamicStrings_String> (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2147,21 +2157,21 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } k = 0; while (s != NULL) { - if ((k+s->contents.len) < o) + if ((k+static_cast<DynamicStrings_String__opaque> (s)->contents.len) < o) { - k += s->contents.len; + k += static_cast<DynamicStrings_String__opaque> (s)->contents.len; } else { i = o-k; - while (i < s->contents.len) + while (i < static_cast<DynamicStrings_String__opaque> (s)->contents.len) { - if (s->contents.buf.array[i] == ch) + if (static_cast<DynamicStrings_String__opaque> (s)->contents.buf.array[i] == ch) { return k+i; } @@ -2170,7 +2180,7 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned k += i; o = k; } - s = s->contents.next; + s = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next); } return -1; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2180,8 +2190,9 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned /* RIndex - returns the indice of the last occurance of, ch, - in String, s. The search starts at position, o. - -1 is returned if, ch, is not found. + in String, s. The search starts at position, o. + -1 is returned if, ch, is not found. The search + is performed left to right. */ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o) @@ -2192,15 +2203,15 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } j = -1; k = 0; while (s != NULL) { - if ((k+s->contents.len) < o) + if ((k+static_cast<DynamicStrings_String__opaque> (s)->contents.len) < o) { - k += s->contents.len; + k += static_cast<DynamicStrings_String__opaque> (s)->contents.len; } else { @@ -2212,9 +2223,9 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned { i = o-k; } - while (i < s->contents.len) + while (i < static_cast<DynamicStrings_String__opaque> (s)->contents.len) { - if (s->contents.buf.array[i] == ch) + if (static_cast<DynamicStrings_String__opaque> (s)->contents.buf.array[i] == ch) { j = k; } @@ -2222,7 +2233,7 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned i += 1; } } - s = s->contents.next; + s = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next); } return j; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2231,6 +2242,52 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned /* + ReverseIndex - returns the indice of the last occurance of ch + in String s. The search starts at position o + and searches from right to left. The start position + may be indexed negatively from the right (-1 is the + last index). + The return value if ch is found will always be positive. + -1 is returned if ch is not found. +*/ + +extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o) +{ + unsigned int c; + + if (PoisonOn) + { + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); + } + if (o < 0) + { + o = ((int ) (DynamicStrings_Length (s)))+o; + if (o < 0) + { + return -1; + } + } + if (((unsigned int ) (o)) < (DynamicStrings_Length (s))) + { + while (o >= 0) + { + if ((DynamicStrings_char (s, o)) == ch) + { + return o; + } + else + { + o -= 1; + } + } + } + return -1; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* RemoveComment - assuming that, comment, is a comment delimiter which indicates anything to its right is a comment then strip off the comment and also any white space @@ -2254,7 +2311,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_St } if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1534, (const char *) "RemoveComment", 13); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1576, (const char *) "RemoveComment", 13)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2279,7 +2336,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicString s = DynamicStrings_Slice (s, (int ) (i), 0); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1646, (const char *) "RemoveWhitePrefix", 17); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1688, (const char *) "RemoveWhitePrefix", 17)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2304,7 +2361,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrin s = DynamicStrings_Slice (s, 0, i+1); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1668, (const char *) "RemoveWhitePostfix", 18); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1710, (const char *) "RemoveWhitePostfix", 18)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2322,12 +2379,12 @@ extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s { char ch; unsigned int i; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { - MarkInvalid (s); - t = s; + MarkInvalid (static_cast<DynamicStrings_String__opaque> (s)); + t = static_cast<DynamicStrings_String__opaque> (s); while (t != NULL) { i = 0; @@ -2359,12 +2416,12 @@ extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s { char ch; unsigned int i; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { - MarkInvalid (s); - t = s; + MarkInvalid (static_cast<DynamicStrings_String__opaque> (s)); + t = static_cast<DynamicStrings_String__opaque> (s); while (t != NULL) { i = 0; @@ -2399,12 +2456,12 @@ extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicSt i = 0; while (i < l) { - a[i] = DynamicStrings_char (s, static_cast<int> (i)); + const_cast<char *>(a)[i] = DynamicStrings_char (s, static_cast<int> (i)); i += 1; } if (i <= _a_high) { - a[i] = ASCII_nul; + const_cast<char *>(a)[i] = ASCII_nul; } } @@ -2419,7 +2476,7 @@ extern "C" char DynamicStrings_char (DynamicStrings_String s, int i) if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } if (i < 0) { @@ -2429,18 +2486,18 @@ extern "C" char DynamicStrings_char (DynamicStrings_String s, int i) { c = i; } - while ((s != NULL) && (c >= s->contents.len)) + while ((s != NULL) && (c >= static_cast<DynamicStrings_String__opaque> (s)->contents.len)) { - c -= s->contents.len; - s = s->contents.next; + c -= static_cast<DynamicStrings_String__opaque> (s)->contents.len; + s = static_cast<DynamicStrings_String> (static_cast<DynamicStrings_String__opaque> (s)->contents.next); } - if ((s == NULL) || (c >= s->contents.len)) + if ((s == NULL) || (c >= static_cast<DynamicStrings_String__opaque> (s)->contents.len)) { return ASCII_nul; } else { - return s->contents.buf.array[c]; + return static_cast<DynamicStrings_String__opaque> (s)->contents.buf.array[c]; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2455,14 +2512,14 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) { typedef char *string__T2; - DynamicStrings_String a; + DynamicStrings_String__opaque a; unsigned int l; unsigned int i; string__T2 p; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast<DynamicStrings_String> (CheckPoisoned (static_cast<DynamicStrings_String__opaque> (s))); } if (s == NULL) { @@ -2470,18 +2527,18 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) } else { - if (! s->head->charStarValid) + if (! static_cast<DynamicStrings_String__opaque> (s)->head->charStarValid) { l = DynamicStrings_Length (s); - if (! (s->head->charStarUsed && (s->head->charStarSize > l))) + if (! (static_cast<DynamicStrings_String__opaque> (s)->head->charStarUsed && (static_cast<DynamicStrings_String__opaque> (s)->head->charStarSize > l))) { - DeallocateCharStar (s); - Storage_ALLOCATE (&s->head->charStar, l+1); - s->head->charStarSize = l+1; - s->head->charStarUsed = true; + DeallocateCharStar (static_cast<DynamicStrings_String__opaque> (s)); + Storage_ALLOCATE (&static_cast<DynamicStrings_String__opaque> (s)->head->charStar, l+1); + static_cast<DynamicStrings_String__opaque> (s)->head->charStarSize = l+1; + static_cast<DynamicStrings_String__opaque> (s)->head->charStarUsed = true; } - p = static_cast<string__T2> (s->head->charStar); - a = s; + p = static_cast<string__T2> (static_cast<DynamicStrings_String__opaque> (s)->head->charStar); + a = static_cast<DynamicStrings_String__opaque> (s); while (a != NULL) { i = 0; @@ -2494,9 +2551,9 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) a = a->contents.next; } (*p) = ASCII_nul; - s->head->charStarValid = true; + static_cast<DynamicStrings_String__opaque> (s)->head->charStarValid = true; } - return s->head->charStar; + return static_cast<DynamicStrings_String__opaque> (s)->head->charStar; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2516,7 +2573,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, un memcpy (a, a_, _a_high+1); memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitString ((const char *) a, _a_high), (const char *) file, _file_high, line, (const char *) "InitString", 10); + return static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitString ((const char *) a, _a_high)), (const char *) file, _file_high, line, (const char *) "InitString", 10)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2533,7 +2590,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitStringCharStar (a), (const char *) file, _file_high, line, (const char *) "InitStringCharStar", 18); + return static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitStringCharStar (a)), (const char *) file, _file_high, line, (const char *) "InitStringCharStar", 18)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2550,7 +2607,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitStringChar (ch), (const char *) file, _file_high, line, (const char *) "InitStringChar", 14); + return static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_InitStringChar (ch)), (const char *) file, _file_high, line, (const char *) "InitStringChar", 14)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2567,7 +2624,7 @@ extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_Mult (s, n), (const char *) file, _file_high, line, (const char *) "Mult", 4); + return static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_Mult (s, n)), (const char *) file, _file_high, line, (const char *) "Mult", 4)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2584,7 +2641,7 @@ extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_Dup (s), (const char *) file, _file_high, line, (const char *) "Dup", 3); + return static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_Dup (s)), (const char *) file, _file_high, line, (const char *) "Dup", 3)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2602,8 +2659,8 @@ extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s memcpy (file, file_, _file_high+1); DSdbEnter (); - s = AssignDebug (DynamicStrings_Slice (s, low, high), (const char *) file, _file_high, line, (const char *) "Slice", 5); - DSdbExit (s); + s = static_cast<DynamicStrings_String> (AssignDebug (static_cast<DynamicStrings_String__opaque> (DynamicStrings_Slice (s, low, high)), (const char *) file, _file_high, line, (const char *) "Slice", 5)); + DSdbExit (static_cast<DynamicStrings_String__opaque> (s)); return s; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2623,8 +2680,8 @@ extern "C" void DynamicStrings_PushAllocation (void) Init (); Storage_ALLOCATE ((void **) &f, sizeof (DynamicStrings_frameRec)); f->next = frameHead; - f->alloc = NULL; - f->dealloc = NULL; + f->alloc = static_cast<DynamicStrings_String__opaque> (NULL); + f->dealloc = static_cast<DynamicStrings_String__opaque> (NULL); frameHead = f; } } @@ -2643,7 +2700,7 @@ extern "C" void DynamicStrings_PopAllocation (bool halt) { if (CheckOn) { - if ((DynamicStrings_PopAllocationExemption (halt, NULL)) == NULL) + if ((DynamicStrings_PopAllocationExemption (halt, static_cast<DynamicStrings_String> (NULL))) == NULL) {} /* empty. */ } } @@ -2661,7 +2718,7 @@ extern "C" void DynamicStrings_PopAllocation (bool halt) extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; bool b; Init (); @@ -2682,7 +2739,7 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal s = frameHead->alloc; while (s != NULL) { - if (! (((e == s) || (IsOnGarbage (e, s))) || (IsOnGarbage (s, e)))) + if (! (((e == s) || (IsOnGarbage (static_cast<DynamicStrings_String__opaque> (e), s))) || (IsOnGarbage (s, static_cast<DynamicStrings_String__opaque> (e))))) { if (! b) { @@ -2707,12 +2764,12 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal __builtin_unreachable (); } -extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Initialized = false; Init (); } -extern "C" void _M2_DynamicStrings_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_DynamicStrings_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/pge-boot/GDynamicStrings.h b/gcc/m2/pge-boot/GDynamicStrings.h index 76f4cea..e0652a7 100644 --- a/gcc/m2/pge-boot/GDynamicStrings.h +++ b/gcc/m2/pge-boot/GDynamicStrings.h @@ -194,13 +194,26 @@ EXTERN int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int /* RIndex - returns the indice of the last occurance of, ch, - in String, s. The search starts at position, o. - -1 is returned if, ch, is not found. + in String, s. The search starts at position, o. + -1 is returned if ch is not found. The search + is performed left to right. */ EXTERN int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o); /* + ReverseIndex - returns the indice of the last occurance of ch + in String s. The search starts at position o + and searches from right to left. The start position + may be indexed negatively from the right (-1 is the + last index). + The return value if ch is found will always be positive. + -1 is returned if ch is not found. +*/ + +EXTERN int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o); + +/* RemoveComment - assuming that, comment, is a comment delimiter which indicates anything to its right is a comment then strip off the comment and also any white space diff --git a/gcc/m2/pge-boot/GM2RTS.h b/gcc/m2/pge-boot/GM2RTS.h index 055cc95..4186c8f 100644 --- a/gcc/m2/pge-boot/GM2RTS.h +++ b/gcc/m2/pge-boot/GM2RTS.h @@ -54,6 +54,11 @@ typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP; typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *); struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; }; +#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \ + M2RTS_RegisterModule (reinterpret_cast <void *> (const_cast <char *> (MODNAME)), \ + reinterpret_cast <void *> (const_cast <char *> (LIBNAME)), \ + init, fini, dep) + EXTERN void M2RTS_ConstructModules (void * applicationmodule, void * libname, void * overrideliborder, int argc, void * argv, void * envp); EXTERN void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp); @@ -63,7 +68,10 @@ EXTERN void M2RTS_DeconstructModules (void * applicationmodule, void * libname, explored to determine initialization order. */ -EXTERN void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies); +EXTERN void M2RTS_RegisterModule (void *name, void *libname, + M2RTS_ArgCVEnvP init, + M2RTS_ArgCVEnvP fini, + PROC dependencies); /* RequestDependant - used to specify that modulename is dependant upon diff --git a/gcc/m2/pge-boot/GSymbolKey.cc b/gcc/m2/pge-boot/GSymbolKey.cc index 5f22ae2..ec27e2c 100644 --- a/gcc/m2/pge-boot/GSymbolKey.cc +++ b/gcc/m2/pge-boot/GSymbolKey.cc @@ -20,6 +20,8 @@ You should have received a copy of the GNU General Public License along with GNU Modula-2; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ +#include "config.h" +#include "system.h" #include <stdbool.h> # if !defined (PROC_D) # define PROC_D @@ -31,15 +33,14 @@ along with GNU Modula-2; see the file COPYING3. If not see # define FALSE (1==0) # endif -#include <stddef.h> # include "GStorage.h" #if defined(__cplusplus) # undef NULL # define NULL 0 #endif -#define _SymbolKey_H #define _SymbolKey_C +#include "GSymbolKey.h" # include "GStorage.h" # include "GStrIO.h" # include "GNumberIO.h" @@ -54,19 +55,13 @@ typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation; typedef struct SymbolKey_Node_r SymbolKey_Node; -typedef SymbolKey_Node *SymbolKey_SymbolTree; - -typedef bool (*SymbolKey_IsSymbol_t) (unsigned int); -struct SymbolKey_IsSymbol_p { SymbolKey_IsSymbol_t proc; }; - -typedef void (*SymbolKey_PerformOperation_t) (unsigned int); -struct SymbolKey_PerformOperation_p { SymbolKey_PerformOperation_t proc; }; +typedef SymbolKey_Node *SymbolKey_SymbolTree__opaque; struct SymbolKey_Node_r { NameKey_Name KeyName; unsigned int KeySym; - SymbolKey_SymbolTree Left; - SymbolKey_SymbolTree Right; + SymbolKey_SymbolTree__opaque Left; + SymbolKey_SymbolTree__opaque Right; }; extern "C" void SymbolKey_InitTree (SymbolKey_SymbolTree *t); @@ -142,7 +137,7 @@ extern "C" void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, Symbol if an entry is found, parent is set to the node above child. */ -static void FindNodeParentInTree (SymbolKey_SymbolTree t, NameKey_Name n, SymbolKey_SymbolTree *child, SymbolKey_SymbolTree *parent); +static void FindNodeParentInTree (SymbolKey_SymbolTree__opaque t, NameKey_Name n, SymbolKey_SymbolTree__opaque *child, SymbolKey_SymbolTree__opaque *parent); /* SearchForAny - performs the search required for DoesTreeContainAny. @@ -150,7 +145,7 @@ static void FindNodeParentInTree (SymbolKey_SymbolTree t, NameKey_Name n, Symbol therefore we must skip over it. */ -static bool SearchForAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P); +static bool SearchForAny (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol P); /* SearchAndDo - searches all the nodes in SymbolTree, t, and @@ -158,19 +153,19 @@ static bool SearchForAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P); It traverse the tree in order. */ -static void SearchAndDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P); +static void SearchAndDo (SymbolKey_SymbolTree__opaque t, SymbolKey_PerformOperation P); /* CountNodes - wrapper for NoOfNodes. */ -static unsigned int CountNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, unsigned int count); +static unsigned int CountNodes (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol condition, unsigned int count); /* SearchConditional - wrapper for ForeachNodeConditionDo. */ -static void SearchConditional (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P); +static void SearchConditional (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P); /* @@ -178,7 +173,7 @@ static void SearchConditional (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condit if an entry is found, parent is set to the node above child. */ -static void FindNodeParentInTree (SymbolKey_SymbolTree t, NameKey_Name n, SymbolKey_SymbolTree *child, SymbolKey_SymbolTree *parent) +static void FindNodeParentInTree (SymbolKey_SymbolTree__opaque t, NameKey_Name n, SymbolKey_SymbolTree__opaque *child, SymbolKey_SymbolTree__opaque *parent) { /* remember to skip the sentinal value and assign parent and child */ (*parent) = t; @@ -213,7 +208,7 @@ static void FindNodeParentInTree (SymbolKey_SymbolTree t, NameKey_Name n, Symbol therefore we must skip over it. */ -static bool SearchForAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P) +static bool SearchForAny (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol P) { if (t == NULL) { @@ -234,7 +229,7 @@ static bool SearchForAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P) It traverse the tree in order. */ -static void SearchAndDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P) +static void SearchAndDo (SymbolKey_SymbolTree__opaque t, SymbolKey_PerformOperation P) { if (t != NULL) { @@ -249,7 +244,7 @@ static void SearchAndDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P) CountNodes - wrapper for NoOfNodes. */ -static unsigned int CountNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, unsigned int count) +static unsigned int CountNodes (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol condition, unsigned int count) { if (t != NULL) { @@ -270,7 +265,7 @@ static unsigned int CountNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condi SearchConditional - wrapper for ForeachNodeConditionDo. */ -static void SearchConditional (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P) +static void SearchConditional (SymbolKey_SymbolTree__opaque t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P) { if (t != NULL) { @@ -286,8 +281,8 @@ static void SearchConditional (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condit extern "C" void SymbolKey_InitTree (SymbolKey_SymbolTree *t) { Storage_ALLOCATE ((void **) &(*t), sizeof (SymbolKey_Node)); /* The value entity */ - (*t)->Left = NULL; - (*t)->Right = NULL; + static_cast<SymbolKey_SymbolTree__opaque> ((*t))->Left = static_cast<SymbolKey_SymbolTree__opaque> (NULL); + static_cast<SymbolKey_SymbolTree__opaque> ((*t))->Right = static_cast<SymbolKey_SymbolTree__opaque> (NULL); } extern "C" void SymbolKey_KillTree (SymbolKey_SymbolTree *t) @@ -322,10 +317,10 @@ END Kill ; */ if ((*t) != NULL) { - SymbolKey_KillTree (&(*t)->Left); - SymbolKey_KillTree (&(*t)->Right); + SymbolKey_KillTree (reinterpret_cast<SymbolKey_SymbolTree *> (&static_cast<SymbolKey_SymbolTree__opaque> ((*t))->Left)); + SymbolKey_KillTree (reinterpret_cast<SymbolKey_SymbolTree *> (&static_cast<SymbolKey_SymbolTree__opaque> ((*t))->Right)); Storage_DEALLOCATE ((void **) &(*t), sizeof (SymbolKey_Node)); - (*t) = NULL; + (*t) = static_cast<SymbolKey_SymbolTree> (NULL); } } @@ -336,10 +331,10 @@ END Kill ; extern "C" unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey) { - SymbolKey_SymbolTree father; - SymbolKey_SymbolTree child; + SymbolKey_SymbolTree__opaque father; + SymbolKey_SymbolTree__opaque child; - FindNodeParentInTree (t, NameKey, &child, &father); + FindNodeParentInTree (static_cast<SymbolKey_SymbolTree__opaque> (t), NameKey, &child, &father); if (child == NULL) { return static_cast<unsigned int> (SymbolKey_NulKey); @@ -359,10 +354,10 @@ extern "C" unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Nam extern "C" void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey, unsigned int SymKey) { - SymbolKey_SymbolTree father; - SymbolKey_SymbolTree child; + SymbolKey_SymbolTree__opaque father; + SymbolKey_SymbolTree__opaque child; - FindNodeParentInTree (t, NameKey, &child, &father); + FindNodeParentInTree (static_cast<SymbolKey_SymbolTree__opaque> (t), NameKey, &child, &father); if (child == NULL) { /* no child found, now is NameKey less than father or greater? */ @@ -386,8 +381,8 @@ extern "C" void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKe father->Right = child; } } - child->Right = NULL; - child->Left = NULL; + child->Right = static_cast<SymbolKey_SymbolTree__opaque> (NULL); + child->Left = static_cast<SymbolKey_SymbolTree__opaque> (NULL); child->KeySym = SymKey; child->KeyName = NameKey; } @@ -407,11 +402,11 @@ extern "C" void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKe extern "C" void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey) { - SymbolKey_SymbolTree i; - SymbolKey_SymbolTree child; - SymbolKey_SymbolTree father; + SymbolKey_SymbolTree__opaque i; + SymbolKey_SymbolTree__opaque child; + SymbolKey_SymbolTree__opaque father; - FindNodeParentInTree (t, NameKey, &child, &father); /* find father and child of the node */ + FindNodeParentInTree (static_cast<SymbolKey_SymbolTree__opaque> (t), NameKey, &child, &father); /* find father and child of the node */ if ((child != NULL) && (child->KeyName == NameKey)) { /* Have found the node to be deleted */ @@ -471,7 +466,7 @@ extern "C" void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKe extern "C" bool SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t) { - return t->Left == NULL; + return static_cast<SymbolKey_SymbolTree__opaque> (t)->Left == NULL; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -487,7 +482,7 @@ extern "C" bool SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t) extern "C" bool SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P) { - return SearchForAny (t->Left, P); + return SearchForAny (static_cast<SymbolKey_SymbolTree__opaque> (t)->Left, P); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -502,7 +497,7 @@ extern "C" bool SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_ extern "C" void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P) { - SearchAndDo (t->Left, P); + SearchAndDo (static_cast<SymbolKey_SymbolTree__opaque> (t)->Left, P); } @@ -512,10 +507,10 @@ extern "C" void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_Perfo extern "C" bool SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey) { - SymbolKey_SymbolTree father; - SymbolKey_SymbolTree child; + SymbolKey_SymbolTree__opaque father; + SymbolKey_SymbolTree__opaque child; - FindNodeParentInTree (t, NameKey, &child, &father); + FindNodeParentInTree (static_cast<SymbolKey_SymbolTree__opaque> (t), NameKey, &child, &father); return child != NULL; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -528,7 +523,7 @@ extern "C" bool SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name N extern "C" unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition) { - return CountNodes (t->Left, condition, 0); + return CountNodes (static_cast<SymbolKey_SymbolTree__opaque> (t)->Left, condition, 0); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -543,15 +538,15 @@ extern "C" void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, Symbol { if (t != NULL) { - Assertion_Assert (t->Right == NULL); - SearchConditional (t->Left, condition, P); + Assertion_Assert (static_cast<SymbolKey_SymbolTree__opaque> (t)->Right == NULL); + SearchConditional (static_cast<SymbolKey_SymbolTree__opaque> (t)->Left, condition, P); } } -extern "C" void _M2_SymbolKey_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SymbolKey_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_SymbolKey_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SymbolKey_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/pge-boot/GSysExceptions.cc b/gcc/m2/pge-boot/GSysExceptions.cc index dee36f9..d16197d 100644 --- a/gcc/m2/pge-boot/GSysExceptions.cc +++ b/gcc/m2/pge-boot/GSysExceptions.cc @@ -226,12 +226,12 @@ SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef, EXTERN void -_M2_SysExceptions_init (void) +_M2_SysExceptions_init (int argc, char *argv[], char *envp[]) { } EXTERN void -_M2_SysExceptions_fini (void) +_M2_SysExceptions_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/pge-boot/GUnixArgs.cc b/gcc/m2/pge-boot/GUnixArgs.cc index 02d0df3..cab9f7a 100644 --- a/gcc/m2/pge-boot/GUnixArgs.cc +++ b/gcc/m2/pge-boot/GUnixArgs.cc @@ -88,6 +88,6 @@ struct _M2_UnixArgs_ctor { _M2_UnixArgs_ctor (); } _M2_UnixArgs_ctor; _M2_UnixArgs_ctor::_M2_UnixArgs_ctor (void) { - M2RTS_RegisterModule ("UnixArgs", LIBNAME, _M2_UnixArgs_init, _M2_UnixArgs_fini, - _M2_UnixArgs_dep); + M2RTS_RegisterModule_Cstr ("UnixArgs", LIBNAME, _M2_UnixArgs_init, + _M2_UnixArgs_fini, _M2_UnixArgs_dep); } diff --git a/gcc/m2/pge-boot/Gerrno.cc b/gcc/m2/pge-boot/Gerrno.cc index d51a619..ca4e232 100644 --- a/gcc/m2/pge-boot/Gerrno.cc +++ b/gcc/m2/pge-boot/Gerrno.cc @@ -38,14 +38,14 @@ errno_geterrno (void) /* init constructor for the module. */ void -_M2_errno_init (int argc, char *p) +_M2_errno_init (int argc, char *argv[], char *envp[]) { } /* finish deconstructor for the module. */ void -_M2_errno_fini (int argc, char *p) +_M2_errno_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/pge-boot/Gldtoa.cc b/gcc/m2/pge-boot/Gldtoa.cc index c1a7450..a3ae396 100644 --- a/gcc/m2/pge-boot/Gldtoa.cc +++ b/gcc/m2/pge-boot/Gldtoa.cc @@ -43,22 +43,22 @@ extern int dtoa_calcsign (char *p, int str_size); (ndigits may be negative). */ long double -ldtoa_strtold (const char *s, int *error) +ldtoa_strtold (void *s, bool *error) { char *endp; long double d; errno = 0; #if defined(HAVE_STRTOLD) - d = strtold (s, &endp); + d = strtold (reinterpret_cast <char *> (s), &endp); #else /* fall back to using strtod. */ - d = (long double)strtod (s, &endp); + d = (long double) strtod (reinterpret_cast <char *> (s), &endp); #endif if (endp != NULL && (*endp == '\0')) *error = (errno != 0); else - *error = TRUE; + *error = true; return d; } diff --git a/gcc/m2/pge-boot/Gldtoa.h b/gcc/m2/pge-boot/Gldtoa.h index df1f791..0678e9e 100644 --- a/gcc/m2/pge-boot/Gldtoa.h +++ b/gcc/m2/pge-boot/Gldtoa.h @@ -57,7 +57,7 @@ typedef enum {ldtoa_maxsignificant, ldtoa_decimaldigits} ldtoa_Mode; error to TRUE if the number is too large or badly formed. */ -EXTERN long double ldtoa_strtold (void * s, bool *error); +EXTERN long double ldtoa_strtold (void *s, bool *error); /* ldtoa - converts a LONGREAL, d, into a string. The address of the diff --git a/gcc/m2/pge-boot/Glibc.cc b/gcc/m2/pge-boot/Glibc.cc index abeb56a..a63b328 100644 --- a/gcc/m2/pge-boot/Glibc.cc +++ b/gcc/m2/pge-boot/Glibc.cc @@ -29,15 +29,15 @@ along with GNU Modula-2; see the file COPYING3. If not see #endif EXTERN -int -libc_read (int fd, void *a, int nbytes) +size_t +libc_read (int fd, void *a, size_t nbytes) { return read (fd, a, nbytes); } EXTERN -int -libc_write (int fd, void *a, int nbytes) +size_t +libc_write (int fd, void *a, size_t nbytes) { return write (fd, a, nbytes); } @@ -58,7 +58,7 @@ libc_exit (int code) EXTERN void -libc_perror (char *s) +libc_perror (const char *s) { perror (s); } @@ -71,7 +71,7 @@ libc_abort () } EXTERN -int +size_t libc_strlen (char *s) { return strlen (s); @@ -79,7 +79,7 @@ libc_strlen (char *s) EXTERN int -libc_printf (char *_format, unsigned int _format_high, ...) +libc_printf (const char *_format, unsigned int _format_high, ...) { va_list arg; int done; @@ -90,7 +90,7 @@ libc_printf (char *_format, unsigned int _format_high, ...) do { - c = index (&_format[i], '\\'); + c = index (&const_cast <char *> (_format)[i], '\\'); if (c == NULL) strcpy (&format[j], &_format[i]); else @@ -117,7 +117,7 @@ libc_printf (char *_format, unsigned int _format_high, ...) EXTERN int -libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_high, ...) +libc_snprintf (void *dest, size_t length, const char *_format, unsigned int _format_high, ...) { va_list arg; int done; @@ -128,7 +128,7 @@ libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_hi do { - c = index (&_format[i], '\\'); + c = index (&const_cast <char *> (_format)[i], '\\'); if (c == NULL) strcpy (&format[j], &_format[i]); else @@ -147,14 +147,14 @@ libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_hi while (c != NULL); va_start (arg, _format_high); - done = vsnprintf (dest, length, format, arg); + done = vsnprintf (reinterpret_cast<char *> (dest), length, format, arg); va_end (arg); return done; } EXTERN void * -libc_malloc (unsigned int size) +libc_malloc (size_t size) { return malloc (size); } @@ -196,9 +196,9 @@ libc_system (char *command) EXTERN void * -libc_memcpy (void *dest, void *src, int n) +libc_memcpy (void *dest, void *src, size_t nbytes) { - return memcpy (dest, src, n); + return memcpy (dest, src, nbytes); } EXTERN @@ -224,9 +224,14 @@ libc_creat (char *p, mode_t mode) EXTERN int -libc_open (char *p, int flags, mode_t mode) +libc_open (void *p, int oflag, ...) { - return open (p, flags, mode); + va_list arg; + va_start (arg, oflag); + mode_t mode = va_arg (arg, mode_t); + int result = open (reinterpret_cast <char *> (p), oflag, mode); + va_end (arg); + return result; } EXTERN diff --git a/gcc/m2/pge-boot/Glibc.h b/gcc/m2/pge-boot/Glibc.h index 382b737..a555893 100644 --- a/gcc/m2/pge-boot/Glibc.h +++ b/gcc/m2/pge-boot/Glibc.h @@ -198,7 +198,7 @@ EXTERN ssize_t libc_lseek (int fd, ssize_t offset, int whence); perror - writes errno and string. (ARRAY OF CHAR is translated onto ADDRESS). */ -EXTERN void libc_perror (const char *string_, unsigned int _string_high); +EXTERN void libc_perror (const char *str); /* readv - reads an io vector of bytes. diff --git a/gcc/m2/pge-boot/Gpge.cc b/gcc/m2/pge-boot/Gpge.cc index 1fbf961..e231abe 100644 --- a/gcc/m2/pge-boot/Gpge.cc +++ b/gcc/m2/pge-boot/Gpge.cc @@ -504,20 +504,20 @@ static void EndModName (pge_SetOfStop stop); static void DoDeclaration (pge_SetOfStop stop); /* - CollectLiteral := + CollectLiteral := % LastLiteral := GetCurrentToken() ; AdvanceToken ; % - + first symbols:literaltok - + cannot reachend */ static void CollectLiteral (pge_SetOfStop stopset); /* - CollectTok := + CollectTok := % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := tokel ; @@ -532,46 +532,46 @@ static void CollectLiteral (pge_SetOfStop stopset); INC(LargestValue) END ; AdvanceToken() ; % - + first symbols:identtok - + cannot reachend */ static void CollectTok (pge_SetOfStop stopset); /* - DefineToken := + DefineToken := % AddEntry(Aliases, LastLiteral, GetCurrentToken()) ; AddEntry(ReverseAliases, GetCurrentToken(), LastLiteral) ; AddEntry(Values, GetCurrentToken(), LargestValue) ; AddEntry(ReverseValues, Name(LargestValue), GetCurrentToken()) ; INC(LargestValue) ; AdvanceToken ; % - + first symbols:identtok - + cannot reachend */ static void DefineToken (pge_SetOfStop stopset); /* - Rules := '%' 'rules' { Defs } ExtBNF + Rules := '%' 'rules' { Defs } ExtBNF first symbols:codetok - + cannot reachend */ static void Rules (pge_SetOfStop stopset); /* - Special := Ident + Special := Ident % VAR p: ProductionDesc ; % - + % p := NewProduction() ; p^.statement := NewStatement() ; p^.statement^.followinfo^.calcfollow := TRUE ; @@ -583,31 +583,31 @@ static void Rules (pge_SetOfStop stopset); p^.followinfo^.calcfollow := TRUE ; p^.followinfo^.epsilon := false ; p^.followinfo^.reachend := false % - First Follow [ 'epsilon' - % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging + First Follow [ 'epsilon' + % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging p^.statement^.followinfo^.reachend := true ; p^.followinfo^.epsilon := true ; p^.followinfo^.reachend := true % - ] [ Literal + ] [ Literal % p^.description := LastLiteral % - ] + ] first symbols:identtok - + cannot reachend */ static void Special (pge_SetOfStop stopset); /* - Factor := '%' Modula2Code '%' | - Ident + Factor := '%' Modula2Code '%' | + Ident % WITH CurrentFactor^ DO type := id ; ident := CurrentIdent END ; % - | Literal + | Literal % WITH CurrentFactor^ DO type := lit ; string := LastLiteral ; @@ -616,39 +616,39 @@ static void Special (pge_SetOfStop stopset); WarnError1('no token defined for literal %s', LastLiteral) END END ; % - | '{' + | '{' % WITH CurrentFactor^ DO type := mult ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression '}' | '[' + Expression '}' | '[' % WITH CurrentFactor^ DO type := opt ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ']' | '(' + Expression ']' | '(' % WITH CurrentFactor^ DO type := sub ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ')' + Expression ')' first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ static void Factor (pge_SetOfStop stopset); /* - Statement := + Statement := % VAR i: IdentDesc ; % - Ident + Ident % VAR p: ProductionDesc ; % - + % p := FindDefinition(CurrentIdent^.name) ; IF p=NIL THEN @@ -660,264 +660,264 @@ static void Factor (pge_SetOfStop stopset); END END ; i := CurrentIdent ; % - ':=' + ':=' % VAR e: ExpressionDesc ; % - + % e := NewExpression() ; CurrentExpression := e ; % - + % VAR s: StatementDesc ; % - + % s := NewStatement() ; WITH s^ DO ident := i ; expr := e END ; % - Expression + Expression % p^.statement := s ; % - '=:' + '=:' first symbols:identtok - + cannot reachend */ static void Statement (pge_SetOfStop stopset); /* - Defs := 'special' Special | 'token' Token | - 'error' ErrorProcedures | - 'tokenfunc' TokenProcedure | - 'symfunc' SymProcedure + Defs := 'special' Special | 'token' Token | + 'error' ErrorProcedures | + 'tokenfunc' TokenProcedure | + 'symfunc' SymProcedure first symbols:symfunctok, tfunctok, errortok, tokentok, specialtok - + cannot reachend */ static void Defs (pge_SetOfStop stopset); /* - ExtBNF := 'BNF' { Production } 'FNB' + ExtBNF := 'BNF' { Production } 'FNB' first symbols:BNFtok - + cannot reachend */ static void ExtBNF (pge_SetOfStop stopset); /* - Main := Header Decls Footer Rules + Main := Header Decls Footer Rules first symbols:codetok - + cannot reachend */ static void Main (pge_SetOfStop stopset); /* - Header := '%' 'module' StartModName + Header := '%' 'module' StartModName first symbols:codetok - + cannot reachend */ static void Header (pge_SetOfStop stopset); /* - Decls := '%' 'declaration' DoDeclaration + Decls := '%' 'declaration' DoDeclaration first symbols:codetok - + cannot reachend */ static void Decls (pge_SetOfStop stopset); /* - Footer := '%' 'module' EndModName + Footer := '%' 'module' EndModName first symbols:codetok - + cannot reachend */ static void Footer (pge_SetOfStop stopset); /* - First := 'first' '{' { LitOrTokenOrIdent + First := 'first' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.first ; END ; TailProduction^.first := CurrentSetDesc % - } '}' + } '}' first symbols:firsttok - + cannot reachend */ static void First (pge_SetOfStop stopset); /* - Follow := 'follow' '{' { LitOrTokenOrIdent + Follow := 'follow' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.followinfo^.follow ; END ; TailProduction^.followinfo^.follow := CurrentSetDesc % - } '}' + } '}' first symbols:followtok - + cannot reachend */ static void Follow (pge_SetOfStop stopset); /* - LitOrTokenOrIdent := Literal + LitOrTokenOrIdent := Literal % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := litel ; string := LastLiteral ; END ; % - | '<' CollectTok '>' | - Ident + | '<' CollectTok '>' | + Ident % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := idel ; ident := CurrentIdent ; END ; % - + first symbols:dquotetok, squotetok, identtok, lesstok - + cannot reachend */ static void LitOrTokenOrIdent (pge_SetOfStop stopset); /* - Literal := '"' CollectLiteral '"' | - "'" CollectLiteral "'" + Literal := '"' CollectLiteral '"' | + "'" CollectLiteral "'" first symbols:squotetok, dquotetok - + cannot reachend */ static void Literal (pge_SetOfStop stopset); /* - Token := Literal DefineToken + Token := Literal DefineToken first symbols:dquotetok, squotetok - + cannot reachend */ static void Token (pge_SetOfStop stopset); /* - ErrorProcedures := Literal + ErrorProcedures := Literal % ErrorProcArray := LastLiteral % - Literal + Literal % ErrorProcString := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void ErrorProcedures (pge_SetOfStop stopset); /* - TokenProcedure := Literal + TokenProcedure := Literal % TokenTypeProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void TokenProcedure (pge_SetOfStop stopset); /* - SymProcedure := Literal + SymProcedure := Literal % SymIsProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void SymProcedure (pge_SetOfStop stopset); /* - Production := Statement + Production := Statement first symbols:identtok - + cannot reachend */ static void Production (pge_SetOfStop stopset); /* - Expression := + Expression := % VAR t1, t2: TermDesc ; e : ExpressionDesc ; % - + % e := CurrentExpression ; t1 := NewTerm() ; CurrentTerm := t1 ; % - Term + Term % e^.term := t1 ; % - { '|' + { '|' % t2 := NewTerm() ; CurrentTerm := t2 % - Term + Term % t1^.next := t2 ; t1 := t2 % - } + } first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ static void Expression (pge_SetOfStop stopset); /* - Term := + Term := % VAR t1: TermDesc ; f1, f2: FactorDesc ; % - + % CurrentFactor := NewFactor() ; f1 := CurrentFactor ; t1 := CurrentTerm ; % - Factor + Factor % t1^.factor := f1 ; f2 := NewFactor() ; CurrentFactor := f2 % - { Factor + { Factor % f1^.next := f2 ; f1 := f2 ; f2 := NewFactor() ; CurrentFactor := f2 ; % - } + } first symbols:squotetok, dquotetok, codetok, identtok, lcparatok, lsparatok, lparatok - + cannot reachend */ @@ -1994,20 +1994,20 @@ static void EndModName (pge_SetOfStop stop); static void DoDeclaration (pge_SetOfStop stop); /* - CollectLiteral := + CollectLiteral := % LastLiteral := GetCurrentToken() ; AdvanceToken ; % - + first symbols:literaltok - + cannot reachend */ static void CollectLiteral (pge_SetOfStop stopset); /* - CollectTok := + CollectTok := % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := tokel ; @@ -2022,46 +2022,46 @@ static void CollectLiteral (pge_SetOfStop stopset); INC(LargestValue) END ; AdvanceToken() ; % - + first symbols:identtok - + cannot reachend */ static void CollectTok (pge_SetOfStop stopset); /* - DefineToken := + DefineToken := % AddEntry(Aliases, LastLiteral, GetCurrentToken()) ; AddEntry(ReverseAliases, GetCurrentToken(), LastLiteral) ; AddEntry(Values, GetCurrentToken(), LargestValue) ; AddEntry(ReverseValues, Name(LargestValue), GetCurrentToken()) ; INC(LargestValue) ; AdvanceToken ; % - + first symbols:identtok - + cannot reachend */ static void DefineToken (pge_SetOfStop stopset); /* - Rules := '%' 'rules' { Defs } ExtBNF + Rules := '%' 'rules' { Defs } ExtBNF first symbols:codetok - + cannot reachend */ static void Rules (pge_SetOfStop stopset); /* - Special := Ident + Special := Ident % VAR p: ProductionDesc ; % - + % p := NewProduction() ; p^.statement := NewStatement() ; p^.statement^.followinfo^.calcfollow := TRUE ; @@ -2073,31 +2073,31 @@ static void Rules (pge_SetOfStop stopset); p^.followinfo^.calcfollow := TRUE ; p^.followinfo^.epsilon := false ; p^.followinfo^.reachend := false % - First Follow [ 'epsilon' - % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging + First Follow [ 'epsilon' + % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging p^.statement^.followinfo^.reachend := true ; p^.followinfo^.epsilon := true ; p^.followinfo^.reachend := true % - ] [ Literal + ] [ Literal % p^.description := LastLiteral % - ] + ] first symbols:identtok - + cannot reachend */ static void Special (pge_SetOfStop stopset); /* - Factor := '%' Modula2Code '%' | - Ident + Factor := '%' Modula2Code '%' | + Ident % WITH CurrentFactor^ DO type := id ; ident := CurrentIdent END ; % - | Literal + | Literal % WITH CurrentFactor^ DO type := lit ; string := LastLiteral ; @@ -2106,39 +2106,39 @@ static void Special (pge_SetOfStop stopset); WarnError1('no token defined for literal %s', LastLiteral) END END ; % - | '{' + | '{' % WITH CurrentFactor^ DO type := mult ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression '}' | '[' + Expression '}' | '[' % WITH CurrentFactor^ DO type := opt ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ']' | '(' + Expression ']' | '(' % WITH CurrentFactor^ DO type := sub ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ')' + Expression ')' first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ static void Factor (pge_SetOfStop stopset); /* - Statement := + Statement := % VAR i: IdentDesc ; % - Ident + Ident % VAR p: ProductionDesc ; % - + % p := FindDefinition(CurrentIdent^.name) ; IF p=NIL THEN @@ -2150,264 +2150,264 @@ static void Factor (pge_SetOfStop stopset); END END ; i := CurrentIdent ; % - ':=' + ':=' % VAR e: ExpressionDesc ; % - + % e := NewExpression() ; CurrentExpression := e ; % - + % VAR s: StatementDesc ; % - + % s := NewStatement() ; WITH s^ DO ident := i ; expr := e END ; % - Expression + Expression % p^.statement := s ; % - '=:' + '=:' first symbols:identtok - + cannot reachend */ static void Statement (pge_SetOfStop stopset); /* - Defs := 'special' Special | 'token' Token | - 'error' ErrorProcedures | - 'tokenfunc' TokenProcedure | - 'symfunc' SymProcedure + Defs := 'special' Special | 'token' Token | + 'error' ErrorProcedures | + 'tokenfunc' TokenProcedure | + 'symfunc' SymProcedure first symbols:symfunctok, tfunctok, errortok, tokentok, specialtok - + cannot reachend */ static void Defs (pge_SetOfStop stopset); /* - ExtBNF := 'BNF' { Production } 'FNB' + ExtBNF := 'BNF' { Production } 'FNB' first symbols:BNFtok - + cannot reachend */ static void ExtBNF (pge_SetOfStop stopset); /* - Main := Header Decls Footer Rules + Main := Header Decls Footer Rules first symbols:codetok - + cannot reachend */ static void Main (pge_SetOfStop stopset); /* - Header := '%' 'module' StartModName + Header := '%' 'module' StartModName first symbols:codetok - + cannot reachend */ static void Header (pge_SetOfStop stopset); /* - Decls := '%' 'declaration' DoDeclaration + Decls := '%' 'declaration' DoDeclaration first symbols:codetok - + cannot reachend */ static void Decls (pge_SetOfStop stopset); /* - Footer := '%' 'module' EndModName + Footer := '%' 'module' EndModName first symbols:codetok - + cannot reachend */ static void Footer (pge_SetOfStop stopset); /* - First := 'first' '{' { LitOrTokenOrIdent + First := 'first' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.first ; END ; TailProduction^.first := CurrentSetDesc % - } '}' + } '}' first symbols:firsttok - + cannot reachend */ static void First (pge_SetOfStop stopset); /* - Follow := 'follow' '{' { LitOrTokenOrIdent + Follow := 'follow' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.followinfo^.follow ; END ; TailProduction^.followinfo^.follow := CurrentSetDesc % - } '}' + } '}' first symbols:followtok - + cannot reachend */ static void Follow (pge_SetOfStop stopset); /* - LitOrTokenOrIdent := Literal + LitOrTokenOrIdent := Literal % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := litel ; string := LastLiteral ; END ; % - | '<' CollectTok '>' | - Ident + | '<' CollectTok '>' | + Ident % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := idel ; ident := CurrentIdent ; END ; % - + first symbols:dquotetok, squotetok, identtok, lesstok - + cannot reachend */ static void LitOrTokenOrIdent (pge_SetOfStop stopset); /* - Literal := '"' CollectLiteral '"' | - "'" CollectLiteral "'" + Literal := '"' CollectLiteral '"' | + "'" CollectLiteral "'" first symbols:squotetok, dquotetok - + cannot reachend */ static void Literal (pge_SetOfStop stopset); /* - Token := Literal DefineToken + Token := Literal DefineToken first symbols:dquotetok, squotetok - + cannot reachend */ static void Token (pge_SetOfStop stopset); /* - ErrorProcedures := Literal + ErrorProcedures := Literal % ErrorProcArray := LastLiteral % - Literal + Literal % ErrorProcString := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void ErrorProcedures (pge_SetOfStop stopset); /* - TokenProcedure := Literal + TokenProcedure := Literal % TokenTypeProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void TokenProcedure (pge_SetOfStop stopset); /* - SymProcedure := Literal + SymProcedure := Literal % SymIsProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ static void SymProcedure (pge_SetOfStop stopset); /* - Production := Statement + Production := Statement first symbols:identtok - + cannot reachend */ static void Production (pge_SetOfStop stopset); /* - Expression := + Expression := % VAR t1, t2: TermDesc ; e : ExpressionDesc ; % - + % e := CurrentExpression ; t1 := NewTerm() ; CurrentTerm := t1 ; % - Term + Term % e^.term := t1 ; % - { '|' + { '|' % t2 := NewTerm() ; CurrentTerm := t2 % - Term + Term % t1^.next := t2 ; t1 := t2 % - } + } first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ static void Expression (pge_SetOfStop stopset); /* - Term := + Term := % VAR t1: TermDesc ; f1, f2: FactorDesc ; % - + % CurrentFactor := NewFactor() ; f1 := CurrentFactor ; t1 := CurrentTerm ; % - Factor + Factor % t1^.factor := f1 ; f2 := NewFactor() ; CurrentFactor := f2 % - { Factor + { Factor % f1^.next := f2 ; f1 := f2 ; f2 := NewFactor() ; CurrentFactor := f2 ; % - } + } first symbols:squotetok, dquotetok, codetok, identtok, lcparatok, lsparatok, lparatok - + cannot reachend */ @@ -4466,13 +4466,13 @@ static void DoDeclaration (pge_SetOfStop stop) /* - CollectLiteral := + CollectLiteral := % LastLiteral := GetCurrentToken() ; AdvanceToken ; % - + first symbols:literaltok - + cannot reachend */ @@ -4484,7 +4484,7 @@ static void CollectLiteral (pge_SetOfStop stopset) /* - CollectTok := + CollectTok := % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := tokel ; @@ -4499,10 +4499,10 @@ static void CollectLiteral (pge_SetOfStop stopset) INC(LargestValue) END ; AdvanceToken() ; % - + first symbols:identtok - + cannot reachend */ @@ -4524,17 +4524,17 @@ static void CollectTok (pge_SetOfStop stopset) /* - DefineToken := + DefineToken := % AddEntry(Aliases, LastLiteral, GetCurrentToken()) ; AddEntry(ReverseAliases, GetCurrentToken(), LastLiteral) ; AddEntry(Values, GetCurrentToken(), LargestValue) ; AddEntry(ReverseValues, Name(LargestValue), GetCurrentToken()) ; INC(LargestValue) ; AdvanceToken ; % - + first symbols:identtok - + cannot reachend */ @@ -4550,10 +4550,10 @@ static void DefineToken (pge_SetOfStop stopset) /* - Rules := '%' 'rules' { Defs } ExtBNF + Rules := '%' 'rules' { Defs } ExtBNF first symbols:codetok - + cannot reachend */ @@ -4571,9 +4571,9 @@ static void Rules (pge_SetOfStop stopset) /* - Special := Ident + Special := Ident % VAR p: ProductionDesc ; % - + % p := NewProduction() ; p^.statement := NewStatement() ; p^.statement^.followinfo^.calcfollow := TRUE ; @@ -4585,18 +4585,18 @@ static void Rules (pge_SetOfStop stopset) p^.followinfo^.calcfollow := TRUE ; p^.followinfo^.epsilon := false ; p^.followinfo^.reachend := false % - First Follow [ 'epsilon' - % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging + First Follow [ 'epsilon' + % p^.statement^.followinfo^.epsilon := true ; these are not used - but they are displayed when debugging p^.statement^.followinfo^.reachend := true ; p^.followinfo^.epsilon := true ; p^.followinfo^.reachend := true % - ] [ Literal + ] [ Literal % p^.description := LastLiteral % - ] + ] first symbols:identtok - + cannot reachend */ @@ -4635,13 +4635,13 @@ static void Special (pge_SetOfStop stopset) /* - Factor := '%' Modula2Code '%' | - Ident + Factor := '%' Modula2Code '%' | + Ident % WITH CurrentFactor^ DO type := id ; ident := CurrentIdent END ; % - | Literal + | Literal % WITH CurrentFactor^ DO type := lit ; string := LastLiteral ; @@ -4650,28 +4650,28 @@ static void Special (pge_SetOfStop stopset) WarnError1('no token defined for literal %s', LastLiteral) END END ; % - | '{' + | '{' % WITH CurrentFactor^ DO type := mult ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression '}' | '[' + Expression '}' | '[' % WITH CurrentFactor^ DO type := opt ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ']' | '(' + Expression ']' | '(' % WITH CurrentFactor^ DO type := sub ; expr := NewExpression() ; CurrentExpression := expr ; END ; % - Expression ')' + Expression ')' first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ @@ -4740,11 +4740,11 @@ static void Factor (pge_SetOfStop stopset) /* - Statement := + Statement := % VAR i: IdentDesc ; % - Ident + Ident % VAR p: ProductionDesc ; % - + % p := FindDefinition(CurrentIdent^.name) ; IF p=NIL THEN @@ -4756,25 +4756,25 @@ static void Factor (pge_SetOfStop stopset) END END ; i := CurrentIdent ; % - ':=' + ':=' % VAR e: ExpressionDesc ; % - + % e := NewExpression() ; CurrentExpression := e ; % - + % VAR s: StatementDesc ; % - + % s := NewStatement() ; WITH s^ DO ident := i ; expr := e END ; % - Expression + Expression % p^.statement := s ; % - '=:' + '=:' first symbols:identtok - + cannot reachend */ @@ -4812,13 +4812,13 @@ static void Statement (pge_SetOfStop stopset) /* - Defs := 'special' Special | 'token' Token | - 'error' ErrorProcedures | - 'tokenfunc' TokenProcedure | - 'symfunc' SymProcedure + Defs := 'special' Special | 'token' Token | + 'error' ErrorProcedures | + 'tokenfunc' TokenProcedure | + 'symfunc' SymProcedure first symbols:symfunctok, tfunctok, errortok, tokentok, specialtok - + cannot reachend */ @@ -4862,10 +4862,10 @@ static void Defs (pge_SetOfStop stopset) /* - ExtBNF := 'BNF' { Production } 'FNB' + ExtBNF := 'BNF' { Production } 'FNB' first symbols:BNFtok - + cannot reachend */ @@ -4882,10 +4882,10 @@ static void ExtBNF (pge_SetOfStop stopset) /* - Main := Header Decls Footer Rules + Main := Header Decls Footer Rules first symbols:codetok - + cannot reachend */ @@ -4899,10 +4899,10 @@ static void Main (pge_SetOfStop stopset) /* - Header := '%' 'module' StartModName + Header := '%' 'module' StartModName first symbols:codetok - + cannot reachend */ @@ -4915,10 +4915,10 @@ static void Header (pge_SetOfStop stopset) /* - Decls := '%' 'declaration' DoDeclaration + Decls := '%' 'declaration' DoDeclaration first symbols:codetok - + cannot reachend */ @@ -4931,10 +4931,10 @@ static void Decls (pge_SetOfStop stopset) /* - Footer := '%' 'module' EndModName + Footer := '%' 'module' EndModName first symbols:codetok - + cannot reachend */ @@ -4947,16 +4947,16 @@ static void Footer (pge_SetOfStop stopset) /* - First := 'first' '{' { LitOrTokenOrIdent + First := 'first' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.first ; END ; TailProduction^.first := CurrentSetDesc % - } '}' + } '}' first symbols:firsttok - + cannot reachend */ @@ -4976,16 +4976,16 @@ static void First (pge_SetOfStop stopset) /* - Follow := 'follow' '{' { LitOrTokenOrIdent + Follow := 'follow' '{' { LitOrTokenOrIdent % WITH CurrentSetDesc^ DO next := TailProduction^.followinfo^.follow ; END ; TailProduction^.followinfo^.follow := CurrentSetDesc % - } '}' + } '}' first symbols:followtok - + cannot reachend */ @@ -5005,25 +5005,25 @@ static void Follow (pge_SetOfStop stopset) /* - LitOrTokenOrIdent := Literal + LitOrTokenOrIdent := Literal % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := litel ; string := LastLiteral ; END ; % - | '<' CollectTok '>' | - Ident + | '<' CollectTok '>' | + Ident % CurrentSetDesc := NewSetDesc() ; WITH CurrentSetDesc^ DO type := idel ; ident := CurrentIdent ; END ; % - + first symbols:dquotetok, squotetok, identtok, lesstok - + cannot reachend */ @@ -5060,11 +5060,11 @@ static void LitOrTokenOrIdent (pge_SetOfStop stopset) /* - Literal := '"' CollectLiteral '"' | - "'" CollectLiteral "'" + Literal := '"' CollectLiteral '"' | + "'" CollectLiteral "'" first symbols:squotetok, dquotetok - + cannot reachend */ @@ -5092,10 +5092,10 @@ static void Literal (pge_SetOfStop stopset) /* - Token := Literal DefineToken + Token := Literal DefineToken first symbols:dquotetok, squotetok - + cannot reachend */ @@ -5107,14 +5107,14 @@ static void Token (pge_SetOfStop stopset) /* - ErrorProcedures := Literal + ErrorProcedures := Literal % ErrorProcArray := LastLiteral % - Literal + Literal % ErrorProcString := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ @@ -5128,12 +5128,12 @@ static void ErrorProcedures (pge_SetOfStop stopset) /* - TokenProcedure := Literal + TokenProcedure := Literal % TokenTypeProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ @@ -5145,12 +5145,12 @@ static void TokenProcedure (pge_SetOfStop stopset) /* - SymProcedure := Literal + SymProcedure := Literal % SymIsProc := LastLiteral % - + first symbols:dquotetok, squotetok - + cannot reachend */ @@ -5162,10 +5162,10 @@ static void SymProcedure (pge_SetOfStop stopset) /* - Production := Statement + Production := Statement first symbols:identtok - + cannot reachend */ @@ -5176,25 +5176,25 @@ static void Production (pge_SetOfStop stopset) /* - Expression := + Expression := % VAR t1, t2: TermDesc ; e : ExpressionDesc ; % - + % e := CurrentExpression ; t1 := NewTerm() ; CurrentTerm := t1 ; % - Term + Term % e^.term := t1 ; % - { '|' + { '|' % t2 := NewTerm() ; CurrentTerm := t2 % - Term + Term % t1^.next := t2 ; t1 := t2 % - } + } first symbols:dquotetok, squotetok, lparatok, lsparatok, lcparatok, identtok, codetok - + cannot reachend */ @@ -5223,25 +5223,25 @@ static void Expression (pge_SetOfStop stopset) /* - Term := + Term := % VAR t1: TermDesc ; f1, f2: FactorDesc ; % - + % CurrentFactor := NewFactor() ; f1 := CurrentFactor ; t1 := CurrentTerm ; % - Factor + Factor % t1^.factor := f1 ; f2 := NewFactor() ; CurrentFactor := f2 % - { Factor + { Factor % f1^.next := f2 ; f1 := f2 ; f2 := NewFactor() ; CurrentFactor := f2 ; % - } + } first symbols:squotetok, dquotetok, codetok, identtok, lcparatok, lsparatok, lparatok - + cannot reachend */ @@ -6321,7 +6321,7 @@ static void CodeFactor (pge_FactorDesc f, pge_TermDesc t, pge_m2condition l, pge CodeExpression (f->expr, pge_m2none, inopt, inwhile, consumed, NULL); if (f->next != NULL) { - /* + /* * the test above makes sure that we don't emit a RETURN( TRUE ) * after a subexpression. Remember sub expressions are not conditional */ @@ -6725,7 +6725,7 @@ static void EmitIsInFirst (pge_SetDesc to, pge_m2condition m) static void FlushRecoverCode (pge_FactorDesc *codeStack) { - /* + /* FlushCode - */ if ((*codeStack) != NULL) @@ -7382,7 +7382,7 @@ static void EmitStopParametersAndFollow (pge_FactorDesc f, pge_m2condition m) pge_SetDesc to; to = NULL; - /* + /* IF m=m2while THEN CalcFirstFactor(f, NIL, to) @@ -7490,6 +7490,7 @@ static bool FindStr (pge_CodeHunk *code, unsigned int *i, const char *str_, unsi /* make a local copy of each unbounded array. */ memcpy (str, str_, _str_high+1); + j = StrLib_StrLen ((const char *) str, _str_high); t = (*code); k = (StrLib_StrLen ((const char *) &(*code)->codetext.array[0], MaxCodeHunkLength))+1; while (t != NULL) @@ -7952,7 +7953,7 @@ static void WorkOutFollowFactor (pge_FactorDesc f, pge_SetDesc *followset, pge_S pge_TraverseResult foundepsilon; pge_TraverseResult canreachend; - /* + /* WorkOutFollow - */ foundepsilon = pge_true; @@ -8323,7 +8324,7 @@ static void CalcEpsilonProduction (pge_ProductionDesc p) { if (p != NULL) { - /* + /* IF p^.statement^.ident^.name=MakeKey('DefinitionModule') THEN stop diff --git a/gcc/m2/pge-boot/Gtermios.cc b/gcc/m2/pge-boot/Gtermios.cc index 5f96640..55220e7 100644 --- a/gcc/m2/pge-boot/Gtermios.cc +++ b/gcc/m2/pge-boot/Gtermios.cc @@ -1081,8 +1081,8 @@ EXPORT (GetFlag) (struct termios *t, Flag f, int *b) /* SetFlag - sets a flag value in, t, to, b, and returns TRUE if this flag value is supported. */ -int -EXPORT (SetFlag) (struct termios *t, Flag f, int b) +bool +EXPORT (SetFlag) (struct termios *t, Flag f, bool b) { switch (f) { @@ -1933,12 +1933,12 @@ EXPORT (SetChar) (struct termios *t, ControlChar c, char ch) } void -_M2_termios_init (void) +_M2_termios_init (int argc, char *argv[], char *envp[]) { } void -_M2_termios_fini (void) +_M2_termios_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/pge-boot/m2rts.h b/gcc/m2/pge-boot/m2rts.h index 7345074..fe9745b 100644 --- a/gcc/m2/pge-boot/m2rts.h +++ b/gcc/m2/pge-boot/m2rts.h @@ -28,8 +28,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef void (*proc_con) (int, char **, char **); typedef void (*proc_dep) (void); +#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \ + M2RTS_RegisterModule (reinterpret_cast <void *> (const_cast <char *> (MODNAME)), \ + reinterpret_cast <void *> (const_cast <char *> (LIBNAME)), \ + init, fini, dep) + extern "C" void M2RTS_RequestDependant (const char *modulename, const char *dependancy); -extern "C" void M2RTS_RegisterModule (const char *modulename, const char *libname, +extern "C" void M2RTS_RegisterModule (void *modulename, void *libname, proc_con init, proc_con fini, proc_dep dependencies); extern "C" void _M2_M2RTS_init (void); |