On Wednesday, 2002-06-12 at 11:55:49 +0100, Matt Sergeant wrote:
> Are there any solaris C experts on cpan-testers that can help out with
> this?

Sigh. I'm not, but sometimes I play one for my clients...
Please state the nature of your C programming emergency.

I found this in the Solaris strptime manpage:

  Non-zeroing Behavior
     cc [flag ...] file ... -D_STRPTIME_DONTZERO [library ...]

     char *strptime(const char *buf, const char  *format,  struct
     tm *tm);

Yepp. Inserting #define _STRPTIME_DONTZERO in Piece.xs make the tests
all pass on Solaris. Your code relies on seemingly undefined behaviour
in strptime, namely the non-zeroing of the struct tm fields.

I found this on sunsolve in the Symptoms and Resolutions:

------------------------------------------------------------------------
Problems with strptime(3C).
[strptime converts a source date in character string format to a tm structure.]

1. strptime() fails partially on dates beyond Jan 18, 2038
2. strptime() does not generate some fields.
3. strptime() doesn't comprehend %Ec or %Ey in the C locale.
4. tm structure is zeroed upon entry.

Description:

....

4. tm structure is zeroed upon entry.

When members of the tm structure cannot be determined from the input,
two possible behaviors can be expected:

    a.  The indeterminate members are not changed.
    b.  The indeterminate members are set to a reserved value.

At least 1 other vendor choses option "a".

Solaris 2.5.1 choses option "b", but the reserved value that is used is 0
(zero). This is not a good choice, because 0 is a reasonable result for
8 of the 9 members [exception: tm_mday]. The caller cannot distinguish
whether an input field was not determined, or whether it was determined
to be 0. A better return would be a symbol, say TM_UNDEFINED, placed
in <time.h>, that can never be a valid result. The value of this symbol
can be left to the implementation, but -1 is probably a safe value.

Regardless of how this is decided, the behavior of strptime() with
indeterminate fields should be documented in the manual page.

OS:             Solaris 2.5.1 (Generic) &  Solaris 2.6 (Generic)
------------------------------------------------------------------------

I think just defining _STRPTIME_DONTZERO would not hurt any other
platform. But if you're worried, use this:

#ifdef sun
#define _STRPTIME_DONTZERO
#endif

HTH,
Lupe Christoph
-- 
| [EMAIL PROTECTED]       |           http://www.lupe-christoph.de/ |
| I have challenged the entire ISO-9000 quality assurance team to a      |
| Bat-Leth contest on the holodeck. They will not concern us again.      |
| http://public.logica.com/~stepneys/joke/klingon.htm                    |

Reply via email to