On Sat 19-Aug-06 3:13pm -0600, Yegappan Lakshmanan wrote:

> On 8/10/06, Bill McCarthy <[EMAIL PROTECTED]> wrote:

>> The function reltimestr() return a string which may have
>> leading spaces.  Is that a bug or a feature?

> The string returned by reltimestr() has leading spaces, because
> the following code is internally used to generate this string (on
> non MS-Windows systems):
>     sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec);
> On MS-Windows, the following code is used:
>     sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart);

>> A workaround for this is:
>> function Reltimestr(t)
>>     return matchstr(reltimestr(a:t),'[0-9.]\+')
>> endfunction

That code, from profile_msg() in ex_cmds2.c is also used in
several other functions to produce formatted text.  However,
the function f_reltimestr() is only used to perform for the
end user.

IMO the docs should disclose that the string returned has a
minimum field width of 10 characters padded on the left with
blanks OR any leading blanks should be stripped by the

I prefer the latter.  A patch is attached.

(However, since I don't think this list accepts attachments,
I have included this small patch as text below my sig and
copying the vim-dev list - beware of email client tab

Best regards,

*** eval.7.0.063.c      Wed Aug 16 15:21:55 2006
--- eval.c      Sat Aug 19 20:10:45 2006
*** 13001,13007 ****
--- 13001,13011 ----
      rettv->vval.v_string = NULL;
      if (list2proftime(&argvars[0], &tm) == OK)
+     {
        rettv->vval.v_string = vim_strsave((char_u *)profile_msg(&tm));
+       while (rettv->vval.v_string[0] == ' ')
+           rettv->vval.v_string++;
+     }

Attachment: eval.c.diff
Description: Binary data

Reply via email to