This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/4772] strptime() doesn't support strftime()'s flags


------- Additional Comments From tomek at jot23 dot org  2007-07-11 04:52 -------
I see you are unconvinced, let the code speak:
----
#include <clocale>
#include <ctime>
#include <iostream>
#include <langinfo.h>

int main()
{
  time_t t;
  tm t1, t2;
  char *p, buf[128];
  setlocale(LC_ALL, "pl_PL.UTF8");
  t = time(NULL);
  t1 = *localtime(&t);
  std::cout << "nl_langinfo(D_FMT):" << nl_langinfo(D_FMT) << std::endl;
  strftime(buf, sizeof(buf), nl_langinfo(D_FMT), &t1);
  std::cout << "strftime (1): " << buf << std::endl;
  p = strptime(buf, nl_langinfo(D_FMT), &t2);
  strftime(buf, sizeof(buf), nl_langinfo(D_FMT), &t2);
  std::cout << "strftime (2): " << buf << std::endl;
  return(0);
}
----

Results from FC6:
nl_langinfo(D_FMT):%Y-%m-%d
strftime (1): 2007-07-11
strftime (2): 2007-07-11

Results from F7:
nl_langinfo(D_FMT):%-d %b %Y
strftime (1): 11 VII 2007
strftime (2): 0 II 1953

My question is: what have I done wrong?
Now, if the answer is nothing, then fix the library.
If the answer is: you haven't removed flags characters from
format string, then my answer is: fix the library.
Reasoning:
As in #6. If I have to work around something in a library
then what happens if someone decides thar strftime needs
to support flag, let's say '+'? I have to change the code
and in that case I can as well write my own fuction. This
puts us in a position where I can as well write my own library
and renders strptime completly useless and in a posistion
where I have as application developer to check ALL strptime
calls to verify that they will work.
THIS IS UNREASONABLE.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |


http://sourceware.org/bugzilla/show_bug.cgi?id=4772

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]