perky 03/05/26 08:06:46
Modified: src _shift_jis.c
Log:
Iterate correctly for JIS X 0201
Revision Changes Path
1.4 +13 -10 cjkcodecs/src/_shift_jis.c
Index: _shift_jis.c
===================================================================
RCS file: /cvsroot/koco/cjkcodecs/src/_shift_jis.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- _shift_jis.c 26 May 2003 07:37:09 -0000 1.3
+++ _shift_jis.c 26 May 2003 15:06:45 -0000 1.4
@@ -26,7 +26,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: _shift_jis.c,v 1.3 2003/05/26 07:37:09 perky Exp $
+ * $Id: _shift_jis.c,v 1.4 2003/05/26 15:06:45 perky Exp $
*/
#include "codeccommon.h"
@@ -89,10 +89,9 @@
{
while (inleft > 0) {
unsigned char c = **inbuf;
- Py_UNICODE code;
RESERVE_OUTBUF(1)
- JISX0201_DECODE(c, code)
+ JISX0201_DECODE(c, **outbuf)
else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)) {
unsigned char c1, c2;
@@ -106,23 +105,27 @@
c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1) + 0x21);
c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21;
- TRYMAP_DEC(jisx0208, code, c1, c2);
- else return 2;
+ TRYMAP_DEC(jisx0208, **outbuf, c1, c2) {
+ NEXT(2, 1)
+ continue;
+ } else
+ return 2;
} else if (c >= 0xf0 && c <= 0xf9) {
unsigned char c2;
RESERVE_INBUF(2)
c2 = (*inbuf)[1];
- if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc))
- code = 0xe000 + 188 * (c - 0xf0) +
+ if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) {
+ **outbuf = 0xe000 + 188 * (c - 0xf0) +
(c2 < 0x80 ? c2 - 0x40 : c2 - 0x41);
- else
+ NEXT(2, 1)
+ continue;
+ } else
return 2;
} else
return 2;
- **outbuf = code;
- NEXT(2, 1)
+ NEXT(1, 1) /* JIS X 0201 */
}
return 0;
|