summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-01-10 22:39:45 (GMT)
committersebres <sebres@users.sourceforge.net>2017-01-10 22:39:45 (GMT)
commit61be8dc3b8493311781e3fec5575cb85161d16ab (patch)
tree9a70f36cfb397e12af45a39977d8dad643efbd12 /generic
parent9487f2cdcd7045ccc7f540099755acc0d2b36244 (diff)
downloadtcl-61be8dc3b8493311781e3fec5575cb85161d16ab.zip
tcl-61be8dc3b8493311781e3fec5575cb85161d16ab.tar.gz
tcl-61be8dc3b8493311781e3fec5575cb85161d16ab.tar.bz2
other locale scan token switched from list seek to index tree + list search case insensitive now
Diffstat (limited to 'generic')
-rw-r--r--generic/tclClockFmt.c44
-rw-r--r--generic/tclDate.h8
2 files changed, 31 insertions, 21 deletions
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c
index 478941b..999f191 100644
--- a/generic/tclClockFmt.c
+++ b/generic/tclClockFmt.c
@@ -530,20 +530,26 @@ ObjListSearch(ClockFmtScnCmdArgs *opts,
int minLen, int maxLen)
{
int i, l, lf = -1;
- const char *s;
+ const char *s, *f, *sf;
/* search in list */
for (i = 0; i < lstc; i++) {
s = TclGetString(lstv[i]);
l = lstv[i]->length;
- if ( l >= minLen && l <= maxLen
- && strncasecmp(yyInput, s, l) == 0
+
+ if ( l >= minLen
+ && (f = TclUtfFindEqualNC(yyInput, yyInput + maxLen, s, s + l, &sf)) > yyInput
) {
+ l = f - yyInput;
+ if (l < minLen) {
+ continue;
+ }
/* found, try to find longest value (greedy search) */
if (l < maxLen && minLen != maxLen) {
lf = i;
minLen = l + 1;
continue;
}
+ /* max possible - end of search */
*val = i;
yyInput += l;
break;
@@ -818,9 +824,12 @@ static int
ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts,
DateInfo *info, ClockScanToken *tok)
{
+ static int dowKeys[] = {MCLIT_DAYS_OF_WEEK_ABBREV, MCLIT_DAYS_OF_WEEK_FULL, 0};
+
int ret, val;
int minLen, maxLen;
char curTok = *tok->tokWord.start;
+ TclStrIdxTree *idxTree;
DetermineGreedySearchLen(opts, info, tok, &minLen, &maxLen);
@@ -836,9 +845,13 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts,
val = *yyInput - '0';
}
} else {
- int ret = LocaleListSearch(opts, info, (int)tok->map->data, &val,
- minLen, maxLen);
- if (ret == TCL_ERROR) {
+ idxTree = ClockMCGetListIdxTree(opts, (int)tok->map->data /* mcKey */);
+ if (idxTree == NULL) {
+ return TCL_ERROR;
+ }
+
+ ret = ClockStrIdxTreeSearch(opts, info, idxTree, &val, minLen, maxLen);
+ if (ret != TCL_OK) {
return ret;
}
}
@@ -847,7 +860,7 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts,
if (val == 0) {
val = 7;
}
- if (val > 7 && curTok != 'a' && curTok != 'A') {
+ if (val > 7) {
Tcl_SetResult(opts->interp, "day of week is greater than 7",
TCL_STATIC);
Tcl_SetErrorCode(opts->interp, "CLOCK", "badDayOfWeek", NULL);
@@ -863,17 +876,14 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts,
}
/* %a %A */
- ret = LocaleListSearch(opts, info, MCLIT_DAYS_OF_WEEK_FULL, &val,
- minLen, maxLen);
+ idxTree = ClockMCGetMultiListIdxTree(opts, MCLIT_DAYS_OF_WEEK_COMB, dowKeys);
+ if (idxTree == NULL) {
+ return TCL_ERROR;
+ }
+
+ ret = ClockStrIdxTreeSearch(opts, info, idxTree, &val, minLen, maxLen);
if (ret != TCL_OK) {
- /* if not found */
- if (ret == TCL_RETURN) {
- ret = LocaleListSearch(opts, info, MCLIT_DAYS_OF_WEEK_ABBREV, &val,
- minLen, maxLen);
- }
- if (ret != TCL_OK) {
- return ret;
- }
+ return ret;
}
if (val == 0) {
diff --git a/generic/tclDate.h b/generic/tclDate.h
index 85bcd35..fe38436 100644
--- a/generic/tclDate.h
+++ b/generic/tclDate.h
@@ -105,8 +105,8 @@ typedef enum ClockLiteral {
typedef enum ClockMsgCtLiteral {
MCLIT__NIL, /* placeholder */
MCLIT_MONTHS_FULL, MCLIT_MONTHS_ABBREV, MCLIT_MONTHS_COMB,
- MCLIT_DAYS_OF_WEEK_FULL, MCLIT_DAYS_OF_WEEK_ABBREV,
- MCLIT_AM, MCLIT_PM,
+ MCLIT_DAYS_OF_WEEK_FULL, MCLIT_DAYS_OF_WEEK_ABBREV, MCLIT_DAYS_OF_WEEK_COMB,
+ MCLIT_AM, MCLIT_PM,
MCLIT_BCE, MCLIT_CE,
MCLIT_BCE2, MCLIT_CE2,
MCLIT_BCE3, MCLIT_CE3,
@@ -117,8 +117,8 @@ typedef enum ClockMsgCtLiteral {
#define CLOCK_LOCALE_LITERAL_ARRAY(litarr, pref) static const char *const litarr[] = { \
pref "", \
pref "MONTHS_FULL", pref "MONTHS_ABBREV", pref "MONTHS_COMB", \
- pref "DAYS_OF_WEEK_FULL", pref "DAYS_OF_WEEK_ABBREV", \
- pref "AM", pref "PM", \
+ pref "DAYS_OF_WEEK_FULL", pref "DAYS_OF_WEEK_ABBREV", pref "DAYS_OF_WEEK_COMB", \
+ pref "AM", pref "PM", \
pref "BCE", pref "CE", \
pref "b.c.e.", pref "c.e.", \
pref "b.c.", pref "a.d.", \