diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-03-19 08:15:26 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-03-19 08:15:26 +0000 |
commit | 151a7146c6cc3ef5413a600e6145037af4fa63f1 (patch) | |
tree | 5f981b664fb6b2f868dd632b1cd3947dcd55818c /Build/source | |
parent | 6da10d8e2ab5bd73ba2de9c53b957bb33366ee77 (diff) |
bibtex8 and bibtexu: use identical C code
git-svn-id: svn://tug.org/texlive/trunk@29431 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
22 files changed, 886 insertions, 353 deletions
diff --git a/Build/source/texk/bibtex8/ChangeLog b/Build/source/texk/bibtex8/ChangeLog index b8fa9ee7a0d..8976873c912 100644 --- a/Build/source/texk/bibtex8/ChangeLog +++ b/Build/source/texk/bibtex8/ChangeLog @@ -1,3 +1,11 @@ +2013-03-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + * bibtex-2.c: Use char_less_than and char_greater_than macros. + + Remove diffs with bibtexu. + * bibtex-[234].c, bibtex.[ch], gblprocs.h, gblvars.h, utils.c: + Add '#ifdef UTF_8 <bibtexu code> #endif'. + 2013-02-08 Peter Breitenlohner <peb@mppmu.mpg.de> * Makefile.am (btdocdir): Change texmf => texmf-dist. diff --git a/Build/source/texk/bibtex8/bibtex-2.c b/Build/source/texk/bibtex8/bibtex-2.c index 546ae15c64a..5280e408d05 100644 --- a/Build/source/texk/bibtex8/bibtex-2.c +++ b/Build/source/texk/bibtex8/bibtex-2.c @@ -923,10 +923,29 @@ BEGIN name_bf_xptr = name_tok[cur_token + 1]; while (name_bf_ptr < name_bf_xptr) BEGIN +#ifdef UTF_8 +/* +For output the first character which is encodage UTF-8, we sould discuter different length of character. 23/sep/2009 +*/ + if((lex_class[NAME_BUF[name_bf_ptr]] != WHITE_SPACE) && (NAME_BUF[name_bf_ptr] != LEFT_BRACE)) + BEGIN + DO_UTF8(NAME_BUF[name_bf_ptr], + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]), + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]), + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]), + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]); + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+3])); +#else if (lex_class[NAME_BUF[name_bf_ptr]] == ALPHA) BEGIN APPEND_EX_BUF_CHAR_AND_CHECK ( NAME_BUF[name_bf_ptr]); +#endif goto Loop_Exit_Label; END else if ((NAME_BUF[name_bf_ptr] == LEFT_BRACE) @@ -2907,15 +2926,49 @@ END ***************************************************************************/ Boolean_T less_than (CiteNumber_T arg1, CiteNumber_T arg2) BEGIN - Boolean_T less_than; - Integer_T char_ptr; StrEntLoc_T ptr1, ptr2; +#ifdef UTF_8 +/* +We use ICU libs to processing UTF-8. First, we have to transform UTF-8 to +Unicode/UChar with the fonction icu_UCHars. Then we use the UCollator +in the ICU libs to conparer the Unicode. There is an option "location", +we use "-o" to indicate the rule of conpare. 23/sep/2009 +*/ + Integer_T lenk1, lenk2; + UChar uch1[BUF_SIZE+1], uch2[BUF_SIZE+1]; + UBool u_less; + UCollator * ucol1; + int32_t ucap = BUF_SIZE+1; + int32_t uchlen1, uchlen2; + UErrorCode err1 = U_ZERO_ERROR; +#else + Boolean_T less_than; + Integer_T char_ptr; ASCIICode_T char1, char2; +#endif ptr1 = (arg1 * num_ent_strs) + sort_key_num; ptr2 = (arg2 * num_ent_strs) + sort_key_num; +#ifdef UTF_8 + lenk1 = strlen((char *)&ENTRY_STRS(ptr1, 0)); + lenk2 = strlen((char *)&ENTRY_STRS(ptr2, 0)); + + uchlen1 = icu_toUChars(entry_strs, (ptr1 * (ENT_STR_SIZE+1)), lenk1, uch1, ucap); + uchlen2 = icu_toUChars(entry_strs, (ptr2 * (ENT_STR_SIZE+1)), lenk2, uch2, ucap); + + if(Flag_location) + ucol1 = ucol_open(Str_location, &err1); + else + ucol1 = ucol_open(NULL, &err1); + if (!U_SUCCESS(err1)) + printf("there is a error: U_ZERO_ERROR, open a ucol."); + u_less = !ucol_greaterOrEqual(ucol1, uch1, uchlen1, uch2, uchlen2); + + ucol_close(ucol1); + return u_less; +#else char_ptr = 0; LOOP BEGIN @@ -2947,8 +3000,6 @@ BEGIN BEGIN COMPARE_RETURN (FALSE); END - -#ifdef SUPPORT_8BIT else if char_less_than(char1, char2) BEGIN COMPARE_RETURN (TRUE); @@ -2957,21 +3008,11 @@ BEGIN BEGIN COMPARE_RETURN (FALSE); END -#else /* NOT SUPPORT_8BIT */ - else if (char1 < char2) - BEGIN - COMPARE_RETURN (TRUE); - END - else if (char1 > char2) - BEGIN - COMPARE_RETURN (FALSE); - END -#endif /* SUPPORT_8BIT */ - INCR (char_ptr); END Exit_Label: return (less_than); +#endif END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -3010,8 +3051,147 @@ BEGIN END END END -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#ifdef UTF_8 +/* +"lower_case_uni" is the fonction for processing the characters, actually the UTF-8. +We transform UTF-8 to Unicode, then to low case, then back to UTF-8 for output. +When we transform the character, the length have been changed. So we have do +some job for the length. And the output of this fonction we should be careful +to the length. 23/sep/2009 +*/ +BufPointer_T lower_case_uni (BufType_T buf, BufPointer_T bf_ptr, + BufPointer_T len) +BEGIN + + UChar target[BUF_SIZE+1]; + int32_t tarcap=BUF_SIZE+1; + int32_t tarlen = icu_toUChars(buf, bf_ptr, len, target, tarcap); + + UChar tarlow[BUF_SIZE+1]; + int32_t tlcap=BUF_SIZE+1; + int32_t tllen=icu_strToLower(tarlow, tlcap,target, tarlen); + + unsigned char dest[BUF_SIZE+1]; + int32_t destcap= BUF_SIZE-bf_ptr; + + int32_t tblen=icu_fromUChars(dest, destcap, (const UChar *) tarlow, tllen); + + BufPointer_T i; + if (tblen > 0) + BEGIN + if (len!=tblen) + BEGIN + unsigned char tmp[BUF_SIZE+1]; + BufPointer_T tmppr=0; + for (i=bf_ptr+len;i<=(BUF_SIZE-tblen+len);i++) + BEGIN + tmp[tmppr]=buf[i]; + tmppr++; + END + i=bf_ptr+tblen; + tmppr=0; + for (tmppr=0;tmppr<=(BUF_SIZE-bf_ptr-tblen);tmppr++) + BEGIN + buf[i]=tmp[tmppr]; + i++; + END + END + for (i = 0; i <= (tblen - 1); i++) + BEGIN + + buf[i+bf_ptr]=dest[i]; + + END + END + + return tblen; +END + + +/* +This fonction is for transform UTF-8 to Unicode with ICU libs. 23/sep/2009 +*/ +int32_t icu_toUChars(BufType_T buf, BufPointer_T bf_ptr,BufPointer_T len,UChar * target, int32_t tarcap) +BEGIN + UConverter * ucon1; + UErrorCode err1 = U_ZERO_ERROR; + ucon1 = ucnv_open(NULL, &err1); + if (!U_SUCCESS(err1)) + BEGIN + printf("1there is a error: U_ZERO_ERROR"); + END + ucnv_toUChars(ucon1, target, tarcap, (char *)&buf[bf_ptr], len, &err1); + if (!U_SUCCESS(err1)) + BEGIN + printf("2there is a error: U_ZERO_ERROR"); + END + + return len; +END + +/* +This fonction is for transform Unicode string to low case. 23/sep/2009 +*/ +int32_t icu_strToLower(UChar * tarlow, int32_t tlcap, UChar * target, int32_t tarlen) +BEGIN + int32_t tllen; + UErrorCode err1 = U_ZERO_ERROR; + if (!U_SUCCESS(err1)) + BEGIN + printf("3there is a error: U_ZERO_ERROR"); + END + if (Flag_language) + { + tllen=u_strToLower(tarlow,tlcap, target,tarlen,Str_language,&err1); + } + else + { + tllen=u_strToLower(tarlow,tlcap, target,tarlen,NULL,&err1); + } + if (!U_SUCCESS(err1)) + BEGIN + int16_t i=0; + printf("4there is a error: U_ZERO_ERROR"); + for (i=0;i<tarlen;i++) + BEGIN + printf("%X", target[i]); + END + printf("\n"); + for (i=0;i<tllen;i++) + BEGIN + printf("%X", tarlow[i]); + END + printf("\n"); + END + + return tllen; +END + + +/* +This fonction is for transform Unicode to UTF-8. 23/sep/2009 +*/ +int32_t icu_fromUChars(unsigned char * dest, int32_t destcap, const UChar * src, int32_t srclen) +BEGIN + UConverter * ucon2; + UErrorCode err2 = U_ZERO_ERROR; + int32_t tblen; + ucon2 = ucnv_open(NULL, &err2); + if (!U_SUCCESS(err2)) + BEGIN + printf("5there is a error: U_ZERO_ERROR"); + END + tblen=ucnv_fromUChars(ucon2, (char *)dest, destcap, src, srclen, &err2); + if (!U_SUCCESS(err2)) + BEGIN + printf("6there is a error: U_ZERO_ERROR"); + END + + return tblen; +END +#endif +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ diff --git a/Build/source/texk/bibtex8/bibtex-3.c b/Build/source/texk/bibtex8/bibtex-3.c index b7129558c11..629e91c4914 100644 --- a/Build/source/texk/bibtex8/bibtex-3.c +++ b/Build/source/texk/bibtex8/bibtex-3.c @@ -3055,6 +3055,7 @@ END * This system-independent procedure is the same as the previous except * that it converts lower- to upper-case letters. ***************************************************************************/ +#ifndef UTF_8 void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) BEGIN @@ -3080,6 +3081,79 @@ BEGIN END END END +#else +/* +This foction "upper_case_uni" is for prcessing the character UTF-8. +It's like lower_case_uni. 23/sep/2009 +*/ + +BufPointer_T upper_case_uni (BufType_T buf, BufPointer_T bf_ptr, + BufPointer_T len) +BEGIN +// printf("O~ lala~~"); + UChar target[BUF_SIZE+1]; + int32_t tarcap=BUF_SIZE+1; + int32_t tarlen = icu_toUChars(buf, bf_ptr, len, target, tarcap); + + UChar tarup[BUF_SIZE+1]; + int32_t tucap=BUF_SIZE+1; + int32_t tulen=icu_strToUpper(tarup, tucap,target, tarlen); + + unsigned char dest[BUF_SIZE+1]; + int32_t destcap= BUF_SIZE-bf_ptr; + + int32_t tblen=icu_fromUChars(dest, destcap, (const UChar *) tarup, tulen); + + BufPointer_T i; + if (tblen > 0) + BEGIN + if (len!=tblen) + BEGIN + unsigned char tmp[BUF_SIZE+1]; + BufPointer_T tmppr=0; + for (i=bf_ptr+len;i<=(BUF_SIZE-tblen+len);i++) + BEGIN + tmp[tmppr]=buf[i]; + tmppr++; + END + i=bf_ptr+tblen; + tmppr=0; + for (tmppr=0;tmppr<=(BUF_SIZE-bf_ptr-tblen);tmppr++) + BEGIN + buf[i]=tmp[tmppr]; + i++; + END + END + for (i = 0; i <= (tblen - 1); i++) + BEGIN + + buf[i+bf_ptr]=dest[i]; + END + END + return tblen; +END + +/* +This fonction is for transform Unicode string to up case. 23/sep/2009 +*/ + +int32_t icu_strToUpper(UChar * tarup, int32_t tucap, UChar * target, int32_t tarlen) +BEGIN + int32_t tulen; + UErrorCode err1 = U_ZERO_ERROR; + if (!U_SUCCESS(err1)) + BEGIN + printf("3there is a error: U_ZERO_ERROR"); + END + tulen=u_strToUpper(tarup,tucap, target,tarlen,NULL,&err1); + if (!U_SUCCESS(err1)) + BEGIN + printf("4there is a error: U_ZERO_ERROR"); + END + + return tulen; +END +#endif /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ diff --git a/Build/source/texk/bibtex8/bibtex-4.c b/Build/source/texk/bibtex8/bibtex-4.c index 7af0293e206..95f30801fca 100644 --- a/Build/source/texk/bibtex8/bibtex-4.c +++ b/Build/source/texk/bibtex8/bibtex-4.c @@ -301,7 +301,7 @@ BEGIN case N_OE_UPPER: case N_AE_UPPER: case N_AA_UPPER: - lower_case (ex_buf, ex_buf_xptr, + Lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); break; default: @@ -397,7 +397,7 @@ BEGIN BEGIN case TITLE_LOWERS: case ALL_LOWERS: - lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + Lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); break; case ALL_UPPERS: upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); @@ -437,7 +437,15 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; case TITLE_LOWERS: if (ex_buf_ptr == 0) BEGIN +#ifdef UTF_8 +/* +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 +*/ + DO_UTF8(ex_buf[ex_buf_ptr], , ex_buf_ptr = 1, ex_buf_ptr = 2, ex_buf_ptr = 3); +#else DO_NOTHING; +#endif END else if ((prev_colon) && (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE)) @@ -446,7 +454,23 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; END else BEGIN +#ifdef UTF_8 +/* +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; +#else lower_case (ex_buf, ex_buf_ptr, 1); +#endif END if (ex_buf[ex_buf_ptr] == COLON) BEGIN @@ -458,10 +482,42 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; END break; case ALL_LOWERS: +#ifdef UTF_8 +/* +Here the same for processing the length of string after change case. 23/sep/2009 +*/ + BEGIN + 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); + END +#else lower_case (ex_buf, ex_buf_ptr, 1); +#endif break; case ALL_UPPERS: +#ifdef UTF_8 +/* +Here the same for processing the length of string after change case. 23/sep/2009 +*/ + BEGIN + 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); + END +#else upper_case (ex_buf, ex_buf_ptr, 1); +#endif break; case BAD_CONVERSION: DO_NOTHING; @@ -1763,8 +1819,20 @@ BEGIN case ALPHA: case NUMERIC: BEGIN +#ifdef UTF_8 +/* +When we processe the character UTF-8, the length has been changed. This focntion is used in +quick_sort. 23/sep/2009 +*/ + DO_UTF8(ex_buf[ex_buf_ptr], + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr++], + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 2, + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 3, + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 4); +#else ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; INCR (ex_buf_xptr); +#endif END break; default: @@ -1939,7 +2007,21 @@ BEGIN END else BEGIN +#ifdef UTF_8 +/* +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 +*/ + 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; +#else sp_length = LENGTH (pop_lit3); +#endif if (pop_lit1 >= (Integer_T) sp_length) BEGIN if ((pop_lit2 == 1) || (pop_lit2 == -1)) @@ -1967,12 +2049,27 @@ BEGIN BEGIN if (pop_lit2 > 0) BEGIN +#ifdef UTF_8 + 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); +#endif if (pop_lit1 > (sp_length - (pop_lit2 - 1))) BEGIN pop_lit1 = sp_length - (pop_lit2 - 1); END +#ifdef UTF_8 + 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; +#else sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1); sp_end = sp_ptr + pop_lit1; +#endif if (pop_lit2 == 1) BEGIN if (pop_lit3 >= cmd_str_ptr) @@ -1986,13 +2083,29 @@ BEGIN END else BEGIN +#ifdef UTF_8 + 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); +#endif pop_lit2 = -pop_lit2; if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1))) BEGIN pop_lit1 = sp_length - (pop_lit2 - 1); END +#ifdef UTF_8 + 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; +#else sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1); sp_ptr = sp_end - pop_lit1; +#endif END STR_ROOM (sp_end - sp_ptr); while (sp_ptr < sp_end) @@ -2122,6 +2235,12 @@ BEGIN END INCR (sp_ptr); END +#ifdef UTF_8 +/* +The length of character of UTF-8 is different. 23/sep/2009 +*/ + DO_UTF8(str_pool[sp_ptr], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); +#endif INCR (num_text_chars); END END @@ -2135,6 +2254,12 @@ BEGIN END else BEGIN +#ifdef UTF_8 +/* +The same for the length of character. 23/sep/2009 +*/ + DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); +#endif INCR (num_text_chars); END END @@ -2231,6 +2356,12 @@ BEGIN END INCR (sp_xptr1); END +#ifdef UTF_8 +/* +The same for the length of character UTF-8. 23/sep/2009 +*/ + DO_UTF8(str_pool[sp_xptr1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); +#endif INCR (num_text_chars); END END @@ -2244,6 +2375,12 @@ BEGIN END else BEGIN +#ifdef UTF_8 +/* +The same for the length of character UTF-8. 23/sep/2009 +*/ + DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); +#endif INCR (num_text_chars); END END diff --git a/Build/source/texk/bibtex8/bibtex.c b/Build/source/texk/bibtex8/bibtex.c index 6d0c596fac6..0964f4df60c 100644 --- a/Build/source/texk/bibtex8/bibtex.c +++ b/Build/source/texk/bibtex8/bibtex.c @@ -102,6 +102,11 @@ #include <config.h> #endif +#ifdef KPATHSEA +#include <kpathsea/config.h> +#include <kpathsea/progname.h> +#endif + #include "sysdep.h" #include "bibtex.h" #include "datatype.h" @@ -110,11 +115,6 @@ #include "utils.h" #include "version.h" -#ifdef KPATHSEA -#include <kpathsea/config.h> -#include <kpathsea/progname.h> -#endif - /*************************************************************************** * WEB section number: 39 @@ -263,7 +263,7 @@ BEGIN command_line_arg_strings = (char **) argv; #ifdef KPATHSEA - kpse_set_program_name(argv[0], "bibtex8"); + kpse_set_program_name(argv[0], PROGNAME); #endif history = SPOTLESS; diff --git a/Build/source/texk/bibtex8/bibtex.h b/Build/source/texk/bibtex8/bibtex.h index f297539dd7c..c1c65d4fc09 100644 --- a/Build/source/texk/bibtex8/bibtex.h +++ b/Build/source/texk/bibtex8/bibtex.h @@ -99,11 +99,18 @@ * The BANNER string is defined here and should be changed whenever BibTeX * is modified. ***************************************************************************/ -#ifdef SUPPORT_8BIT -# define BANNER "This is 8-bit Big BibTeX version 0.99d" -#else /* NOT SUPPORT_8BIT */ -# define BANNER "This is Big BibTeX version 0.99d" -#endif /* SUPPORT_8BIT */ +#ifdef UTF_8 +# define BANNER "This is BibTeXu: a UTF-8 Big BibTeX version 0.99d" +# define PROGNAME "bibtexu" +# define SUPPORT_8BIT +#else +# ifdef SUPPORT_8BIT +# define BANNER "This is 8-bit Big BibTeX version 0.99d" +# else +# define BANNER "This is Big BibTeX version 0.99d" +# endif +# define PROGNAME "bibtex8" +#endif /*************************************************************************** @@ -1456,6 +1463,19 @@ /*************************************************************************** * WEB section number: N/A * ~~~~~~~~~~~~~~~~~~~ + * Define a macro to handle 1-, 2-, 3-, and 4-byte UTF-8 codes. + ***************************************************************************/ +#define DO_UTF8(ch, do_1, do_2, do_3, do_4) \ + if (ch <= 0x7F) { do_1; } \ + else if ((ch >= 0xC2) && (ch <= 0xDF)) { do_2; } \ + else if ((ch >= 0xE0) && (ch <= 0xEF)) { do_3; } \ + else if ((ch >= 0xF0) && (ch <= 0xF4)) { do_4; } \ + else printf("this isn't a right UTF-8 char!\n") + + +/*************************************************************************** + * WEB section number: N/A + * ~~~~~~~~~~~~~~~~~~~ * Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically * resize arrays. ***************************************************************************/ diff --git a/Build/source/texk/bibtex8/gblprocs.h b/Build/source/texk/bibtex8/gblprocs.h index c52e7aa9518..fff0248d974 100644 --- a/Build/source/texk/bibtex8/gblprocs.h +++ b/Build/source/texk/bibtex8/gblprocs.h @@ -93,6 +93,30 @@ # define __GBLPROCS_H__ 1 +#ifdef UTF_8 +#include "unicode/uchar.h" +#include "unicode/ustdio.h" +#include "unicode/ustring.h" +#include "unicode/ucnv.h" +#include "unicode/ucol.h" +int32_t icu_toUChars (BufType_T buf, + BufPointer_T bf_ptr, + BufPointer_T len, + UChar * target, + int32_t tarcap); +int32_t icu_strToLower (UChar * tarlow, + int32_t tlcap, + UChar * target, + int32_t tarlen); +int32_t icu_fromUChars (unsigned char * dest, + int32_t destcap, + const UChar * src, + int32_t srclen); +int32_t icu_strToUpper (UChar * tarup, + int32_t tucap, + UChar * target, + int32_t tarlen); +#endif void a_close (const AlphaFile_T file_pointer); Boolean_T a_open_in (AlphaFile_T *file_pointer, Integer_T search_path); @@ -200,6 +224,18 @@ Boolean_T less_than (CiteNumber_T arg1, void lower_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); +#ifdef UTF_8 +BufPointer_T lower_case_uni (BufType_T buf, + BufPointer_T bf_ptr, + BufPointer_T len); +static inline +void Lower_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) +{ + bf_ptr += lower_case_uni (buf, bf_ptr, len); +} +#else +# define Lower_case lower_case +#endif void macro_warn_print (void); StrNumber_T make_string (void); @@ -298,9 +334,20 @@ void trace_pr_fn_class (HashLoc_T fnloc); void unknwn_function_class_confusion (void); void unknwn_literal_confusion (void); +#ifdef UTF_8 +BufPointer_T upper_case_uni (BufType_T buf, + BufPointer_T bf_ptr, + BufPointer_T len); +static inline +void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) +{ + bf_ptr += upper_case_uni (buf, bf_ptr, len); +} +#else void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); +#endif void von_name_ends_and_last_name_sta (void); Boolean_T von_token_found (void); diff --git a/Build/source/texk/bibtex8/gblvars.h b/Build/source/texk/bibtex8/gblvars.h index 39903ac88c8..41d9f7535dc 100644 --- a/Build/source/texk/bibtex8/gblvars.h +++ b/Build/source/texk/bibtex8/gblvars.h @@ -422,6 +422,12 @@ __EXTERN__ HashPtr2_T *wiz_functions; ** Variables used to record the results of the command line parsing. **---------------------------------------------------------------------------- */ +#ifdef UTF_8 +__EXTERN__ Boolean_T Flag_language; +__EXTERN__ char *Str_language; +__EXTERN__ Boolean_T Flag_location; +__EXTERN__ char *Str_location; +#endif __EXTERN__ Boolean_T Flag_7bit; __EXTERN__ Boolean_T Flag_8bit; __EXTERN__ Boolean_T Flag_8bit_alpha; diff --git a/Build/source/texk/bibtex8/utils.c b/Build/source/texk/bibtex8/utils.c index cb4085bf6aa..44b3c82da32 100644 --- a/Build/source/texk/bibtex8/utils.c +++ b/Build/source/texk/bibtex8/utils.c @@ -173,15 +173,24 @@ #define VALUE_OPT 2 static struct option long_options[] = { +#ifndef UTF_8 {"8bit", VALUE_NONE, 0, '8'}, {"csfile", VALUE_REQD, 0, 'c'}, - {"debug", VALUE_REQD, 0, 'd'}, +#endif + {"debug", VALUE_REQD, 0, 'd'}, {"help", VALUE_NONE, 0, '?'}, {"statistics", VALUE_NONE, 0, 's'}, {"trace", VALUE_NONE, 0, 't'}, +#ifndef UTF_8 {"traditional", VALUE_NONE, 0, '7'}, +#endif {"version", VALUE_NONE, 0, 'v'}, +#ifdef UTF_8 + {"language", VALUE_REQD, 0, 'l'}, + {"location", VALUE_REQD, 0, 'o'}, +#endif + {"big", VALUE_NONE, 0, 'B'}, {"huge", VALUE_NONE, 0, 'H'}, {"wolfgang", VALUE_NONE, 0, 'W'}, @@ -197,7 +206,15 @@ static struct option long_options[] = { {0, 0, 0, 0} }; -static const char *getopt_str = "78c:d:?stvBHM:W"; +static const char *getopt_str = +#ifndef UTF_8 + "78c:" +#endif + "d:?stv" +#ifdef UTF_8 + "l:o:" +#endif + "BHM:W"; @@ -978,6 +995,12 @@ void parse_cmd_line (int argc, char **argv) Flag_trace = FALSE; Str_auxfile = NULL; Str_csfile = NULL; +#ifdef UTF_8 + Flag_language = FALSE; + Str_language = NULL; + Flag_location = FALSE; + Str_location = NULL; +#endif while (1) { int option_index = 0; @@ -992,6 +1015,7 @@ void parse_cmd_line (int argc, char **argv) usage (NULL); break; +#ifndef UTF_8 case '7': /**************** -7, --traditional ********/ Flag_7bit = TRUE; break; @@ -999,14 +1023,17 @@ void parse_cmd_line (int argc, char **argv) case '8': /**************** -8, --8bit ***************/ Flag_8bit = TRUE; break; +#endif case 'B': /**************** -B, --big ****************/ Flag_big = TRUE; break; +#ifndef UTF_8 case 'c': /**************** -c, --csfile *************/ Str_csfile = strdup (optarg); break; +#endif case 'd': /**************** -d, --debug **************/ if ((optarg == NULL) || (*optarg == '\0')) @@ -1019,6 +1046,13 @@ void parse_cmd_line (int argc, char **argv) Flag_huge = TRUE; break; +#ifdef UTF_8 + case 'l': /**************** -l, --language ***********/ + Flag_language =TRUE; + Str_language = optarg; + break; +#endif + case 'M': /**************** -M, --min_crossrefs ******/ M_min_crossrefs = checklong (optarg); if (M_min_crossrefs < 0) { @@ -1027,6 +1061,13 @@ void parse_cmd_line (int argc, char **argv) } break; +#ifdef UTF_8 + case 'o': /**************** -o, --location ***********/ + Flag_location =TRUE; + Str_location = optarg; + break; +#endif + case 's': /**************** -s, --statistics *********/ Flag_stats = TRUE; break; @@ -1237,7 +1278,7 @@ static void setup_bound_variable (Integer_T *var, const char *name, const char *src = " or texmf.cnf"; #else char *expansion = getenv (name); - const char *me = "bibtex8"; + const char *me = PROGNAME; const char *src = ""; #endif @@ -1463,20 +1504,27 @@ void usage (const char *printf_fmt, ...) va_list printf_args; if (printf_fmt != NULL) { - fprintf (stderr, "BibTeX: "); +#ifdef UTF_8 + fprintf (stderr, "BibTeXu: "); +#else + fprintf (stderr, "BibTeX8: "); +#endif va_start (printf_args, printf_fmt); vfprintf (stderr, printf_fmt, printf_args); va_end (printf_args); fprintf (stderr, "\n"); } - FSO ("\nUsage: bibtex8 [options] aux-file\n\n"); + FSO ("\nUsage: " PROGNAME " [options] aux-file\n\n"); FSO (" Valid options are:\n\n"); FSO (" -? --help display this help text\n"); + +#ifndef UTF_8 FSO (" -7 --traditional operate in the original 7-bit mode\n"); FSO (" -8 --8bit force 8-bit mode, no CS file used\n"); FSO (" -c --csfile FILE read FILE as the BibTeX character set\n"); FSO (" and sort definition file\n"); +#endif #ifdef DEBUG FSO (" -d --debug TYPE report debugging information. TYPE is one\n"); @@ -1493,6 +1541,11 @@ void usage (const char *printf_fmt, ...) FSO (" -v --version report BibTeX version\n\n"); +#ifdef UTF_8 + FSO (" -l --language LANG use language LANG, ex: -l fr\n"); + FSO (" -o --location LOC use location LOC, ex: -o fr\n\n"); +#endif + FSO (" -B --big same as --mstrings 10000\n"); FSO (" -H --huge same as --mstrings 19000\n"); FSO (" -W --wolfgang same as --mstrings 30000\n"); diff --git a/Build/source/texk/bibtex8/version.h b/Build/source/texk/bibtex8/version.h index 11780510478..37ce123b3aa 100644 --- a/Build/source/texk/bibtex8/version.h +++ b/Build/source/texk/bibtex8/version.h @@ -91,6 +91,6 @@ */ #ifndef __VERSION_H__ # define __VERSION_H__ 1 -# define VERSION "3.71 (31 May 2005)" +# define VERSION "3.71 (18 mar 2013)" #endif /* __VERSION_H__ */ diff --git a/Build/source/texk/bibtexu/ChangeLog b/Build/source/texk/bibtexu/ChangeLog index b8105f95b28..57a122575fa 100644 --- a/Build/source/texk/bibtexu/ChangeLog +++ b/Build/source/texk/bibtexu/ChangeLog @@ -1,3 +1,12 @@ +2013-03-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + * bibtex-[24].c, bibtex.h: Define and use DO_UTF8 to handle + 1-, 2-, 3-, and 4-byte UTF-8 codes. + + Remove diffs with bibtex8. + * bibtex-[234].c, bibtex.[ch], gblprocs.h, gblvars.h, utils.c: + Add '#ifndef UTF_8 <bibtex8 code> #endif'. + 2013-03-15 Peter Breitenlohner <peb@mppmu.mpg.de> Reduce diffs with bibtex8. diff --git a/Build/source/texk/bibtexu/Makefile.am b/Build/source/texk/bibtexu/Makefile.am index a77bb71bd4a..0da62b3fe2d 100644 --- a/Build/source/texk/bibtexu/Makefile.am +++ b/Build/source/texk/bibtexu/Makefile.am @@ -5,7 +5,7 @@ ## ACLOCAL_AMFLAGS = -I ../../m4 -AM_CPPFLAGS = $(KPATHSEA_INCLUDES) $(ICU_INCLUDES) -DUNIX -DKPATHSEA -DSUPPORT_8BIT +AM_CPPFLAGS = $(KPATHSEA_INCLUDES) $(ICU_INCLUDES) -DUNIX -DKPATHSEA -DUTF_8 AM_CFLAGS = $(WARNING_CFLAGS) bin_PROGRAMS = bibtexu diff --git a/Build/source/texk/bibtexu/Makefile.in b/Build/source/texk/bibtexu/Makefile.in index 5e0b34f6a71..28ff1ec7048 100644 --- a/Build/source/texk/bibtexu/Makefile.in +++ b/Build/source/texk/bibtexu/Makefile.in @@ -532,7 +532,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I ../../m4 -AM_CPPFLAGS = $(KPATHSEA_INCLUDES) $(ICU_INCLUDES) -DUNIX -DKPATHSEA -DSUPPORT_8BIT +AM_CPPFLAGS = $(KPATHSEA_INCLUDES) $(ICU_INCLUDES) -DUNIX -DKPATHSEA -DUTF_8 AM_CFLAGS = $(WARNING_CFLAGS) # Force Automake to use CXXLD for linking diff --git a/Build/source/texk/bibtexu/bibtex-2.c b/Build/source/texk/bibtexu/bibtex-2.c index f12abe88abb..5280e408d05 100644 --- a/Build/source/texk/bibtexu/bibtex-2.c +++ b/Build/source/texk/bibtexu/bibtex-2.c @@ -923,37 +923,29 @@ BEGIN name_bf_xptr = name_tok[cur_token + 1]; while (name_bf_ptr < name_bf_xptr) BEGIN +#ifdef UTF_8 /* For output the first character which is encodage UTF-8, we sould discuter different length of character. 23/sep/2009 */ if((lex_class[NAME_BUF[name_bf_ptr]] != WHITE_SPACE) && (NAME_BUF[name_bf_ptr] != LEFT_BRACE)) BEGIN - if(NAME_BUF[name_bf_ptr] <= 0x7F) - BEGIN + DO_UTF8(NAME_BUF[name_bf_ptr], + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]), APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); - END - else if((NAME_BUF[name_bf_ptr] >= 0xC2) && (NAME_BUF[name_bf_ptr] <= 0xDF)) - BEGIN + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]), APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]); - END - else if((NAME_BUF[name_bf_ptr] >= 0xE0) && (NAME_BUF[name_bf_ptr] <= 0xEF)) - BEGIN - APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); - APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]); - APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]); - END - else if((NAME_BUF[name_bf_ptr] >= 0xF0) && (NAME_BUF[name_bf_ptr] <= 0xF4)) - BEGIN + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]), APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr]); APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+1]); APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+2]); - APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+3]); - END - else - BEGIN - printf("this isn't a right UTF-8 char!"); - END + APPEND_EX_BUF_CHAR_AND_CHECK (NAME_BUF[name_bf_ptr+3])); +#else + if (lex_class[NAME_BUF[name_bf_ptr]] == ALPHA) + BEGIN + APPEND_EX_BUF_CHAR_AND_CHECK ( + NAME_BUF[name_bf_ptr]); +#endif goto Loop_Exit_Label; END else if ((NAME_BUF[name_bf_ptr] == LEFT_BRACE) @@ -2932,16 +2924,17 @@ END * |ASCII_code|s to compare, so it might give ``interesting'' results * when handling nonletters. ***************************************************************************/ +Boolean_T less_than (CiteNumber_T arg1, CiteNumber_T arg2) +BEGIN + StrEntLoc_T ptr1, + ptr2; +#ifdef UTF_8 /* We use ICU libs to processing UTF-8. First, we have to transform UTF-8 to Unicode/UChar with the fonction icu_UCHars. Then we use the UCollator in the ICU libs to conparer the Unicode. There is an option "location", we use "-o" to indicate the rule of conpare. 23/sep/2009 */ -Boolean_T less_than (CiteNumber_T arg1, CiteNumber_T arg2) -BEGIN - StrEntLoc_T ptr1, - ptr2; Integer_T lenk1, lenk2; UChar uch1[BUF_SIZE+1], uch2[BUF_SIZE+1]; UBool u_less; @@ -2949,32 +2942,77 @@ BEGIN int32_t ucap = BUF_SIZE+1; int32_t uchlen1, uchlen2; UErrorCode err1 = U_ZERO_ERROR; +#else + Boolean_T less_than; + Integer_T char_ptr; + ASCIICode_T char1, + char2; +#endif ptr1 = (arg1 * num_ent_strs) + sort_key_num; ptr2 = (arg2 * num_ent_strs) + sort_key_num; - - lenk1= strlen((char *)&ENTRY_STRS(ptr1, 0)); - lenk2= strlen((char *)&ENTRY_STRS(ptr2, 0)); +#ifdef UTF_8 + lenk1 = strlen((char *)&ENTRY_STRS(ptr1, 0)); + lenk2 = strlen((char *)&ENTRY_STRS(ptr2, 0)); + uchlen1 = icu_toUChars(entry_strs, (ptr1 * (ENT_STR_SIZE+1)), lenk1, uch1, ucap); + uchlen2 = icu_toUChars(entry_strs, (ptr2 * (ENT_STR_SIZE+1)), lenk2, uch2, ucap); - uchlen1 = icu_toUChars(entry_strs, (ptr1 * (ENT_STR_SIZE+1)), lenk1, uch1, ucap); - uchlen2 = icu_toUChars(entry_strs, (ptr2 * (ENT_STR_SIZE+1)), lenk2, uch2, ucap); - - if(Flag_location) - { - ucol1 = ucol_open(Str_location, &err1); - } - else - { - ucol1 = ucol_open(NULL, &err1); - } - if (!U_SUCCESS(err1)) - { printf("there is a error: U_ZERO_ERROR, open a ucol."); - } - u_less = !ucol_greaterOrEqual(ucol1, uch1, uchlen1, uch2, uchlen2); - - ucol_close(ucol1); - return u_less; + if(Flag_location) + ucol1 = ucol_open(Str_location, &err1); + else + ucol1 = ucol_open(NULL, &err1); + if (!U_SUCCESS(err1)) + printf("there is a error: U_ZERO_ERROR, open a ucol."); + u_less = !ucol_greaterOrEqual(ucol1, uch1, uchlen1, uch2, uchlen2); + + ucol_close(ucol1); + return u_less; +#else + char_ptr = 0; + LOOP + BEGIN + char1 = ENTRY_STRS(ptr1, char_ptr); + char2 = ENTRY_STRS(ptr2, char_ptr); + if (char1 == END_OF_STRING) + BEGIN + if (char2 == END_OF_STRING) + BEGIN + if (arg1 < arg2) + BEGIN + COMPARE_RETURN (TRUE); + END + else if (arg1 > arg2) + BEGIN + COMPARE_RETURN (FALSE); + END + else + BEGIN + CONFUSION ("Duplicate sort key"); + END + END + else + BEGIN + COMPARE_RETURN (TRUE); + END + END + else if (char2 == END_OF_STRING) + BEGIN + COMPARE_RETURN (FALSE); + END + else if char_less_than(char1, char2) + BEGIN + COMPARE_RETURN (TRUE); + END + else if char_greater_than(char1, char2) + BEGIN + COMPARE_RETURN (FALSE); + END + INCR (char_ptr); + END +Exit_Label: + return (less_than); +#endif END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2988,12 +3026,6 @@ END * lower case for the specified part of |buf|. It is system independent * because it uses only the internal representation for characters. ***************************************************************************/ - -/* -Because the bibtex use "lower_case" a lot of time, but for processing the charcater -not many. We reserver the original code "lower_case" for other cases. 23/sep/2009 -*/ - void lower_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) BEGIN @@ -3019,8 +3051,8 @@ BEGIN END END END -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#ifdef UTF_8 /* "lower_case_uni" is the fonction for processing the characters, actually the UTF-8. We transform UTF-8 to Unicode, then to low case, then back to UTF-8 for output. @@ -3080,7 +3112,6 @@ END /* This fonction is for transform UTF-8 to Unicode with ICU libs. 23/sep/2009 */ - int32_t icu_toUChars(BufType_T buf, BufPointer_T bf_ptr,BufPointer_T len,UChar * target, int32_t tarcap) BEGIN UConverter * ucon1; @@ -3102,7 +3133,6 @@ END /* This fonction is for transform Unicode string to low case. 23/sep/2009 */ - int32_t icu_strToLower(UChar * tarlow, int32_t tlcap, UChar * target, int32_t tarlen) BEGIN int32_t tllen; @@ -3142,7 +3172,6 @@ END /* This fonction is for transform Unicode to UTF-8. 23/sep/2009 */ - int32_t icu_fromUChars(unsigned char * dest, int32_t destcap, const UChar * src, int32_t srclen) BEGIN UConverter * ucon2; @@ -3161,6 +3190,8 @@ BEGIN return tblen; END +#endif +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ diff --git a/Build/source/texk/bibtexu/bibtex-3.c b/Build/source/texk/bibtexu/bibtex-3.c index dd6df5603d2..629e91c4914 100644 --- a/Build/source/texk/bibtexu/bibtex-3.c +++ b/Build/source/texk/bibtexu/bibtex-3.c @@ -3055,11 +3055,7 @@ END * This system-independent procedure is the same as the previous except * that it converts lower- to upper-case letters. ***************************************************************************/ - -/* -This is original code of upper_case. 23/sep/2009 -*/ - +#ifndef UTF_8 void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) BEGIN @@ -3085,9 +3081,7 @@ BEGIN END END END -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ - - +#else /* This foction "upper_case_uni" is for prcessing the character UTF-8. It's like lower_case_uni. 23/sep/2009 @@ -3159,6 +3153,11 @@ BEGIN return tulen; END +#endif +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + + + /*************************************************************************** * WEB section number: 401 diff --git a/Build/source/texk/bibtexu/bibtex-4.c b/Build/source/texk/bibtexu/bibtex-4.c index ae06cf0ae18..95f30801fca 100644 --- a/Build/source/texk/bibtexu/bibtex-4.c +++ b/Build/source/texk/bibtexu/bibtex-4.c @@ -301,7 +301,8 @@ BEGIN case N_OE_UPPER: case N_AE_UPPER: case N_AA_UPPER: - ex_buf_ptr=ex_buf_xptr+lower_case_uni(ex_buf, ex_buf_xptr,ex_buf_ptr - ex_buf_xptr); + Lower_case (ex_buf, ex_buf_xptr, + ex_buf_ptr - ex_buf_xptr); break; default: DO_NOTHING; @@ -316,7 +317,7 @@ BEGIN case N_OE: case N_AE: case N_AA: - ex_buf_ptr=ex_buf_xptr+upper_case_uni (ex_buf, ex_buf_xptr, + upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); break; case N_I: @@ -330,7 +331,7 @@ BEGIN * |backslash| and any following |white_space|. ***************************************************************************/ BEGIN - ex_buf_ptr=ex_buf_xptr+ upper_case_uni (ex_buf, ex_buf_xptr, + upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); while (ex_buf_xptr < ex_buf_ptr) BEGIN @@ -396,10 +397,10 @@ BEGIN BEGIN case TITLE_LOWERS: case ALL_LOWERS: - ex_buf_ptr = ex_buf_xptr + lower_case_uni(ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + Lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); break; case ALL_UPPERS: - ex_buf_ptr=ex_buf_xptr+ upper_case_uni (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); + upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr); break; case BAD_CONVERSION: DO_NOTHING; @@ -434,32 +435,17 @@ OK_Pascal_I_Give_Up_Label: prev_colon = FALSE; switch (conversion_type) BEGIN case TITLE_LOWERS: + if (ex_buf_ptr == 0) + BEGIN +#ifdef UTF_8 /* 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 - 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 + DO_UTF8(ex_buf[ex_buf_ptr], , ex_buf_ptr = 1, ex_buf_ptr = 2, ex_buf_ptr = 3); +#else + DO_NOTHING; +#endif END else if ((prev_colon) && (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE)) @@ -468,19 +454,23 @@ character. When it's UTF-8, we should care about the length of charater. 23/se END else BEGIN +#ifdef UTF_8 /* 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++; + 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; - +#else + lower_case (ex_buf, ex_buf_ptr, 1); +#endif END if (ex_buf[ex_buf_ptr] == COLON) BEGIN @@ -492,36 +482,43 @@ for the precessing after lower case. Here there may be some potential bug. END break; case ALL_LOWERS: - BEGIN +#ifdef UTF_8 /* 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); + BEGIN + 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); - + END +#else + lower_case (ex_buf, ex_buf_ptr, 1); +#endif break; - END case ALL_UPPERS: - BEGIN +#ifdef UTF_8 /* 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; + BEGIN + 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); END +#else + upper_case (ex_buf, ex_buf_ptr, 1); +#endif + break; case BAD_CONVERSION: DO_NOTHING; break; @@ -1821,47 +1818,21 @@ BEGIN break; case ALPHA: case NUMERIC: + BEGIN +#ifdef UTF_8 /* 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 - + DO_UTF8(ex_buf[ex_buf_ptr], + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr++], + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 2, + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 3, + ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr]; ex_buf_xptr += 4); +#else 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 - +#endif END break; default: @@ -2013,13 +1984,6 @@ 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 @@ -2043,12 +2007,21 @@ BEGIN END else BEGIN +#ifdef UTF_8 +/* +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 +*/ 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; +#else + sp_length = LENGTH (pop_lit3); +#endif if (pop_lit1 >= (Integer_T) sp_length) BEGIN if ((pop_lit2 == 1) || (pop_lit2 == -1)) @@ -2076,23 +2049,27 @@ BEGIN BEGIN if (pop_lit2 > 0) BEGIN +#ifdef UTF_8 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); - +#endif 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; +#ifdef UTF_8 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; + ptrfrUch = icu_fromUChars(frUch2, frUchCap, uchs, pop_lit2-1); + sp_ptr = str_start[pop_lit3] + ptrfrUch; + sp_end = sp_ptr + lenfrUch; +#else + sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1); + sp_end = sp_ptr + pop_lit1; +#endif if (pop_lit2 == 1) BEGIN if (pop_lit3 >= cmd_str_ptr) @@ -2106,25 +2083,29 @@ BEGIN END else BEGIN +#ifdef UTF_8 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); - +#endif pop_lit2 = -pop_lit2; if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1))) BEGIN pop_lit1 = sp_length - (pop_lit2 - 1); END +#ifdef UTF_8 + 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; +#else 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; +#endif END STR_ROOM (sp_end - sp_ptr); while (sp_ptr < sp_end) @@ -2254,36 +2235,12 @@ BEGIN END INCR (sp_ptr); END - +#ifdef UTF_8 /* 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 + DO_UTF8(str_pool[sp_ptr], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); +#endif INCR (num_text_chars); END END @@ -2297,35 +2254,12 @@ The length of character of UTF-8 is different. 23/sep/2009 END else BEGIN +#ifdef UTF_8 /* 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 + DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3); +#endif INCR (num_text_chars); END END @@ -2422,36 +2356,12 @@ BEGIN END INCR (sp_xptr1); END - +#ifdef UTF_8 /* 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 + DO_UTF8(str_pool[sp_xptr1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); +#endif INCR (num_text_chars); END END @@ -2465,35 +2375,12 @@ The same for the length of character UTF-8. 23/sep/2009 END else BEGIN +#ifdef UTF_8 /* 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 + DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3); +#endif INCR (num_text_chars); END END diff --git a/Build/source/texk/bibtexu/bibtex.c b/Build/source/texk/bibtexu/bibtex.c index 653e51e5f8f..0964f4df60c 100644 --- a/Build/source/texk/bibtexu/bibtex.c +++ b/Build/source/texk/bibtexu/bibtex.c @@ -263,7 +263,7 @@ BEGIN command_line_arg_strings = (char **) argv; #ifdef KPATHSEA - kpse_set_program_name(argv[0], "bibtexu"); + kpse_set_program_name(argv[0], PROGNAME); #endif history = SPOTLESS; diff --git a/Build/source/texk/bibtexu/bibtex.h b/Build/source/texk/bibtexu/bibtex.h index 9c9b1854d10..c1c65d4fc09 100644 --- a/Build/source/texk/bibtexu/bibtex.h +++ b/Build/source/texk/bibtexu/bibtex.h @@ -99,11 +99,18 @@ * The BANNER string is defined here and should be changed whenever BibTeX * is modified. ***************************************************************************/ -#ifdef SUPPORT_8BIT +#ifdef UTF_8 # define BANNER "This is BibTeXu: a UTF-8 Big BibTeX version 0.99d" -#else /* NOT SUPPORT_8BIT */ -# define BANNER "This is Big BibTeX version 0.99d" -#endif /* SUPPORT_8BIT */ +# define PROGNAME "bibtexu" +# define SUPPORT_8BIT +#else +# ifdef SUPPORT_8BIT +# define BANNER "This is 8-bit Big BibTeX version 0.99d" +# else +# define BANNER "This is Big BibTeX version 0.99d" +# endif +# define PROGNAME "bibtex8" +#endif /*************************************************************************** @@ -1456,6 +1463,19 @@ /*************************************************************************** * WEB section number: N/A * ~~~~~~~~~~~~~~~~~~~ + * Define a macro to handle 1-, 2-, 3-, and 4-byte UTF-8 codes. + ***************************************************************************/ +#define DO_UTF8(ch, do_1, do_2, do_3, do_4) \ + if (ch <= 0x7F) { do_1; } \ + else if ((ch >= 0xC2) && (ch <= 0xDF)) { do_2; } \ + else if ((ch >= 0xE0) && (ch <= 0xEF)) { do_3; } \ + else if ((ch >= 0xF0) && (ch <= 0xF4)) { do_4; } \ + else printf("this isn't a right UTF-8 char!\n") + + +/*************************************************************************** + * WEB section number: N/A + * ~~~~~~~~~~~~~~~~~~~ * Macros adapted from Kpathsea (lib.h) and Web2C (cpascal.h) to dynamically * resize arrays. ***************************************************************************/ diff --git a/Build/source/texk/bibtexu/gblprocs.h b/Build/source/texk/bibtexu/gblprocs.h index b650d26f0f5..fff0248d974 100644 --- a/Build/source/texk/bibtexu/gblprocs.h +++ b/Build/source/texk/bibtexu/gblprocs.h @@ -92,6 +92,8 @@ #ifndef __GBLPROCS_H__ # define __GBLPROCS_H__ 1 + +#ifdef UTF_8 #include "unicode/uchar.h" #include "unicode/ustdio.h" #include "unicode/ustring.h" @@ -110,7 +112,11 @@ int32_t icu_fromUChars (unsigned char * dest, int32_t destcap, const UChar * src, int32_t srclen); - +int32_t icu_strToUpper (UChar * tarup, + int32_t tucap, + UChar * target, + int32_t tarlen); +#endif void a_close (const AlphaFile_T file_pointer); Boolean_T a_open_in (AlphaFile_T *file_pointer, Integer_T search_path); @@ -218,9 +224,18 @@ Boolean_T less_than (CiteNumber_T arg1, void lower_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); +#ifdef UTF_8 BufPointer_T lower_case_uni (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); +static inline +void Lower_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) +{ + bf_ptr += lower_case_uni (buf, bf_ptr, len); +} +#else +# define Lower_case lower_case +#endif void macro_warn_print (void); StrNumber_T make_string (void); @@ -319,16 +334,20 @@ void trace_pr_fn_class (HashLoc_T fnloc); void unknwn_function_class_confusion (void); void unknwn_literal_confusion (void); -void upper_case (BufType_T buf, +#ifdef UTF_8 +BufPointer_T upper_case_uni (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); -BufPointer_T upper_case_uni (BufType_T buf, +static inline +void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len) +{ + bf_ptr += upper_case_uni (buf, bf_ptr, len); +} +#else +void upper_case (BufType_T buf, BufPointer_T bf_ptr, BufPointer_T len); -int32_t icu_strToUpper (UChar * tarup, - int32_t tucap, - UChar * target, - int32_t tarlen); +#endif void von_name_ends_and_last_name_sta (void); Boolean_T von_token_found (void); diff --git a/Build/source/texk/bibtexu/gblvars.h b/Build/source/texk/bibtexu/gblvars.h index af57b80726f..41d9f7535dc 100644 --- a/Build/source/texk/bibtexu/gblvars.h +++ b/Build/source/texk/bibtexu/gblvars.h @@ -422,11 +422,12 @@ __EXTERN__ HashPtr2_T *wiz_functions; ** Variables used to record the results of the command line parsing. **---------------------------------------------------------------------------- */ +#ifdef UTF_8 __EXTERN__ Boolean_T Flag_language; __EXTERN__ char *Str_language; __EXTERN__ Boolean_T Flag_location; __EXTERN__ char *Str_location; - +#endif __EXTERN__ Boolean_T Flag_7bit; __EXTERN__ Boolean_T Flag_8bit; __EXTERN__ Boolean_T Flag_8bit_alpha; diff --git a/Build/source/texk/bibtexu/utils.c b/Build/source/texk/bibtexu/utils.c index d818f0f1092..44b3c82da32 100644 --- a/Build/source/texk/bibtexu/utils.c +++ b/Build/source/texk/bibtexu/utils.c @@ -172,18 +172,24 @@ #define VALUE_REQD 1 #define VALUE_OPT 2 -/* -Add the option "-l" for language, and "-o" for location. 23/sep/2009 -*/ static struct option long_options[] = { - {"debug", VALUE_REQD, 0, 'd'}, +#ifndef UTF_8 + {"8bit", VALUE_NONE, 0, '8'}, + {"csfile", VALUE_REQD, 0, 'c'}, +#endif + {"debug", VALUE_REQD, 0, 'd'}, {"help", VALUE_NONE, 0, '?'}, {"statistics", VALUE_NONE, 0, 's'}, {"trace", VALUE_NONE, 0, 't'}, +#ifndef UTF_8 + {"traditional", VALUE_NONE, 0, '7'}, +#endif {"version", VALUE_NONE, 0, 'v'}, - {"language", VALUE_REQD, 0, 'l'}, - {"location", VALUE_REQD, 0, 'o'}, +#ifdef UTF_8 + {"language", VALUE_REQD, 0, 'l'}, + {"location", VALUE_REQD, 0, 'o'}, +#endif {"big", VALUE_NONE, 0, 'B'}, {"huge", VALUE_NONE, 0, 'H'}, @@ -200,7 +206,15 @@ static struct option long_options[] = { {0, 0, 0, 0} }; -static const char *getopt_str = ":d:?stvl:o:BHM:W"; +static const char *getopt_str = +#ifndef UTF_8 + "78c:" +#endif + "d:?stv" +#ifdef UTF_8 + "l:o:" +#endif + "BHM:W"; @@ -981,14 +995,12 @@ void parse_cmd_line (int argc, char **argv) Flag_trace = FALSE; Str_auxfile = NULL; Str_csfile = NULL; - -/* -For the input of the option language and location. 23/sep/2009 -*/ +#ifdef UTF_8 Flag_language = FALSE; Str_language = NULL; Flag_location = FALSE; Str_location = NULL; +#endif while (1) { int option_index = 0; @@ -1003,10 +1015,26 @@ For the input of the option language and location. 23/sep/2009 usage (NULL); break; +#ifndef UTF_8 + case '7': /**************** -7, --traditional ********/ + Flag_7bit = TRUE; + break; + + case '8': /**************** -8, --8bit ***************/ + Flag_8bit = TRUE; + break; +#endif + case 'B': /**************** -B, --big ****************/ Flag_big = TRUE; break; +#ifndef UTF_8 + case 'c': /**************** -c, --csfile *************/ + Str_csfile = strdup (optarg); + break; +#endif + case 'd': /**************** -d, --debug **************/ if ((optarg == NULL) || (*optarg == '\0')) Flag_debug = DBG_ALL; @@ -1018,6 +1046,13 @@ For the input of the option language and location. 23/sep/2009 Flag_huge = TRUE; break; +#ifdef UTF_8 + case 'l': /**************** -l, --language ***********/ + Flag_language =TRUE; + Str_language = optarg; + break; +#endif + case 'M': /**************** -M, --min_crossrefs ******/ M_min_crossrefs = checklong (optarg); if (M_min_crossrefs < 0) { @@ -1026,6 +1061,13 @@ For the input of the option language and location. 23/sep/2009 } break; +#ifdef UTF_8 + case 'o': /**************** -o, --location ***********/ + Flag_location =TRUE; + Str_location = optarg; + break; +#endif + case 's': /**************** -s, --statistics *********/ Flag_stats = TRUE; break; @@ -1042,19 +1084,6 @@ For the input of the option language and location. 23/sep/2009 "calling longjmp (Exit_Program_Flag) ... "); longjmp (Exit_Program_Flag, 1); break; -/* -Get the option, and change the flag. 23/sep/2009 -*/ - case 'l': - Flag_language =TRUE; - Str_language = optarg; - break; - - case 'o': - Flag_location =TRUE; - Str_location = optarg; - break; - case 'W': /**************** -W, --wolfgang ***********/ Flag_wolfgang = TRUE; @@ -1249,7 +1278,7 @@ static void setup_bound_variable (Integer_T *var, const char *name, const char *src = " or texmf.cnf"; #else char *expansion = getenv (name); - const char *me = "bibtexu"; + const char *me = PROGNAME; const char *src = ""; #endif @@ -1475,17 +1504,28 @@ void usage (const char *printf_fmt, ...) va_list printf_args; if (printf_fmt != NULL) { +#ifdef UTF_8 fprintf (stderr, "BibTeXu: "); +#else + fprintf (stderr, "BibTeX8: "); +#endif va_start (printf_args, printf_fmt); vfprintf (stderr, printf_fmt, printf_args); va_end (printf_args); fprintf (stderr, "\n"); } - FSO ("\nUsage: bibtexu [options] aux-file\n\n"); + FSO ("\nUsage: " PROGNAME " [options] aux-file\n\n"); FSO (" Valid options are:\n\n"); FSO (" -? --help display this help text\n"); +#ifndef UTF_8 + FSO (" -7 --traditional operate in the original 7-bit mode\n"); + FSO (" -8 --8bit force 8-bit mode, no CS file used\n"); + FSO (" -c --csfile FILE read FILE as the BibTeX character set\n"); + FSO (" and sort definition file\n"); +#endif + #ifdef DEBUG FSO (" -d --debug TYPE report debugging information. TYPE is one\n"); FSO (" or more of all, csf, io, mem, misc, search.\n"); @@ -1500,9 +1540,11 @@ void usage (const char *printf_fmt, ...) #endif /* TRACE */ FSO (" -v --version report BibTeX version\n\n"); - - FSO (" -l --language input the option language, ex: -l fr\n"); - FSO (" -o --location input the option location, ex: -o fr\n\n"); + +#ifdef UTF_8 + FSO (" -l --language LANG use language LANG, ex: -l fr\n"); + FSO (" -o --location LOC use location LOC, ex: -o fr\n\n"); +#endif FSO (" -B --big same as --mstrings 10000\n"); FSO (" -H --huge same as --mstrings 19000\n"); diff --git a/Build/source/texk/bibtexu/version.h b/Build/source/texk/bibtexu/version.h index 0cf90f21b5e..37ce123b3aa 100644 --- a/Build/source/texk/bibtexu/version.h +++ b/Build/source/texk/bibtexu/version.h @@ -91,6 +91,6 @@ */ #ifndef __VERSION_H__ # define __VERSION_H__ 1 -# define VERSION "3.71 (23 sep 2009)" +# define VERSION "3.71 (18 mar 2013)" #endif /* __VERSION_H__ */ |