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