Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 3438 invoked from network); 20 Aug 2007 10:32:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Aug 2007 10:32:08 -0000 Received: (qmail 74905 invoked by uid 500); 20 Aug 2007 10:32:05 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 74891 invoked by uid 500); 20 Aug 2007 10:32:05 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 74880 invoked by uid 99); 20 Aug 2007 10:32:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Aug 2007 03:32:05 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of travis.vitek@gmail.com designates 64.233.162.234 as permitted sender) Received: from [64.233.162.234] (HELO nz-out-0506.google.com) (64.233.162.234) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Aug 2007 10:32:02 +0000 Received: by nz-out-0506.google.com with SMTP id o37so373016nzf for ; Mon, 20 Aug 2007 03:31:41 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=tT+U2XUVIzhEo9pszxF5HSuqkssv2zsTMSw1SlqV5eThFRWtfjiX/6XUzwf/Wobfs1T7la6H7MhYOIBfWujKcEx2/+L89P7BuC8eCmDQjcyVSt8mDMx+sHkDRKOevy3dL0LEkjfojHA77Hca24ZgEVWzmxf0HzP5aliAxqQ0idA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=BX5CcZpJu1boxIyaTBd1Je/sMssFLUvxkn4jm0pUEPoJkRdU7x2N4YEMvJzmz0rorUtndEidW/c8Q7Fk3niA6wlo3ZmreRzWKY/1KF+hegsOQ2WX5RVViMIXuooUtpkkyB0GNRAEkjs9eRAdw25UaGkDWE8KxFmMVkoeSHvCB68= Received: by 10.142.153.8 with SMTP id a8mr313217wfe.1187605900505; Mon, 20 Aug 2007 03:31:40 -0700 (PDT) Received: by 10.142.100.19 with HTTP; Mon, 20 Aug 2007 03:31:40 -0700 (PDT) Message-ID: Date: Mon, 20 Aug 2007 03:31:40 -0700 From: "Travis Vitek" Sender: travis.vitek@gmail.com To: stdcxx-dev@incubator.apache.org Subject: RE: expectation vs requirements for locale facets MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_138807_2096900.1187605900478" X-Google-Sender-Auth: 906ffb74e89010ba X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_138807_2096900.1187605900478 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline >Martin Sebor wrote: > > >Yes. But notice the text doesn't say anything about time_put_byname or >time_get_byname ;-) > Well, the standard doesn't say much at all about the *_byname<> facets. All it really says about them is [21.1.1.2 p4] For some standard facets a standard "..._byname" class, derived from it, implements the virtual function semantics equivalent to the facet of the locale constructed by locale(const char*) with the same name. Each such facet provides a constructor that takes a const char* argument which names the locale, and a refs argument, which is passed to the base class constructor. [...] So, if I'm reading that right, the *_byname<> facet classes are just there to prevent the user from having to instantiate a std::locale directly. > The C++ standard (or even the C standard for that > matter) isn't going to of help here. Wait. Say what now? I'm not sure what you're trying to tell me here. If the C++ Standard says that these facets read or write years as roman numerals, then they should probably do so, regardless of what any other standard document requires. I think this will actually get cleared up in a few seconds... >> Of >> course that isn't what I'm seeing. > >Test case? Yeah. See attachment. Only tested on Win32/VC8 and Linux/GCC. > >It's hard to say from just looking at the code (and I haven't looked >very carefully). In general, we [try to] to implement the POSIX >semantics, so if it works with strptime()/strftime() it should work >with our time_put_byname/ time_get_byname. > Well, there's the problem right there. The standard requires that the time_put<> facet format its output according to the POSIX function strftime(), with the option for supporting extensions. It makes no indication that the time_get<> facet should read data in such a way as to be compatible with strptime(). The only thing I see that says anything about the format expecte by time_get<> is here... [22.2.5.1 p1] Each get member parses a format as produced by a corresponding format specifier to time_put<>::put. If the sequence being parsed maches the correct format, the corresponding members of the struct tm argument are set to the values used to produce the sequence; otherwise either an error is reported or unspecified values are assigned. note.232) 232) In other words, user confirmation is required for reliable parsing of user-entered dates and times, but *machine-generated formats can be parsed reliably.* This allows parsers to be aggressive about interpreting user variations on standard formats. [emphasis added] This paragraph says that time_get<>::get_date() is supposed to process the output of time_put<>::put(..., 'x'). [22.2.5.1.2 p4] Effects: Reads characters starting at s until it has extracted those struct tm members, and remaining format characters, used by time_put<>::put to produce the format specified by 'x' or until it encounters an error. > >If we test this behavior it's gotta be right ;-) Where does POSIX >say leading spaces must be skipped? I see this under %e: Equivalent >to %d. And under %d: The day of the month [01,31]; leading zeros >are permitted but not required. Nothing about ignoring spaces. > Absolutely. The docs for POSIX strftime()... %d Replaced by the day of the month as a decimal number [01,31]. [ tm_mday] %e Replaced by the day of the month as a decimal number [1,31]; a single digit is preceded by a space. [ tm_mday] Here is the problem. The docs for POSIX strptime()... %d The day of the month [01,31]; leading zeros are permitted but not required. %e Equivalent to %d. So strftime() isn't even compatible with strptime() when it comes to '%e'. > >Without too much research, my first take on this is that it will >probably fall under the "not every output format can be parsed" >category. But we need to do some more reading to confirm this >hypothesis. > Unfortunately, without consistent input/output it is going to be difficult for this multi-threading test to verify that no data corruption is occuring with arbitrary locales. Hopefully there is some system in place that allows us to explicitly specify which locales are to be used for a test. >Martin > ------=_Part_138807_2096900.1187605900478 Content-Type: text/plain; name=t.cpp; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Att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wKICAgICJub3J3ZWdpYW4iLCAibnlub3Jz ayIsICJwb2xpc2giLCAicG9ydHVndWVzZSIsICJyb21hbmlhbiIsCiAgICAicnVzc2lhbiIsICJz bG92YWsiLCAic2xvdmVuZSIsICJzbG92ZW5pYW4iLCAic3BhbmlzaCIsICJzd2VkaXNoIiwKICAg ICJ0aGFpIiwgInR1cmtpc2giLAogICAgImFhX0RKIiwgImFhX0VSIiwgImFhX0VUIiwgImFmX1pB IiwgImFtX0VUIiwgImFuX0VTIiwgImFyX0FFIiwgImFyX0JIIiwKICAgICJhcl9EWiIsICJhcl9F RyIsICJhcl9JTiIsICJhcl9JUSIsICJhcl9KTyIsICJhcl9LVyIsICJhcl9MQiIsICJhcl9MWSIs CiAgICAiYXJfTUEiLCAiYXJfT00iLCAiYXJfUUEiLCAiYXJfU0EiLCAiYXJfU0QiLCAiYXJfU1ki LCAiYXJfVE4iLCAiYXJfWUUiLAogICAgImJlX0JZIiwgImJnX0JHIiwgImJuX0JEIiwgImJuX0lO IiwgImJyX0ZSIiwgImJzX0JBIiwgImNhX0VTIiwgImNzX0NaIiwKICAgICJjeV9HQiIsICJkYV9E SyIsICJkZV9BVCIsICJkZV9CRSIsICJkZV9DSCIsICJkZV9ERSIsICJkZV9MVSIsICJlbF9HUiIs CiAgICAiZW5fQVUiLCAiZW5fQlciLCAiZW5fQ0EiLCAiZW5fREsiLCAiZW5fR0IiLCAiZW5fSEsi LCAiZW5fSUUiLCAiZW5fSU4iLAogICAgImVuX05aIiwgImVuX1BIIiwgImVuX1NHIiwgImVuX1VT IiwgImVuX1pBIiwgImVuX1pXIiwgImVzX0FSIiwgImVzX0JPIiwKICAgICJlc19DTCIsICJlc19D TyIsICJlc19DUiIsICJlc19ETyIsICJlc19FQyIsICJlc19FUyIsICJlc19HVCIsICJlc19ITiIs CiAgICAiZXNfTVgiLCAiZXNfTkkiLCAiZXNfUEEiLCAiZXNfUEUiLCAiZXNfUFIiLCAiZXNfUFki LCAiZXNfU1YiLCAiZXNfVVMiLAogICAgImVzX1VZIiwgImVzX1ZFIiwgImV0X0VFIiwgImV1X0VT IiwgImZhX0lSIiwgImZpX0ZJIiwgImZvX0ZPIiwgImZyX0JFIiwKICAgICJmcl9DQSIsICJmcl9D SCIsICJmcl9GUiIsICJmcl9MVSIsICJnYV9JRSIsICJnZF9HQiIsICJnbF9FUyIsICJndV9JTiIs CiAgICAiZ3ZfR0IiLCAiaGVfSUwiLCAiaGlfSU4iLCAiaHJfSFIiLCAiaHVfSFUiLCAiaWRfSUQi LCAiaXNfSVMiLCAiaXRfQ0giLAogICAgIml0X0lUIiwgIml3X0lMIiwgImphX0pQIiwgImthX0dF IiwgImtrX0taIiwgImtsX0dMIiwgImtuX0lOIiwgImtvX0tSIiwKICAgICJrd19HQiIsICJsZ19V RyIsICJsb19MQSIsICJsdF9MVCIsICJsdl9MViIsICJtaV9OWiIsICJta19NSyIsICJtbF9JTiIs CiAgICAibW5fTU4iLCAibXJfSU4iLCAibXNfTVkiLCAibXRfTVQiLCAibmJfTk8iLCAibmVfTlAi LCAibmxfQkUiLCAibmxfTkwiLAogICAgIm5uX05PIiwgIm5vX05PIiwgIm9jX0ZSIiwgIm9tX0VU IiwgIm9tX0tFIiwgInBhX0lOIiwgInBsX1BMIiwgInB0X0JSIiwKICAgICJwdF9QVCIsICJyb19S TyIsICJydV9SVSIsICJydV9VQSIsICJzZV9OTyIsICJza19TSyIsICJzbF9TSSIsICJzb19ESiIs CiAgICAic29fRVQiLCAic29fS0UiLCAic29fU08iLCAic3FfQUwiLCAic3JfQ1MiLCAic3RfWkEi LCAic3ZfRkkiLCAic3ZfU0UiLAogICAgInRhX0lOIiwgInRlX0lOIiwgInRnX1RKIiwgInRoX1RI IiwgInRpX0VSIiwgInRpX0VUIiwgInRsX1BIIiwgInRyX1RSIiwKICAgICJ1a19VQSIsICJ1cl9Q SyIsICJ1el9VWiIsICJ2aV9WTiIsICJ3YV9CRSIsICJ4aF9aQSIsICJ5aV9VUyIsICJ6aF9DTiIs CiAgICAiemhfSEsiLCAiemhfU0ciLCAiemhfVFciLCAienVfWkEiIH07CgojZW5kaWYKCmludCBt YWluKGludCBhcmdjLCBjaGFyKiBbXSkKewogICAgc3RkOjp0bSBzcmMsIGRzdCA9IHN0ZDo6dG0g KCk7CiAgICBzcmMudG1faXNkc3QgPSAwOwogICAgc3JjLnRtX3NlYyAgID0gMTsKICAgIHNyYy50 bV9taW4gICA9IDI7CiAgICBzcmMudG1faG91ciAgPSAzOwogICAgc3JjLnRtX3dkYXkgID0gNDsK ICAgIHNyYy50bV9tb24gICA9IDU7CiAgICBzcmMudG1fbWRheSAgPSA3OwogICAgc3JjLnRtX3lk YXkgID0gNzsKICAgIHNyYy50bV95ZWFyICA9IDg7CgogICAgdW5zaWduZWQgbjsKICAgIGZvciAo biA9IDA7IG4gPCBzaXplb2YgbG9jYWxlcyAvIHNpemVvZiAqbG9jYWxlczsgKytuKSB7CiAgICAg ICAgdHJ5IHsKICAgICAgICAgICAgY29uc3Qgc3RkOjpsb2NhbGUgbG9jIChsb2NhbGVzIFtuXSk7 CgogICAgICAgICAgICBzdGQ6OnN0cmluZ3N0cmVhbSBzczsKICAgICAgICAgICAgc3MuaW1idWUg KGxvYyk7CgogICAgICAgICAgICBjb25zdCBzdGQ6OnRpbWVfcHV0PGNoYXI+JiB0cCA9CiAgICAg ICAgICAgICAgICBzdGQ6OnVzZV9mYWNldDxzdGQ6OnRpbWVfcHV0PGNoYXI+ID4obG9jKTsKCgog ICAgICAgICAgICBjb25zdCBzdGQ6OnRpbWVfZ2V0PGNoYXI+JiB0ZyA9CiAgICAgICAgICAgICAg ICBzdGQ6OnVzZV9mYWNldDxzdGQ6OnRpbWVfZ2V0PGNoYXI+ID4obG9jKTsKCiAgICAgICAgICAg IHN0ZDo6aW9zX2Jhc2U6Omlvc3RhdGUgc3RhdGUgPSBzdGQ6Omlvc19iYXNlOjpnb29kYml0OwoK ICAgICAgICAgICAgaWYgKGFyZ2MgPCAyKSB7CiAgICAgICAgICAgICAgICB0cC5wdXQgKHN0ZDo6 b3N0cmVhbWJ1Zl9pdGVyYXRvcjxjaGFyPihzcyksCiAgICAgICAgICAgICAgICAgICAgICAgIHNz LCAnICcsICZzcmMsICd4Jyk7CgogICAgICAgICAgICAgICAgdGcuZ2V0X2RhdGUgKHN0ZDo6aXN0 cmVhbWJ1Zl9pdGVyYXRvcjxjaGFyPihzcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg c3RkOjppc3RyZWFtYnVmX2l0ZXJhdG9yPGNoYXI+KCksIHNzLAogICAgICAgICAgICAgICAgICAg ICAgICAgICAgIHN0YXRlLCAmZHN0KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsK ICAgICAgICAgICAgICAgIHRwLnB1dCAoc3RkOjpvc3RyZWFtYnVmX2l0ZXJhdG9yPGNoYXI+KHNz KSwKICAgICAgICAgICAgICAgICAgICAgICAgc3MsICcgJywgJnNyYywgJ1gnKTsKCiAgICAgICAg ICAgICAgICB0Zy5nZXRfdGltZSAoc3RkOjppc3RyZWFtYnVmX2l0ZXJhdG9yPGNoYXI+KHNzKSwK ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OmlzdHJlYW1idWZfaXRlcmF0b3I8Y2hh cj4oKSwgc3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUsICZkc3QpOwogICAg ICAgICAgICB9CgogICAgICAgICAgICBjb25zdCBib29sIGZhaWxlZCA9IChzdGF0ZSAmIHN0ZDo6 aW9zX2Jhc2U6OmZhaWxiaXQpICE9IDA7CgogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgInN0cmlu Zz0iICAgPDwgc3Muc3RyICgpLmNfc3RyICgpCiAgICAgICAgICAgICAgICAgICAgICA8PCAiXHRy ZXN1bHQ9IiA8PCAoZmFpbGVkID8gImZhaWwiIDogImdvb2QiKQogICAgICAgICAgICAgICAgICAg ICAgPDwgIlx0bG9jYWxlPSIgPDwgbG9jYWxlcyBbbl0gPDwgc3RkOjplbmRsOwogICAgICAgICAg ICAgICAgICAgICAgCiAgICAgICAgfQogICAgICAgIGNhdGNoKGNvbnN0IHN0ZDo6ZXhjZXB0aW9u JiBleCkgewogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgZXgud2hhdCAoKSA8PCBzdGQ6OmVuZGw7 CiAgICAgICAgfQogICAgfQoKICAgIHJldHVybiAwOwp9Cgo= ------=_Part_138807_2096900.1187605900478--