Fixes various warts in header files, such as: * macros -added parens to prevent problems with operator precedence -removed ; at end * removed SSIZE_MAX, since ssize_t is no longer used * removed some misinformation about NULL and function pointers from a comment. * added some more INLINE definitions for MSVC and C99 compilers * fixed occurences of 2<<n where 1<<n is obviously is what was meant (esp. clear upon reading the comments).
################################## diff -ur include/parrot/interp_guts.h include/myparrot/interp_guts.h --- include/parrot/interp_guts.h Thu Dec 27 11:08:48 2001 +++ include/myparrot/interp_guts.h Fri Feb 22 17:38:04 2002 @@ -5,7 +5,7 @@ #ifndef INTERP_GUTS_H #define INTERP_GUTS_H -#define DO_OP(PC,INTERP) PC = ((INTERP->op_func_table)[*PC])(PC,INTERP); +#define DO_OP(PC,INTERP) (PC = ((INTERP->op_func_table)[*PC])(PC,INTERP)) #endif /* INTERP_GUTS_H */ diff -ur include/parrot/io.h include/myparrot/io.h --- include/parrot/io.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/io.h Fri Feb 22 17:43:14 2002 @@ -17,9 +17,6 @@ #if !defined(PARROT_IO_H_GUARD) #define PARROT_IO_H_GUARD -#ifndef SSIZE_MAX -#define SSIZE_MAX 8192 -#endif #ifndef STDIN_FILENO # define STDIN_FILENO 0 diff -ur include/parrot/packfile.h include/myparrot/packfile.h --- include/parrot/packfile.h Mon Feb 11 11:57:12 2002 +++ include/myparrot/packfile.h Fri Feb 22 17:46:58 2002 @@ -8,8 +8,8 @@ #include <parrot/parrot.h> -#define PF_NCONST(pf) (pf)->const_table->const_count -#define PF_CONST(pf,i) (pf)->const_table->constants[i] +#define PF_NCONST(pf) ((pf)->const_table->const_count) +#define PF_CONST(pf,i) ((pf)->const_table->constants[(i)]) /* diff -ur include/parrot/parrot.h include/myparrot/parrot.h --- include/parrot/parrot.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/parrot.h Fri Feb 22 17:52:28 2002 @@ -75,21 +75,21 @@ /* define some shortcuts for dealing with function pointers */ /* according to ANSI C, casting between function and non-function pointers is - * no good. So we should use "funcptr_t" in place of void* when dealing with - * function pointers and NULLfunc in place of NULL */ + * no good, except in the special case of NULL. So we should use "funcptr_t" + * in place of void* when dealing with function pointers*/ typedef void (*funcptr_t)(void); -#define NULLfunc (funcptr_t)0 +#define NULLfunc NULL /* Provide support for inline keyword where available. Just make sure to use * "INLINE" instead and it will DTRT. */ -#ifdef __cplusplus +#if defined(__cplusplus) || (defined(__STDC__)&&__STDC_VERSION__>199901L) #define INLINE inline +#elif defined(__GNUC__) + #define INLINE __inline__ +#elif definded(_MSC_VER) + #define INLINE __inline #else - #ifdef __GNUC__ - #define INLINE __inline__ - #else - #define INLINE - #endif + #define INLINE #endif /* On Win32 we need the constant O_BINARY for open() (at least for Borland C), diff -ur include/parrot/pmc.h include/myparrot/pmc.h --- include/parrot/pmc.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/pmc.h Fri Feb 22 17:53:10 2002 @@ -47,30 +47,30 @@ * classes. It is suggested that you alias these within an individual * class's header file */ - PMC_private0_FLAG = 2 << 0, - PMC_private1_FLAG = 2 << 1, - PMC_private2_FLAG = 2 << 2, - PMC_private3_FLAG = 2 << 3, - PMC_private4_FLAG = 2 << 4, - PMC_private5_FLAG = 2 << 5, - PMC_private6_FLAG = 2 << 6, - PMC_private7_FLAG = 2 << 7, + PMC_private0_FLAG = 1 << 0, + PMC_private1_FLAG = 1 << 1, + PMC_private2_FLAG = 1 << 2, + PMC_private3_FLAG = 1 << 3, + PMC_private4_FLAG = 1 << 4, + PMC_private5_FLAG = 1 << 5, + PMC_private6_FLAG = 1 << 6, + PMC_private7_FLAG = 1 << 7, /* The rest of the flags are for use by Parrot */ /* Set if the PMC has a destroy method that must be called */ - PMC_active_destroy_FLAG = 2 << 8, + PMC_active_destroy_FLAG = 1 << 8, /* Set if the PMC can hold multiple PMCs. (Hash, array, list, whatever) */ - PMC_is_container_FLAG = 2 << 9, + PMC_is_container_FLAG = 1 << 9, /* Set to true if the PMC data pointer points to something that looks like a string or buffer pointer */ - PMC_is_buffer_ptr_FLAG = 2 << 10, + PMC_is_buffer_ptr_FLAG = 1 << 10, /* Set to true if the data pointer points to a PMC */ - PMC_is_PMC_ptr_FLAG = 2 << 11, + PMC_is_PMC_ptr_FLAG = 1 << 11, /* Set to true if the PMC has a private GC function. For PMCs the GC system can't snoop into */ - PMC_private_GC_FLAG = 2 << 12 + PMC_private_GC_FLAG = 1 << 12 } PMC_flags; /* XXX add various bit test macros once we have need of them */ diff -ur include/parrot/rx.h include/myparrot/rx.h --- include/parrot/rx.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/rx.h Fri Feb 22 17:56:22 2002 @@ -79,11 +79,11 @@ BOOLVAL bitmap_match(Bitmap, INTVAL); void bitmap_destroy(Bitmap); -#define RX_dUNPACK(pmc) rxinfo *rx=(rxinfo *)pmc->data -#define RxCurChar(rx) (char)string_ord(rx->string, rx->index) +#define RX_dUNPACK(pmc) rxinfo *rx=(rxinfo *)(pmc)->data +#define RxCurChar(rx) ((char)string_ord((rx)->string, (rx)->index)) -#define RxAdvance(rx) RxAdvanceX(rx, 1) -#define RxAdvanceX(rx, x) rx->index += x * rx->whichway +#define RxAdvance(rx) RxAdvanceX((rx), 1) +#define RxAdvanceX(rx, x) ((rx)->index += (x) * (rx)->whichway) #define RxCaseInsensitive_on(rx) RxFlagOn(rx, enum_rxflags_case_insensitive) #define RxCaseInsensitive_off(rx) RxFlagOff(rx, enum_rxflags_case_insensitive) @@ -101,10 +101,10 @@ #define RxReverse_off(rx) RxFlagOff(rx, enum_rxflags_reverse) #define RxReverse_test(rx) RxFlagTest(rx, enum_rxflags_reverse) -#define RxFlagOn(rx, flag) (rx->flags |= flag) -#define RxFlagOff(rx, flag) (rx->flags &= ~flag) -#define RxFlagTest(rx, flag) (rx->flags & flag) +#define RxFlagOn(rx, flag) ((rx)->flags |= (flag)) +#define RxFlagOff(rx, flag) ((rx)->flags &= ~(flag)) +#define RxFlagTest(rx, flag) ((rx)->flags & (flag)) -#define RxFlagsOff(rx) rx->flags = enum_rxflags_none +#define RxFlagsOff(rx) ((rx)->flags = enum_rxflags_none) #endif /* PARROT_RX_H_GUARD */ diff -ur include/parrot/unicode.h include/myparrot/unicode.h --- include/parrot/unicode.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/unicode.h Fri Feb 22 17:59:44 2002 @@ -46,7 +46,7 @@ (uv) < 0x800 ? 2 : \ (uv) < 0x10000 ? 3 : 4 ) -#define UTF16SKIP(s) ( UNICODE_IS_HIGH_SURROGATE(*s) ? 2 : 1 ) +#define UTF16SKIP(s) ( UNICODE_IS_HIGH_SURROGATE(*(s)) ? 2 : 1 ) /* diff -ur include/parrot/warnings.h include/myparrot/warnings.h --- include/parrot/warnings.h Thu Feb 21 18:53:34 2002 +++ include/myparrot/warnings.h Fri Feb 22 18:00:38 2002 @@ -10,9 +10,9 @@ #include "parrot/parrot.h" -#define PARROT_WARNINGS_on(interp, flag) interp->warns->classes |= flag -#define PARROT_WARNINGS_off(interp, flag) interp->warns->classes &= ~flag -#define PARROT_WARNINGS_test(interp, flag) interp->warns->classes & flag +#define PARROT_WARNINGS_on(interp, flag) ((interp)->warns->classes |= (flag)) +#define PARROT_WARNINGS_off(interp, flag) ((interp)->warns->classes &= ~(flag)) +#define PARROT_WARNINGS_test(interp, flag) ((interp)->warns->classes & (flag)) INTVAL Parrot_warn(struct Parrot_Interp *, INTVAL warnclass, const char* message, ....);