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

From: Kinkie <gkinkie_at_gmail.com>
Date: Fri, 26 Oct 2012 17:30:02 +0200

Ok, fixed and committed as r12411.

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.
>

-- 
    /kinkie
Received on Fri Oct 26 2012 - 15:30:08 MDT

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