bugGNU Octave - Bugs: bug #45976, ctime and asctime add a trailing...

 
 

bug #45976: ctime and asctime add a trailing newline character to the return value

Submitter:  None
Submitted:  Wed 16 Sep 2015 10:41:20 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  T Herzke Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 20 Sep 2015 09:29:58 AM UTC, comment #6: 
Mike Miller <mtmiller>
Group Member
Sun 20 Sep 2015 07:24:48 AM UTC, comment #5: 

Regarding the previous comment:

There is/should be a literal backslash between the 2015 and the n in the result example. It's displayed as such on the web bug tracker,but missing from the email that I received after comment submission.

T Herzke

Anonymous
Sun 20 Sep 2015 07:19:34 AM UTC, comment #4: 

As a user, I'd like to see

       ctime (time ())
          => "Sun Sep 20 08:54:28 2015\n"

being displayed with the double quotes when I invoke e.g. help ctime, or doc ctime.

The meaning of backslash-n is clear enough to me as a casual octave user, even though I was not aware of the exact difference between single-quoted vs. double-quoted strings regarding escape sequences before reporting this issue.

Now how that backslash might need to be escaped in the source to be displayed correctly in the output of help / doc is something I do not know.

T Herzke

Anonymous
Sat 19 Sep 2015 10:14:10 PM UTC, comment #3: 

Any thoughts on how to represent that? I don't see any existing examples of @result{} showing a string containing a newline. Keep the @result{} as is, just note the trailing newline in the text?

Maybe we should update to a new example timestamp also ;)

Mike Miller <mtmiller>
Group Member
Wed 16 Sep 2015 12:12:13 PM UTC, comment #2: 

Both of these functions are patterned after the C library functions of the same name.  The C library version of asctime is explicitly documented to include a trailing newline in the result.  I think we should just fix the Octave documentation to make that clear.

John W. Eaton <jwe>
Group administrator
Wed 16 Sep 2015 11:41:12 AM UTC, comment #1: 

I can confirm this behavior w Octave-4.1.0+ on Windows:

>> uint16 (ctime (time ()))
ans =

 Columns 1 through 16:

   87  101  100   32   83  101  112   32   49   54   32   49   51   58   51   55

 Columns 17 through 25:

   58   51   48   32   50   48   49   53   10

>>


Release -> dev, OS -> Any

Philip Nienhuis <philipnienhuis>
Group Member
Wed 16 Sep 2015 10:41:20 AM UTC, original submission:  

The functions "ctime" and "asctime" return a string representation of the time argument.

The documentation of both functions suggests that there will be neither leading nor trailing white space. Documentation excerpt:

     ctime (time ())
             => "Mon Feb 17 01:15:06 1997"

However, the return value contains a newline as the last character.

Either the functions should be modified to not append the newline character, or the documentation should be altered to indicate that the return values will end in a newline.

To my knowledge, matlab does not implement these functions, so matlab compatibility should not be a concern in resolving this issue.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-20 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-09-16 rik5 Item GroupIncorrect Result Documentation
    2015-09-16 philipnienhuis StatusNone Confirmed
        Release4.0.0 dev
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code