Re: date() should not append a final "\n" ?!?

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: date() should not append a final "\n" ?!?
From: Kurt Hornik (Kurt.Hornik@ci.tuwien.ac.at)
Date: Thu 19 Aug 1999 - 19:43:46 EST


Message-ID: <14267.53714.885909.438577@fangorn.ci.tuwien.ac.at>

>>>>> Martin Maechler writes:

>>>>> On Thu, 19 Aug 1999 10:45:35 +0200,
>>>>> Martin Maechler (MM) wrote:

MM> Between R 0.63.2 and 0.64, the behavior of
MM> date()
MM> has been changed in order to become platform independent.
MM> It now uses POSIX calls, basically

MM> time_t t;
MM> time(&t);
MM> return ctime(&t);

MM> This currently returns (for me on Sun SPARC Solaris)

>>>> date()
MM> [1] "Thu Aug 19 10:36:28 1999\n"

MM> where I think the final "\n" is really UNdesired.

FrL> Yes!

> Okay,
> I checked Lewine (1991) "POSIX Programmer's Guide" :

> POSIX specifies that ctime() has a final "\n"
> (before the string terminator \0)
> and always length 26 (incl. terminator)

> Hence, we have to drop the final "\n",
> already in function R_Date() which is [in src/main/platform.c]
> currently
> char *R_Date()
> {
> time_t t;
> time(&t);
> return ctime(&t);
> }

> How can we drop is this done in the most elegant way?
> (without having to allocate a char[26] ?)

Be brutal, do

        date <- function() substring(.Internal(date()), 1, 24)

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:07 EST