--- cvs-1.11.6-orig/src/client.c Wed May 21 03:12:22 2003 +++ cvs-1.11.6/src/client.c Fri Jun 6 01:07:39 2003 @@ -22,6 +22,10 @@ #include "edit.h" #include "buffer.h" +/* JCONV patch */ +#include "subr_jconv.h" +/* patch end */ + #ifdef CLIENT_SUPPORT # include "md5.h" @@ -861,7 +865,12 @@ } if (resultp != NULL) + { +/* JCONV patch */ + MEMJCNV_TO_CLIENT(&result, &len); +/* patch end */ *resultp = result; + } else free (result); @@ -1923,8 +1932,14 @@ (unsigned char *) buf, size)) error (1, 0, "aborting due to compression error"); } - else if (write (fd, buf, size) != size) - error (1, errno, "writing %s", short_pathname); + else + { +/* JCONV patch */ + if (!bin) MEMJCNV_TO_CLIENT(&buf, &size); /* jcode conversion */ +/* patch end */ + if (write (fd, buf, size) != size) + error (1, errno, "writing %s", short_pathname); + } } if (close (fd) < 0) @@ -1983,6 +1998,9 @@ get_file (filename, short_pathname, bin ? FOPEN_BINARY_READ : "r", &filebuf, &filebufsize, &nread); +/* JCONV patch */ + if (!bin) MEMJCNV_TO_SERVER(&filebuf, &nread); +/* patch end */ /* At this point the contents of the existing file are in FILEBUF, and the length of the contents is in NREAD. The contents of the patch from the network are in BUF, @@ -2021,6 +2039,10 @@ { FILE *e; +/* JCONV patch */ + if (!bin) MEMJCNV_TO_CLIENT(&patchedbuf, &patchedlen); +/* patch end */ + e = open_file (temp_filename, bin ? FOPEN_BINARY_WRITE : "w"); if (fwrite (patchedbuf, 1, patchedlen, e) != patchedlen) @@ -4935,6 +4957,9 @@ error (1, errno, "reading %s", short_pathname); newsize = bufp - buf; +/* JCONV patch */ + if (!bin) MEMJCNV_TO_SERVER(&buf, &newsize); +/* patch end */ } if (close (fd) < 0) error (0, errno, "warning: can't close %s", short_pathname); --- cvs-1.11.6-orig/src/commit.c Sun May 25 23:10:16 2003 +++ cvs-1.11.6/src/commit.c Fri Jun 6 01:12:52 2003 @@ -21,6 +21,10 @@ #include "fileattr.h" #include "hardlink.h" +/* JCONV patch */ +#include "subr_jconv.h" +/* patch end */ + static Dtype check_direntproc PROTO ((void *callerdat, char *dir, char *repos, char *update_dir, List *entries)); @@ -510,6 +514,10 @@ if (use_editor) do_editor (".", &saved_message, (char *)NULL, find_args.ulist); +/* JCONV patch */ + MEMJCNV_TO_SERVER(&saved_message, NULL); +/* patch end */ + /* We always send some sort of message, even if empty. */ option_with_arg ("-m", saved_message ? saved_message : ""); @@ -1224,8 +1232,13 @@ !server_active && #endif use_editor) + { do_editor (finfo->update_dir, &saved_message, finfo->repository, ulist); +/* JCONV patch */ + MEMJCNV_TO_SERVER(&saved_message, NULL); +/* patch end */ + } do_verify (&saved_message, finfo->repository); } @@ -1501,7 +1514,12 @@ !server_active && #endif use_editor) + { do_editor (update_dir, &saved_message, real_repos, ulist); +/* JCONV patch */ + MEMJCNV_TO_SERVER(&saved_message, NULL); +/* patch end */ + } do_verify (&saved_message, real_repos); free (real_repos); return (R_PROCESS); --- cvs-1.11.6-orig/src/import.c Sat Feb 1 05:15:11 2003 +++ cvs-1.11.6/src/import.c Fri Jun 6 01:14:42 2003 @@ -20,6 +20,10 @@ #include "savecwd.h" #include +/* JCONV patch */ +#include "subr_jconv.h" +/* patch end */ + static char *get_comment PROTO((char *user)); static int add_rev PROTO((char *message, RCSNode *rcs, char *vfile, char *vers)); @@ -229,6 +233,9 @@ repository, (List *) NULL); } +/* JCONV patch */ + MEMJCNV_TO_SERVER(&message, NULL); +/* patch end */ do_verify (&message, repository); msglen = message == NULL ? 0 : strlen (message); if (msglen == 0 || message[msglen - 1] != '\n') --- cvs-1.11.6-orig/src/subr.c Fri Mar 7 05:58:14 2003 +++ cvs-1.11.6/src/subr.c Fri Jun 6 01:19:32 2003 @@ -913,5 +913,10 @@ #endif } } + +/* JCONV patch */ +#include "subr_jconv.c" +/* patch end */ + /* vim:tabstop=8:shiftwidth=4 */ --- cvs-1.11.6-orig/src/subr_jconv.c Thu Jan 1 09:00:00 1970 +++ cvs-1.11.6/src/subr_jconv.c Wed Jun 4 11:29:59 2003 @@ -0,0 +1,137 @@ +/* + On-memory ShiftJIS / EUC Converter +*/ + +#include + +/* first byte of EUC char? */ +#define is_euc1(c) (0xa1 <= (c) && (c) <= 0xfe) + +#define KANA_SHIFT 0x8e + +/* second byte of EUC char? */ +#define is_euc2(c) is_euc1(c) + +/* first byte of SJIS char? */ +#define is_sjis1(c) (0x81 <= (c) && (c) <= 0x9f || 0xe0 <= (c) && (c) <= 0xfc) + +/* second byte of SJIS char? */ +#define is_sjis2(c) (0x40 <= (c) && (c) <= 0x7e || 0x80 <= (c) && (c) <= 0xfc) + +/* 1byte Kana char? */ +#define is_kana(c) (0xa1 <= (c) && (c) <= 0xdf) + +/* scan 8bit char */ +static int scan_8bit_char(const unsigned char *s, int len) +{ + int i; + for (i = 0; i < len; ++i) { + if (s[i] >= 0x80) return 1; + } + return 0; +} + +/* convert ShiftJIS char into EUC char */ +static unsigned short sjis2euc(unsigned short c) +{ + unsigned short c2; + + c2 = c & 0xff; + if (c2 > 0x7e) --c2; + c2 -= 0x40; + c >>= 8; + if (c > 0x9f) c -= 0x40; + c = (c - 0x81) * 2; + if (c2 >= 0x5e) { + c2 -= 0x5e; + ++c; + } + return (c << 8) + c2 + 0xa1a1; +} + +/* convert EUC char into ShiftJIS char */ +static unsigned short euc2sjis(unsigned short c) +{ + unsigned short c2; + + c -= 0xa1a1; + c2 = c & 0xff; + if (c & 0x100) c2 += 0x5e; + c >>= 9; + if ((c += 0x81) > 0x9f) + c += 0x40; + if ((c2 += 0x40) > 0x7e) + ++c2; + return (c << 8) + c2; +} + +/* convert from EUC into ShiftJIS */ +/* psiz ==NULL specifies C-string (terminated by 0) */ +void memjcnv_euc2sjis(char **pmem, int *psiz) +{ + int len = (psiz != NULL) ? *psiz : strlen(*pmem); + if (scan_8bit_char(*pmem, len)) { + unsigned char *beg = (unsigned char *)(*pmem); + unsigned char *end = beg + len; + unsigned char *src = beg; + unsigned char *dst = beg; + unsigned short c1; + + while (src < end && (c1 = *src++) != 0) { + unsigned short c2 = *src; + if (src < end && is_euc1(c1) && is_euc2(c2)) { + unsigned short cc = euc2sjis((c1 << 8) + c2); + *dst++ = cc >> 8; + *dst++ = cc & 0xff; + src++; + } else if (src < end && c1 == KANA_SHIFT && is_kana(c2)) { + *dst++ = c2; + src++; + } else { + *dst++ = c1; + } + } + + if (dst < end) { + *dst = 0; + if (psiz != NULL) *psiz = dst - beg; + } + } +} + + +/* convert from ShiftJIS into EUC */ +/* psiz ==NULL specifies C-string (terminated by 0) */ +void memjcnv_sjis2euc(char **pmem, int *psiz) +{ + int len = (psiz != NULL) ? *psiz : strlen(*pmem); + if (scan_8bit_char(*pmem, len)) { + char *mem = (char *)xmalloc( len*2 + 1 ); + unsigned char *beg = (unsigned char *)(*pmem); + unsigned char *end = beg + len; + unsigned char *src = beg; + unsigned char *dst = (unsigned char *)mem; + unsigned short c1; + + while (src < end && (c1 = *src++) != 0) { + unsigned short c2 = *src; + if (src < end && is_sjis1(c1) && is_sjis2(c2)) { + unsigned short cc = sjis2euc((c1 << 8) + c2); + *dst++ = cc >> 8; + *dst++ = cc & 0xff; + src++; + } else if (src < end && is_kana(c1)) { + *dst++ = KANA_SHIFT; + *dst++ = c1; + } else { + *dst++ = c1; + } + } + + *dst = 0; + free(*pmem); + *pmem = mem; + if (psiz != NULL) *psiz = (char *)dst - mem; + } +} + --- cvs-1.11.6-orig/src/subr_jconv.h Thu Jan 1 09:00:00 1970 +++ cvs-1.11.6/src/subr_jconv.h Wed Jun 4 10:58:47 2003 @@ -0,0 +1,13 @@ +/* EUC (local) <=> SJIS (repository) conversion */ +#define EUC_CLIENT + +#ifdef EUC_CLIENT +# define MEMJCNV_TO_CLIENT memjcnv_sjis2euc +# define MEMJCNV_TO_SERVER memjcnv_euc2sjis +#else +# define MEMJCNV_TO_CLIENT memjcnv_euc2sjis +# define MEMJCNV_TO_SERVER memjcnv_sjis2euc +#endif + +extern void memjcnv_euc2sjis(char **pmem, int *psiz); +extern void memjcnv_sjis2euc(char **pmem, int *psiz); --- cvs-1.11.6-orig/src/version.c Sat Feb 1 05:15:13 2003 +++ cvs-1.11.6/src/version.c Fri Jun 6 01:18:22 2003 @@ -14,9 +14,13 @@ #ifdef CLIENT_SUPPORT #ifdef SERVER_SUPPORT -char *config_string = " (client/server)\n"; +/* JCONV patch */ +char *config_string = " (client/server with sjis/euc conversion 1.1)\n"; +/* char *config_string = " (client/server)\n"; */ #else -char *config_string = " (client)\n"; +char *config_string = " (client with sjis/euc conversion 1.1)\n"; +/* char *config_string = " (client)\n"; */ +/* patch end */ #endif #else #ifdef SERVER_SUPPORT