Re: msvcp90: Add istream::operator>>complex implementation and tests.
Hi, On 03/07/15 12:13, YongHao Hu wrote:
+/* ??$?5MDU?$char_traits(a)D@std@@@std@@YAAAV?$basic_istream(a)DU?$char_traits(a)D@std@@@0(a)AAV10@AAV?$complex(a)M@0@@Z */ +/* ??$?5MDU?$char_traits(a)D@std@@@std@@YAAEAV?$basic_istream(a)DU?$char_traits(a)D@std@@@0(a)AEAV10@AEAV?$complex(a)M@0@@Z */ +basic_istream_char* __cdecl basic_istream_char_read_complex_float(basic_istream_char *this, complex_float *v) +{ + float r; + basic_ios_char *base = basic_istream_char_get_basic_ios(this); + if(ios_base_good(&base->base)) { There's no need to check the stream state here, it will be done by stream reading functions. + ws_basic_istream_char(this); + if(basic_istream_char_peek(this) == '(') { + basic_istream_char_get(this); + basic_istream_char_read_float(this, &r); + if(!ios_base_fail(&base->base)) { I think that the implementation will be more readable if you just return on error here. The if(!ios_base_fail(...)) line can be changed to: if(ios_base_fail(&base->base)) return this; You don't need to set failbit in this case because it's already set by basic_istream_char_read_float. The same applies to some other ios_base_fail() checks.
Thanks, Piotr
Good point. I had sent a new patch to wine-patch. Thank you very much for your comment. : ) On 2015年03月09日 18:23, Piotr Caban wrote:
Hi,
On 03/07/15 12:13, YongHao Hu wrote:
+/* ??$?5MDU?$char_traits(a)D@std@@@std@@YAAAV?$basic_istream(a)DU?$char_traits(a)D@std@@@0(a)AAV10@AAV?$complex(a)M@0@@Z */ +/* ??$?5MDU?$char_traits(a)D@std@@@std@@YAAEAV?$basic_istream(a)DU?$char_traits(a)D@std@@@0(a)AEAV10@AEAV?$complex(a)M@0@@Z */ +basic_istream_char* __cdecl basic_istream_char_read_complex_float(basic_istream_char *this, complex_float *v) +{ + float r; + basic_ios_char *base = basic_istream_char_get_basic_ios(this); + if(ios_base_good(&base->base)) { There's no need to check the stream state here, it will be done by stream reading functions. + ws_basic_istream_char(this); + if(basic_istream_char_peek(this) == '(') { + basic_istream_char_get(this); + basic_istream_char_read_float(this, &r); + if(!ios_base_fail(&base->base)) { I think that the implementation will be more readable if you just return on error here. The if(!ios_base_fail(...)) line can be changed to: if(ios_base_fail(&base->base)) return this; You don't need to set failbit in this case because it's already set by basic_istream_char_read_float. The same applies to some other ios_base_fail() checks.
Thanks, Piotr
participants (2)
-
Piotr Caban -
YongHao Hu