branch: elpa/datetime commit 53834b79cb4b42e35ee1230f7c0cb6e53dad8c32 Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Fix an embarassing bug in quoteString() that resulted in some incorrect database entries, e.g. for Hebrew. --- datetime.el | 4 ++-- dev/HarvestData.java | 6 +++++- locale-data.extmap | Bin 349524 -> 349522 bytes test/base.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++ test/format.el | 6 ++++++ timezone-name-data.extmap | Bin 2997365 -> 2997351 bytes 6 files changed, 63 insertions(+), 3 deletions(-) diff --git a/datetime.el b/datetime.el index 61bf880071..5ae19d558a 100644 --- a/datetime.el +++ b/datetime.el @@ -1966,7 +1966,7 @@ create based on locales `datetime' knows about. Note that this database doesn't include timezone names. See `datetime-timezone-name-database-version'." - 5) + 6) (defun datetime-timezone-database-version () "Return timezone database version, a simple integer. @@ -1989,7 +1989,7 @@ Other locale-specific data as well as locale-independent data about timezones is contained in different databases. See `datetime-locale-database-version' and `datetime-timezone-database-version'." - 4) + 5) (provide 'datetime) diff --git a/dev/HarvestData.java b/dev/HarvestData.java index 8735a5d523..eabd023a40 100644 --- a/dev/HarvestData.java +++ b/dev/HarvestData.java @@ -5,6 +5,7 @@ import java.time.temporal.*; import java.time.zone.*; import java.util.*; import java.util.function.*; +import java.util.regex.*; import java.util.stream.*; @@ -606,9 +607,12 @@ public class HarvestData return patterns; } + private static final String ESCAPED_BACKSLASH = Matcher.quoteReplacement ("\\\\"); + private static final String ESCAPED_DOUBLE_QUOTE = Matcher.quoteReplacement ("\\\""); + protected static String quoteString (String string) { - return string != null ? String.format ("\"%s\"", string.replaceAll ("\\\\", "\\\\").replaceAll ("\"", "\\\"")) : "nil"; + return string != null ? String.format ("\"%s\"", string.replaceAll ("\\\\", ESCAPED_BACKSLASH).replaceAll ("\"", ESCAPED_DOUBLE_QUOTE)) : "nil"; } diff --git a/locale-data.extmap b/locale-data.extmap index 04bab090b0..015a56a6f4 100644 Binary files a/locale-data.extmap and b/locale-data.extmap differ diff --git a/test/base.el b/test/base.el index b597eca5f2..ef17b8ca09 100644 --- a/test/base.el +++ b/test/base.el @@ -128,4 +128,54 @@ (error (format "[failed to retrieve: %S]" error)))))))))) +(ert-deftest datetime-locale-database-sanity () + (dolist (locale (datetime-list-locales t)) + (let ((decimal-separator (datetime-locale-field locale :decimal-separator)) + (eras (datetime-locale-field locale :eras)) + (month-context-abbr (datetime-locale-field locale :month-context-abbr)) + (month-context-names (datetime-locale-field locale :month-context-names)) + (weekday-context-abbr (datetime-locale-field locale :weekday-context-abbr)) + (weekday-context-names (datetime-locale-field locale :weekday-context-names)) + (month-standalone-abbr (datetime-locale-field locale :month-standalone-abbr)) + (month-standalone-names (datetime-locale-field locale :month-standalone-names)) + (weekday-standalone-abbr (datetime-locale-field locale :weekday-standalone-abbr)) + (weekday-standalone-names (datetime-locale-field locale :weekday-standalone-names)) + (am-pm (datetime-locale-field locale :am-pm))) + (ert-info ((format "\ +locale = %S +decimal-separator = %S +eras = %S +month-context-abbr = %S +month-context-names = %S +weekday-context-abbr = %S +weekday-context-names = %S +month-standalone-abbr = %S +month-standalone-names = %S +weekday-standalone-abbr = %S +weekday-standalone-names = %S +am-pm = %S" + locale decimal-separator eras + month-context-abbr month-context-names + weekday-context-abbr weekday-context-names + month-standalone-abbr month-standalone-names + weekday-standalone-abbr weekday-standalone-names + am-pm)) + (should (memq decimal-separator '(?. ?, ?٫))) + (dolist (entry `((,eras 2) + (,month-context-abbr 12) + (,month-context-names 12) + (,weekday-context-abbr 7) + (,weekday-context-names 7) + (,month-standalone-abbr 12) + (,month-standalone-names 12) + (,weekday-standalone-abbr 7) + (,weekday-standalone-names 7) + (,am-pm 2))) + (let ((value (car entry)) + (length (cadr entry))) + (should (and (vectorp value) (= (length value) length))) + (dotimes (k length) + (should (stringp (aref value k)))))))))) + + (provide 'test/base) diff --git a/test/format.el b/test/format.el index 3607e86e3c..c25a345061 100644 --- a/test/format.el +++ b/test/format.el @@ -165,4 +165,10 @@ (datetime--test-formatter times))))) +;; A real bug fixed in 0.9.1. A more thorough test for it is `datetime-locale-database-sanity'. +(ert-deftest datetime-formatting-hebrew-1 () + (datetime--test-set-up-formatter 'UTC 'he "yyyy G" + (datetime--test-formatter 0))) + + (provide 'test/format) diff --git a/timezone-name-data.extmap b/timezone-name-data.extmap index 80ab282566..32e472f874 100644 Binary files a/timezone-name-data.extmap and b/timezone-name-data.extmap differ