Fix for /bin/date -R (was Re: 822-date obsolete?)
On Jan 11, Chris Lawrence wrote:
> On Jan 10, Marco d'Itri wrote:
> > On Jan 09, "Karl B. Hammar" <karl@kalle.csb.ki.se> wrote:
> > >You can't simply substitute 822-date with date -R, since date cares about
> > >your LANG variable.
> > This is a bug in /bin/date: RFC 822 compliant dates must not use
> > translated names.
>
> How about the following replacement for /usr/bin/822-date:
>
> #!/bin/sh
> LANG=C /bin/date --rfc
>
> Either that or fixing the bug in /bin/date would work...
The following patch should fix 'date -R' to use English for the date
(as per RFC 822):
--- date.c.old Mon Jan 11 01:24:05 1999
+++ date.c Mon Jan 11 01:27:05 1999
@@ -336,12 +336,16 @@
return;
}
+ if(rfc_format)
+ setlocale (LC_ALL, "C");
do
{
out_length += 200;
out = (char *) xrealloc (out, out_length);
}
while (strftime (out, out_length, format, tm) == 0);
+ if(rfc_format)
+ setlocale (LC_ALL, "");
printf ("%s\n", out);
free (out);
The only (slight) bug is that if xrealloc or strftime fail the failure
message will be in English.
Chris
--
=============================================================================
| Chris Lawrence | My home page: |
| <quango@watervalley.net> | http://www.clark.net/pub/lawrencc/ |
| | |
| Amiga A4000/060 with | Join the party that opposed the CDA |
| Linux/m68k 2.1.127 | http://www.lp.org/ |
=============================================================================
Reply to: