[PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-25 Thread Michal Sojka
On Mon, 24 Jan 2011, Jameson Rollins wrote:
> On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka  
> wrote:
> > 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
> 
> Hi, Michal.  I don't fully understand what's going on here, but it seems
> like you're embedding code copies from somewhere else.  If that's the
> case, is there a reason that we would need to do that, rather than just
> linking against an external library?

Well, if the embedded code is available in a library, it would be
definitely better to just use the library. But the above code is
statically linked to things like `date` command and is not available
separately.

Most of the dependencies could be eliminated since they usually
replicate functionality which is available in modern C library and are
there only for compatibility reasons.

On the other hand, if anybody knows a better date parser, perhaps in a
separate library, let me know.

-Michal


Re: [PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-25 Thread Michal Sojka
On Mon, 24 Jan 2011, Jameson Rollins wrote:
 On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka sojk...@fel.cvut.cz wrote:
  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
 
 Hi, Michal.  I don't fully understand what's going on here, but it seems
 like you're embedding code copies from somewhere else.  If that's the
 case, is there a reason that we would need to do that, rather than just
 linking against an external library?

Well, if the embedded code is available in a library, it would be
definitely better to just use the library. But the above code is
statically linked to things like `date` command and is not available
separately.

Most of the dependencies could be eliminated since they usually
replicate functionality which is available in modern C library and are
there only for compatibility reasons.

On the other hand, if anybody knows a better date parser, perhaps in a
separate library, let me know.

-Michal
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-24 Thread Jameson Rollins
On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka  wrote:
> 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

Hi, Michal.  I don't fully understand what's going on here, but it seems
like you're embedding code copies from somewhere else.  If that's the
case, is there a reason that we would need to do that, rather than just
linking against an external library?

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-24 Thread Jameson Rollins
On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka sojk...@fel.cvut.cz wrote:
 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

Hi, Michal.  I don't fully understand what's going on here, but it seems
like you're embedding code copies from somewhere else.  If that's the
case, is there a reason that we would need to do that, rather than just
linking against an external library?

jamie.


pgpNWUXRWNPNA.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-23 Thread Michal Sojka
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':
+