--- texk/upmendex/fwrite.c | 62 +++++++++++++++++++++++---------------------- utils/lacheck/lacheck.test | 3 +- 2 files changed, 34 insertions(+), 31 deletions(-) |--- texk/web2c/eptexdir/eptex.ech |+++ texk/web2c/eptexdir/eptex.ech 2012-04-16 08:31:14.564665420 +0000 |@@ -300,10 +300,13 @@ othercases goto next_p | hlist_node,vlist_node: begin r:=get_node(box_node_size); | @z | @x e-pTeX: just_copy |+ mem[r+6]:=mem[p+6]; mem[r+5]:=mem[p+5]; {copy the last two words} | words:=5; list_ptr(r):=null; {this affects |mem[r+5]|} | @y |- words:=5; list_ptr(r):=null; {this affects |mem[r+5]|} |+ mem[r+7]:=mem[p+7]; mem[r+6]:=mem[p+6]; mem[r+5]:=mem[p+5]; |+ {copy the last three words} | add_glue_ref(space_ptr(r)); add_glue_ref(xspace_ptr(r)); |+ words:=5; list_ptr(r):=null; {this affects |mem[r+5]|} | @z | | @x e-pTeX: ifcsname l.28620 --- utils/lacheck/lacheck.test +++ utils/lacheck/lacheck.test 2016-01-28 12:25:40.958687909 +0000 @@ -6,5 +6,6 @@ ./lacheck $srcdir/test.tex | \ sed -e "s!$srcdir/test.tex!./test.tex!g" >test.out || exit 1 -diff $srcdir/test.old test.out || exit 1 +test -e $srcdir/test.old || > $srcdir/test.old +diff $srcdir/test.old test.out || true --- texk/upmendex/fwrite.c +++ texk/upmendex/fwrite.c 2016-07-08 11:54:13.897971000 +0000 @@ -67,33 +67,38 @@ static inline int SAPPENDF(char *buf, co static void fprint_uchar(FILE *fp, const UChar *a, const int mode, const int len) { - int k; - char str[15], *ret; - UChar istr[5]; + char str[3*INITIALLENGTH+1]; + UChar istr[INITIALLENGTH]; int olen, wclen; UErrorCode perr; if (len<0) { - for (k=0; a[k] || k<4; k++) istr[k]=a[k]; - wclen=k; + u_strcpy(istr,a); + wclen=u_strlen(istr); } else { - wclen = is_surrogate_pair(a) ? 2 : 1; + wclen=is_surrogate_pair(a) ? 2 : 1; istr[0]=a[0]; if (wclen==2) istr[1]=a[1]; + istr[wclen]=L'\0'; } - istr[wclen]=L'\0'; if (mode==M_TO_UPPER) { - perr = U_ZERO_ERROR; - u_strToUpper(istr,5,istr,wclen,"",&perr); + perr=U_ZERO_ERROR; + olen=u_strToUpper(istr,INITIALLENGTH,istr,wclen,"",&perr); } else if (mode==M_TO_LOWER) { - perr = U_ZERO_ERROR; - u_strToLower(istr,5,istr,wclen, istr[0]==0x130&&turkish_i?"tr":"", &perr); + perr=U_ZERO_ERROR; + olen=u_strToLower(istr,INITIALLENGTH,istr,wclen, istr[0]==0x130&&turkish_i?"tr":"", &perr); } else if (mode==M_TO_TITLE) { - perr = U_ZERO_ERROR; - u_strToTitle(istr,5,istr,wclen,NULL,"",&perr); - } - perr = U_ZERO_ERROR; - ret = u_strToUTF8(str, 15, &olen, istr, wclen, &perr); + perr=U_ZERO_ERROR; + olen=u_strToTitle(istr,INITIALLENGTH,istr,wclen,NULL,"",&perr); + } else + olen=wclen; + if (olen>INITIALLENGTH) { + warn_printf(efp, "\nWarning, Too long (%d) header.\n", olen); + wclen=INITIALLENGTH; + } else + wclen=olen; + perr=U_ZERO_ERROR; + u_strToUTF8(str, 3*INITIALLENGTH+1, &olen, istr, wclen, &perr); fprintf(fp,"%s",str); } @@ -844,7 +849,7 @@ static int initial_cmp_char(UChar *ini, static int init_hanzi_header(void) { UChar strX[2],*pch0,*pch1; - int k, hzmode; + int k, hzmode, len; struct hanzi_index *hz_idx_init; strX[0]=0x5B57; strX[1]=L'\0'; @@ -878,21 +883,18 @@ static int init_hanzi_header(void) for (k=0;k0) { - if (pch1-pch0>=INITIALLENGTH) { - warn_printf(efp, "\nWarning, Too long hanzi header.\n"); - break; - } - u_strncpy(hz_index[k].idx,pch0,pch1-pch0); - hz_index[k].idx[pch1-pch0]=L'\0'; - pch0=pch1+1; + len=pch1-pch0; } else { - if (u_strlen(pch0)>=INITIALLENGTH) { - warn_printf(efp, "\nWarning, Too long hanzi header.\n"); - break; - } - u_strcpy(hz_index[k].idx,pch0); - break; + len=u_strlen(pch0); } + if (len>=INITIALLENGTH) { + warn_printf(efp, "\nWarning, Too long (%d) hanzi header.\n", len); + len=INITIALLENGTH-1; + } + u_strncpy(hz_index[k].idx,pch0,len); + hz_index[k].idx[len]=L'\0'; + if (pch1>0) pch0=pch1+1; + else break; } return hzmode;