[PATCH v2 2/5] lib: Move _filename_is_in_maildir
authorAustin Clements <amdragon@MIT.EDU>
Sat, 9 Jun 2012 19:14:15 +0000 (15:14 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:38 +0000 (09:47 -0800)
13/4911e2d835f7d692a9baaf0a8edb8748e247a9 [new file with mode: 0644]

diff --git a/13/4911e2d835f7d692a9baaf0a8edb8748e247a9 b/13/4911e2d835f7d692a9baaf0a8edb8748e247a9
new file mode 100644 (file)
index 0000000..d8dfac6
--- /dev/null
@@ -0,0 +1,184 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3F24D431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  9 Jun 2012 12:14:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id WRM8j-tTIMj8 for <notmuch@notmuchmail.org>;\r
+       Sat,  9 Jun 2012 12:14:57 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 521F8431FB6\r
+       for <notmuch@notmuchmail.org>; Sat,  9 Jun 2012 12:14:55 -0700 (PDT)\r
+X-AuditID: 1209190e-b7fb56d0000008b2-8b-4fd3a0aea1a9\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 77.43.02226.EA0A3DF4; Sat,  9 Jun 2012 15:14:54 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q59JErUa015441; \r
+       Sat, 9 Jun 2012 15:14:53 -0400\r
+Received: from drake.dyndns.org\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q59JEqkw026105\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 9 Jun 2012 15:14:53 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SdR75-0000wp-MN; Sat, 09 Jun 2012 15:14:19 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/5] lib: Move _filename_is_in_maildir\r
+Date: Sat,  9 Jun 2012 15:14:15 -0400\r
+Message-Id: <1339269258-3542-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1339269258-3542-1-git-send-email-amdragon@mit.edu>\r
+References: <1338742656-11640-1-git-send-email-amdragon@mit.edu>\r
+       <1339269258-3542-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixCmqrLtuwWV/g1/XDSyapjtbXL85k9mB\r
+       yePW/dfsHs9W3WIOYIrisklJzcksSy3St0vgyljyeAlrwWOJio3vp7M1MP4U6mLk5JAQMJF4\r
+       fHQxI4QtJnHh3nq2LkYuDiGBfYwSk3Z8ZoFw1jNKdDbNZ4ZwHjJJbDv2nxXCmcso0bJ0JTNI\r
+       P5uAhsS2/cvBZokISEvsvDsbqIiDg1nAXOJmSxxIWFjAUuL6uoPsIDaLgKpE/6oHbCA2r4C9\r
+       xJQzzewQZ8hLPL3fBxbnFHCQePZ9OthIIYEyiWenZ7NNYORfwMiwilE2JbdKNzcxM6c4NVm3\r
+       ODkxLy+1SNdYLzezRC81pXQTIziQJPl2MH49qHSIUYCDUYmHV1f+kr8Qa2JZcWXuIUZJDiYl\r
+       Ud762Zf9hfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwbmUCKudNSaysSi3Kh0lJc7AoifMmcp31\r
+       FxJITyxJzU5NLUgtgsnKcHAoSfDumg80VLAoNT21Ii0zpwQhzcTBCTKcB2j4G5Aa3uKCxNzi\r
+       zHSI/ClGXY55h85dZxRiycvPS5UShxgkAFKUUZoHNweWAF4xigO9Jcy7H6SKB5g84Ca9AlrC\r
+       BLSkNeoCyJKSRISUVANjYbiN53b+vVPCnxTvCzgz52+CZOSp2fZbFkX83JDr3Xlze7H0PDm5\r
+       mfMjH6eZ7G708D7Vuespn8SFW2eeRHHO2vTx86VzX+ZmcGsw2SU6RTXmRAr8D99p5dWoVW/M\r
+       cmPD475XGk/LwuLk18cvTCtrLVrbabv+lsuU4P0hD3OfvzeZuqRN8USUEktxRqKhFnNRcSIA\r
+       GXbw6tsCAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 09 Jun 2012 19:14:58 -0000\r
+\r
+This way notmuch_message_maildir_flags_to_tags can call it.  It makes\r
+more sense for this to be just above all of the maildir\r
+synchronization code rather than mixed in the middle.\r
+---\r
+ lib/message.cc |   82 ++++++++++++++++++++++++++++----------------------------\r
+ 1 file changed, 41 insertions(+), 41 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 6787506..ed96477 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -1027,6 +1027,47 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag)\r
+     return NOTMUCH_STATUS_SUCCESS;\r
+ }\r
+ \r
++/* Is the given filename within a maildir directory?\r
++ *\r
++ * Specifically, is the final directory component of 'filename' either\r
++ * "cur" or "new". If so, return a pointer to that final directory\r
++ * component within 'filename'. If not, return NULL.\r
++ *\r
++ * A non-NULL return value is guaranteed to be a valid string pointer\r
++ * pointing to the characters "new/" or "cur/", (but not\r
++ * NUL-terminated).\r
++ */\r
++static const char *\r
++_filename_is_in_maildir (const char *filename)\r
++{\r
++    const char *slash, *dir = NULL;\r
++\r
++    /* Find the last '/' separating directory from filename. */\r
++    slash = strrchr (filename, '/');\r
++    if (slash == NULL)\r
++      return NULL;\r
++\r
++    /* Jump back 4 characters to where the previous '/' will be if the\r
++     * directory is named "cur" or "new". */\r
++    if (slash - filename < 4)\r
++      return NULL;\r
++\r
++    slash -= 4;\r
++\r
++    if (*slash != '/')\r
++      return NULL;\r
++\r
++    dir = slash + 1;\r
++\r
++    if (STRNCMP_LITERAL (dir, "cur/") == 0 ||\r
++      STRNCMP_LITERAL (dir, "new/") == 0)\r
++    {\r
++      return dir;\r
++    }\r
++\r
++    return NULL;\r
++}\r
++\r
+ notmuch_status_t\r
+ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)\r
+ {\r
+@@ -1083,47 +1124,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)\r
+     return status;\r
+ }\r
+ \r
+-/* Is the given filename within a maildir directory?\r
+- *\r
+- * Specifically, is the final directory component of 'filename' either\r
+- * "cur" or "new". If so, return a pointer to that final directory\r
+- * component within 'filename'. If not, return NULL.\r
+- *\r
+- * A non-NULL return value is guaranteed to be a valid string pointer\r
+- * pointing to the characters "new/" or "cur/", (but not\r
+- * NUL-terminated).\r
+- */\r
+-static const char *\r
+-_filename_is_in_maildir (const char *filename)\r
+-{\r
+-    const char *slash, *dir = NULL;\r
+-\r
+-    /* Find the last '/' separating directory from filename. */\r
+-    slash = strrchr (filename, '/');\r
+-    if (slash == NULL)\r
+-      return NULL;\r
+-\r
+-    /* Jump back 4 characters to where the previous '/' will be if the\r
+-     * directory is named "cur" or "new". */\r
+-    if (slash - filename < 4)\r
+-      return NULL;\r
+-\r
+-    slash -= 4;\r
+-\r
+-    if (*slash != '/')\r
+-      return NULL;\r
+-\r
+-    dir = slash + 1;\r
+-\r
+-    if (STRNCMP_LITERAL (dir, "cur/") == 0 ||\r
+-      STRNCMP_LITERAL (dir, "new/") == 0)\r
+-    {\r
+-      return dir;\r
+-    }\r
+-\r
+-    return NULL;\r
+-}\r
+-\r
+ /* From the set of tags on 'message' and the flag2tag table, compute a\r
+  * set of maildir-flag actions to be taken, (flags that should be\r
+  * either set or cleared).\r
+-- \r
+1.7.10\r
+\r