Changeset: 8c393a0ad3d1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8c393a0ad3d1
Added Files:
        common/utils/strptime.cpp
Removed Files:
        common/utils/strptime.c
Modified Files:
        buildtools/autogen/autogen/codegen.py
        buildtools/autogen/autogen/filesplit.py
        buildtools/autogen/autogen/msc.py
        clients/mapiclient/eventparser.c
        common/utils/Makefile.ag
        monetdb5/modules/atoms/mtime.c
        monetdb5/tools/Makefile.ag
Branch: Mar2018
Log Message:

On Windows, use C++ std::get_time() function for strptime.
In new enough C++ versions, std::get_time() is defined and it is
compatible with the definition of strptime.
Unfortunately, this doesn't fix bug 6626.


diffs (truncated from 567 to 300 lines):

diff --git a/buildtools/autogen/autogen/codegen.py 
b/buildtools/autogen/autogen/codegen.py
--- a/buildtools/autogen/autogen/codegen.py
+++ b/buildtools/autogen/autogen/codegen.py
@@ -27,6 +27,7 @@ code_gen = {'y':        [ '.tab.c', '.ta
             'brg':      [ '.c' ],
             't':        [ '.c' ],
             'c':        [ '.o' ],
+            'cpp':      [ '.o' ],
 #            'java':     [ '.class' ],
             #'tex':      [ '.html', '.dvi', '.pdf' ],
             #'dvi':      [ '.ps' ],
@@ -68,6 +69,7 @@ t_inc = re.compile(t_inc, re.MULTILINE)
 
 scan_map = {
     'c': [ c_inc, None, '' ],
+    'cpp': [ c_inc, None, '' ],
     'h': [ c_inc, None, '' ],
     'y': [ c_inc, None, '' ],
     'l': [ c_inc, None, '' ],
diff --git a/buildtools/autogen/autogen/filesplit.py 
b/buildtools/autogen/autogen/filesplit.py
--- a/buildtools/autogen/autogen/filesplit.py
+++ b/buildtools/autogen/autogen/filesplit.py
@@ -13,7 +13,7 @@ def rsplit_filename(f):
         return f[:s], f[s+1:]
     return base, ext
 
-automake_ext = ['', 'c', 'def', 'h', 'lo', 'o', 'pm.c', 'tab.c', 'tab.h', 
'yy.c', 'pm.i']
+automake_ext = ['', 'c', 'cpp', 'def', 'h', 'lo', 'o', 'pm.c', 'tab.c', 
'tab.h', 'yy.c', 'pm.i']
 automake_extra_extensions = set([rsplit_filename(x)[1] for x in automake_ext 
if '.' in x])
 extra_extensions = ['in', 'bat', 'sed']
 
diff --git a/buildtools/autogen/autogen/msc.py 
b/buildtools/autogen/autogen/msc.py
--- a/buildtools/autogen/autogen/msc.py
+++ b/buildtools/autogen/autogen/msc.py
@@ -344,8 +344,8 @@ def msc_dep(fd, tar, deplist, msc):
             name = name[1:]
         if target == "LIB":
             d, dext = split_filename(deplist[0])
-            if dext in ("c", "yy.c", "tab.c"):
-                fd.write('\t$(CC) $(CFLAGS) $(%s_CFLAGS) $(GENDLL) 
-D_CRT_SECURE_NO_WARNINGS -DLIB%s "-Fo%s" -c "%s"\n' %
+            if dext in ("c", "cpp", "yy.c", "tab.c"):
+                fd.write('\t$(CC) /EHsc $(CFLAGS) $(%s_CFLAGS) $(GENDLL) 
-D_CRT_SECURE_NO_WARNINGS -DLIB%s "-Fo%s" -c "%s"\n' %
                          (split_filename(msc_basename(src))[0], name, t, src))
     if ext == 'res':
         fd.write("\t$(RC) -fo%s %s\n" % (t, src))
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -25,11 +25,6 @@ int debug=0;
 char *currentquery=0;
 int eventcounter = 0;
 
-#ifndef HAVE_STRPTIME
-extern char *strptime(const char *, const char *, struct tm *);
-#include "strptime.c"
-#endif
-
 #define DATETIME_CHAR_LENGTH 27
 
 static void
diff --git a/common/utils/Makefile.ag b/common/utils/Makefile.ag
--- a/common/utils/Makefile.ag
+++ b/common/utils/Makefile.ag
@@ -30,4 +30,8 @@ lib_msabaoth = {
        SOURCES = msabaoth.h msabaoth.c
 }
 
-EXTRA_DIST = strptime.c
+lib_strptime = {
+       NOINST
+       SOURCES = strptime.cpp
+       COND = NATIVE_WIN32
+}
diff --git a/common/utils/strptime.c b/common/utils/strptime.c
deleted file mode 100644
--- a/common/utils/strptime.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright (c) 1999 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden). 
- * All rights reserved. 
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- *
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- *
- * 3. Neither the name of KTH nor the names of its contributors may be
- *    used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
-
-#ifdef WIN32
-
-/* #include "platform/platform.h" */
-
-
-static const char *abb_weekdays[] = {
-    "Sun",
-    "Mon",
-    "Tue",
-    "Wed",
-    "Thu",
-    "Fri",
-    "Sat",
-    NULL
-};
-
-static const char *full_weekdays[] = {
-    "Sunday",
-    "Monday",
-    "Tuesday",
-    "Wednesday",
-    "Thursday",
-    "Friday",
-    "Saturday",
-    NULL
-};
-
-static const char *abb_month[] = {
-    "Jan",
-    "Feb",
-    "Mar",
-    "Apr",
-    "May",
-    "Jun",
-    "Jul",
-    "Aug",
-    "Sep",
-    "Oct",
-    "Nov",
-    "Dec",
-    NULL
-};
-
-static const char *full_month[] = {
-    "January",
-    "February",
-    "Mars",
-    "April",
-    "May",
-    "June",
-    "July",
-    "August",
-    "September",
-    "October",
-    "November",
-    "December",
-    NULL,
-};
-
-static const char *ampm[] = {
-    "am",
-    "pm",
-    NULL
-};
-
-/*
- * Try to match `*buf' to one of the strings in `strs'.  Return the
- * index of the matching string (or -1 if none).  Also advance buf.
- */
-
-static int
-match_string (const char **buf, const char **strs)
-{
-    int i = 0;
-
-    for (i = 0; strs[i] != NULL; ++i) {
-       size_t len = strlen (strs[i]);
-
-       if (strncasecmp (*buf, strs[i], len) == 0) {
-           *buf += len;
-           return i;
-       }
-    }
-    return -1;
-}
-
-/*
- * tm_year is relative this year */
-
-const int tm_year_base = 1900;
-
-/*
- * Return TRUE iff `year' was a leap year.
- */
-
-static int
-is_leap_year (int year)
-{
-    return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
-}
-
-/*
- * Return the weekday [0,6] (0 = Sunday) of the first day of `year'
- */
-
-static int
-first_day (int year)
-{
-    int ret = 4;
-
-    for (; year > 1970; --year)
-       ret = (ret + 365 + is_leap_year (year) ? 1 : 0) % 7;
-    return ret;
-}
-
-/*
- * Set `timeptr' given `wnum' (week number [0, 53])
- */
-
-static void
-set_week_number_sun (struct tm *timeptr, int wnum)
-{
-    int fday = first_day (timeptr->tm_year + tm_year_base);
-
-    timeptr->tm_yday = wnum * 7 + timeptr->tm_wday - fday;
-    if (timeptr->tm_yday < 0) {
-       timeptr->tm_wday = fday;
-       timeptr->tm_yday = 0;
-    }
-}
-
-/*
- * Set `timeptr' given `wnum' (week number [0, 53])
- */
-
-static void
-set_week_number_mon (struct tm *timeptr, int wnum)
-{
-    int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
-
-    timeptr->tm_yday = wnum * 7 + (timeptr->tm_wday + 6) % 7 - fday;
-    if (timeptr->tm_yday < 0) {
-       timeptr->tm_wday = (fday + 1) % 7;
-       timeptr->tm_yday = 0;
-    }
-}
-
-/*
- * Set `timeptr' given `wnum' (week number [0, 53])
- */
-
-static void
-set_week_number_mon4 (struct tm *timeptr, int wnum)
-{
-    int fday = (first_day (timeptr->tm_year + tm_year_base) + 6) % 7;
-    int offset = 0;
-
-    if (fday < 4)
-       offset += 7;
-
-    timeptr->tm_yday = offset + (wnum - 1) * 7 + timeptr->tm_wday - fday;
-    if (timeptr->tm_yday < 0) {
-       timeptr->tm_wday = fday;
-       timeptr->tm_yday = 0;
-    }
-}
-
-/*
- *
- */
-
-char *
-strptime (const char *buf, const char *fmt, struct tm *timeptr)
-{
-    char c;
-
-    for (; (c = *fmt) != '\0'; ++fmt) {
-       char *s;
-       int ret;
-
-       if (isspace ((unsigned char) c)) {
-           while (isspace ((unsigned char) *buf))
-               ++buf;
-       } else if (c == '%' && fmt[1] != '\0') {
-           c = *++fmt;
-           if (c == 'E' || c == 'O')
-               c = *++fmt;
-           switch (c) {
-           case 'A' :
-               ret = match_string (&buf, full_weekdays);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to