[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] svn --version --verbose += /etc/os-release

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Tue, 27 Jan 2015 11:28:35 +0000

Daniel Shahaf <d.s_at_daniel.shahaf.name> writes:

> +static const char *
> +systemd_release(apr_pool_t *pool)
> +{
> + svn_error_t *err;
> + svn_stream_t *stream;
> +
> + err = svn_stream_open_readonly(&stream, "/etc/os-release", pool, pool);
> + if (err && APR_STATUS_IS_ENOENT(err->apr_err))
> + {
> + svn_error_clear(err);
> + err = svn_stream_open_readonly(&stream, "/usr/lib/os-release", pool,
> + pool);
> + }
> + if (err)
> + {
> + svn_error_clear(err);
> + return NULL;
> + }
> +
> + while (TRUE)
> + {
> + svn_stringbuf_t *line;
> + svn_boolean_t eof;
> +
> + err = svn_stream_readline(stream, &line, "\n", &eof, pool);
> + if (err)
> + {
> + svn_error_clear(err);
> + return NULL;
> + }
> +
> + if (!strncmp(line->data, "PRETTY_NAME=", 12))
> + return remove_shell_quoting(line, 12, pool);

The file below the stream is still open and will remain open until the
pool is cleared and that also clears the result. scratch/result pools
would allow the caller to close the stream and keep the result. It
might be better to arrange for this function to close the stream,
perhaps just assume the file is small and read it all into memory.

> +
> + if (eof)
> + break;
> + }
> +
> + return NULL;
> +}
> +

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*
Received on 2015-01-27 12:29:05 CET

This is an archived mail posted to the Subversion Dev mailing list.