From: Johannes Schindelin Date: Wed, 11 Jul 2007 19:17:06 GMT Subject: Re: [PATCH 1/2] Function stripspace now gets a buffer instead file descriptors. Message-ID: In-Reply-To: <4695267A.7080202@gmail.com> Hi, On Wed, 11 Jul 2007, Carlos Rica wrote: > @@ -28,52 +26,67 @@ static int cleanup(char *line, int len) > * Remove empty lines from the beginning and end > * and also trailing spaces from every line. > * > + * Note that the buffer will not be null-terminated. > + * > * Turn multiple consecutive empty lines between paragraphs > * into just one empty line. > * > * If the input has only empty lines and spaces, > * no output will be produced. > * > + * If last line has a newline at the end, it will be removed. > + * Please let me comment about the rationale for both changes: The stripspace() function (which this hunk is about) is more useful if it does not allocate a new buffer, but works in-place. And since it knows the new length already, it can just as well return the length, and _not_ NUL terminate (which would mean that we have to reallocate if we used read_pipe() to get the buffer). The reason for the missing newline at the end is the same: since we accept buffers with a missing newline at the end, we would have to reallocate in that case. So for the sake of simplicity, we neither NUL-terminate, nor \n terminate the buffer, and leave that to the callers. Ciao, Dscho