From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 9FC591F66E for ; Wed, 19 Aug 2020 16:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgHSQBX (ORCPT ); Wed, 19 Aug 2020 12:01:23 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:57238 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbgHSQBU (ORCPT ); Wed, 19 Aug 2020 12:01:20 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 9797DF3241; Wed, 19 Aug 2020 12:01:18 -0400 (EDT) (envelope-from junio@pobox.com) 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=NTv2hF0eY5UBJlgGsB4nlToeJrg=; b=tJlqme TPX/01RD2EWjBDDVWeNIb4HPrBKCkazcGS4rje0gTlIYjrttIKvucdxnvdbAkvXZ 6JzHfQPWTR8CSNxaPM8aNBYRCydhD1+UtOKrWqOFHi1Mnh0tfYvviS/zCyysnwXM MrSbeR9CmjIbK+l9lXeFSZk4UBbehBnuQLG9I= 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=C91dUj0QU/lCMpO+QOtGPIrl+D32hcUT y/ZLGBOFIJvgRuYFjSHPRJfSXW6tt/mDZuTg7bTwGWGXqe/jecjNjDxQSUjE3FJj Va7UPkAdVVrLIcL7wNxu9gbAMoLnbO6mQR6FyhG0nmug+NWfgwCPbsy4zMs8gaCu wRgBjbqwyjo= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 908B0F323F; Wed, 19 Aug 2020 12:01:18 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.75.7.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id CD907F323D; Wed, 19 Aug 2020 12:01:15 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Hariom verma Cc: Hariom Verma via GitGitGadget , git , Christian Couder , Heba Waly Subject: Re: [PATCH v3 7/9] pretty: refactor `format_sanitized_subject()` References: <0ad22c7cdd3c692aa5b46444e64a3b76f1e87b4c.1597687822.git.gitgitgadget@gmail.com> Date: Wed, 19 Aug 2020 09:01:14 -0700 In-Reply-To: (Hariom verma's message of "Wed, 19 Aug 2020 19:06:59 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 363156F2-E235-11EA-93BC-843F439F7C89-77302942!pb-smtp21.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hariom verma writes: >> Also, because neither LF or SP is a titlechar(), wouldn't the "if >> r[i] is LF, replace it with SP" a no-op wrt what will be in sb at >> the end? > > Maybe its better to directly replace LF with hyphen? [Instead of first > replacing LF with SP and then replacing SP with '-'.] Why do you think LF is so special? Everything other than titlechar() including HT, '#', '*', SP is treated in the same way as the body of that loop. It does not directly contribute to the final contents of sb, but just leaves the marker in the variable "space" the fact that when adding the next titlechar() to the resulting sb, we need a SP to wordbreak. LF now happens to be in the set due to the way you extended the function (it wasn't fed to this function by its sole caller), but other than that, it is no more special than HT, SP or '*'. And they are not replaced with SP or replaced with '-'. So it would be the most sensible to just drop 'if LF, replace it with SP before doing anything else' you added. The existing 'if titlechar, add it to sb but if we saw non-title, add a SP before doing so to wordbreak, and if not titlechar, just remember the fact that we saw one' should work fine as-is without special casing LF at all. Or am I missing something subtle?