[pacman-dev] [PATCH 2/2] Overhaul archive fgets function

Allan McRae allan at archlinux.org
Wed Dec 15 07:17:50 EST 2010


On 15/12/10 16:48, Dan McGee wrote:
> Please let me know if it is unclear how the new function works, so more
> comments can be put in there.

This is a really nice improvement over the old character at a time 
implementation.  I found the comments in the function to clearly 
describe what is happening.

I only have one query and what will forever be known as "the worlds most 
trivial correction" to make.

<snip>

> +	/* loop until we reach EOF or other error */
> +	while(_alpm_archive_fgets(a,&buf) == ARCHIVE_OK) {
> +		char *line = buf.line ? _alpm_strtrim(buf.line) : "";

<snip>

> +	if(_alpm_archive_fgets(archive,&buf) != ARCHIVE_OK) goto error; \
> +	s = buf.line ? _alpm_strtrim(buf.line) : ""; \

<snip>

> +		while(_alpm_archive_fgets(archive,&buf) == ARCHIVE_OK) {
> +			char *line = _alpm_strtrim(buf.line);

I am unsure why the ?: NULL check is done with the first two and not the 
third.  I might be missing something here...


<snip>

Prepare yourself for this insight I am about to impart:

> +			/* zero-copy- this is the entire next block of data. */

Space between "zero-copy" and the hyphen.  :P

Allan


More information about the pacman-dev mailing list