[PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.
Hi C?dric, thanks for the patch. I checked it and it didn't break anything for me. But it made me thinking why zsh completion does not work for a long time. Carl, please apply the patch below. -Michal >From 72f6488b39aec318264caf26d2b163f73d3cf694 Mon Sep 17 00:00:00 2001 From: Michal SojkaDate: Sun, 23 Jan 2011 21:57:07 +0100 Subject: [PATCH] Fix installation of zsh completion --- completion/Makefile.local |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/completion/Makefile.local b/completion/Makefile.local index 6a6012d..1624bd7 100644 --- a/completion/Makefile.local +++ b/completion/Makefile.local @@ -15,4 +15,4 @@ install-$(dir): mkdir -p $(DESTDIR)$(bash_completion_dir) install -m0644 $(bash_script) $(DESTDIR)$(bash_completion_dir)/notmuch mkdir -p $(DESTDIR)$(zsh_completion_dir) - install -m0644 $(zsh_script) $(DESTDIR)$(zsh_completion_dir)/notmuch + install -m0644 $(zsh_script) $(DESTDIR)$(zsh_completion_dir)/_notmuch -- 1.7.2.3
[PATCH 3.5/8] Query parser tests for wildcard queries.
Oops, yes. I'm not sure why you had to initialize qparser_desc (are you sure it doesn't compile if you omit that?), but a change in the later patch 5/8 requires the extra argument to _notmuch_qparser_add_db_prefix. I've got another patch with tests for patch 5/8 that adds and tests the argument that I'll send out shortly (along with tests for the remaining patches). Glad to see you're taking advantage of the query parser! On Sat, Jan 22, 2011 at 11:47 AM, Michal Sojka wrote: > On Fri, 21 Jan 2011, Austin Clements wrote: > > Since wildcard queries require a database, qparser-test can now open a > > database. > > Hi Austin, > > I had to apply the following changes in order to be able to compile the > tests (make test). > > I'm going to test the parser in my daily use, but so far it looks really > nice. I especially enjoy the before and after searches. Thanks. > > -Michal > > diff --git a/test/qparser-test.cc b/test/qparser-test.cc > index 18318aa..5be6220 100644 > --- a/test/qparser-test.cc > +++ b/test/qparser-test.cc > @@ -61,7 +61,7 @@ test_one (void *ctx, const char *query_str) > void *local = talloc_new (ctx); > Xapian::Query q; > _notmuch_token_t *toks, *root; > -char *error, *qparser_desc, *xqparser_desc; > +char *error, *qparser_desc = NULL, *xqparser_desc; > > toks = _notmuch_qparser_lex (local, qparser, query_str); > printf("[lex]%s\n", _notmuch_token_show_list (local, toks)); > @@ -100,9 +100,9 @@ static _notmuch_qparser_t * > create_qparser (void *ctx) > { > _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, notmuch); > -_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE); > -_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE); > -_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE); > +_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE, FALSE); > +_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE, FALSE); > +_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE, FALSE); > return qparser; > } > > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch > -- next part -- An HTML attachment was scrubbed... URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110123/e2d97574/attachment.html>
[PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.
add --bashcompletiondir and --zshcompletiondir (like --emacslispdir) to choose installation dir for bash/zsh completion files Make some features optional: --without-emacs / --with-emacs=no do not install lisp file --without-bash-completion / --with-bash-completion=no do not install bash files --without-zsh-completion / --with-zsh-completion=no do not install zsh files By default, everything is enabled. You can reenable something with --with-feature=yes --- Makefile.local|2 + completion/Makefile.local |4 +++ configure | 53 +++- emacs/Makefile.local |2 + 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Makefile.local b/Makefile.local index f9b5a9b..3c6151c 100644 --- a/Makefile.local +++ b/Makefile.local @@ -277,6 +277,7 @@ ifeq ($(MAKECMDGOALS), install) @echo "through the process of configuring notmuch and creating" @echo "a database of existing email messages. The \"notmuch\"" @echo "command will also offer some sample search commands." +ifeq ($(WITH_EMACS), 1) @echo "" @echo "Beyond the command-line interface, notmuch also offers" @echo "a full-featured interface for reading and writing mail" @@ -288,6 +289,7 @@ ifeq ($(MAKECMDGOALS), install) @echo "And then run emacs as \"emacs -f notmuch\" or invoke" @echo "the command \"M-x notmuch\" from within emacs." endif +endif .PHONY: install-desktop install-desktop: diff --git a/completion/Makefile.local b/completion/Makefile.local index 6a6012d..0b74c06 100644 --- a/completion/Makefile.local +++ b/completion/Makefile.local @@ -12,7 +12,11 @@ install: install-$(dir) install-$(dir): @echo $@ +ifeq ($(WITH_BASH),1) mkdir -p $(DESTDIR)$(bash_completion_dir) install -m0644 $(bash_script) $(DESTDIR)$(bash_completion_dir)/notmuch +endif +ifeq ($(WITH_ZSH),1) mkdir -p $(DESTDIR)$(zsh_completion_dir) install -m0644 $(zsh_script) $(DESTDIR)$(zsh_completion_dir)/notmuch +endif diff --git a/configure b/configure index c58dd0f..c7ec414 100755 --- a/configure +++ b/configure @@ -28,6 +28,9 @@ XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config} # options. PREFIX=/usr/local LIBDIR= +WITH_EMACS=1 +WITH_BASH=1 +WITH_ZSH=1 usage () { @@ -81,6 +84,15 @@ Fine tuning of some installation directories is available: --mandir=DIRInstall man pages to DIR [PREFIX/share/man] --sysconfdir=DIRRead-only single-machine data [PREFIX/etc] --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp] + --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d] + --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix] + +Some features can be disabled (--with-feature=no is equivalent to +--without-feature) : + + --without-emacs Do not install lisp file + --without-bash-completion Do not install bash completions files + --without-zsh-completionDo not install zsh completions files Additional options are accepted for compatibility with other configure-script calling conventions, but don't do anything yet: @@ -114,6 +126,34 @@ for option; do SYSCONFDIR="${option#*=}" elif [ "${option%%=*}" = '--emacslispdir' ] ; then EMACSLISPDIR="${option#*=}" +elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then + BASHCOMPLETIONDIR="${option#*=}" +elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then + ZSHCOMLETIONDIR="${option#*=}" +elif [ "${option%%=*}" = '--with-emacs' ]; then + if [ "${option#*=}" = 'no' ]; then + WITH_EMACS=0 + else + WITH_EMACS=1 + fi +elif [ "${option}" = '--without-emacs' ] ; then + WITH_EMACS=0 +elif [ "${option%%=*}" = '--with-bash-completion' ]; then + if [ "${option#*=}" = 'no' ]; then + WITH_BASH=0 + else + WITH_BASH=1 + fi +elif [ "${option}" = '--without-bash-completion' ] ; then + WITH_BASH=0 +elif [ "${option%%=*}" = '--with-zsh-completion' ]; then + if [ "${option#*=}" = 'no' ]; then + WITH_ZSH=0 + else + WITH_ZSH=1 + fi +elif [ "${option}" = '--without-zsh-completion' ] ; then + WITH_ZSH=0 elif [ "${option%%=*}" = '--build' ] ; then build_option="${option#*=}" case ${build_option} in @@ -527,10 +567,10 @@ HAVE_EMACS = ${have_emacs} desktop_dir = \$(prefix)/share/applications # The directory to which bash completions files should be installed -bash_completion_dir = \$(sysconfdir)/bash_completion.d +bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d} # The directory to which zsh completions files should be installed -zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix +zsh_completion_dir =
[PATCH 4/4] Add first date parser tests
Some tests are currently broken for several reasons: 1) in the context of e-mails, we implicitly mean past dates e.g. Monday means the last Monday and not the next one, as it is currently implemented by the parser. 2) yesterday means "now -24 hours" and I think that should be "midnight -24 hours". --- lib/getdate.c | 52 +++--- lib/getdate.y | 52 +++--- test/Makefile.local |9 ++- test/basic |2 +- test/date-parser| 37 test/notmuch-test |2 +- 6 files changed, 126 insertions(+), 28 deletions(-) create mode 100755 test/date-parser diff --git a/lib/getdate.c b/lib/getdate.c index 57f33e9..685c51f 100644 --- a/lib/getdate.c +++ b/lib/getdate.c @@ -3471,19 +3471,50 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) #if TEST int +_internal_error (const char *format, ...) +{ +va_list va_args; + +va_start (va_args, format); + +fprintf (stderr, "Internal error: "); +vfprintf (stderr, format, va_args); + +exit (1); + +return 1; +} + +int main (int ac, char **av) { char buff[BUFSIZ]; - printf ("Enter date, or blank line to exit.\n\t> "); - fflush (stdout); - - buff[BUFSIZ - 1] = '\0'; - while (fgets (buff, BUFSIZ - 1, stdin) && buff[0]) + buff[BUFSIZ - 2] = '\0'; + while (fgets (buff, BUFSIZ - 2, stdin) && buff[0]) { - struct timespec d; + struct timespec d, ref = { 0, 0 }; struct tm const *tm; - if (! get_date (, buff, NULL)) + char *arrow; + arrow = strstr (buff, "->"); + if (arrow) + *arrow = 0; + else { + arrow = buff + strlen (buff); + while (arrow > buff && *(arrow-1) == '\n') + arrow--; + *arrow-- = 0; + if (arrow >= buff && ( *arrow != ' ' || *arrow != '\t' )) + strcat (buff, " "); + } + if (ac > 1) { + struct tm tm_arg; + memset (_arg, 0, sizeof (tm_arg)); + strptime (av[1], "%Y-%m-%d %H:%M", _arg); + ref.tv_sec = mktime (_arg); + } else + clock_gettime (CLOCK_REALTIME, ); + if (! get_date (, buff, )) printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (_sec))) { @@ -3492,13 +3523,10 @@ main (int ac, char **av) } else { - int ns = d.tv_nsec; - printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", + printf ("%s-> %04ld-%02d-%02d %02d:%02d:%02d\n", buff, tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, ns); + tm->tm_hour, tm->tm_min, tm->tm_sec); } - printf ("\t> "); - fflush (stdout); } return 0; } diff --git a/lib/getdate.y b/lib/getdate.y index d423f5b..657416e 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -1547,19 +1547,50 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) #if TEST int +_internal_error (const char *format, ...) +{ +va_list va_args; + +va_start (va_args, format); + +fprintf (stderr, "Internal error: "); +vfprintf (stderr, format, va_args); + +exit (1); + +return 1; +} + +int main (int ac, char **av) { char buff[BUFSIZ]; - printf ("Enter date, or blank line to exit.\n\t> "); - fflush (stdout); - - buff[BUFSIZ - 1] = '\0'; - while (fgets (buff, BUFSIZ - 1, stdin) && buff[0]) + buff[BUFSIZ - 2] = '\0'; + while (fgets (buff, BUFSIZ - 2, stdin) && buff[0]) { - struct timespec d; + struct timespec d, ref = { 0, 0 }; struct tm const *tm; - if (! get_date (, buff, NULL)) + char *arrow; + arrow = strstr (buff, "->"); + if (arrow) + *arrow = 0; + else { + arrow = buff + strlen (buff); + while (arrow > buff && *(arrow-1) == '\n') + arrow--; + *arrow-- = 0; + if (arrow >= buff && ( *arrow != ' ' || *arrow != '\t' )) + strcat (buff, " "); + } + if (ac > 1) { + struct tm tm_arg; + memset (_arg, 0, sizeof (tm_arg)); + strptime (av[1], "%Y-%m-%d %H:%M", _arg); + ref.tv_sec = mktime (_arg); + } else + clock_gettime (CLOCK_REALTIME, ); + if (! get_date (, buff, )) printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (_sec))) { @@ -1568,13 +1599,10 @@ main (int ac, char **av) } else { - int ns = d.tv_nsec; - printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", + printf ("%s-> %04ld-%02d-%02d %02d:%02d:%02d\n", buff, tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, ns); + tm->tm_hour, tm->tm_min, tm->tm_sec); } - printf ("\t> "); - fflush
[PATCH 3/4] Use the time/date parser for after: and before: prefixes
This allows to have queries like: after:10am after:"10:00 GMT" after:"now -2 hours" after:"2 hours ago" after:yesterday after:"last month" --- lib/database.cc | 14 -- 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index cb02220..615b408 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -19,6 +19,7 @@ */ #include "database-private.h" +#include "getdate.h" #include @@ -643,16 +644,17 @@ transform_date (_notmuch_token_t *root, void *opaque) int before = (strcmp (root->text, "before") == 0); if (after || before) { _notmuch_token_t *tok = root->left; - struct tm t; + bool ok; + struct timespec result, now; time_t time_value; - char *end, *serialzed; + char *serialzed; /* Parse the date */ assert (tok && tok->type == TOK_LIT); - memset(, 0, sizeof(t)); - end = strptime (tok->text, "%Y/%m/%d", ); - time_value = mktime(); - if (!end || *end || time_value == -1) { + clock_gettime (CLOCK_REALTIME, ); + ok = get_date (, tok->text, ); + time_value = result.tv_sec; + if (!ok || time_value == -1) { char *msg = talloc_asprintf (root, "Invalid date \"%s\"", tok->text); return _notmuch_token_create_term (root, TOK_ERROR, msg); -- 1.7.2.3
[PATCH 2/4] Compile the date/time parser into notmuch library
--- Makefile.local |3 + configure |8 ++ lib/Makefile.local |5 +- lib/config.h | 45 + lib/getdate.c | 185 +++- lib/getdate.h |9 +++ lib/getdate.y | 15 - 7 files changed, 178 insertions(+), 92 deletions(-) create mode 100644 lib/config.h diff --git a/Makefile.local b/Makefile.local index f9b5a9b..ce35c59 100644 --- a/Makefile.local +++ b/Makefile.local @@ -205,6 +205,9 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) %.o: %.c $(global_deps) $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ +%.c: %.y + $(call quiet,YACC $(YFLAGS)) $(YFLAGS) $< -o $@ + .deps/%.d: %.c $(global_deps) @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@. 2>/dev/null ; \ diff --git a/configure b/configure index c58dd0f..6d9fda4 100755 --- a/configure +++ b/configure @@ -12,9 +12,11 @@ tab="$(printf '\t')" # environemnt variables) CC=${CC:-gcc} CXX=${CXX:-g++} +YACC=${YACC:-yacc} CFLAGS=${CFLAGS:--O2} CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)} LDFLAGS=${LDFLAGS:-} +YFLAGS=${YFLAGS} XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config} # We don't allow the EMACS or GZIP Makefile variables inherit values @@ -477,6 +479,9 @@ CC = ${CC} # The C++ compiler to use CXX = ${CXX} +# The parser generator to use +YACC = ${YACC} + # Command to execute emacs from Makefiles EMACS = emacs --quick @@ -495,6 +500,9 @@ WARN_CXXFLAGS=${WARN_CXXFLAGS} # Flags to enable warnings when using the C compiler WARN_CFLAGS=${WARN_CFLAGS} +# Default FLAGS for parser generator (can be overridden by user such as "make YFLAGS=-y") +YFLAGS = ${YFLAGS} + # The prefix to which notmuch should be installed # Note: If you change this value here, be sure to ensure that the # LIBDIR_IN_LDCONFIG value below is still set correctly. diff --git a/lib/Makefile.local b/lib/Makefile.local index 37d3735..89b5bb7 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -56,7 +56,10 @@ libnotmuch_c_srcs = \ $(dir)/messages.c \ $(dir)/sha1.c \ $(dir)/tags.c \ - $(dir)/xutil.c + $(dir)/xutil.c \ + $(dir)/getdate.c\ + $(dir)/c-ctype.c\ + $(dir)/gettime.c libnotmuch_cxx_srcs = \ $(dir)/database.cc \ diff --git a/lib/config.h b/lib/config.h new file mode 100644 index 000..e8bc5b7 --- /dev/null +++ b/lib/config.h @@ -0,0 +1,45 @@ +/* lib/config.h. Generated from config.hin by configure. */ +/* lib/config.hin. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if you have compound literals. */ +#define HAVE_COMPOUND_LITERALS 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the `nanotime' function. */ +/* #undef HAVE_NANOTIME */ + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define if struct tm has the tm_gmtoff member. */ +#define HAVE_TM_GMTOFF 1 + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 + + +/* Define as a marker that can be attached to declarations that might not +be used. This helps to reduce warnings, such as from +GCC -Wunused-parameter. */ +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_UNUSED +#endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED diff --git a/lib/getdate.c b/lib/getdate.c index 5b20eeb..57f33e9 100644 --- a/lib/getdate.c +++ b/lib/getdate.c @@ -68,7 +68,7 @@ /* Copy the first part of user declarations. */ /* Line 189 of yacc.c */ -#line 1 "getdate.y" +#line 1 "lib/getdate.y" /* Parse a string into an internal time stamp. @@ -102,6 +102,8 @@ /* FIXME: Check for arithmetic overflow in all cases, not just some of them. */ +#include "notmuch-private.h" /* For xmalloc() */ + #include #include "getdate.h" @@ -137,9 +139,6 @@ #include #include -#include "xalloc.h" - - /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. @@ -344,7 +343,7 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, /* Line 189 of yacc.c */ -#line 348 "getdate.c" +#line 347 "lib/getdate.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -423,7 +422,7 @@ typedef union
[PATCH 1/4] Import date/time parser from GNU coreutils
This function have quite a lot dependencies. We may reduce them later it it is a problem. --- lib/c-ctype.c | 398 +++ lib/c-ctype.h | 297 + lib/getdate.c | 3497 lib/getdate.h | 22 + lib/getdate.y | 1572 + lib/gettime.c | 48 + lib/intprops.h | 83 ++ lib/timespec.h | 39 + lib/verify.h | 140 +++ 9 files changed, 6096 insertions(+), 0 deletions(-) create mode 100644 lib/c-ctype.c create mode 100644 lib/c-ctype.h create mode 100644 lib/getdate.c create mode 100644 lib/getdate.h create mode 100644 lib/getdate.y create mode 100644 lib/gettime.c create mode 100644 lib/gettime.h create mode 100644 lib/intprops.h create mode 100644 lib/timespec.h create mode 100644 lib/verify.h diff --git a/lib/c-ctype.c b/lib/c-ctype.c new file mode 100644 index 000..48baa72 --- /dev/null +++ b/lib/c-ctype.c @@ -0,0 +1,398 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Character handling in C locale. + + Copyright 2000-2003, 2006, 2009-2010 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include + +/* Specification. */ +#define NO_C_CTYPE_MACROS +#include "c-ctype.h" + +/* The function isascii is not locale dependent. Its use in EBCDIC is + questionable. */ +bool +c_isascii (int c) +{ + return (c >= 0x00 && c <= 0x7f); +} + +bool +c_isalnum (int c) +{ +#if C_CTYPE_CONSECUTIVE_DIGITS \ +&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII + return ((c >= '0' && c <= '9') + || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); +#else + return ((c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z')); +#endif +#else + switch (c) +{ +case '0': case '1': case '2': case '3': case '4': case '5': +case '6': case '7': case '8': case '9': +case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': +case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': +case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': +case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': +case 'Y': case 'Z': +case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': +case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': +case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': +case 's': case 't': case 'u': case 'v': case 'w': case 'x': +case 'y': case 'z': + return 1; +default: + return 0; +} +#endif +} + +bool +c_isalpha (int c) +{ +#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII + return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); +#else + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +#endif +#else + switch (c) +{ +case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': +case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': +case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': +case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': +case 'Y': case 'Z': +case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': +case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': +case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': +case 's': case 't': case 'u': case 'v': case 'w': case 'x': +case 'y': case 'z': + return 1; +default: + return 0; +} +#endif +} + +bool +c_isblank (int c) +{ + return (c == ' ' || c == '\t'); +} + +bool +c_iscntrl (int c) +{ +#if C_CTYPE_ASCII + return ((c & ~0x1f) == 0 || c == 0x7f); +#else + switch (c) +{ +case ' ': case '!': case '"': case '#': case '$': case '%': +case '&': case '\'': case '(': case ')': case '*': case '+': +case ',': case '-': case '.': case '/': +case '0': case '1': case '2': case '3': case '4': case '5': +case '6': case '7': case '8': case '9': +case ':': case ';': case '<': case '=': case '>': case '?': +case '@': +case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': +case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': +case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': +case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': +case 'Y': case 'Z': +
[PATCH 0/4] Versatile date/time parser
Hi all, the following patch series brings into notmuch date/time parser stolen from GNU coreutils. It can be applied on top of custom query parser patches from Austin Clements. This is RFC and it not meant for merging. With these patches you can specify the date/time in many ways such as: after:"last monday", after:"2 hours ago", etc. There are some problems, though. 1) The parser is meant for parsing time instant specifications, which not convenient for use with before/after prepositions. For example after:"last Tuesday" should mean Wednesday, Thursday etc. and before:"last Tuesday" should mean Monday, Sunday, etc. Currently, "last Tuesday" means "Tuesday 00:00" and therefore, after:"last Tuesday" also matches mails sent on Tuesday. 2) "yesterday" means "24 hours ago" and not "yesterday midnight" as I would expect. 3) "Tuesday" means the "next Tuesday" instead of the "last Tuesday", which is natural in the context of emails (usually, there are no mails with future dates). I think that all these problems could be fixed in the parser, but maybe some others do not see them as problems or there might be a better parser available for us to use. What do you think? In any way, if anybody wants to try it, the whole patch serie (custom query parser + date parse (without cworth's folder-based search)) is available from my git repository: git pull git://rtime.felk.cvut.cz/notmuch.git date-parser If we decide to use this parser, we might also want to reduce its dependencies a bit. Since it is able to run even on DOS, there are many compatibility functions included. -Michal Michal Sojka (4): Import date/time parser from GNU coreutils Compile the date/time parser into notmuch library Use the time/date parser for after: and before: prefixes Add first date parser tests Makefile.local |3 + configure |8 + lib/Makefile.local |5 +- lib/c-ctype.c | 398 ++ lib/c-ctype.h | 297 + lib/config.h| 45 + lib/database.cc | 14 +- lib/getdate.c | 3534 +++ lib/getdate.h | 31 + lib/getdate.y | 1609 +++ lib/gettime.c | 48 + lib/intprops.h | 83 ++ lib/timespec.h | 39 + lib/verify.h| 140 ++ test/Makefile.local |9 +- test/basic |2 +- test/date-parser| 37 + test/notmuch-test |2 +- 18 files changed, 6293 insertions(+), 11 deletions(-) create mode 100644 lib/c-ctype.c create mode 100644 lib/c-ctype.h create mode 100644 lib/config.h create mode 100644 lib/getdate.c create mode 100644 lib/getdate.h create mode 100644 lib/getdate.y create mode 100644 lib/gettime.c create mode 100644 lib/gettime.h create mode 100644 lib/intprops.h create mode 100644 lib/timespec.h create mode 100644 lib/verify.h create mode 100755 test/date-parser -- 1.7.2.3
[PATCH] test: Make it easier to resolve conflicts when adding new tests
Currently, there are two places in the test framework that contain very long list on a single line. Whenever a test is added (or changed) in several branches and these branches are merged, it results in conflict which is hard to resolve because one has to go through the whole long line to find where the conflict is. This patch splits these long lists to several lines so that the conflicts are easier to resolve. --- test/basic|9 +++-- test/notmuch-test | 21 - 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/basic b/test/basic index e1269e2..3b43ad9 100755 --- a/test/basic +++ b/test/basic @@ -51,8 +51,13 @@ test_expect_code 2 'failure to clean up causes the test to fail' ' # Ensure that all tests are being run test_begin_subtest 'Ensure that all available tests will be run by notmuch-test' -tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e "s/TESTS=\"\(.*\)\"/\1/" | tr " " "\n" | sort) -available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|test.expected-output|.*~)" | sort) +eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test ../notmuch-test) +tests_in_suite=$(for i in $TESTS; do echo $i; done | sort) +available=$(ls -1 ../ | \ +sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \ + -e "/^(README|test-lib.sh|test-results|tmp.*|valgrind|corpus*)/d" \ + -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \ + -e "/^(test.expected-output|.*~)/d" | sort) test_expect_equal "$tests_in_suite" "$available" EXPECTED=../test.expected-output diff --git a/test/notmuch-test b/test/notmuch-test index fcf43a8..1e5ac11 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -16,7 +16,26 @@ fi cd $(dirname "$0") -TESTS="basic new search search-output search-by-folder json thread-naming raw reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync" +TESTS=" + basic + new + search + search-output + search-by-folder + json + thread-naming + raw + reply + dump-restore + uuencode + thread-order + author-order + from-guessing + long-id + encoding + emacs + maildir-sync +" # Clean up any results from a previous run rm -r test-results >/dev/null 2>/dev/null -- 1.7.2.3
[PATCH] emacs: View the output of pipe command when it fails
Previously, the user didn't know whether the pipe command succeeded or not. It was only possible to find it out by manually inspecting the work done (or not done) by the command or by manually switching to *notmuch-pipe* buffer and determine it from command output. For this the user had to first find the text corresponding to the last run of pipe command as the buffer accumulated the output from all pipe commands. This patch changes the following. The *notmuch-pipe* buffer is erased before every pipe command so it contains only the output from the last command. Additionally, when the command failed, the *notmuch-pipe* buffer is shown and an error message is displayed. with the output of pipe command. --- emacs/notmuch-show.el | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 3a60d43..f3150af 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -948,7 +948,7 @@ any effects from previous calls to The given command will be executed with the raw contents of the current email message as stdin. Anything printed by the command -to stdout or stderr will appear in the *Messages* buffer. +to stdout or stderr will appear in the *notmuch-pipe* buffer. When invoked with a prefix argument, the command will receive all open messages in the current thread (formatted as an mbox) rather @@ -964,7 +964,18 @@ than only the current message." (setq shell-command (concat notmuch-command " show --format=raw " (shell-quote-argument (notmuch-show-get-message-id)) " | " command))) -(start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*" shell-command))) +(let ((buf (get-buffer-create (concat "*notmuch-pipe*" + (with-current-buffer buf + (setq buffer-read-only nil) + (erase-buffer) + (let ((exit-code (call-process-shell-command shell-command nil buf))) + (goto-char (point-max)) + (set-buffer-modified-p nil) + (setq buffer-read-only t) + (unless (zerop exit-code) + (switch-to-buffer-other-window buf) + (message (format "Command '%s' exited abnormally with code %d" +shell-command exit-code (defun notmuch-show-add-tags-worker (current-tags add-tags) "Add to `current-tags' with any tags from `add-tags' not -- 1.7.2.3
[PATCH] test: Make it easier to resolve conflicts when adding new tests
Currently, there are two places in the test framework that contain very long list on a single line. Whenever a test is added (or changed) in several branches and these branches are merged, it results in conflict which is hard to resolve because one has to go through the whole long line to find where the conflict is. This patch splits these long lists to several lines so that the conflicts are easier to resolve. --- test/basic|9 +++-- test/notmuch-test | 21 - 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/basic b/test/basic index e1269e2..3b43ad9 100755 --- a/test/basic +++ b/test/basic @@ -51,8 +51,13 @@ test_expect_code 2 'failure to clean up causes the test to fail' ' # Ensure that all tests are being run test_begin_subtest 'Ensure that all available tests will be run by notmuch-test' -tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e s/TESTS=\\(.*\)\/\1/ | tr \n | sort) -available=$(ls -1 ../ | grep -v -E ^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|test.expected-output|.*~) | sort) +eval $(sed -n -e '/^TESTS=$/,/^$/p' notmuch-test ../notmuch-test) +tests_in_suite=$(for i in $TESTS; do echo $i; done | sort) +available=$(ls -1 ../ | \ +sed -r -e /^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d \ + -e /^(README|test-lib.sh|test-results|tmp.*|valgrind|corpus*)/d \ + -e /^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d \ + -e /^(test.expected-output|.*~)/d | sort) test_expect_equal $tests_in_suite $available EXPECTED=../test.expected-output diff --git a/test/notmuch-test b/test/notmuch-test index fcf43a8..1e5ac11 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -16,7 +16,26 @@ fi cd $(dirname $0) -TESTS=basic new search search-output search-by-folder json thread-naming raw reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync +TESTS= + basic + new + search + search-output + search-by-folder + json + thread-naming + raw + reply + dump-restore + uuencode + thread-order + author-order + from-guessing + long-id + encoding + emacs + maildir-sync + # Clean up any results from a previous run rm -r test-results /dev/null 2/dev/null -- 1.7.2.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/4] Versatile date/time parser
Hi all, the following patch series brings into notmuch date/time parser stolen from GNU coreutils. It can be applied on top of custom query parser patches from Austin Clements. This is RFC and it not meant for merging. With these patches you can specify the date/time in many ways such as: after:last monday, after:2 hours ago, etc. There are some problems, though. 1) The parser is meant for parsing time instant specifications, which not convenient for use with before/after prepositions. For example after:last Tuesday should mean Wednesday, Thursday etc. and before:last Tuesday should mean Monday, Sunday, etc. Currently, last Tuesday means Tuesday 00:00 and therefore, after:last Tuesday also matches mails sent on Tuesday. 2) yesterday means 24 hours ago and not yesterday midnight as I would expect. 3) Tuesday means the next Tuesday instead of the last Tuesday, which is natural in the context of emails (usually, there are no mails with future dates). I think that all these problems could be fixed in the parser, but maybe some others do not see them as problems or there might be a better parser available for us to use. What do you think? In any way, if anybody wants to try it, the whole patch serie (custom query parser + date parse (without cworth's folder-based search)) is available from my git repository: git pull git://rtime.felk.cvut.cz/notmuch.git date-parser If we decide to use this parser, we might also want to reduce its dependencies a bit. Since it is able to run even on DOS, there are many compatibility functions included. -Michal Michal Sojka (4): Import date/time parser from GNU coreutils Compile the date/time parser into notmuch library Use the time/date parser for after: and before: prefixes Add first date parser tests Makefile.local |3 + configure |8 + lib/Makefile.local |5 +- lib/c-ctype.c | 398 ++ lib/c-ctype.h | 297 + lib/config.h| 45 + lib/database.cc | 14 +- lib/getdate.c | 3534 +++ lib/getdate.h | 31 + lib/getdate.y | 1609 +++ lib/gettime.c | 48 + lib/intprops.h | 83 ++ lib/timespec.h | 39 + lib/verify.h| 140 ++ test/Makefile.local |9 +- test/basic |2 +- test/date-parser| 37 + test/notmuch-test |2 +- 18 files changed, 6293 insertions(+), 11 deletions(-) create mode 100644 lib/c-ctype.c create mode 100644 lib/c-ctype.h create mode 100644 lib/config.h create mode 100644 lib/getdate.c create mode 100644 lib/getdate.h create mode 100644 lib/getdate.y create mode 100644 lib/gettime.c create mode 100644 lib/gettime.h create mode 100644 lib/intprops.h create mode 100644 lib/timespec.h create mode 100644 lib/verify.h create mode 100755 test/date-parser -- 1.7.2.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/4] Compile the date/time parser into notmuch library
--- Makefile.local |3 + configure |8 ++ lib/Makefile.local |5 +- lib/config.h | 45 + lib/getdate.c | 185 +++- lib/getdate.h |9 +++ lib/getdate.y | 15 - 7 files changed, 178 insertions(+), 92 deletions(-) create mode 100644 lib/config.h diff --git a/Makefile.local b/Makefile.local index f9b5a9b..ce35c59 100644 --- a/Makefile.local +++ b/Makefile.local @@ -205,6 +205,9 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) %.o: %.c $(global_deps) $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $ -o $@ +%.c: %.y + $(call quiet,YACC $(YFLAGS)) $(YFLAGS) $ -o $@ + .deps/%.d: %.c $(global_deps) @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \ $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $ $@. 2/dev/null ; \ diff --git a/configure b/configure index c58dd0f..6d9fda4 100755 --- a/configure +++ b/configure @@ -12,9 +12,11 @@ tab=$(printf '\t') # environemnt variables) CC=${CC:-gcc} CXX=${CXX:-g++} +YACC=${YACC:-yacc} CFLAGS=${CFLAGS:--O2} CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)} LDFLAGS=${LDFLAGS:-} +YFLAGS=${YFLAGS} XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config} # We don't allow the EMACS or GZIP Makefile variables inherit values @@ -477,6 +479,9 @@ CC = ${CC} # The C++ compiler to use CXX = ${CXX} +# The parser generator to use +YACC = ${YACC} + # Command to execute emacs from Makefiles EMACS = emacs --quick @@ -495,6 +500,9 @@ WARN_CXXFLAGS=${WARN_CXXFLAGS} # Flags to enable warnings when using the C compiler WARN_CFLAGS=${WARN_CFLAGS} +# Default FLAGS for parser generator (can be overridden by user such as make YFLAGS=-y) +YFLAGS = ${YFLAGS} + # The prefix to which notmuch should be installed # Note: If you change this value here, be sure to ensure that the # LIBDIR_IN_LDCONFIG value below is still set correctly. diff --git a/lib/Makefile.local b/lib/Makefile.local index 37d3735..89b5bb7 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -56,7 +56,10 @@ libnotmuch_c_srcs = \ $(dir)/messages.c \ $(dir)/sha1.c \ $(dir)/tags.c \ - $(dir)/xutil.c + $(dir)/xutil.c \ + $(dir)/getdate.c\ + $(dir)/c-ctype.c\ + $(dir)/gettime.c libnotmuch_cxx_srcs = \ $(dir)/database.cc \ diff --git a/lib/config.h b/lib/config.h new file mode 100644 index 000..e8bc5b7 --- /dev/null +++ b/lib/config.h @@ -0,0 +1,45 @@ +/* lib/config.h. Generated from config.hin by configure. */ +/* lib/config.hin. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if you have compound literals. */ +#define HAVE_COMPOUND_LITERALS 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the `nanotime' function. */ +/* #undef HAVE_NANOTIME */ + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define if struct tm has the tm_gmtoff member. */ +#define HAVE_TM_GMTOFF 1 + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 + + +/* Define as a marker that can be attached to declarations that might not +be used. This helps to reduce warnings, such as from +GCC -Wunused-parameter. */ +#if __GNUC__ = 3 || (__GNUC__ == 2 __GNUC_MINOR__ = 7) +# define _GL_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_UNUSED +#endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED diff --git a/lib/getdate.c b/lib/getdate.c index 5b20eeb..57f33e9 100644 --- a/lib/getdate.c +++ b/lib/getdate.c @@ -68,7 +68,7 @@ /* Copy the first part of user declarations. */ /* Line 189 of yacc.c */ -#line 1 getdate.y +#line 1 lib/getdate.y /* Parse a string into an internal time stamp. @@ -102,6 +102,8 @@ /* FIXME: Check for arithmetic overflow in all cases, not just some of them. */ +#include notmuch-private.h /* For xmalloc() */ + #include config.h #include getdate.h @@ -137,9 +139,6 @@ #include stdlib.h #include string.h -#include xalloc.h - - /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. @@ -344,7 +343,7 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, /* Line 189 of yacc.c */ -#line 348 getdate.c +#line 347 lib/getdate.c /* Enabling traces. */ #ifndef YYDEBUG @@ -423,7 +422,7 @@
[PATCH 4/4] Add first date parser tests
Some tests are currently broken for several reasons: 1) in the context of e-mails, we implicitly mean past dates e.g. Monday means the last Monday and not the next one, as it is currently implemented by the parser. 2) yesterday means now -24 hours and I think that should be midnight -24 hours. --- lib/getdate.c | 52 +++--- lib/getdate.y | 52 +++--- test/Makefile.local |9 ++- test/basic |2 +- test/date-parser| 37 test/notmuch-test |2 +- 6 files changed, 126 insertions(+), 28 deletions(-) create mode 100755 test/date-parser diff --git a/lib/getdate.c b/lib/getdate.c index 57f33e9..685c51f 100644 --- a/lib/getdate.c +++ b/lib/getdate.c @@ -3471,19 +3471,50 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) #if TEST int +_internal_error (const char *format, ...) +{ +va_list va_args; + +va_start (va_args, format); + +fprintf (stderr, Internal error: ); +vfprintf (stderr, format, va_args); + +exit (1); + +return 1; +} + +int main (int ac, char **av) { char buff[BUFSIZ]; - printf (Enter date, or blank line to exit.\n\t ); - fflush (stdout); - - buff[BUFSIZ - 1] = '\0'; - while (fgets (buff, BUFSIZ - 1, stdin) buff[0]) + buff[BUFSIZ - 2] = '\0'; + while (fgets (buff, BUFSIZ - 2, stdin) buff[0]) { - struct timespec d; + struct timespec d, ref = { 0, 0 }; struct tm const *tm; - if (! get_date (d, buff, NULL)) + char *arrow; + arrow = strstr (buff, -); + if (arrow) + *arrow = 0; + else { + arrow = buff + strlen (buff); + while (arrow buff *(arrow-1) == '\n') + arrow--; + *arrow-- = 0; + if (arrow = buff ( *arrow != ' ' || *arrow != '\t' )) + strcat (buff, ); + } + if (ac 1) { + struct tm tm_arg; + memset (tm_arg, 0, sizeof (tm_arg)); + strptime (av[1], %Y-%m-%d %H:%M, tm_arg); + ref.tv_sec = mktime (tm_arg); + } else + clock_gettime (CLOCK_REALTIME, ref); + if (! get_date (d, buff, ref)) printf (Bad format - couldn't convert.\n); else if (! (tm = localtime (d.tv_sec))) { @@ -3492,13 +3523,10 @@ main (int ac, char **av) } else { - int ns = d.tv_nsec; - printf (%04ld-%02d-%02d %02d:%02d:%02d.%09d\n, + printf (%s- %04ld-%02d-%02d %02d:%02d:%02d\n, buff, tm-tm_year + 1900L, tm-tm_mon + 1, tm-tm_mday, - tm-tm_hour, tm-tm_min, tm-tm_sec, ns); + tm-tm_hour, tm-tm_min, tm-tm_sec); } - printf (\t ); - fflush (stdout); } return 0; } diff --git a/lib/getdate.y b/lib/getdate.y index d423f5b..657416e 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -1547,19 +1547,50 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) #if TEST int +_internal_error (const char *format, ...) +{ +va_list va_args; + +va_start (va_args, format); + +fprintf (stderr, Internal error: ); +vfprintf (stderr, format, va_args); + +exit (1); + +return 1; +} + +int main (int ac, char **av) { char buff[BUFSIZ]; - printf (Enter date, or blank line to exit.\n\t ); - fflush (stdout); - - buff[BUFSIZ - 1] = '\0'; - while (fgets (buff, BUFSIZ - 1, stdin) buff[0]) + buff[BUFSIZ - 2] = '\0'; + while (fgets (buff, BUFSIZ - 2, stdin) buff[0]) { - struct timespec d; + struct timespec d, ref = { 0, 0 }; struct tm const *tm; - if (! get_date (d, buff, NULL)) + char *arrow; + arrow = strstr (buff, -); + if (arrow) + *arrow = 0; + else { + arrow = buff + strlen (buff); + while (arrow buff *(arrow-1) == '\n') + arrow--; + *arrow-- = 0; + if (arrow = buff ( *arrow != ' ' || *arrow != '\t' )) + strcat (buff, ); + } + if (ac 1) { + struct tm tm_arg; + memset (tm_arg, 0, sizeof (tm_arg)); + strptime (av[1], %Y-%m-%d %H:%M, tm_arg); + ref.tv_sec = mktime (tm_arg); + } else + clock_gettime (CLOCK_REALTIME, ref); + if (! get_date (d, buff, ref)) printf (Bad format - couldn't convert.\n); else if (! (tm = localtime (d.tv_sec))) { @@ -1568,13 +1599,10 @@ main (int ac, char **av) } else { - int ns = d.tv_nsec; - printf (%04ld-%02d-%02d %02d:%02d:%02d.%09d\n, + printf (%s- %04ld-%02d-%02d %02d:%02d:%02d\n, buff, tm-tm_year + 1900L, tm-tm_mon + 1, tm-tm_mday, - tm-tm_hour, tm-tm_min, tm-tm_sec, ns); + tm-tm_hour, tm-tm_min, tm-tm_sec); } - printf (\t ); - fflush (stdout); } return 0; } diff --git
Re: [PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.
Hi Cedric, On Sun, 23 Jan 2011 14:33:43 +0100, Cédric Cabessa c...@ryick.net wrote: add --bashcompletiondir and --zshcompletiondir (like --emacslispdir) to choose installation dir for bash/zsh completion files Make some features optional: --without-emacs / --with-emacs=no do not install lisp file --without-bash-completion / --with-bash-completion=no do not install bash files --without-zsh-completion / --with-zsh-completion=no do not install zsh files By default, everything is enabled. You can reenable something with --with-feature=yes Why not just try to detect whether bash/zsh or even emacs is available on the system and install the dependent files when it is the case ? /Xavier ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch