Re: [PATCH] c++-stream-ify purge/conffile.cc

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Fri, 26 Oct 2012 10:37:54 -0600

On 10/26/2012 09:30 AM, Kinkie wrote:
> Ok, fixed and committed as r12411.

> - FILE* in = fopen( fn, "r" );
> - if ( in == NULL ) {
> + std::ifstream cfgin(fn);
> + if (cfgin) {

Missing "!" in the if-statement condition.

Alex.

>
> On Thu, Oct 25, 2012 at 6:29 PM, Alex Rousskov
> <rousskov_at_measurement-factory.com> wrote:
>> On 10/24/2012 11:14 AM, Kinkie wrote:
>>> Hi,
>>> the attached patch changes purge/conffile.cc to use c++ file streams
>>> instaed of C-FILE handles.
>>>
>>> Ok for merging?
>>>
>>
>>
>>> - FILE* in = fopen( fn, "r" );
>>> - if ( in == NULL ) {
>>> + std::ifstream cfgin(fn);
>>> + if ( !cfgin.good() ) {
>>> fprintf( stderr, "fopen %s: %s\n", fn, strerror(errno) );
>>> return -1;
>>
>> This is not exactly a 1:1 conversion. The old and the patch code might
>> behave differently on empty files. To preserve old behavior, you would
>> need to do
>>
>> if (!cfgin) {
>> ...
>> }
>>
>> instead of calling .good().
>>
>>
>> HTH,
>>
>> Alex.
>>
>
>
>
Received on Fri Oct 26 2012 - 16:37:59 MDT

This archive was generated by hypermail 2.2.0 : Fri Oct 26 2012 - 12:00:09 MDT