Subject: | Compilation failure on Solaris using Sun C 5.7 |
Sun C 5.7 is unable to compile the generated strptime.c file. The
combination of the ternary operator and the complex expansion of the
XPUSH macro puts an "if" in a place that the compiler is not expecting one.
I've attached a version of strptime.xs which uses more explicit blocks
to ensure that macro expansion doesn't cause compiler confusion.
Subject: | strptime.xs |
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <time.h>
MODULE = POSIX::strptime PACKAGE = POSIX::strptime
void
strptime(input, format)
const char *input
const char *format
PREINIT:
struct tm tm_t = { -1,-1,-1,-1,-1,-1,-1,-1 };
PPCODE:
strptime(input, format, &tm_t);
if ( tm_t.tm_sec == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_sec); }
if ( tm_t.tm_min == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_min); }
if ( tm_t.tm_hour == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_hour); }
if ( tm_t.tm_mday == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_mday); }
if ( tm_t.tm_mon == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_mon); }
if ( tm_t.tm_year == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_year); }
if ( tm_t.tm_wday == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_wday); }
if ( tm_t.tm_yday == -1 ) { XPUSHs(&PL_sv_undef); } else { mXPUSHi(tm_t.tm_yday); }