[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strjust
From: |
Ozzy Lash |
Subject: |
Re: strjust |
Date: |
Thu, 14 Oct 2010 14:20:33 -0500 |
On Thu, Oct 14, 2010 at 10:36 AM, Ben Abbott <address@hidden> wrote:
> On Oct 14, 2010, at 7:03 AM, Leo Butler <address@hidden> wrote:
>
>> On Wed, 13 Oct 2010, Ben Abbott wrote:
>>
>> < On Oct 13, 2010, at 12:16 AM, Leo Butler <address@hidden> wrote:
>> <
>> < > In 3.3.52+, I find the following behaviour of strjust,
>> < > which appears to conflict with its description.
>> < >
>> < > octave> s=sprintf("\tstring");
>> < > octave> s=strjust(s,"left")
>> < > s = string
>> < > octave> s=sprintf(" string");
>> < > octave> s=strjust(s,"left")
>> < > s = string
>> < >
>> < > You can see that it is not removing leading tabs.
>> < >
>> < > Leo
>> <
>> < Does the description below clarify how strjust functions?
>> <
>> < strjust (S)
>> < strjust (S, "right")
>> < Returns the text, S, justified to the right.
>> < strjust (S, "left")
>> < Returns left justified text.
>> < strjust (S, "center")
>> < Returns center justified text.
>> < Null characters are replaced by spaces.
>>
>> Here is the info description:
>>
>> -- Function File: strjust (S, ["left"|"right"|"center"])
>> Shift the non-blank text of S to the left, right or center of the
>> string. If S is a string array, justify each string in the array.
>> Null characters are replaced by blanks. If no
>> justification is
>> specified, then all rows are right-justified.
>>
>> By comparison:
>> -- Function File: strtrim (S)
>> Remove leading and trailing blanks and nulls from S.
>>
>> And here is how each works:
>>
>> octave> s=sprintf("\tstring");
>> octave> strjust(s,"left")
>> ans = string
>> octave> strtrim(s)
>> ans = string
>>
>> You see that the definition of 'blank' is inconsistent.
>>
>> Leo
>
> I've pushed the change below.
>
> http://hg.savannah.gnu.org/hgweb/octave/rev/04c3aacbbc46
>
> Thanks
> Ben
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
I think I agree with Leo, and that tabs should be treated as
whitespace (or blanks) and should be stripped for justification, If
not, I think that there is an issue for right justification as well.
For example try the following:
octave:4> a = ["notab";" typedtab";"\tescapedtab";"
eightspaces"]a =
notab
typedtab
escapedtab
eightspaces
octave:5> strjust(a,"left")
ans =
notab
typedtab
escapedtab
eightspaces
octave:6> strjust(a,"right")
ans =
notab
typedtab
escapedtab
eightspaces
octave:7>
Where the " typedtab" element was typed using ^V^I. If you look
at the right justification, you'll notice that the two with the tab
don't line up on the right. I think the tab is being treated as a
single character for alignment purposes, but then is displayed as 8
spaces.
Removing the leading tab would fix this issue, although I suppose
there may still be issues with tabs in the string that aren't at the
beginning of the string.
Bill
- strjust, Leo Butler, 2010/10/13
- Re: strjust, Ben Abbott, 2010/10/13
- Re: strjust, Leo Butler, 2010/10/14
- Re: strjust, Ben Abbott, 2010/10/14
- Re: strjust,
Ozzy Lash <=
- Re: strjust, Ben Abbott, 2010/10/14
- Re: strjust, Ozzy Lash, 2010/10/14
- Re: strjust, Ben Abbott, 2010/10/14
- Re: strjust, Ozzy Lash, 2010/10/14
- Re: strjust, Leo Butler, 2010/10/15
- Re: strjust, Jaroslav Hajek, 2010/10/15
- Re: strjust, Ben Abbott, 2010/10/15
- Re: strjust, John W. Eaton, 2010/10/15
- Re: strjust, Leo Butler, 2010/10/15
- Re: strjust, Ben Abbott, 2010/10/15