[8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Richard Sargent
Administrator
In most places, EwNumericFormat handles padCharacter correctly, using #nextPut: to add it to the stream.
However, I just noticed one place where it incorrectly uses #nextPutAll:.

        formatChar == $S ifTrue: [
           
self isSignFixed ifTrue: [outputStream nextPutAll: self signString].
           
self isSignFloating ifTrue: [outputStream nextPutAll: self padCharacter]].

The effect is that the padding does not get emitted. Characters answer 0 for their size.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Seth Berman
Hi Richard,

I created case 56368 for this item.
At first glance, looks like previousFormatChar in the 'formatChar == $T' will always be nil due to its scope so I will just make note to review the whole method.
Thanks

-- Seth

On Thursday, September 25, 2014 7:09:13 PM UTC-4, Richard Sargent wrote:
In most places, EwNumericFormat handles padCharacter correctly, using #nextPut: to add it to the stream.
However, I just noticed one place where it incorrectly uses #nextPutAll:.

        formatChar == $S ifTrue: [
           
self isSignFixed ifTrue: [outputStream nextPutAll: self signString].
           
self isSignFloating ifTrue: [outputStream nextPutAll: self padCharacter]].

The effect is that the padding does not get emitted. Characters answer 0 for their size.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Richard Sargent
Administrator
On Wednesday, October 1, 2014 1:09:22 PM UTC-7, Seth Berman wrote:
I created case 56368 for this item.
At first glance, looks like previousFormatChar in the 'formatChar == $T' will always be nil due to its scope so I will just make note to review the whole method.

Thanks. I think the latter is good. The loop schematic is:
    self formatString doWithIndex: [:formatChar :i |

        previousFormatChar
:= formatChar].

I read the condition as "if already writing digits or the padded leading zeros, emit a thousands separator otherwise a padding character."


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Seth Berman
Hi Richard,

In your version is previousFormatChar declared within the inner loop?
I see something like.
self formatString doWithIndex: [:formatChar :|
        | previousFormatChar |

        "test the value of previousFormatChar (which I think is always nil)"

        previousFormatChar 
:= formatChar].

Do you see something different?

On Wednesday, October 1, 2014 4:48:49 PM UTC-4, Richard Sargent wrote:
On Wednesday, October 1, 2014 1:09:22 PM UTC-7, Seth Berman wrote:
I created case 56368 for this item.
At first glance, looks like previousFormatChar in the 'formatChar == $T' will always be nil due to its scope so I will just make note to review the whole method.

Thanks. I think the latter is good. The loop schematic is:
    self formatString doWithIndex: [:formatChar :i |

        previousFormatChar
:= formatChar].

I read the condition as "if already writing digits or the padded leading zeros, emit a thousands separator otherwise a padding character."


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Richard Sargent
Administrator
On Wednesday, October 1, 2014 2:16:24 PM UTC-7, Seth Berman wrote:
In your version is previousFormatChar declared within the inner loop?
I see something like.
self formatString doWithIndex: [:formatChar :|
        | previousFormatChar |

        "test the value of previousFormatChar (which I think is always nil)"

        previousFormatChar 
:= formatChar].

Do you see something different?

Oops. That is what I see, alright. That ain't gonna work.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] Error handling padCharacter in EwNumericFormat>>#formatNumber:

Seth Berman
Ok good.  That will be fixed as well.  Thank you again

-- Seth

On Wednesday, October 1, 2014 5:23:59 PM UTC-4, Richard Sargent wrote:
On Wednesday, October 1, 2014 2:16:24 PM UTC-7, Seth Berman wrote:
In your version is previousFormatChar declared within the inner loop?
I see something like.
self formatString doWithIndex: [:formatChar :|
        | previousFormatChar |

        "test the value of previousFormatChar (which I think is always nil)"

        previousFormatChar 
:= formatChar].

Do you see something different?

Oops. That is what I see, alright. That ain't gonna work.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.