1 Return-Path: <gzjjgod@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 8F453431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 19:07:56 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id FOM2OT-pNV7G for <notmuch@notmuchmail.org>;
\r
11 Sat, 21 Nov 2009 19:07:56 -0800 (PST)
\r
12 Received: from mail-gx0-f221.google.com (mail-gx0-f221.google.com
\r
14 by olra.theworths.org (Postfix) with ESMTP id EC1DA431FAE
\r
15 for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 19:07:55 -0800 (PST)
\r
16 Received: by gxk21 with SMTP id 21so3933233gxk.10
\r
17 for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 19:07:55 -0800 (PST)
\r
18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
19 h=domainkey-signature:received:received:from:to:cc:subject:date
\r
20 :message-id:x-mailer;
\r
21 bh=1b4qTuTZy7cuCliveYb0PuCPZtCMfJ9ELOFeMa1N0tc=;
\r
22 b=ZRViiUXOIMHjW/QVaVoG5nm0s9DC/4j+tGZ+8UQpy6kb76BC6hbwdcqtzpn3vn0mkQ
\r
23 AL/YYm3H7lHKBxATFcrJ0degaFI3Ej13thFm+7620XgZDfhFvnIpH+JwDb2IwOywZiJS
\r
24 Va2l2MA1kSqX5WCTXoiHzktc/tGWzPWPoVbpA=
\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer;
\r
27 b=hAxsseWffc8HTQR9UXrqgEZhiYZvck6guLr/XCXgl6Ln2q5ELJtCzgYYt+5Rn6ghWU
\r
28 AV5vFsgrOpOHDLvFktR+JXGfTYh77dKzq6FcTS+om5Ew1p+LfMYqL+/EGLEK1bF28VRz
\r
29 aPCPIIljyQCXE05NphN72DBSXGwEvTQ4n6RUo=
\r
30 Received: by 10.150.38.4 with SMTP id l4mr5562259ybl.340.1258859275618;
\r
31 Sat, 21 Nov 2009 19:07:55 -0800 (PST)
\r
32 Received: from localhost.localdomain ([123.116.120.71])
\r
33 by mx.google.com with ESMTPS id 14sm1524526gxk.10.2009.11.21.19.07.51
\r
34 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
35 Sat, 21 Nov 2009 19:07:54 -0800 (PST)
\r
36 From: Jjgod Jiang <gzjjgod@gmail.com>
\r
37 To: notmuch@notmuchmail.org
\r
38 Date: Sun, 22 Nov 2009 11:07:36 +0800
\r
39 Message-Id: <1258859256-33197-1-git-send-email-gzjjgod@gmail.com>
\r
40 X-Mailer: git-send-email 1.6.4
\r
41 Subject: [notmuch] [PATCH] Mac OS X compatibility fixes
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.12
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sun, 22 Nov 2009 03:07:56 -0000
\r
56 Add missing GNU extensions strdup() and getline(). The C library
\r
57 shipped with Mac OS X does not include them (though it does support
\r
58 some GNU extensions when _GNU_SOURCE is defined), so we have to
\r
59 add these two. The getline() implementation is a modified version
\r
60 of getdelim() from GNU Libc.
\r
62 lib/xutil.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
64 2 files changed, 105 insertions(+), 0 deletions(-)
\r
66 diff --git a/lib/xutil.c b/lib/xutil.c
\r
67 index 6fa5eb0..805b236 100644
\r
70 @@ -79,6 +79,105 @@ xstrdup (const char *s)
\r
75 +/* Mac OS X don't have strndup even if _GNU_SOURCE is defined */
\r
76 +char *strndup (const char *s, size_t n)
\r
78 + size_t len = strlen (s);
\r
82 + return strdup (s);
\r
84 + ret = malloc(n + 1);
\r
85 + strncpy(ret, s, n);
\r
90 +/* getline implementation is copied from glibc. */
\r
93 +# define SIZE_MAX ((size_t) -1)
\r
96 +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
\r
99 +ssize_t getline (char **lineptr, size_t *n, FILE *fp)
\r
102 + size_t cur_len = 0;
\r
104 + if (lineptr == NULL || n == NULL || fp == NULL)
\r
110 + if (*lineptr == NULL || *n == 0)
\r
113 + *lineptr = (char *) malloc (*n);
\r
114 + if (*lineptr == NULL)
\r
132 + /* Make enough space for len+1 (for final NUL) bytes. */
\r
133 + if (cur_len + 1 >= *n)
\r
135 + size_t needed_max =
\r
136 + SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
\r
137 + size_t needed = 2 * *n + 1; /* Be generous. */
\r
138 + char *new_lineptr;
\r
140 + if (needed_max < needed)
\r
141 + needed = needed_max;
\r
142 + if (cur_len + 1 >= needed)
\r
148 + new_lineptr = (char *) realloc (*lineptr, needed);
\r
149 + if (new_lineptr == NULL)
\r
155 + *lineptr = new_lineptr;
\r
159 + (*lineptr)[cur_len] = i;
\r
165 + (*lineptr)[cur_len] = '\0';
\r
166 + result = cur_len ? (ssize_t) cur_len : result;
\r
174 xstrndup (const char *s, size_t n)
\r
176 diff --git a/lib/xutil.h b/lib/xutil.h
\r
177 index b973f7d..0b53f7c 100644
\r
181 #include <sys/types.h>
\r
185 +/* Mac OS X don't have strndup and getline even if _GNU_SOURCE is defined */
\r
186 +char *strndup (const char *s, size_t n);
\r
187 +ssize_t getline(char **lineptr, size_t *n, FILE *stream);
\r
192 xcalloc (size_t nmemb, size_t size);
\r