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

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Thu, 25 Oct 2012 10:29:23 -0600

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 Thu Oct 25 2012 - 16:29:26 MDT

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