From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-5.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 1F666207DF for ; Mon, 12 Sep 2016 23:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113AbcILXxM (ORCPT ); Mon, 12 Sep 2016 19:53:12 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:64442 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751652AbcILXxL (ORCPT ); Mon, 12 Sep 2016 19:53:11 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 6A2263CD82; Mon, 12 Sep 2016 19:53:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=FOYXfOLWRBd2fOYam2v/8udGJo4=; b=Io01aQ HytkrWRY2evar6xIt5mjuntqH+j3xIwWE0K3VsLOcXjeIz3OWN9hCbzmmuqdIXyf QAdVNgOYFlBHk/ZBFA1gg3QcL/wHk2VHsoC9lBTS/8ml8j+YpuhNtikFOTOSxSe3 Wlpgu4VUStn2CrhnFJKYg05nWj0ysLj5yuCAY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Yn5LCgGV1whbcE639SjKqa7Lej3Gr7wD vzLpm5LiwItPLz85it5l/wBeb9bmmg1rqykoORKwvMXAx+dbRAzirhIirlcS6ngM NuFW4zXR+T5D+4cKNlGdqxdhigxqV6hnhs5pfO820ilrAbBmmbpRiJ7PHUPw23TB CGQPRzfAZNc= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 635D83CD81; Mon, 12 Sep 2016 19:53:10 -0400 (EDT) Received: from pobox.com (unknown [104.132.0.95]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id E195F3CD80; Mon, 12 Sep 2016 19:53:09 -0400 (EDT) From: Junio C Hamano To: Stefan Beller Cc: git@vger.kernel.org, Stefan Beller Subject: Re: [PATCH 03/10] diff.c: drop tautologous condition in emit_line_0 References: <1473572530-25764-1-git-send-email-stefanbeller@gmail.com> <1473572530-25764-4-git-send-email-stefanbeller@gmail.com> Date: Mon, 12 Sep 2016 16:53:07 -0700 In-Reply-To: <1473572530-25764-4-git-send-email-stefanbeller@gmail.com> (Stefan Beller's message of "Sat, 10 Sep 2016 22:42:03 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 0F183BE8-7944-11E6-9E1C-F7BB12518317-77302942!pb-smtp1.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stefan Beller writes: > diff --git a/diff.c b/diff.c > index 156c2aa..9d2e704 100644 > --- a/diff.c > +++ b/diff.c > @@ -460,8 +460,7 @@ static void emit_line_0(struct diff_options *o, const char *set, const char *res > > if (len == 0) { > has_trailing_newline = (first == '\n'); > - has_trailing_carriage_return = (!has_trailing_newline && > - (first == '\r')); > + has_trailing_carriage_return = (first == '\r'); > nofirst = has_trailing_newline || has_trailing_carriage_return; > } else { > has_trailing_newline = (len > 0 && line[len-1] == '\n'); Interesting. This may be a mis-conversion at 250f7993 ("diff.c: split emit_line() from the first char and the rest of the line", 2009-09-14), I suspect. The original took line[] with length and peeked for '\n', and when it saw one, it decremented length before checking line[len-1] for '\r'. But of course if there is only one byte on the line (i.e. len == 0 after first is stripped off), it cannot be both '\n' or '\r' at the same time. Thanks for spotting.