octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rat and rats ported from octave-forge


From: David Bateman
Subject: Re: rat and rats ported from octave-forge
Date: Thu, 26 Jul 2007 18:41:23 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

David Bateman wrote:
> John W. Eaton wrote:
>   
>> I think the source of the problem is that the string computed by rats
>> should be a character array with the same number of rows as the
>> original numeric matrix instead of a character array with one row and
>> embedded newline characters.  If it were, then Octave would display it
>> as you expect.
>>
>>   
>>     
> So what is the best way of converting a "\n" line terminated string into
> an appropriate character matrix? Does any code exist for it already? 
> Unfortunately we can't guarantee that the string length between the "\n"
> will be identical, This might mean that its better to do rats separately
> than the "format rat" code...
>
> D.
>
>   
This version of the patch should do it, though there might be a better way..

D.


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** ./src/pr-output.cc.orig2    2007-07-26 17:55:10.820091559 +0200
--- ./src/pr-output.cc  2007-07-26 18:38:26.464646219 +0200
***************
*** 2765,2771 ****
          rat_format = true;
          std::ostringstream buf;
          args(0).print (buf);
!         retval = buf.str ();
          rat_format = save_rat_format;
        }
        else
--- 2765,2788 ----
          rat_format = true;
          std::ostringstream buf;
          args(0).print (buf);
!         std::string s = buf.str ();
!         string_vector sv;
!         size_t n = 0;
!         while (true)
!           {
!             size_t m = s.find_first_of ('\n',  n);
!             if (m == NPOS)
!               {
!                 sv.append (s.substr (n, m));
!                 break;
!               }
!             else
!               {
!                 sv.append (s.substr (n, m - n));
!                 n = m + 1;
!               }
!           }
!         retval = octave_value (sv);
          rat_format = save_rat_format;
        }
        else

reply via email to

[Prev in Thread] Current Thread [Next in Thread]