[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #56419] Implementation of newline
From: |
Guillaume |
Subject: |
[Octave-bug-tracker] [bug #56419] Implementation of newline |
Date: |
Thu, 30 May 2019 07:23:43 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 |
URL:
<https://savannah.gnu.org/bugs/?56419>
Summary: Implementation of newline
Project: GNU Octave
Submitted by: gyom
Submitted on: Thu 30 May 2019 11:23:41 AM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: Guillaume
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
Matlab introduced a newline function that returns "\n":
https://www.mathworks.com/help/matlab/ref/newline.html
Here is a possible implementation (with much help from IRC):
diff -r 3d9e72cac668 libinterp/corefcn/strfns.cc
--- a/libinterp/corefcn/strfns.cc Wed May 29 03:28:05 2019 +0000
+++ b/libinterp/corefcn/strfns.cc Thu May 30 10:54:46 2019 +0100
@@ -45,6 +45,31 @@
#include "oct-string.h"
+DEFUN (newline, args, nargout,
+ doc: /* -*- texinfo -*-
address@hidden {} {} newline ()
+Return the character corresponding to a newline.
+
+This is equivalent to @code{"\n"}.
+
address@hidden, char}
address@hidden deftypefn */)
+{
+ if ((args.length () != 0) || (nargout > 1))
+ print_usage ();
+
+ static octave_value_list retval = ovl ("\n");
+
+ return retval;
+}
+
+/*
+%!assert (newline (), "\n")
+
+%!error newline (1)
+%!error [a, b] = newline ()
+*/
+
DEFUN (char, args, ,
doc: /* -*- texinfo -*-
@deftypefn {} {} char (@var{x})
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?56419>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #56419] Implementation of newline,
Guillaume <=