aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/datetime-parser.c65
-rw-r--r--src/error.c14
-rw-r--r--src/error.h2
-rw-r--r--src/renderer.c30
-rw-r--r--tests/check_datetime_parser.c78
5 files changed, 94 insertions, 95 deletions
diff --git a/src/datetime-parser.c b/src/datetime-parser.c
index 572c9f0..85d4e9c 100644
--- a/src/datetime-parser.c
+++ b/src/datetime-parser.c
@@ -53,6 +53,15 @@ blogc_convert_datetime(const char *orig, const char *format,
if (err == NULL || *err != NULL)
return NULL;
+#ifndef HAVE_TIME_H
+
+ *err = blogc_error_new(BLOGC_WARNING_DATETIME_PARSER,
+ "Your operating system does not supports the datetime functionalities "
+ "used by blogc. Sorry.");
+ return NULL;
+
+#else
+
struct tm t;
memset(&t, 0, sizeof(struct tm));
t.tm_isdst = -1;
@@ -72,7 +81,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -83,7 +92,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_THIRD_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -94,7 +103,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FOURTH_YEAR;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid third digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -103,7 +112,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1900;
if (tmp < 0) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid year. Found %d, must be >= 1900.",
tmp + 1900);
break;
@@ -112,7 +121,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid fourth digit of year. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -123,7 +132,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between year and month. "
"Found '%c', must be '-'.", c);
break;
@@ -134,7 +143,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MONTH;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of month. "
"Found '%c', must be integer >= 0 and <= 1.", c);
break;
@@ -143,7 +152,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff - 1;
if (tmp < 0 || tmp > 11) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid month. Found %d, must be >= 1 and <= 12.",
tmp + 1);
break;
@@ -152,7 +161,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HYPHEN;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of month. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -163,7 +172,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between month and day. "
"Found '%c', must be '-'.", c);
break;
@@ -174,7 +183,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_DAY;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of day. "
"Found '%c', must be integer >= 0 and <= 3.", c);
break;
@@ -183,7 +192,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 1 || tmp > 31) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid day. Found %d, must be >= 1 and <= 31.",
tmp);
break;
@@ -192,7 +201,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SPACE;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of day. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -203,7 +212,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between date and time. "
"Found '%c', must be ' ' (empty space).", c);
break;
@@ -214,7 +223,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_HOUR;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of hours. "
"Found '%c', must be integer >= 0 and <= 2.", c);
break;
@@ -223,7 +232,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 23) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid hours. Found %d, must be >= 0 and <= 23.",
tmp);
break;
@@ -232,7 +241,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of hours. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -243,7 +252,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between hours and minutes. "
"Found '%c', must be ':'.", c);
break;
@@ -254,7 +263,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_MINUTE;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of minutes. "
"Found '%c', must be integer >= 0 and <= 5.", c);
break;
@@ -266,7 +275,7 @@ blogc_convert_datetime(const char *orig, const char *format,
// this won't happen because we are restricting the digits
// to 00-59 already, but lets keep the code here for
// reference.
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid minutes. Found %d, must be >= 0 and <= 59.",
tmp);
break;
@@ -275,7 +284,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_COLON;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of minutes. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -286,7 +295,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_FIRST_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid separator between minutes and seconds. "
"Found '%c', must be ':'.", c);
break;
@@ -297,7 +306,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_SECOND_SECOND;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid first digit of seconds. "
"Found '%c', must be integer >= 0 and <= 6.", c);
break;
@@ -306,7 +315,7 @@ blogc_convert_datetime(const char *orig, const char *format,
if (c >= '0' && c <= '9') {
tmp += c - diff;
if (tmp < 0 || tmp > 60) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid seconds. Found %d, must be >= 0 and <= 60.",
tmp);
break;
@@ -315,7 +324,7 @@ blogc_convert_datetime(const char *orig, const char *format,
state = DATETIME_DONE;
break;
}
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid second digit of seconds. "
"Found '%c', must be integer >= 0 and <= 9.", c);
break;
@@ -347,7 +356,7 @@ blogc_convert_datetime(const char *orig, const char *format,
case DATETIME_SECOND_MINUTE:
case DATETIME_FIRST_SECOND:
case DATETIME_SECOND_SECOND:
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Invalid datetime string. "
"Found '%s', formats allowed are: 'yyyy-mm-dd hh:mm:ss', "
"'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and 'yyyy-mm-dd'.",
@@ -366,11 +375,13 @@ blogc_convert_datetime(const char *orig, const char *format,
char buf[1024];
if (0 == strftime(buf, sizeof(buf), format, &t)) {
- *err = blogc_error_new_printf(BLOGC_ERROR_DATETIME_PARSER,
+ *err = blogc_error_new_printf(BLOGC_WARNING_DATETIME_PARSER,
"Failed to format DATE variable, FORMAT is too long: %s",
format);
return NULL;
}
return b_strdup(buf);
+
+#endif
}
diff --git a/src/error.c b/src/error.c
index 0576d34..4cb3be1 100644
--- a/src/error.c
+++ b/src/error.c
@@ -114,19 +114,19 @@ blogc_error_print(blogc_error_t *err)
switch(err->type) {
case BLOGC_ERROR_SOURCE_PARSER:
- fprintf(stderr, "Source parser error: %s\n", err->msg);
+ fprintf(stderr, "blogc: error: source: %s\n", err->msg);
break;
case BLOGC_ERROR_TEMPLATE_PARSER:
- fprintf(stderr, "Template parser error: %s\n", err->msg);
- break;
- case BLOGC_ERROR_DATETIME_PARSER:
- fprintf(stderr, "Datetime parser error: %s\n", err->msg);
+ fprintf(stderr, "blogc: error: template: %s\n", err->msg);
break;
case BLOGC_ERROR_LOADER:
- fprintf(stderr, "Loader error: %s\n", err->msg);
+ fprintf(stderr, "blogc: error: loader: %s\n", err->msg);
+ break;
+ case BLOGC_WARNING_DATETIME_PARSER:
+ fprintf(stderr, "blogc: warning: datetime: %s\n", err->msg);
break;
default:
- fprintf(stderr, "Unknown error: %s\n", err->msg);
+ fprintf(stderr, "blogc: error: %s\n", err->msg);
}
}
diff --git a/src/error.h b/src/error.h
index d9b2862..845a316 100644
--- a/src/error.h
+++ b/src/error.h
@@ -15,8 +15,8 @@
typedef enum {
BLOGC_ERROR_SOURCE_PARSER = 1,
BLOGC_ERROR_TEMPLATE_PARSER,
- BLOGC_ERROR_DATETIME_PARSER,
BLOGC_ERROR_LOADER,
+ BLOGC_WARNING_DATETIME_PARSER,
} blogc_error_type_t;
typedef struct {
diff --git a/src/renderer.c b/src/renderer.c
index 47a5f87..c5b3e9f 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -10,13 +10,11 @@
#include <config.h>
#endif /* HAVE_CONFIG_H */
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif /* HAVE_TIME_H */
-
#include <stdio.h>
#include <string.h>
#include "utils/utils.h"
+#include "datetime-parser.h"
+#include "error.h"
#include "loader.h"
#include "source-parser.h"
#include "template-parser.h"
@@ -46,25 +44,15 @@ blogc_format_date(const char *date, b_trie_t *global, b_trie_t *local)
return NULL;
if (date_format == NULL)
return b_strdup(date);
-#ifdef HAVE_TIME_H
- struct tm tm;
- memset(&tm, 0, sizeof(struct tm));
- if (NULL == strptime(date, "%Y-%m-%d %H:%M:%S", &tm)) {
- fprintf(stderr, "blogc: warning: Failed to parse DATE variable: %s\n",
- date);
- return b_strdup(date);
- }
- char tmp[1024];
- if (0 == strftime(tmp, sizeof(tmp), date_format, &tm)) {
- fprintf(stderr, "blogc: warning: Failed to format DATE variable, "
- "FORMAT is too long: %s\n", date_format);
+
+ blogc_error_t *err = NULL;
+ char *rv = blogc_convert_datetime(date, date_format, &err);
+ if (err != NULL) {
+ blogc_error_print(err);
+ blogc_error_free(err);
return b_strdup(date);
}
- return b_strdup(tmp);
-#else
- fprintf(stderr, "blogc: warning: Can't pre-process DATE variable.\n");
- return NULL;
-#endif
+ return rv;
}
diff --git a/tests/check_datetime_parser.c b/tests/check_datetime_parser.c
index 1997678..1ac976d 100644
--- a/tests/check_datetime_parser.c
+++ b/tests/check_datetime_parser.c
@@ -76,7 +76,7 @@ test_convert_datetime_invalid_formats(void **state)
char *dt = blogc_convert_datetime("", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -87,7 +87,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -98,7 +98,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("20", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '20', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -109,7 +109,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("201", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '201', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -120,7 +120,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -131,7 +131,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -142,7 +142,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-1", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -153,7 +153,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-11", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -164,7 +164,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-11-", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -175,7 +175,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-11-3", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-3', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -186,7 +186,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-11-30 ", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 ', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -197,7 +197,7 @@ test_convert_datetime_invalid_formats(void **state)
dt = blogc_convert_datetime("2010-11-30 1", "%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -209,7 +209,7 @@ test_convert_datetime_invalid_formats(void **state)
&err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 12:1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -221,7 +221,7 @@ test_convert_datetime_invalid_formats(void **state)
&err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid datetime string. Found '2010-11-30 12:13:1', formats allowed are: "
"'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:ss', 'yyyy-mm-dd hh' and "
@@ -238,7 +238,7 @@ test_convert_datetime_invalid_1st_year(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of year. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -253,7 +253,7 @@ test_convert_datetime_invalid_2nd_year(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of year. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -268,7 +268,7 @@ test_convert_datetime_invalid_3rd_year(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid third digit of year. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -283,7 +283,7 @@ test_convert_datetime_invalid_4th_year(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid fourth digit of year. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -298,7 +298,7 @@ test_convert_datetime_invalid_year(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid year. Found 1899, must be >= 1900.");
blogc_error_free(err);
@@ -313,7 +313,7 @@ test_convert_datetime_invalid_1st_hyphen(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between year and month. Found ' ', must be '-'.");
blogc_error_free(err);
@@ -328,7 +328,7 @@ test_convert_datetime_invalid_1st_month(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of month. Found 'a', must be integer >= 0 and <= 1.");
blogc_error_free(err);
@@ -343,7 +343,7 @@ test_convert_datetime_invalid_2nd_month(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of month. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -358,7 +358,7 @@ test_convert_datetime_invalid_month(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid month. Found 13, must be >= 1 and <= 12.");
blogc_error_free(err);
@@ -373,7 +373,7 @@ test_convert_datetime_invalid_2nd_hyphen(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between month and day. Found ' ', must be '-'.");
blogc_error_free(err);
@@ -388,7 +388,7 @@ test_convert_datetime_invalid_1st_day(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of day. Found 'a', must be integer >= 0 and <= 3.");
blogc_error_free(err);
@@ -403,7 +403,7 @@ test_convert_datetime_invalid_2nd_day(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of day. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -418,7 +418,7 @@ test_convert_datetime_invalid_day(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid day. Found 32, must be >= 1 and <= 31.");
blogc_error_free(err);
@@ -433,7 +433,7 @@ test_convert_datetime_invalid_space(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between date and time. Found '-', must be ' ' "
"(empty space).");
@@ -449,7 +449,7 @@ test_convert_datetime_invalid_1st_hours(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of hours. Found 'a', must be integer >= 0 and <= 2.");
blogc_error_free(err);
@@ -464,7 +464,7 @@ test_convert_datetime_invalid_2nd_hours(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of hours. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -479,7 +479,7 @@ test_convert_datetime_invalid_hours(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid hours. Found 24, must be >= 0 and <= 23.");
blogc_error_free(err);
@@ -494,7 +494,7 @@ test_convert_datetime_invalid_1st_colon(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between hours and minutes. Found ' ', must be ':'.");
blogc_error_free(err);
@@ -509,7 +509,7 @@ test_convert_datetime_invalid_1st_minutes(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of minutes. Found 'a', must be integer >= 0 and <= 5.");
blogc_error_free(err);
@@ -524,7 +524,7 @@ test_convert_datetime_invalid_2nd_minutes(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of minutes. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -539,7 +539,7 @@ test_convert_datetime_invalid_2nd_colon(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid separator between minutes and seconds. Found ' ', must be ':'.");
blogc_error_free(err);
@@ -554,7 +554,7 @@ test_convert_datetime_invalid_1st_seconds(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid first digit of seconds. Found 'a', must be integer >= 0 and <= 6.");
blogc_error_free(err);
@@ -569,7 +569,7 @@ test_convert_datetime_invalid_2nd_seconds(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid second digit of seconds. Found 'a', must be integer >= 0 and <= 9.");
blogc_error_free(err);
@@ -584,7 +584,7 @@ test_convert_datetime_invalid_seconds(void **state)
"%b %d, %Y, %I:%M:%S %p GMT", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Invalid seconds. Found 69, must be >= 0 and <= 60.");
blogc_error_free(err);
@@ -613,7 +613,7 @@ test_convert_datetime_invalid_format_long(void **state)
"jgipsincitulscikxviaruryfraeqssykeftcphtndlfhdxokg", &err);
assert_null(dt);
assert_non_null(err);
- assert_int_equal(err->type, BLOGC_ERROR_DATETIME_PARSER);
+ assert_int_equal(err->type, BLOGC_WARNING_DATETIME_PARSER);
assert_string_equal(err->msg,
"Failed to format DATE variable, FORMAT is too long: "
"bovhsuhxwybfrxoluiejaoqpmoylgvkrjtnuntmcgtupwabexkapnklvkwmddmplfqopvb"