1 Return-Path: <jani@nikula.org>
\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 AA331429E34
\r
6 for <notmuch@notmuchmail.org>; Wed, 10 Aug 2011 03:23:46 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id EqsqxWvrYV13 for <notmuch@notmuchmail.org>;
\r
17 Wed, 10 Aug 2011 03:23:42 -0700 (PDT)
\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com
\r
19 [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id C2ECC429E33
\r
22 for <notmuch@notmuchmail.org>; Wed, 10 Aug 2011 03:23:41 -0700 (PDT)
\r
23 Received: by qyk34 with SMTP id 34so596577qyk.5
\r
24 for <notmuch@notmuchmail.org>; Wed, 10 Aug 2011 03:22:21 -0700 (PDT)
\r
25 Received: by 10.229.160.12 with SMTP id l12mr47462qcx.258.1312971741415;
\r
26 Wed, 10 Aug 2011 03:22:21 -0700 (PDT)
\r
27 Received: from localhost (nikula.org [92.243.24.172])
\r
28 by mx.google.com with ESMTPS id s14sm710886qct.30.2011.08.10.03.22.17
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Wed, 10 Aug 2011 03:22:19 -0700 (PDT)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [RFC PATCH 2/3] Compile the date/time parser into notmuch library
\r
34 Date: Wed, 10 Aug 2011 10:22:06 +0000
\r
36 <09761de1bad20ecc80888a7dd472bcd6a14d504b.1312964528.git.jani@nikula.org>
\r
37 X-Mailer: git-send-email 1.7.1
\r
38 In-Reply-To: <cover.1312964528.git.jani@nikula.org>
\r
39 References: <cover.1312964528.git.jani@nikula.org>
\r
40 In-Reply-To: <cover.1312964528.git.jani@nikula.org>
\r
41 References: <cover.1312964528.git.jani@nikula.org>
\r
42 Cc: amdragon@mit.edu
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Wed, 10 Aug 2011 10:23:47 -0000
\r
57 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
60 Makefile.local | 3 +
\r
62 lib/Makefile.local | 5 +-
\r
63 lib/config.h | 45 +++++++++++++
\r
64 lib/getdate.c | 185 +++++++++++++++++++++++++++-------------------------
\r
65 lib/getdate.h | 9 +++
\r
66 lib/getdate.y | 15 ++++-
\r
67 7 files changed, 178 insertions(+), 92 deletions(-)
\r
68 create mode 100644 lib/config.h
\r
70 diff --git a/Makefile.local b/Makefile.local
\r
71 index e3d4d03..3da9ad9 100644
\r
72 --- a/Makefile.local
\r
73 +++ b/Makefile.local
\r
74 @@ -234,6 +234,9 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
\r
75 %.o: %.c $(global_deps)
\r
76 $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
\r
79 + $(call quiet,YACC $(YFLAGS)) $(YFLAGS) $< -o $@
\r
81 .deps/%.d: %.c $(global_deps)
\r
82 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
\r
83 $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
\r
84 diff --git a/configure b/configure
\r
85 index 3999ce8..f385c79 100755
\r
88 @@ -25,9 +25,11 @@ fi
\r
89 # environment variables)
\r
93 CFLAGS=${CFLAGS:--O2}
\r
94 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
\r
95 LDFLAGS=${LDFLAGS:-}
\r
97 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
\r
99 # We don't allow the EMACS or GZIP Makefile variables inherit values
\r
100 @@ -571,6 +573,9 @@ CC = ${CC}
\r
101 # The C++ compiler to use
\r
104 +# The parser generator to use
\r
107 # Command to execute emacs from Makefiles
\r
108 EMACS = emacs --quick
\r
110 @@ -589,6 +594,9 @@ WARN_CXXFLAGS=${WARN_CXXFLAGS}
\r
111 # Flags to enable warnings when using the C compiler
\r
112 WARN_CFLAGS=${WARN_CFLAGS}
\r
114 +# Default FLAGS for parser generator (can be overridden by user such as "make YFLAGS=-y")
\r
115 +YFLAGS = ${YFLAGS}
\r
117 # The prefix to which notmuch should be installed
\r
118 # Note: If you change this value here, be sure to ensure that the
\r
119 # LIBDIR_IN_LDCONFIG value below is still set correctly.
\r
120 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
121 index fbc2f6a..a1c234f 100644
\r
122 --- a/lib/Makefile.local
\r
123 +++ b/lib/Makefile.local
\r
124 @@ -56,7 +56,10 @@ libnotmuch_c_srcs = \
\r
125 $(dir)/messages.c \
\r
130 + $(dir)/getdate.c \
\r
131 + $(dir)/c-ctype.c \
\r
134 libnotmuch_cxx_srcs = \
\r
135 $(dir)/database.cc \
\r
136 diff --git a/lib/config.h b/lib/config.h
\r
137 new file mode 100644
\r
138 index 0000000..e8bc5b7
\r
142 +/* lib/config.h. Generated from config.hin by configure. */
\r
143 +/* lib/config.hin. Generated from configure.ac by autoheader. */
\r
145 +/* Define to 1 if you have the `clock_gettime' function. */
\r
146 +#define HAVE_CLOCK_GETTIME 1
\r
148 +/* Define if you have compound literals. */
\r
149 +#define HAVE_COMPOUND_LITERALS 1
\r
151 +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
\r
153 +/* #undef HAVE_DECL_TZNAME */
\r
155 +/* Define to 1 if you have the `nanotime' function. */
\r
156 +/* #undef HAVE_NANOTIME */
\r
158 +/* Define to 1 if `tm_zone' is a member of `struct tm'. */
\r
159 +#define HAVE_STRUCT_TM_TM_ZONE 1
\r
161 +/* Define if struct tm has the tm_gmtoff member. */
\r
162 +#define HAVE_TM_GMTOFF 1
\r
164 +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
\r
165 + `HAVE_STRUCT_TM_TM_ZONE' instead. */
\r
166 +#define HAVE_TM_ZONE 1
\r
168 +/* Define to 1 if you don't have `tm_zone' but do have the external array
\r
170 +/* #undef HAVE_TZNAME */
\r
172 +/* Define to 1 if you have the `tzset' function. */
\r
173 +#define HAVE_TZSET 1
\r
176 +/* Define as a marker that can be attached to declarations that might not
\r
177 + be used. This helps to reduce warnings, such as from
\r
178 + GCC -Wunused-parameter. */
\r
179 +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
\r
180 +# define _GL_UNUSED __attribute__ ((__unused__))
\r
182 +# define _GL_UNUSED
\r
184 +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
\r
185 + is a misnomer outside of parameter lists. */
\r
186 +#define _UNUSED_PARAMETER_ _GL_UNUSED
\r
187 diff --git a/lib/getdate.c b/lib/getdate.c
\r
188 index 5b20eeb..57f33e9 100644
\r
189 --- a/lib/getdate.c
\r
190 +++ b/lib/getdate.c
\r
192 /* Copy the first part of user declarations. */
\r
194 /* Line 189 of yacc.c */
\r
195 -#line 1 "getdate.y"
\r
196 +#line 1 "lib/getdate.y"
\r
198 /* Parse a string into an internal time stamp.
\r
200 @@ -102,6 +102,8 @@
\r
201 /* FIXME: Check for arithmetic overflow in all cases, not just
\r
204 +#include "notmuch-private.h" /* For xmalloc() */
\r
206 #include <config.h>
\r
208 #include "getdate.h"
\r
209 @@ -137,9 +139,6 @@
\r
210 #include <stdlib.h>
\r
211 #include <string.h>
\r
213 -#include "xalloc.h"
\r
216 /* ISDIGIT differs from isdigit, as follows:
\r
217 - Its arg may be any int or unsigned int; it need not be an unsigned char
\r
219 @@ -344,7 +343,7 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes,
\r
222 /* Line 189 of yacc.c */
\r
223 -#line 348 "getdate.c"
\r
224 +#line 347 "lib/getdate.c"
\r
226 /* Enabling traces. */
\r
228 @@ -423,7 +422,7 @@ typedef union YYSTYPE
\r
231 /* Line 214 of yacc.c */
\r
232 -#line 285 "getdate.y"
\r
233 +#line 284 "lib/getdate.y"
\r
236 textint textintval;
\r
237 @@ -433,7 +432,7 @@ typedef union YYSTYPE
\r
240 /* Line 214 of yacc.c */
\r
241 -#line 437 "getdate.c"
\r
242 +#line 436 "lib/getdate.c"
\r
244 # define YYSTYPE_IS_TRIVIAL 1
\r
245 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
\r
246 @@ -445,7 +444,7 @@ typedef union YYSTYPE
\r
249 /* Line 264 of yacc.c */
\r
250 -#line 449 "getdate.c"
\r
251 +#line 448 "lib/getdate.c"
\r
255 @@ -759,15 +758,15 @@ static const yytype_int8 yyrhs[] =
\r
256 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
\r
257 static const yytype_uint16 yyrline[] =
\r
259 - 0, 311, 311, 312, 316, 323, 325, 329, 331, 333,
\r
260 - 335, 337, 339, 340, 341, 345, 350, 355, 362, 367,
\r
261 - 377, 382, 390, 392, 395, 397, 399, 404, 409, 414,
\r
262 - 419, 427, 432, 452, 459, 467, 475, 480, 486, 491,
\r
263 - 500, 502, 504, 509, 511, 513, 515, 517, 519, 521,
\r
264 - 523, 525, 527, 529, 531, 533, 535, 537, 539, 541,
\r
265 - 543, 545, 547, 549, 553, 555, 557, 559, 561, 563,
\r
266 - 568, 572, 572, 575, 576, 581, 582, 587, 592, 603,
\r
268 + 0, 310, 310, 311, 315, 322, 324, 328, 330, 332,
\r
269 + 334, 336, 338, 339, 340, 344, 349, 354, 361, 366,
\r
270 + 376, 381, 389, 391, 394, 396, 398, 403, 408, 413,
\r
271 + 418, 426, 431, 451, 458, 466, 474, 479, 485, 490,
\r
272 + 499, 501, 503, 508, 510, 512, 514, 516, 518, 520,
\r
273 + 522, 524, 526, 528, 530, 532, 534, 536, 538, 540,
\r
274 + 542, 544, 546, 548, 552, 554, 556, 558, 560, 562,
\r
275 + 567, 571, 571, 574, 575, 580, 581, 586, 591, 602,
\r
280 @@ -1742,7 +1741,7 @@ yyreduce:
\r
283 /* Line 1455 of yacc.c */
\r
284 -#line 317 "getdate.y"
\r
285 +#line 316 "lib/getdate.y"
\r
287 pc->seconds = (yyvsp[(2) - (2)].timespec);
\r
288 pc->timespec_seen = true;
\r
289 @@ -1752,42 +1751,42 @@ yyreduce:
\r
292 /* Line 1455 of yacc.c */
\r
293 -#line 330 "getdate.y"
\r
294 +#line 329 "lib/getdate.y"
\r
295 { pc->times_seen++; }
\r
300 /* Line 1455 of yacc.c */
\r
301 -#line 332 "getdate.y"
\r
302 +#line 331 "lib/getdate.y"
\r
303 { pc->local_zones_seen++; }
\r
308 /* Line 1455 of yacc.c */
\r
309 -#line 334 "getdate.y"
\r
310 +#line 333 "lib/getdate.y"
\r
311 { pc->zones_seen++; }
\r
316 /* Line 1455 of yacc.c */
\r
317 -#line 336 "getdate.y"
\r
318 +#line 335 "lib/getdate.y"
\r
319 { pc->dates_seen++; }
\r
324 /* Line 1455 of yacc.c */
\r
325 -#line 338 "getdate.y"
\r
326 +#line 337 "lib/getdate.y"
\r
327 { pc->days_seen++; }
\r
332 /* Line 1455 of yacc.c */
\r
333 -#line 346 "getdate.y"
\r
334 +#line 345 "lib/getdate.y"
\r
336 set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0);
\r
337 pc->meridian = (yyvsp[(2) - (2)].intval);
\r
338 @@ -1797,7 +1796,7 @@ yyreduce:
\r
341 /* Line 1455 of yacc.c */
\r
342 -#line 351 "getdate.y"
\r
343 +#line 350 "lib/getdate.y"
\r
345 set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0);
\r
346 pc->meridian = (yyvsp[(4) - (4)].intval);
\r
347 @@ -1807,7 +1806,7 @@ yyreduce:
\r
350 /* Line 1455 of yacc.c */
\r
351 -#line 356 "getdate.y"
\r
352 +#line 355 "lib/getdate.y"
\r
354 set_hhmmss (pc, (yyvsp[(1) - (5)].textintval).value, (yyvsp[(3) - (5)].textintval).value, 0, 0);
\r
355 pc->meridian = MER24;
\r
356 @@ -1819,7 +1818,7 @@ yyreduce:
\r
359 /* Line 1455 of yacc.c */
\r
360 -#line 363 "getdate.y"
\r
361 +#line 362 "lib/getdate.y"
\r
363 set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec);
\r
364 pc->meridian = (yyvsp[(6) - (6)].intval);
\r
365 @@ -1829,7 +1828,7 @@ yyreduce:
\r
368 /* Line 1455 of yacc.c */
\r
369 -#line 368 "getdate.y"
\r
370 +#line 367 "lib/getdate.y"
\r
372 set_hhmmss (pc, (yyvsp[(1) - (7)].textintval).value, (yyvsp[(3) - (7)].textintval).value, (yyvsp[(5) - (7)].timespec).tv_sec, (yyvsp[(5) - (7)].timespec).tv_nsec);
\r
373 pc->meridian = MER24;
\r
374 @@ -1841,7 +1840,7 @@ yyreduce:
\r
377 /* Line 1455 of yacc.c */
\r
378 -#line 378 "getdate.y"
\r
379 +#line 377 "lib/getdate.y"
\r
381 pc->local_isdst = (yyvsp[(1) - (1)].intval);
\r
382 pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval));
\r
383 @@ -1851,7 +1850,7 @@ yyreduce:
\r
386 /* Line 1455 of yacc.c */
\r
387 -#line 383 "getdate.y"
\r
388 +#line 382 "lib/getdate.y"
\r
390 pc->local_isdst = 1;
\r
391 pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1;
\r
392 @@ -1861,14 +1860,14 @@ yyreduce:
\r
395 /* Line 1455 of yacc.c */
\r
396 -#line 391 "getdate.y"
\r
397 +#line 390 "lib/getdate.y"
\r
398 { pc->time_zone = (yyvsp[(1) - (1)].intval); }
\r
403 /* Line 1455 of yacc.c */
\r
404 -#line 393 "getdate.y"
\r
405 +#line 392 "lib/getdate.y"
\r
406 { pc->time_zone = (yyvsp[(1) - (2)].intval);
\r
407 apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); }
\r
409 @@ -1876,28 +1875,28 @@ yyreduce:
\r
412 /* Line 1455 of yacc.c */
\r
413 -#line 396 "getdate.y"
\r
414 +#line 395 "lib/getdate.y"
\r
415 { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); }
\r
420 /* Line 1455 of yacc.c */
\r
421 -#line 398 "getdate.y"
\r
422 +#line 397 "lib/getdate.y"
\r
423 { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; }
\r
428 /* Line 1455 of yacc.c */
\r
429 -#line 400 "getdate.y"
\r
430 +#line 399 "lib/getdate.y"
\r
431 { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; }
\r
436 /* Line 1455 of yacc.c */
\r
437 -#line 405 "getdate.y"
\r
438 +#line 404 "lib/getdate.y"
\r
440 pc->day_ordinal = 0;
\r
441 pc->day_number = (yyvsp[(1) - (1)].intval);
\r
442 @@ -1907,7 +1906,7 @@ yyreduce:
\r
445 /* Line 1455 of yacc.c */
\r
446 -#line 410 "getdate.y"
\r
447 +#line 409 "lib/getdate.y"
\r
449 pc->day_ordinal = 0;
\r
450 pc->day_number = (yyvsp[(1) - (2)].intval);
\r
451 @@ -1917,7 +1916,7 @@ yyreduce:
\r
454 /* Line 1455 of yacc.c */
\r
455 -#line 415 "getdate.y"
\r
456 +#line 414 "lib/getdate.y"
\r
458 pc->day_ordinal = (yyvsp[(1) - (2)].intval);
\r
459 pc->day_number = (yyvsp[(2) - (2)].intval);
\r
460 @@ -1927,7 +1926,7 @@ yyreduce:
\r
463 /* Line 1455 of yacc.c */
\r
464 -#line 420 "getdate.y"
\r
465 +#line 419 "lib/getdate.y"
\r
467 pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value;
\r
468 pc->day_number = (yyvsp[(2) - (2)].intval);
\r
469 @@ -1937,7 +1936,7 @@ yyreduce:
\r
472 /* Line 1455 of yacc.c */
\r
473 -#line 428 "getdate.y"
\r
474 +#line 427 "lib/getdate.y"
\r
476 pc->month = (yyvsp[(1) - (3)].textintval).value;
\r
477 pc->day = (yyvsp[(3) - (3)].textintval).value;
\r
478 @@ -1947,7 +1946,7 @@ yyreduce:
\r
481 /* Line 1455 of yacc.c */
\r
482 -#line 433 "getdate.y"
\r
483 +#line 432 "lib/getdate.y"
\r
485 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
\r
486 otherwise as MM/DD/YY.
\r
487 @@ -1972,7 +1971,7 @@ yyreduce:
\r
490 /* Line 1455 of yacc.c */
\r
491 -#line 453 "getdate.y"
\r
492 +#line 452 "lib/getdate.y"
\r
494 /* ISO 8601 format. YYYY-MM-DD. */
\r
495 pc->year = (yyvsp[(1) - (3)].textintval);
\r
496 @@ -1984,7 +1983,7 @@ yyreduce:
\r
499 /* Line 1455 of yacc.c */
\r
500 -#line 460 "getdate.y"
\r
501 +#line 459 "lib/getdate.y"
\r
503 /* e.g. 17-JUN-1992. */
\r
504 pc->day = (yyvsp[(1) - (3)].textintval).value;
\r
505 @@ -1997,7 +1996,7 @@ yyreduce:
\r
508 /* Line 1455 of yacc.c */
\r
509 -#line 468 "getdate.y"
\r
510 +#line 467 "lib/getdate.y"
\r
512 /* e.g. JUN-17-1992. */
\r
513 pc->month = (yyvsp[(1) - (3)].intval);
\r
514 @@ -2010,7 +2009,7 @@ yyreduce:
\r
517 /* Line 1455 of yacc.c */
\r
518 -#line 476 "getdate.y"
\r
519 +#line 475 "lib/getdate.y"
\r
521 pc->month = (yyvsp[(1) - (2)].intval);
\r
522 pc->day = (yyvsp[(2) - (2)].textintval).value;
\r
523 @@ -2020,7 +2019,7 @@ yyreduce:
\r
526 /* Line 1455 of yacc.c */
\r
527 -#line 481 "getdate.y"
\r
528 +#line 480 "lib/getdate.y"
\r
530 pc->month = (yyvsp[(1) - (4)].intval);
\r
531 pc->day = (yyvsp[(2) - (4)].textintval).value;
\r
532 @@ -2031,7 +2030,7 @@ yyreduce:
\r
535 /* Line 1455 of yacc.c */
\r
536 -#line 487 "getdate.y"
\r
537 +#line 486 "lib/getdate.y"
\r
539 pc->day = (yyvsp[(1) - (2)].textintval).value;
\r
540 pc->month = (yyvsp[(2) - (2)].intval);
\r
541 @@ -2041,7 +2040,7 @@ yyreduce:
\r
544 /* Line 1455 of yacc.c */
\r
545 -#line 492 "getdate.y"
\r
546 +#line 491 "lib/getdate.y"
\r
548 pc->day = (yyvsp[(1) - (3)].textintval).value;
\r
549 pc->month = (yyvsp[(2) - (3)].intval);
\r
550 @@ -2052,238 +2051,238 @@ yyreduce:
\r
553 /* Line 1455 of yacc.c */
\r
554 -#line 501 "getdate.y"
\r
555 +#line 500 "lib/getdate.y"
\r
556 { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), -1); }
\r
561 /* Line 1455 of yacc.c */
\r
562 -#line 503 "getdate.y"
\r
563 +#line 502 "lib/getdate.y"
\r
564 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
\r
569 /* Line 1455 of yacc.c */
\r
570 -#line 505 "getdate.y"
\r
571 +#line 504 "lib/getdate.y"
\r
572 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
\r
577 /* Line 1455 of yacc.c */
\r
578 -#line 510 "getdate.y"
\r
579 +#line 509 "lib/getdate.y"
\r
580 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); }
\r
585 /* Line 1455 of yacc.c */
\r
586 -#line 512 "getdate.y"
\r
587 +#line 511 "lib/getdate.y"
\r
588 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
\r
593 /* Line 1455 of yacc.c */
\r
594 -#line 514 "getdate.y"
\r
595 +#line 513 "lib/getdate.y"
\r
596 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; }
\r
601 /* Line 1455 of yacc.c */
\r
602 -#line 516 "getdate.y"
\r
603 +#line 515 "lib/getdate.y"
\r
604 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); }
\r
609 /* Line 1455 of yacc.c */
\r
610 -#line 518 "getdate.y"
\r
611 +#line 517 "lib/getdate.y"
\r
612 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
\r
617 /* Line 1455 of yacc.c */
\r
618 -#line 520 "getdate.y"
\r
619 +#line 519 "lib/getdate.y"
\r
620 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; }
\r
625 /* Line 1455 of yacc.c */
\r
626 -#line 522 "getdate.y"
\r
627 +#line 521 "lib/getdate.y"
\r
628 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); }
\r
633 /* Line 1455 of yacc.c */
\r
634 -#line 524 "getdate.y"
\r
635 +#line 523 "lib/getdate.y"
\r
636 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
\r
641 /* Line 1455 of yacc.c */
\r
642 -#line 526 "getdate.y"
\r
643 +#line 525 "lib/getdate.y"
\r
644 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
\r
649 /* Line 1455 of yacc.c */
\r
650 -#line 528 "getdate.y"
\r
651 +#line 527 "lib/getdate.y"
\r
652 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); }
\r
657 /* Line 1455 of yacc.c */
\r
658 -#line 530 "getdate.y"
\r
659 +#line 529 "lib/getdate.y"
\r
660 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
\r
665 /* Line 1455 of yacc.c */
\r
666 -#line 532 "getdate.y"
\r
667 +#line 531 "lib/getdate.y"
\r
668 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; }
\r
673 /* Line 1455 of yacc.c */
\r
674 -#line 534 "getdate.y"
\r
675 +#line 533 "lib/getdate.y"
\r
676 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); }
\r
681 /* Line 1455 of yacc.c */
\r
682 -#line 536 "getdate.y"
\r
683 +#line 535 "lib/getdate.y"
\r
684 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
\r
689 /* Line 1455 of yacc.c */
\r
690 -#line 538 "getdate.y"
\r
691 +#line 537 "lib/getdate.y"
\r
692 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; }
\r
697 /* Line 1455 of yacc.c */
\r
698 -#line 540 "getdate.y"
\r
699 +#line 539 "lib/getdate.y"
\r
700 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); }
\r
705 /* Line 1455 of yacc.c */
\r
706 -#line 542 "getdate.y"
\r
707 +#line 541 "lib/getdate.y"
\r
708 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
\r
713 /* Line 1455 of yacc.c */
\r
714 -#line 544 "getdate.y"
\r
715 +#line 543 "lib/getdate.y"
\r
716 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
\r
721 /* Line 1455 of yacc.c */
\r
722 -#line 546 "getdate.y"
\r
723 +#line 545 "lib/getdate.y"
\r
724 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
\r
729 /* Line 1455 of yacc.c */
\r
730 -#line 548 "getdate.y"
\r
731 +#line 547 "lib/getdate.y"
\r
732 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; }
\r
737 /* Line 1455 of yacc.c */
\r
738 -#line 554 "getdate.y"
\r
739 +#line 553 "lib/getdate.y"
\r
740 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
\r
745 /* Line 1455 of yacc.c */
\r
746 -#line 556 "getdate.y"
\r
747 +#line 555 "lib/getdate.y"
\r
748 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
\r
753 /* Line 1455 of yacc.c */
\r
754 -#line 558 "getdate.y"
\r
755 +#line 557 "lib/getdate.y"
\r
756 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
\r
761 /* Line 1455 of yacc.c */
\r
762 -#line 560 "getdate.y"
\r
763 +#line 559 "lib/getdate.y"
\r
764 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
\r
769 /* Line 1455 of yacc.c */
\r
770 -#line 562 "getdate.y"
\r
771 +#line 561 "lib/getdate.y"
\r
772 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
\r
777 /* Line 1455 of yacc.c */
\r
778 -#line 564 "getdate.y"
\r
779 +#line 563 "lib/getdate.y"
\r
780 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
\r
785 /* Line 1455 of yacc.c */
\r
786 -#line 569 "getdate.y"
\r
787 +#line 568 "lib/getdate.y"
\r
788 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
\r
793 /* Line 1455 of yacc.c */
\r
794 -#line 577 "getdate.y"
\r
795 +#line 576 "lib/getdate.y"
\r
796 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
\r
801 /* Line 1455 of yacc.c */
\r
802 -#line 583 "getdate.y"
\r
803 +#line 582 "lib/getdate.y"
\r
804 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
\r
809 /* Line 1455 of yacc.c */
\r
810 -#line 588 "getdate.y"
\r
811 +#line 587 "lib/getdate.y"
\r
812 { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); }
\r
817 /* Line 1455 of yacc.c */
\r
818 -#line 593 "getdate.y"
\r
819 +#line 592 "lib/getdate.y"
\r
821 /* Hybrid all-digit and relative offset, so that we accept e.g.,
\r
822 "YYYYMMDD +N days" as well as "YYYYMMDD N days". */
\r
823 @@ -2295,35 +2294,35 @@ yyreduce:
\r
826 /* Line 1455 of yacc.c */
\r
827 -#line 603 "getdate.y"
\r
828 +#line 602 "lib/getdate.y"
\r
829 { (yyval.intval) = -1; }
\r
834 /* Line 1455 of yacc.c */
\r
835 -#line 605 "getdate.y"
\r
836 +#line 604 "lib/getdate.y"
\r
837 { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; }
\r
842 /* Line 1455 of yacc.c */
\r
843 -#line 610 "getdate.y"
\r
844 +#line 609 "lib/getdate.y"
\r
845 { (yyval.intval) = MER24; }
\r
850 /* Line 1455 of yacc.c */
\r
851 -#line 612 "getdate.y"
\r
852 +#line 611 "lib/getdate.y"
\r
853 { (yyval.intval) = (yyvsp[(1) - (1)].intval); }
\r
858 /* Line 1455 of yacc.c */
\r
859 -#line 2327 "getdate.c"
\r
860 +#line 2326 "lib/getdate.c"
\r
863 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
\r
864 @@ -2535,7 +2534,7 @@ yyreturn:
\r
867 /* Line 1675 of yacc.c */
\r
868 -#line 615 "getdate.y"
\r
869 +#line 614 "lib/getdate.y"
\r
872 static table const meridian_table[] =
\r
873 @@ -3104,6 +3103,16 @@ mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t)
\r
874 Use heap allocation if TZ's length exceeds this. */
\r
875 enum { TZBUFSIZE = 100 };
\r
877 +/* Clone an object P of size S, with error checking. There's no need
\r
878 + for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
\r
879 + need for an arithmetic overflow check. */
\r
882 +xmemdup (void const *p, size_t s)
\r
884 + return memcpy (xmalloc (s), p, s);
\r
887 /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
\r
890 diff --git a/lib/getdate.h b/lib/getdate.h
\r
891 index 22cc2c0..ad1283c 100644
\r
892 --- a/lib/getdate.h
\r
893 +++ b/lib/getdate.h
\r
895 #include <stdbool.h>
\r
898 +#ifdef __cplusplus
\r
902 bool get_date (struct timespec *, char const *, struct timespec const *);
\r
904 +#ifdef __cplusplus
\r
908 diff --git a/lib/getdate.y b/lib/getdate.y
\r
909 index 445865b..d423f5b 100644
\r
910 --- a/lib/getdate.y
\r
911 +++ b/lib/getdate.y
\r
913 /* FIXME: Check for arithmetic overflow in all cases, not just
\r
916 +#include "notmuch-private.h" /* For xmalloc() */
\r
918 #include <config.h>
\r
920 #include "getdate.h"
\r
922 #include <stdlib.h>
\r
923 #include <string.h>
\r
925 -#include "xalloc.h"
\r
928 /* ISDIGIT differs from isdigit, as follows:
\r
929 - Its arg may be any int or unsigned int; it need not be an unsigned char
\r
931 @@ -1180,6 +1179,16 @@ mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t)
\r
932 Use heap allocation if TZ's length exceeds this. */
\r
933 enum { TZBUFSIZE = 100 };
\r
935 +/* Clone an object P of size S, with error checking. There's no need
\r
936 + for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
\r
937 + need for an arithmetic overflow check. */
\r
940 +xmemdup (void const *p, size_t s)
\r
942 + return memcpy (xmalloc (s), p, s);
\r
945 /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
\r