Commit 85c2d81f authored by Alexander Gottwald's avatar Alexander Gottwald

Set most significant bit to be a one. (Bug #1024, Kensuke Matsuzaki)

Fix conversion from sjis and euc. (Bug #1024, Toshio Takabe)
parent c4d56e4e
...@@ -832,6 +832,8 @@ euc_ctstowcs( ...@@ -832,6 +832,8 @@ euc_ctstowcs(
wchar_t wch; wchar_t wch;
Ulong wc_encoding; Ulong wc_encoding;
CTData ctdp = ctdata; CTData ctdp = ctdata;
CTData GL_ctdp = ctdp; /* GL ctdp save */
CTData GR_ctdp = ctdp; /* GR ctdp save */
Bool save_outbuf = True; Bool save_outbuf = True;
/* If outbufptr is NULL, doen't save output, but just counts /* If outbufptr is NULL, doen't save output, but just counts
a length to hold the output */ a length to hold the output */
...@@ -840,6 +842,18 @@ euc_ctstowcs( ...@@ -840,6 +842,18 @@ euc_ctstowcs(
for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length) for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
{ {
ct_type = CT_STD; ct_type = CT_STD;
/* change GL/GR charset */
if(ctdp->side == XlcGR && isleftside(*inbufptr)){
/* select GL side */
ctdp = GL_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
/* select GR side */
ctdp = GR_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}
if (*inbufptr == '\033' || *inbufptr == (char)'\233') { if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
...@@ -856,6 +870,11 @@ euc_ctstowcs( ...@@ -856,6 +870,11 @@ euc_ctstowcs(
} }
} }
ct_type = ctdp->ct_type; ct_type = ctdp->ct_type;
if(ctdp->side == XlcGL){
GL_ctdp = ctdp; /* save GL ctdp */
}else{
GR_ctdp = ctdp; /* save GR ctdp */
}
break; break;
} }
} }
...@@ -1091,6 +1110,8 @@ euc_ctstombs( ...@@ -1091,6 +1110,8 @@ euc_ctstombs(
unsigned int ct_seglen = 0; unsigned int ct_seglen = 0;
Uchar ct_type = 0; Uchar ct_type = 0;
CTData ctdp = &ctdata[0]; /* default */ CTData ctdp = &ctdata[0]; /* default */
CTData GL_ctdp = ctdp; /* GL ctdp save */
CTData GR_ctdp = ctdp; /* GR ctdp save */
Bool save_outbuf = True; Bool save_outbuf = True;
/* If outbufptr is NULL, doen't save output, but just counts /* If outbufptr is NULL, doen't save output, but just counts
a length to hold the output */ a length to hold the output */
...@@ -1099,6 +1120,18 @@ euc_ctstombs( ...@@ -1099,6 +1120,18 @@ euc_ctstombs(
for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length) for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
{ {
ct_type = CT_STD; ct_type = CT_STD;
/* change GL/GR charset */
if(ctdp->side == XlcGR && isleftside(*inbufptr)){
/* select GL side */
ctdp = GL_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
/* select GR side */
ctdp = GR_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}
if (*inbufptr == '\033' || *inbufptr == (char)'\233') { if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
...@@ -1116,6 +1149,11 @@ euc_ctstombs( ...@@ -1116,6 +1149,11 @@ euc_ctstombs(
} }
} }
ct_type = ctdp->ct_type; ct_type = ctdp->ct_type;
if(ctdp->side == XlcGL){
GL_ctdp = ctdp; /* save GL ctdp */
}else{
GR_ctdp = ctdp; /* save GR ctdp */
}
break; break;
} }
} }
......
...@@ -991,6 +991,13 @@ sjis_mbstocts( ...@@ -991,6 +991,13 @@ sjis_mbstocts(
ct_state.GR_charset = charset; ct_state.GR_charset = charset;
else if (charset->side == XlcGL) else if (charset->side == XlcGL)
ct_state.GL_charset = charset; ct_state.GL_charset = charset;
if (charset->side == XlcGR) {
clen = charset->length;
do {
(*(Uchar *)(ctptr-clen)) = BIT8ON(*(Uchar *)(ctptr-clen));
} while (--clen);
}
} }
*to = (XPointer)ctptr; *to = (XPointer)ctptr;
...@@ -1147,6 +1154,8 @@ sjis_ctstombs( ...@@ -1147,6 +1154,8 @@ sjis_ctstombs(
unsigned int ct_seglen = 0; unsigned int ct_seglen = 0;
Uchar ct_type; Uchar ct_type;
CTData ctdp = ctdata; /* default */ CTData ctdp = ctdata; /* default */
CTData GL_ctdp = ctdp; /* GL ctdp save */
CTData GR_ctdp = ctdp; /* GR ctdp save */
if (*from_left > *to_left) if (*from_left > *to_left)
*from_left = *to_left; *from_left = *to_left;
...@@ -1154,6 +1163,18 @@ sjis_ctstombs( ...@@ -1154,6 +1163,18 @@ sjis_ctstombs(
for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length) for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length)
{ {
ct_type = CT_STD; ct_type = CT_STD;
/* change GL/GR charset */
if(ctdp->side == XlcGR && isleftside(*inbufptr)){
/* select GL side */
ctdp = GL_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
/* select GR side */
ctdp = GR_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}
if (*inbufptr == '\033' || *inbufptr == (char)'\233') { if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
...@@ -1171,6 +1192,11 @@ sjis_ctstombs( ...@@ -1171,6 +1192,11 @@ sjis_ctstombs(
} }
} }
ct_type = ctdp->ct_type; ct_type = ctdp->ct_type;
if(ctdp->side == XlcGL){
GL_ctdp = ctdp; /* save GL ctdp */
}else{
GR_ctdp = ctdp; /* save GR ctdp */
}
break; break;
} }
} }
...@@ -1265,6 +1291,8 @@ sjis_ctstowcs( ...@@ -1265,6 +1291,8 @@ sjis_ctstowcs(
wchar_t wch; wchar_t wch;
Ulong wc_encoding; Ulong wc_encoding;
CTData ctdp = ctdata; CTData ctdp = ctdata;
CTData GL_ctdp = ctdp; /* GL ctdp save */
CTData GR_ctdp = ctdp; /* GR ctdp save */
if (*from_left > *to_left) if (*from_left > *to_left)
*from_left = *to_left; *from_left = *to_left;
...@@ -1272,6 +1300,18 @@ sjis_ctstowcs( ...@@ -1272,6 +1300,18 @@ sjis_ctstowcs(
for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length ) for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length )
{ {
ct_type = CT_STD; ct_type = CT_STD;
/* change GL/GR charset */
if(ctdp->side == XlcGR && isleftside(*inbufptr)){
/* select GL side */
ctdp = GL_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
/* select GR side */
ctdp = GR_ctdp;
length = ctdp->length;
ct_type = ctdp->ct_type;
}
if (*inbufptr == '\033' || *inbufptr == (char)'\233') { if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
...@@ -1288,6 +1328,11 @@ sjis_ctstowcs( ...@@ -1288,6 +1328,11 @@ sjis_ctstowcs(
} }
} }
ct_type = ctdp->ct_type; ct_type = ctdp->ct_type;
if(ctdp->side == XlcGL){
GL_ctdp = ctdp; /* save GL ctdp */
}else{
GR_ctdp = ctdp; /* save GR ctdp */
}
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment