Operating System - OpenVMS
1752754 Members
5137 Online
108789 Solutions
New Discussion юеВ

Re: Bug in strptime() function

 
Joseph Huber_1
Honored Contributor

Re: Bug in strptime() function

I finally think the sentence
"There must be white-space or other non-alphanumeric characters between any two conversion specifications." in the XOPEN specification
leaves no room for formats without delimiters,
so one can't write portable programs using "yyyymmdd with "%Y%m%d", although GNU apparently uses inherent
field width of 4-2-2 to parse it.
http://www.mpp.mpg.de/~huber
WW304289
Frequent Advisor

Re: Bug in strptime() function

I also think that the requirement "There must be white-space or other non-alphanumeric characters between any two conversion specifications" makes format specification "%Y%m%d" illegal. Thanks for pointing it out. So, this is not a bug in the CRTL, as I thought, but rather an undefined behaviour.

Having said that, the CRTL has no problem processing this call:

strptime("2008x01x25", "%Yx%mx%d", ...)

which as also illegal. It is obvious why the function fails for "%Y%m%d" and succeeds for "%Yx%mx%d". I just wish the undefined behaviour in both cases would be the same, and I don't mean failure in both cases :-)

Thanks for all the replies,
-Boris
Hoff
Honored Contributor

Re: Bug in strptime() function

gcc 4.2.1 does not return an error with the example I posted.

An older gcc did return the errors (shown).

But again, a case can be made for standards compliance, and an equally good case can be made for gcc compliance.
Joseph Huber_1
Honored Contributor

Re: Bug in strptime() function

WW304289,
If You desparately need -because there are datasets containing these formats- , then the WGET source I found on this link
http://sourceforge.jp/cvs/view/simplechart/wget/cmpt.cpp?view=co

contains a strptime working, which can replace the VMS CRTL by
cc/prefix=(all,except=strptime) .

(needs a few #defines, or remove all other routines).
http://www.mpp.mpg.de/~huber
WW304289
Frequent Advisor

Re: Bug in strptime() function

"If You desparately need -because there are datasets containing these formats- , then the WGET source ..."

Thanks for the suggestion. I've already implemented workaround (in fact, before I even posted this to an HP Forum) so, I'm all set. Just wanted to bring this problem to the attention of CRTL developers.

Thanks again,
-Boris
Steven Schweda
Honored Contributor

Re: Bug in strptime() function

> [...] the WGET source I found on this link
> [...]

Wow. You don't already _have_ wget source?

http://antinode.info/dec/sw/wget.html

Who could live without wget?

That link seems to have some wget 1.10.2
code, modified (into C++) for some particular
non-VMS system.

(My wget-for-VMS builders seem to claim
HAVE_STRPTIME, so they're using the C RTL
strptime().)
John Gillings
Honored Contributor

Re: Bug in strptime() function

Boris,

>Just wanted to bring this problem to the
>attention of CRTL developers.

Unfortunately you're unlikely to achieve that by posting anything here.

Although this is an official HP web site, there is very little participation by HP engineers. If you want to make sure HP engineering knows about an issue, you'll need to raise a formal case with your local customer support centre.
A crucible of informative mistakes
Manjula M
New Member

Re: Bug in strptime() function

Hello,

In OpenVMS CRTL subroutine strptime(), when more than one format specifier is present, they must be separated by white space or a non-% [percent sign]/non-alphanumeric ordinary character.

The call to strptime API with the following format does pass on OpenVMS as expected: strptime("2008x01x25", "%Yx%mx%d", ...)

Please find below a snapshot of description in the CRTL Reference Manual on OpenVMS

" Any character other than the percent character (%) or a white-space character. This directive causes the function to read the next character.
The character read must be the same as the character that comprises the directive. If the character is different, the function fails. "

Best Regards,
Manjula
[OpenVMS CRTL Engineering]
Hoff
Honored Contributor

Re: Bug in strptime() function

That the OpenVMS manuals and the C standards here say that this C code can be safely claimed as broken (or non-portable, non-compliant, or whatever euphemism) is quite clear.

That's not the nub of the question that I see here.

The nub of the question is which standard(s) will be the ones OpenVMS will comply with?

Whether that's going to continue to be the Unix and C standards (as is presently the case), or whether those extensions and features and changes and, yes, oddities of gcc are (also) a valid compliance target?

I'm locally dealing with far more gcc code going forward, and have thought about porting gcc or clang and the libraries over to OpenVMS. (In addition to differences in strptime, the getopt_long call is entirely missing, for instance.)

There is definitely no right answer here. That's the fun of standards-compliance. There are just so many of them around to choose from.

Dennis Handly
Acclaimed Contributor

Re: Bug in strptime() function

>the CRTL has no problem processing this call:
strptime("2008x01x25", "%Yx%mx%d", ...)

HP-UX detects this as illegal.

>ME: I suppose one way to allow no delimiters is to fully specify (or assume) the widths.

This doesn't work any better on HP-UX. strptime(3) says what Craig quoted.

Not even %4.4Y%2.2m%2.2d works.