unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] lib: clean up _notmuch_database_split_path
Date: Sun, 10 Apr 2016 22:43:23 +0300	[thread overview]
Message-ID: <1460317403-13714-3-git-send-email-jani@nikula.org> (raw)
In-Reply-To: <1460317403-13714-1-git-send-email-jani@nikula.org>

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

  parent reply	other threads:[~2016-04-10 19:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-10 19:43 [PATCH 1/3] test: test one character long directory names at top level Jani Nikula
2016-04-10 19:43 ` [PATCH 2/3] lib: fix handling of " Jani Nikula
2016-04-11  6:44   ` Tomi Ollila
2016-04-10 19:43 ` Jani Nikula [this message]
2016-04-12 23:51   ` [PATCH 3/3] lib: clean up _notmuch_database_split_path David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460317403-13714-3-git-send-email-jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).