From c9b030045c75b1bb6f9d2899666b28654f6406a9 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Thu, 8 Oct 2009 16:07:57 +0000 Subject: install web2c/bibtexu (static icu libs only) git-svn-id: svn://tug.org/texlive/trunk@15686 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/bibtexu/bibtex-4.c | 559 +++++++++++++++++++++++++++++++++-- 1 file changed, 536 insertions(+), 23 deletions(-) (limited to 'Build/source/texk/bibtexu/bibtex-4.c') diff --git a/Build/source/texk/bibtexu/bibtex-4.c b/Build/source/texk/bibtexu/bibtex-4.c index fed22bc919d..86244e7d443 100644 --- a/Build/source/texk/bibtexu/bibtex-4.c +++ b/Build/source/texk/bibtexu/bibtex-4.c @@ -132,6 +132,14 @@ #include "version.h" +/* +Include the ICU heads. 23/sep/2009 +*/ + +#include "unicode/ustdio.h" +#include "unicode/uchar.h" +#include "unicode/ucnv.h" +#include "unicode/ucol.h" /*************************************************************************** * WEB section number: 364 * ~~~~~~~~~~~~~~~~~~~ @@ -158,6 +166,7 @@ ***************************************************************************/ void x_change_case (void) BEGIN + pop_lit_stk (&pop_lit1, &pop_typ1); pop_lit_stk (&pop_lit2, &pop_typ2); if (pop_typ1 != STK_STR) @@ -180,7 +189,8 @@ BEGIN * definitions, to be used in |case| statements, are in order of probable * frequency. ***************************************************************************/ - BEGIN + + BEGIN switch (str_pool[str_start[pop_lit1]]) BEGIN case 't': @@ -206,6 +216,7 @@ BEGIN BST_EX_WARN (" is an illegal case-conversion string"); END END + /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 366 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ ex_buf_length = 0; @@ -217,6 +228,7 @@ BEGIN * Here's where we actually go through the string and do the case * conversion. ***************************************************************************/ + BEGIN brace_level = 0; ex_buf_ptr = 0; @@ -262,6 +274,7 @@ BEGIN * will do reasonably well if there is other stuff, too, between braces, * but it doesn't try to do anything special with |colon|s. ***************************************************************************/ + BEGIN INCR (ex_buf_ptr); while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)) @@ -285,6 +298,7 @@ BEGIN * the consecutive alphabetic characters following the |backslash|; it * might be empty (although ones in this section aren't). ***************************************************************************/ + BEGIN switch (conversion_type) BEGIN @@ -297,8 +311,9 @@ BEGIN case N_OE_UPPER: case N_AE_UPPER: case N_AA_UPPER: - lower_case (ex_buf, ex_buf_xptr, - ex_buf_ptr - ex_buf_xptr); + + ex_buf_ptr=ex_buf_xptr+lower_case_uni(ex_buf, ex_buf_xptr,ex_buf_ptr - ex_buf_xptr); + break; default: DO_NOTHING; @@ -313,8 +328,10 @@ BEGIN case N_OE: case N_AE: case N_AA: - upper_case (ex_buf, ex_buf_xptr, + + ex_buf_ptr=ex_buf_xptr+upper_case_uni (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + break; case N_I: case N_J: @@ -326,9 +343,12 @@ BEGIN * After converting the control sequence, we need to remove the preceding * |backslash| and any following |white_space|. ***************************************************************************/ + BEGIN - upper_case (ex_buf, ex_buf_xptr, + + ex_buf_ptr=ex_buf_xptr+ upper_case_uni (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + while (ex_buf_xptr < ex_buf_ptr) BEGIN ex_buf[ex_buf_xptr - 1] = ex_buf[ex_buf_xptr]; @@ -350,6 +370,7 @@ BEGIN ex_buf_length = tmp_ptr - (ex_buf_ptr - ex_buf_xptr); ex_buf_ptr = ex_buf_xptr; END + /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 374 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ break; @@ -366,6 +387,7 @@ BEGIN break; END END + /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 372 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ ex_buf_xptr = ex_buf_ptr; @@ -389,15 +411,18 @@ BEGIN * There are no control sequences in what we're about to convert, * so a straight conversion suffices. ***************************************************************************/ + switch (conversion_type) BEGIN case TITLE_LOWERS: case ALL_LOWERS: - lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + ex_buf_ptr = ex_buf_xptr + lower_case_uni(ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr);//printf(" 375 "); + break; case ALL_UPPERS: - upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); - break; + ex_buf_ptr=ex_buf_xptr+ upper_case_uni (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + + break; case BAD_CONVERSION: DO_NOTHING; break; @@ -405,10 +430,12 @@ BEGIN case_conversion_confusion (); break; END + /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 375 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ END DECR (ex_buf_ptr); + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -427,13 +454,37 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; * This code does any needed conversion for an ordinary character; it * won't touch nonletters. ***************************************************************************/ + BEGIN switch (conversion_type) BEGIN case TITLE_LOWERS: +/* +For the case of TITLE_LOWERS, we transform the characters to low case except the first +character. When it's UTF-8, we should care about the length of charater. 23/sep/2009 +*/ + if (ex_buf_ptr == 0) BEGIN - DO_NOTHING; + if(ex_buf[ex_buf_ptr] <= 0x7F) + BEGIN + END + else if((ex_buf[ex_buf_ptr] >= 0xC2) && (ex_buf[ex_buf_ptr] <= 0xDF)) + BEGIN + ex_buf_ptr=1; + END + else if((ex_buf[ex_buf_ptr] >= 0xE0) && (ex_buf[ex_buf_ptr] <= 0xEF)) + BEGIN + ex_buf_ptr=2; + END + else if((ex_buf[ex_buf_ptr] >= 0xF0) && (ex_buf[ex_buf_ptr] <= 0xF4)) + BEGIN + ex_buf_ptr=3; + END + else + BEGIN + printf("this isn't a right UTF-8 char!"); + END END else if ((prev_colon) && (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE)) @@ -442,7 +493,19 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; END else BEGIN - lower_case (ex_buf, ex_buf_ptr, 1); +/* +When we do lower_case_uni, the length of string have been changed. So we should do some job +for the precessing after lower case. Here there may be some potential bug. 23/sep/2009 +*/ + int16_t i=ex_buf_ptr; + int16_t llen; + while ((ex_buf[i] != COLON) && (ex_buf[i] != WHITE_SPACE) && (i< ex_buf_length)) + BEGIN + i++; + END + llen=(i-ex_buf_ptr); + ex_buf_ptr=ex_buf_length-1+lower_case_uni (ex_buf, ex_buf_ptr, llen)+ex_buf_ptr; + END if (ex_buf[ex_buf_ptr] == COLON) BEGIN @@ -454,11 +517,38 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; END break; case ALL_LOWERS: - lower_case (ex_buf, ex_buf_ptr, 1); + BEGIN +/* +Here the same for processing the length of string after change case. 23/sep/2009 +*/ + int16_t i=ex_buf_ptr; + int16_t llen; + while ((ex_buf[i] != COLON) && (ex_buf[i] != WHITE_SPACE) && (i< ex_buf_length)) + BEGIN + i++; + END + llen=(i-ex_buf_ptr+1); + ex_buf_ptr=ex_buf_ptr-1+lower_case_uni (ex_buf, ex_buf_ptr, llen); + break; + END case ALL_UPPERS: - upper_case (ex_buf, ex_buf_ptr, 1); + BEGIN +/* +Here the same for processing the length of string after change case. 23/sep/2009 +*/ + int16_t i=ex_buf_ptr; + int16_t ulen; + while ((ex_buf[i] != COLON) && (ex_buf[i] != WHITE_SPACE) && (i< ex_buf_length)) + BEGIN + i++; + END + ulen=(i-ex_buf_ptr+1); + ex_buf_ptr=ex_buf_ptr-1+upper_case_uni (ex_buf, ex_buf_ptr, ulen); + + break; + END case BAD_CONVERSION: DO_NOTHING; break; @@ -466,16 +556,19 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; case_conversion_confusion (); break; END + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 376 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ INCR (ex_buf_ptr); END check_brace_level (pop_lit2); + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 370 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - add_pool_buf_and_push (); + add_pool_buf_and_push (); + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 364 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -498,6 +591,7 @@ BEGIN if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (0, STK_INT); END else if (LENGTH (pop_lit1) != 1) @@ -505,10 +599,12 @@ BEGIN PRINT ("\""); PRINT_POOL_STR (pop_lit1); BST_EX_WARN ("\" isn't a single character"); + push_lit_stk (0, STK_INT); END else BEGIN + push_lit_stk (str_pool[str_start[pop_lit1]], STK_INT); END END @@ -531,6 +627,16 @@ BEGIN END else BEGIN +/* if ((ex_buf[0]== 0xC3) && (ex_buf[1] != 0xA9)) && (ex_buf[1] != 0xA9)){ + printf(" AFTER 378,here is 0XC3"); + int iiii=0; + + while (iiii < ex_buf_length) + { + printf("%c",ex_buf[iiii]);INCR (iiii); + } + } +*/ push_lit_stk (CUR_CITE_STR, STK_STR); END END @@ -555,11 +661,13 @@ BEGIN if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (s_null, STK_STR); END else if (pop_typ2 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); + push_lit_stk (s_null, STK_STR); END else @@ -585,6 +693,7 @@ BEGIN END else if (LENGTH (pop_lit2) == 0) BEGIN + push_lit_stk (pop_lit1, STK_STR); END else @@ -598,7 +707,7 @@ BEGIN APPEND_CHAR (str_pool[sp_ptr]); INCR (sp_ptr); END - push_lit_stk (make_string (), STK_STR); + push_lit_stk (make_string (), STK_STR); END END else @@ -643,6 +752,7 @@ BEGIN INCR (sp_ptr); END pool_ptr = pool_ptr + sp_length; + push_lit_stk (make_string (), STK_STR); END END @@ -660,6 +770,7 @@ BEGIN END else if (LENGTH (pop_lit2) == 0) BEGIN + push_lit_stk (pop_lit1, STK_STR); END else @@ -679,7 +790,7 @@ BEGIN APPEND_CHAR (str_pool[sp_ptr]); INCR (sp_ptr); END - push_lit_stk (make_string (), STK_STR); + push_lit_stk (make_string (), STK_STR); END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 353 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -705,9 +816,14 @@ END void x_duplicate (void) BEGIN pop_lit_stk (&pop_lit1, &pop_typ1); + + if (pop_typ1 != STK_STR) BEGIN + + push_lit_stk (pop_lit1, pop_typ1); + push_lit_stk (pop_lit1, pop_typ1); END else @@ -715,7 +831,7 @@ BEGIN REPUSH_STRING; if (pop_lit1 < cmd_str_ptr) BEGIN - push_lit_stk (pop_lit1, pop_typ1); + push_lit_stk (pop_lit1, pop_typ1); END else BEGIN @@ -727,6 +843,7 @@ BEGIN APPEND_CHAR (str_pool[sp_ptr]); INCR (sp_ptr); END + push_lit_stk (make_string (), STK_STR); END END @@ -765,25 +882,30 @@ BEGIN BEGIN if (lex_class[str_pool[sp_ptr]] != WHITE_SPACE) BEGIN + push_lit_stk (0, STK_INT); goto Exit_Label; END INCR (sp_ptr); END + push_lit_stk (1, STK_INT); END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 381 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ break; case STK_FIELD_MISSING: + push_lit_stk (1, STK_INT); break; case STK_EMPTY: + push_lit_stk (0, STK_INT); break; default: print_stk_lit (pop_lit1, pop_typ1); BST_EX_WARN (", not a string or missing field,"); + push_lit_stk (0, STK_INT); break; END @@ -816,6 +938,7 @@ BEGIN PRINT_NEWLINE; BST_EX_WARN ("---they aren't the same literal types"); END + push_lit_stk (0, STK_INT); END else if ((pop_typ1 != STK_INT) && (pop_typ1 != STK_STR)) @@ -825,25 +948,30 @@ BEGIN print_stk_lit (pop_lit1, pop_typ1); BST_EX_WARN (", not an integer or a string,"); END + push_lit_stk (0, STK_INT); END else if (pop_typ1 == STK_INT) BEGIN if (pop_lit2 == pop_lit1) BEGIN + push_lit_stk (1, STK_INT); END else BEGIN + push_lit_stk (0, STK_INT); END END else if (str_eq_str (pop_lit2, pop_lit1)) BEGIN + push_lit_stk (1, STK_INT); END else BEGIN + push_lit_stk (0, STK_INT); END END @@ -869,19 +997,24 @@ BEGIN pop_lit_stk (&pop_lit1, &pop_typ1); pop_lit_stk (&pop_lit2, &pop_typ2); pop_lit_stk (&pop_lit3, &pop_typ3); + + if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (s_null, STK_STR); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (s_null, STK_STR); END else if (pop_typ3 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR); + push_lit_stk (s_null, STK_STR); END else @@ -1238,7 +1371,10 @@ Loop1_Exit_Label: DO_NOTHING; ex_buf_length = 0; add_buf_pool (pop_lit1); figure_out_the_formatted_name (); + + add_pool_buf_and_push (); + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 382 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1318,10 +1454,14 @@ BEGIN while (sp_ptr < sp_xptr1) BEGIN ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = str_pool[sp_ptr]; + + + INCR (ent_chr_ptr); INCR (sp_ptr); END ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = END_OF_STRING; + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 357 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1418,19 +1558,23 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_lit2 > pop_lit1) BEGIN + push_lit_stk (1, STK_INT); END else BEGIN + push_lit_stk (0, STK_INT); END END @@ -1454,11 +1598,13 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (s_null, STK_STR); END else if ((pop_lit1 < 0) || (pop_lit1 > 127)) BEGIN BST_EX_WARN2 ("%ld isn't valid ASCII", (long) pop_lit1); + push_lit_stk (s_null, STK_STR); END else @@ -1487,12 +1633,15 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (s_null, STK_STR); END else BEGIN int_to_ASCII (pop_lit1, ex_buf, 0, &ex_buf_length); + add_pool_buf_and_push (); + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 423 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1515,19 +1664,23 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_lit2 < pop_lit1) BEGIN + push_lit_stk (1, STK_INT); END else BEGIN + push_lit_stk (0, STK_INT); END END @@ -1551,15 +1704,18 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (0, STK_INT); END else BEGIN + push_lit_stk (pop_lit2 - pop_lit1, STK_INT); END END @@ -1591,14 +1747,17 @@ BEGIN print_stk_lit (pop_lit1, pop_typ1); BST_EX_WARN (", not a string or missing field,"); END + push_lit_stk (0, STK_INT); END else if (pop_typ1 == STK_FIELD_MISSING) BEGIN + push_lit_stk (1, STK_INT); END else BEGIN + push_lit_stk (0, STK_INT); END END @@ -1623,6 +1782,7 @@ BEGIN if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (0, STK_INT); END else @@ -1648,6 +1808,7 @@ BEGIN END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 427 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + push_lit_stk (num_names, STK_INT); END END @@ -1669,15 +1830,18 @@ BEGIN if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (0, STK_INT); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (0, STK_INT); END else BEGIN + push_lit_stk (pop_lit2 + pop_lit1, STK_INT); END END @@ -1702,7 +1866,9 @@ BEGIN add_buf_pool (s_preamble[preamble_ptr]); INCR (preamble_ptr); END + add_pool_buf_and_push (); + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 429 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1722,10 +1888,12 @@ END ***************************************************************************/ void x_purify (void) BEGIN + pop_lit_stk (&pop_lit1, &pop_typ1); if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (s_null, STK_STR); END else @@ -1733,6 +1901,7 @@ BEGIN ex_buf_length = 0; add_buf_pool (pop_lit1); + /*************************************************************************** * WEB section number: 431 * ~~~~~~~~~~~~~~~~~~~ @@ -1758,9 +1927,47 @@ BEGIN break; case ALPHA: case NUMERIC: - BEGIN +/* +When we processe the character UTF-8, the length has been changed. This focntion is used in +quick_sort. 23/sep/2009 +*/ + + BEGIN + if(ex_buf[ex_buf_ptr] <= 0x7F) + BEGIN + + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; + INCR (ex_buf_xptr); + END + else if((ex_buf[ex_buf_ptr] >= 0xC2) && (ex_buf[ex_buf_ptr] <= 0xDF)) + BEGIN + + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; + INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + END + else if((ex_buf[ex_buf_ptr] >= 0xE0) && (ex_buf[ex_buf_ptr] <= 0xEF)) + BEGIN + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + END + else if((ex_buf[ex_buf_ptr] >= 0xF0) && (ex_buf[ex_buf_ptr] <= 0xF4)) + BEGIN + + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; + INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + INCR (ex_buf_xptr); + END + else + BEGIN + printf("this isn't a right UTF-8 char!"); + END + END break; default: @@ -1782,7 +1989,7 @@ BEGIN * |sep_char|s). ***************************************************************************/ BEGIN - INCR (ex_buf_ptr); + INCR (ex_buf_ptr); while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)) BEGIN INCR (ex_buf_ptr); @@ -1806,6 +2013,7 @@ BEGIN * characters. ***************************************************************************/ BEGIN + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_yptr]; INCR (ex_buf_xptr); switch (ilk_info[control_seq_loc]) @@ -1824,6 +2032,7 @@ BEGIN DO_NOTHING; break; END + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 433 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1854,6 +2063,7 @@ BEGIN END END DECR (ex_buf_ptr); + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 432 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1871,10 +2081,13 @@ BEGIN INCR (ex_buf_ptr); END ex_buf_length = ex_buf_xptr; + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 431 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + add_pool_buf_and_push (); + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 430 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -1912,30 +2125,52 @@ END * Note: If |sp_length| is compared with a signed quantity (e.g. pop_lit2), * must be first cast to |Integer_T| because it is an UNSIGNED variable. ***************************************************************************/ + +/* +This is a new code of x_substring for processing the character UTF-8. +We transform the character to Unicode and then get the substring, then +back to UTF-8. 23/sep/2009 +*/ + void x_substring (void) BEGIN + pop_lit_stk (&pop_lit1, &pop_typ1); pop_lit_stk (&pop_lit2, &pop_typ2); pop_lit_stk (&pop_lit3, &pop_typ3); + + if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (s_null, STK_STR); END else if (pop_typ2 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (s_null, STK_STR); END else if (pop_typ3 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR); + push_lit_stk (s_null, STK_STR); END else BEGIN - sp_length = LENGTH (pop_lit3); + + Integer_T str_length = LENGTH (pop_lit3); + + + UChar uchs[BUF_SIZE+1]; + int32_t utcap = BUF_SIZE+1; + + int32_t ulen = icu_toUChars(str_pool,str_start[pop_lit3],str_length,uchs, utcap); + sp_length = ulen; + if (pop_lit1 >= (Integer_T) sp_length) BEGIN if ((pop_lit2 == 1) || (pop_lit2 == -1)) @@ -1949,6 +2184,7 @@ BEGIN || (pop_lit2 > (Integer_T) sp_length) || (pop_lit2 < -(Integer_T) sp_length)) BEGIN + push_lit_stk (s_null, STK_STR); goto Exit_Label; END @@ -1963,12 +2199,29 @@ BEGIN BEGIN if (pop_lit2 > 0) BEGIN + unsigned char frUch1[BUF_SIZE+1]; + int32_t frUchCap = BUF_SIZE + 1; + int32_t lenfrUch = icu_fromUChars(frUch1, frUchCap, &uchs[pop_lit2-1], pop_lit1); + unsigned char frUch2[BUF_SIZE+1]; + int32_t ptrfrUch = icu_fromUChars(frUch2, frUchCap, uchs, pop_lit2-1); + if (pop_lit1 > (sp_length - (pop_lit2 - 1))) BEGIN pop_lit1 = sp_length - (pop_lit2 - 1); END sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1); sp_end = sp_ptr + pop_lit1; + + + frUchCap = BUF_SIZE + 1; + lenfrUch = icu_fromUChars(frUch1, frUchCap, &uchs[pop_lit2-1], pop_lit1); + + + ptrfrUch = icu_fromUChars(frUch2, frUchCap, uchs, pop_lit2-1); + sp_ptr = str_start[pop_lit3] + ptrfrUch; + sp_end = sp_ptr + lenfrUch; + + if (pop_lit2 == 1) BEGIN if (pop_lit3 >= cmd_str_ptr) @@ -1982,6 +2235,12 @@ BEGIN END else BEGIN + unsigned char frUch1[BUF_SIZE+1]; + int32_t frUchCap = BUF_SIZE + 1; + int32_t lenfrUch = icu_fromUChars(frUch1, frUchCap, &uchs[ulen - (pop_lit2-1) - pop_lit1], pop_lit1); + unsigned char frUch2[BUF_SIZE+1]; + int32_t ptrfrUch = icu_fromUChars(frUch2, frUchCap, &uchs[ulen - pop_lit2], pop_lit2-1); + pop_lit2 = -pop_lit2; if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1))) BEGIN @@ -1989,13 +2248,28 @@ BEGIN END sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1); sp_ptr = sp_end - pop_lit1; + + + frUchCap = BUF_SIZE + 1; + lenfrUch = icu_fromUChars(frUch1, frUchCap, &uchs[ulen - (pop_lit2-1) - pop_lit1], pop_lit1); + + + ptrfrUch = icu_fromUChars(frUch2, frUchCap, &uchs[ulen - pop_lit2], pop_lit2-1); + sp_ptr = str_start[pop_lit3] + ptrfrUch; + + sp_end = str_start[pop_lit3 + 1] - ptrfrUch; + sp_ptr = sp_end - lenfrUch; + + END + while (sp_ptr < sp_end) BEGIN APPEND_CHAR (str_pool[sp_ptr]); INCR (sp_ptr); END - push_lit_stk (make_string (), STK_STR); + + push_lit_stk (make_string(), STK_STR); END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 438 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2004,6 +2278,101 @@ Exit_Label: DO_NOTHING; END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 437 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/* +Here is the original code of "x_substring". We just reserver ot but ont to use +it. 23/sep/2009 +*/ +void x_substring_uni (void) +BEGIN + + pop_lit_stk (&pop_lit1, &pop_typ1); + pop_lit_stk (&pop_lit2, &pop_typ2); + pop_lit_stk (&pop_lit3, &pop_typ3); + if (pop_typ1 != STK_INT) + BEGIN + print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (s_null, STK_STR); + END + else if (pop_typ2 != STK_INT) + BEGIN + print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT); + push_lit_stk (s_null, STK_STR); + END + else if (pop_typ3 != STK_STR) + BEGIN + print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR); + push_lit_stk (s_null, STK_STR); + END + else + BEGIN + sp_length = LENGTH (pop_lit3); + if (pop_lit1 >= (Integer_T) sp_length) + BEGIN + if ((pop_lit2 == 1) || (pop_lit2 == -1)) + BEGIN + REPUSH_STRING; + goto Exit_Label; + END + END + + if ((pop_lit1 <= 0) || (pop_lit2 == 0) + || (pop_lit2 > (Integer_T) sp_length) + || (pop_lit2 < -(Integer_T) sp_length)) + BEGIN + push_lit_stk (s_null, STK_STR); + goto Exit_Label; + END + else + +/*************************************************************************** + * WEB section number: 438 + * ~~~~~~~~~~~~~~~~~~~ + * This module finds the substring as described in the last section, + * and slides it into place in the string pool, if necessary. + ***************************************************************************/ + BEGIN + if (pop_lit2 > 0) + BEGIN + if (pop_lit1 > (sp_length - (pop_lit2 - 1))) + BEGIN + pop_lit1 = sp_length - (pop_lit2 - 1); + END + sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1); + sp_end = sp_ptr + pop_lit1; + if (pop_lit2 == 1) + BEGIN + if (pop_lit3 >= cmd_str_ptr) + BEGIN + str_start[pop_lit3 + 1] = sp_end; + UNFLUSH_STRING; + INCR (lit_stk_ptr); + goto Exit_Label; + END + END + END + else + BEGIN + pop_lit2 = -pop_lit2; + if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1))) + BEGIN + pop_lit1 = sp_length - (pop_lit2 - 1); + END + sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1); + sp_ptr = sp_end - pop_lit1; + END + + while (sp_ptr < sp_end) + BEGIN + APPEND_CHAR (str_pool[sp_ptr]); + INCR (sp_ptr); + END + push_lit_stk (make_string (), STK_STR); + END +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 438 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + + END +Exit_Label: DO_NOTHING; +END /*************************************************************************** @@ -2018,17 +2387,20 @@ BEGIN pop_lit_stk (&pop_lit2, &pop_typ2); if ((pop_typ1 != STK_STR) || (pop_lit1 < cmd_str_ptr)) BEGIN + push_lit_stk (pop_lit1, pop_typ1); if ((pop_typ2 == STK_STR) && (pop_lit2 >= cmd_str_ptr)) BEGIN UNFLUSH_STRING; END - push_lit_stk (pop_lit2, pop_typ2); + push_lit_stk (pop_lit2, pop_typ2); END else if ((pop_typ2 != STK_STR) || (pop_lit2 < cmd_str_ptr)) BEGIN UNFLUSH_STRING; + push_lit_stk (pop_lit1, STK_STR); + push_lit_stk (pop_lit2, pop_typ2); END else @@ -2049,8 +2421,11 @@ BEGIN APPEND_CHAR (str_pool[sp_ptr]); INCR (sp_ptr); END + push_lit_stk (make_string (), STK_STR); + add_pool_buf_and_push (); + END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 440 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2073,9 +2448,14 @@ END void x_text_length (void) BEGIN pop_lit_stk (&pop_lit1, &pop_typ1); + + + + if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (s_null, STK_STR); END else @@ -2096,6 +2476,7 @@ BEGIN sp_brace_level = 0; while (sp_ptr < sp_end) BEGIN + INCR (sp_ptr); if (str_pool[sp_ptr - 1] == LEFT_BRACE) BEGIN @@ -2117,7 +2498,38 @@ BEGIN END INCR (sp_ptr); END + +/* +The length of character of UTF-8 is different. 23/sep/2009 +*/ + if (str_pool[sp_ptr]<= 0x7F) + BEGIN + + END + else if((str_pool[sp_ptr] >= 0xC2) && (str_pool[sp_ptr] <= 0xDF)) + BEGIN + INCR (sp_ptr); + + END + else if((str_pool[sp_ptr] >= 0xE0) && (str_pool[sp_ptr] <= 0xEF)) + BEGIN + INCR (sp_ptr); + INCR (sp_ptr); + + END + else if((str_pool[sp_ptr] >= 0xF0) && (str_pool[sp_ptr] <= 0xF4)) + BEGIN + INCR (sp_ptr); + INCR (sp_ptr); + INCR (sp_ptr); + + END + else + BEGIN + printf("this isn't a right UTF-8 char!\n"); + END INCR (num_text_chars); + END END END @@ -2130,12 +2542,42 @@ BEGIN END else BEGIN +/* +The same for the length of character. 23/sep/2009 +*/ + if (str_pool[sp_ptr-1]<= 0x7F) + BEGIN + + END + else if((str_pool[sp_ptr-1] >= 0xC2) && (str_pool[sp_ptr-1] <= 0xDF)) + BEGIN + INCR (sp_ptr); + + END + else if((str_pool[sp_ptr-1] >= 0xE0) && (str_pool[sp_ptr-1] <= 0xEF)) + BEGIN + INCR (sp_ptr); + INCR (sp_ptr); + + END + else if((str_pool[sp_ptr-1] >= 0xF0) && (str_pool[sp_ptr-1] <= 0xF4)) + BEGIN + INCR (sp_ptr); + INCR (sp_ptr); + INCR (sp_ptr); + + END + else + BEGIN + printf("this isn't a right UTF-8 char!\n"); + END INCR (num_text_chars); END + END END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 442 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - + push_lit_stk (num_text_chars, STK_INT); END END @@ -2162,20 +2604,27 @@ END ***************************************************************************/ void x_text_prefix (void) BEGIN + pop_lit_stk (&pop_lit1, &pop_typ1); pop_lit_stk (&pop_lit2, &pop_typ2); + + + if (pop_typ1 != STK_INT) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT); + push_lit_stk (s_null, STK_STR); END else if (pop_typ2 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR); + push_lit_stk (s_null, STK_STR); END else if (pop_lit1 <= 0) BEGIN + push_lit_stk (s_null, STK_STR); goto Exit_Label; END @@ -2191,6 +2640,7 @@ BEGIN sp_ptr = str_start[pop_lit2]; sp_end = str_start[pop_lit2 + 1]; + /*************************************************************************** * WEB section number: 445 * ~~~~~~~~~~~~~~~~~~~ @@ -2226,6 +2676,36 @@ BEGIN END INCR (sp_xptr1); END + +/* +The same for the length of character UTF-8. 23/sep/2009 +*/ + if (str_pool[sp_xptr1]<= 0x7F) + BEGIN + + END + else if((str_pool[sp_xptr1] >= 0xC2) && (str_pool[sp_xptr1] <= 0xDF)) + BEGIN + INCR (sp_xptr1); + + END + else if((str_pool[sp_xptr1] >= 0xE0) && (str_pool[sp_xptr1] <= 0xEF)) + BEGIN + INCR (sp_xptr1); + INCR (sp_xptr1); + + END + else if((str_pool[sp_xptr1] >= 0xF0) && (str_pool[sp_xptr1] <= 0xF4)) + BEGIN + INCR (sp_xptr1); + INCR (sp_xptr1); + INCR (sp_xptr1); + + END + else + BEGIN + printf("this isn't a right UTF-8 char!\n"); + END INCR (num_text_chars); END END @@ -2239,6 +2719,35 @@ BEGIN END else BEGIN +/* +The same for the length of character UTF-8. 23/sep/2009 +*/ + if (str_pool[sp_xptr1-1]<= 0x7F) + BEGIN + + END + else if((str_pool[sp_xptr1-1] >= 0xC2) && (str_pool[sp_xptr1-1] <= 0xDF)) + BEGIN + INCR (sp_xptr1); + + END + else if((str_pool[sp_xptr1-1] >= 0xE0) && (str_pool[sp_xptr1-1] <= 0xEF)) + BEGIN + INCR (sp_xptr1); + INCR (sp_xptr1); + + END + else if((str_pool[sp_xptr1-1] >= 0xF0) && (str_pool[sp_xptr1-1] <= 0xF4)) + BEGIN + INCR (sp_xptr1); + INCR (sp_xptr1); + INCR (sp_xptr1); + + END + else + BEGIN + printf("this isn't a right UTF-8 char!\n"); + END INCR (num_text_chars); END END @@ -2263,6 +2772,7 @@ BEGIN APPEND_CHAR (RIGHT_BRACE); DECR (sp_brace_level); END + push_lit_stk (make_string (), STK_STR); END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 444 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2289,10 +2799,12 @@ BEGIN else if ((type_list[cite_ptr] == UNDEFINED) || (type_list[cite_ptr] == EMPTY)) BEGIN + push_lit_stk (s_null, STK_STR); END else BEGIN + push_lit_stk (hash_text[type_list[cite_ptr]], STK_STR); END END @@ -2345,6 +2857,7 @@ BEGIN if (pop_typ1 != STK_STR) BEGIN print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR); + push_lit_stk (0, STK_INT); END else @@ -2489,7 +3002,7 @@ BEGIN check_brace_level (pop_lit1); END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - + push_lit_stk (string_width, STK_INT); END END -- cgit v1.2.3