From: Jani Nikula Date: Sun, 10 Apr 2016 19:43:23 +0000 (+0300) Subject: [PATCH 3/3] lib: clean up _notmuch_database_split_path X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dc8873ff117dafcc5b586e447caf703b82264623;p=notmuch-archives.git [PATCH 3/3] lib: clean up _notmuch_database_split_path --- diff --git a/7b/bcf58e5360e42cb0f7b2e62a72d91ee126843d b/7b/bcf58e5360e42cb0f7b2e62a72d91ee126843d new file mode 100644 index 000000000..4c6fab14e --- /dev/null +++ b/7b/bcf58e5360e42cb0f7b2e62a72d91ee126843d @@ -0,0 +1,121 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 60B996DE0318 + for ; Sun, 10 Apr 2016 12:44:55 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.558 +X-Spam-Level: +X-Spam-Status: No, score=-0.558 tagged_above=-999 required=5 tests=[AWL=0.162, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 8oAW6XbvSnxj for ; + Sun, 10 Apr 2016 12:44:47 -0700 (PDT) +Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com + [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 0B3AC6DE02C6 for + ; Sun, 10 Apr 2016 12:44:41 -0700 (PDT) +Received: by mail-wm0-f66.google.com with SMTP id a140so16811877wma.2 + for ; Sun, 10 Apr 2016 12:44:41 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula-org.20150623.gappssmtp.com; s=20150623; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=86TDUTEbDlV8CGHHO1dqy+YaduKPRR0cn6tN5KNFINk=; + b=1jMKvYBbAtqCdt2xNtCoh2do7nbBNPawWNYl+RLFW87o5VBZW99QLbKwqkMCVOfuka + IIamqMJOG7l+KWWrlRb1emt/Q3wKyFjGnuPcwPZ1OhYPd+Icbs/PmLGZ/f0iQ6nSWBfo + PV7assZYyDH4fmN6Gri3iMkHzCpTgQCJu44pKMcKtQP2Wbp1XNq9tTHNBgrkvF9NlFxn + r/UzzpIrw+eTZvnL7KjBaLKPTFIqqfRpoBHMDKnBT1/EezTUWjS13RTZv2HQyQq/f9gQ + OLqR9xKOvOnr4Kd5Ir7anbkkpG+6PI+Up5Yd6BIXpKCh9DzKJHic2S5cjt+oCSuPNHji + aBZA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=86TDUTEbDlV8CGHHO1dqy+YaduKPRR0cn6tN5KNFINk=; + b=GczvSy4sDCDWBql/puVaTzAk8XIKfm3CFgFGlgdTbWrzvTksn1O4oRfhgFsAcTM6bE + RIcxHImHQLdP7AFD/UYe5ov93N8WQj3Lhjsb8QotjlDJWn2uPK+XsLdyBlWCJFCFns3M + 7V/ljIhPSNlWgdMXwMJ39YzQxqsV+1GAQOAew/AfUZkzZjI956cR5AwZykZMaDQl763g + Lnt0uRxZnIk/HBWdUglIjJliHElXErH4avagMbuHHx88xhblqumLpuvrCoZsgUJJY7s/ + NCWjniQWsVFhn5E6cBzhzgBXxt327Z461S9zRp5lMu6ECbhnRACZDubh48UQpaX/pmfN + w0Vg== +X-Gm-Message-State: + AD7BkJLEmTGFtnsdAtLI0ADgZxsUe/MlHs+vysbY4iRtox3BpzOafehMaFxFdV5m5TARSA== +X-Received: by 10.28.58.77 with SMTP id h74mr14264048wma.82.1460317480615; + Sun, 10 Apr 2016 12:44:40 -0700 (PDT) +Received: from localhost (mobile-access-bcee7f-102.dhcp.inet.fi. + [188.238.127.102]) + by smtp.gmail.com with ESMTPSA id o128sm13596863wmb.19.2016.04.10.12.44.39 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 10 Apr 2016 12:44:40 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 3/3] lib: clean up _notmuch_database_split_path +Date: Sun, 10 Apr 2016 22:43:23 +0300 +Message-Id: <1460317403-13714-3-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1460317403-13714-1-git-send-email-jani@nikula.org> +References: <1460317403-13714-1-git-send-email-jani@nikula.org> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 10 Apr 2016 19:44:55 -0000 + +Make the logic it a bit easier to read. No functional changes. +--- + lib/database.cc | 17 +++-------------- + 1 file changed, 3 insertions(+), 14 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index b8486f7d5271..c8c5e26106ad 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -1761,18 +1761,11 @@ _notmuch_database_split_path (void *ctx, + slash = path + strlen (path) - 1; + + /* First, skip trailing slashes. */ +- while (slash != path) { +- if (*slash != '/') +- break; +- ++ while (slash != path && *slash == '/') + --slash; +- } + + /* Then, find a slash. */ +- while (slash != path) { +- if (*slash == '/') +- break; +- ++ while (slash != path && *slash != '/') { + if (basename) + *basename = slash; + +@@ -1780,12 +1773,8 @@ _notmuch_database_split_path (void *ctx, + } + + /* Finally, skip multiple slashes. */ +- while (slash != path) { +- if (*(slash - 1) != '/') +- break; +- ++ while (slash != path && *(slash - 1) == '/') + --slash; +- } + + if (slash == path) { + if (directory) +-- +2.1.4 +