kcc-2.3.orig/ 40755 0 0 0 6331376204 11043 5ustar rootrootkcc-2.3.orig/Makefile100444 0 0 2037 5604006250 12571 0ustar rootroot##### << kcc---kanji code converter >> #### # # Makefile # Aug 24 1992 # mod: Feb 03 1994 ################################################### tonooka ############ # @(#)Makefile 2.3 (Y.Tonooka) 3/28/94 BINPATH = /usr/local/bin MANPATH = /usr/man JMANDIR = ja_JP.ujis CFLAGS = -O SHELL = /bin/sh CP = cp MAKE = make INSTALL = install CMDS = kcc SRCS = kcc.c OBJS = kcc.o all: kcc kcc: kcc.o $(CC) $(CFLAGS) -o kcc kcc.o install: $(BINPATH)/kcc @echo "\`make install' done." @echo "Run \`make install.man' to install a manual." install.man: $(MANPATH)/$(JMANDIR)/man1/kcc.1 $(BINPATH)/kcc: kcc.c $(MAKE) kcc $(INSTALL) -s kcc $(BINPATH) $(MANPATH)/$(JMANDIR)/man1/kcc.1: kcc.jman $(INSTALL) -m 644 kcc.jman $@ clean: rm -f $(CMDS) $(OBJS) mon.out gmon.out make.log lint: $(SRCS) $(LINT) $(LINTFLAGS) $(SRCS) kcc-2.3.orig/kcc.c100644 0 0 105706 5604727004 12115 0ustar rootroot/**** << kanji code converter >> **** * * kcc.c * Aug 13 1992 * mod: Jul 1 1994 ************************************************** tonooka ***********/ /* * Copyright (c) 1994 Yasuhiro Tonooka (tonooka@msi.co.jp) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if !defined lint static char sccsid[] = "@(#)kcc.c 2.3 (Y.Tonooka) 7/1/94"; static char copyright[] = "@(#)Copyright (c) 1992 Yasuhiro Tonooka"; #endif #include #include #include #include /*- * OPTIONS * -O or -IO * I specifies input code and O specifies output code. * When input code is not specified, kcc guesses kanji * code. * I is one of: * e EUC (with 7-bit JIS) * d DEC (with 7-bit JIS) * s shift-JIS (with 7-bit JIS) * j, 7 or k * 7-bit JIS * 8 8-bit JIS * O is one of: * e EUC * d DEC * s shift-JIS * jXY, 7XY * 7-bit JIS * kXY 7-bit JIS using "ESC(I" for JIS katakana * 8XY 8-bit JIS * where X is: * B "ESC$B" as kanji shift in * @ "ESC$@" as kanji shift in * + "ESC&@ESC$B" as kanji shift in * Y is: * B "ESC(B" as kanji shift out * J "ESC(J" as kanji shift out * H "ESC(H" as kanji shift out * * -c Check: Only tells file type to stdout. Overrides any * other option except -x and -z. In this mode, kcc * reads all thru the input file to guess the file type. * * -v Verbose: Prints to stderr which kanji code system * kcc guessed the input code is in. * * -x Extended mode: In this mode, recognized area of each * code system is extended in guessing. * * -z Reduced mode: In this mode, only zenkaku characters * are recognized with EUC and shift-JIS in guessing. * (Reduces ambiguity). * * -n Gaiji & undefined kankaku kana characters are replaced * with padding character. * * -h Hiragana is used instead of katakana when converting * hankaku kana to DEC zenkaku. * * -b xxx Specify hold buffer size to xxx (byte). */ #define LENLINE (BUFSIZ * 4) #define HOLDBUFSIZ 8192 /* default size of hold buffer */ #define ESC 0x1b #define SO 0x0e #define SI 0x0f #define SS2 0x8e /* EUC single shift 2 */ #define SS3 0x8f /* EUC single shift 3 */ #define ZENPAD 0x2222 /* padding char for zenkaku */ #define HANPAD 0x25 /* padding char for hankaku */ typedef int bool; #define bitflag(c) (1L << (c) - '@') #define NONASCII 0x01 /* non-ASCII character */ #define JIS 0x02 /* JIS */ #define ESCI 0x04 /* "ESC(I" */ #define ASSUME 0x08 /* assumed EUC (or DEC) */ #define EUC 0x10 #define DEC 0x20 #define SJIS 0x40 #define JIS8 0x80 /* 8-bit JIS */ #define BIT8 (EUC | DEC | SJIS | JIS8) enum mode { M_ASCII, M_KANJI, M_GAIJI, M_SO, /* hankaku kana with SO */ M_ESCI, /* hankaku kana with "ESC(I" */ }; char *progname; char *filename = NULL; char shiftin[7] = "\033$B"; char shiftout[4] = "\033(J"; unsigned incode = 0; unsigned outcode = JIS; bool verbose = 0; bool docheck = 0; bool extend = 0; bool zenkaku = 0; bool nogaiji = 0; extern unsigned short katakana[]; extern unsigned short hiragana[]; unsigned short *kanatbl = katakana; void error(); /********************************************************************** * * * Main Routines * * * **********************************************************************/ /*--------------------------------------------------------------------- NAME main ---------------------------------------------------------------------*/ main(c, v) register int c; register char *v[]; { register char *s; bool codeopt = 0; /* code option is read */ FILE *iop; int status; int dev, ino = -1; struct stat sbuf; unsigned size = HOLDBUFSIZ; void filter(); void check(); void buffalloc(); void setfunc(); progname = *v++; /* * Process options here. */ for (; --c; v++) { /* * With -, input is taken from stdin like cat(1). */ if ((*v)[0] != '-' || (*v)[1] == '\0') break; /* * Size of hold buf can be changed with "-b size". */ if (strcmp(*v, "-b") == 0) { if (--c == 0) error("%s option must have an argument", *v); v++; if ((size = atoi(*v)) <= 0) error("bad buffer size"); continue; } /* * Options: */ for (s = *v + 1; *s; s++) { if (strchr("esdj7k8", *s)) { if (codeopt) error("%s: duplicate code specification", *v); codeopt = 1; if (s[1] && strchr("esdj7k8", s[1])) /* * Input code: e, s, j, 7, k or 8. */ switch (*s++) { case 'e': /* EUC with JIS */ incode = EUC | NONASCII; break; case 's': /* shift-JIS with JIS */ incode = SJIS | NONASCII; break; case 'd': /* DEC with JIS */ incode = DEC | NONASCII; break; case 'j': /* JIS */ case '7': /* equivalent to 'j' */ case 'k': /* JIS */ incode = JIS; break; case '8': /* 8-bit JIS */ incode = JIS | JIS8 | NONASCII; break; } /* * Output code: e, s, d, jXY, 7XY, kXY or 8XY. */ switch (*s) { case 'e': /* EUC */ outcode = EUC; continue; case 's': /* shift-JIS */ outcode = SJIS; continue; case 'd': /* EUC */ outcode = DEC; continue; case 'j': /* 7-bit JIS using SO & SI */ case '7': /* equivalent to 'j' */ outcode = JIS; break; case 'k': /* 7-bit JIS using "ESC(I" */ outcode = JIS | ESCI; break; case '8': /* 8-bit JIS */ outcode = JIS | JIS8; break; } /* * Process "XY" part of options j, 7, k & 8. */ if ((s[1] == 'B' || s[1] == '@' || s[1] == '+') && (s[2] == 'B' || s[2] == 'J' || s[2] == 'H')) { if (s[1] == '+') sprintf(shiftin, "\033&@\033$B"); else sprintf(shiftin, "\033$%c", s[1]); sprintf(shiftout, "\033(%c", s[2]); s += 2; } continue; } /* * Other one letter options: */ switch (*s) { case 'c': /* check */ docheck = 1; break; case 'h': /* hiragana for hankaku->DEC */ kanatbl = hiragana; break; case 'n': /* no gaiji */ nogaiji = 1; break; case 'v': /* verbose */ verbose = 1; break; case 'x': /* extended mode */ extend = 1; break; case 'z': /* reduced mode */ zenkaku = 1; break; default: error("-%c: bad option", *s); } } } if (extend && zenkaku) error("-x and -z can't go together"); if (!docheck) { buffalloc(size); /* allocate hold buf */ setfunc(); } /* * Get some info on output file. */ if (fstat(fileno(stdout), &sbuf) == 0) { sbuf.st_mode &= S_IFMT; if (sbuf.st_mode != S_IFCHR && sbuf.st_mode != S_IFBLK) { dev = sbuf.st_dev; ino = sbuf.st_ino; } } /* * Main loop. */ status = 0; do { if (c == 0 || strcmp(*v, "-") == 0) { /* * Stdin: If tty and at EOF, clear EOF. */ if (isatty(fileno(stdin)) && feof(stdin)) clearerr(stdin); iop = stdin; } else /* * Open a file. */ if ((iop = fopen(*v, "r")) == NULL) { perror(*v); status |= 1; continue; } if (c) filename = *v; if (fstat(fileno(iop), &sbuf) == 0) { /* * Get some info on input file, and see if it is a * directory. */ if ((sbuf.st_mode & S_IFMT) == S_IFDIR) { fprintf(stderr, "%s: read error on %s: Is a directory\n", progname, c ? *v : "standard input"); if (iop != stdin) fclose(iop); status |= 1; continue; } /* * Compare the info of input with that of output, and see * if they are identical. */ if ((sbuf.st_mode & S_IFMT) == S_IFREG && sbuf.st_dev == dev && sbuf.st_ino == ino) { fprintf(stderr, "%s: input %s is output\n", progname, c ? *v : "-"); if (iop != stdin) fclose(iop); status |= 1; continue; } } /* * Do the job here! */ if (docheck) check(iop); else filter(iop); if (iop != stdin) fclose(iop); } while (v++, --c > 0); if (ferror(stdout)) error("output write error"); return (status); } /*--------------------------------------------------------------------- NAME error - print formatted error message on stderr and die ---------------------------------------------------------------------*/ #include void error(va_alist) va_dcl { va_list args; va_start(args); fprintf(stderr, "%s: ", progname); vfprintf(stderr, va_arg(args, char *), args); putc('\n', stderr); va_end(args); exit(1); } /********************************************************************** * * * Filter * * * **********************************************************************/ enum mode gsmode; /* guess: M_ASCII M_KANJI M_SO */ enum mode inmode; /* input: M_ASCII M_KANJI M_GAIJI * M_SO M_ESCI */ enum mode outmode; /* output: M_ASCII M_KANJI M_GAIJI * M_SO M_ESCI */ unsigned long insi; /* JIS shift-in sequence flag */ unsigned long inso; /* JIS shift-out sequence flag * including "ESC(I" */ unsigned long innj; /* JIS 1990 sequence flag */ unsigned long ingj; /* JIS 1990 aux flag */ /*--------------------------------------------------------------------- NAME filter - filtering routine ---------------------------------------------------------------------*/ void filter(fp) FILE *fp; { register bool hold; register unsigned code, c; register int len; char str[LENLINE]; unsigned guess(); bool append(); void flush(); unsigned out(); void showcode(); code = incode ? incode : extend ? BIT8 : BIT8 & ~DEC; gsmode = inmode = outmode = M_ASCII; insi = inso = innj = ingj = 0; hold = 0; while (len = getstr(str, sizeof str, fp)) { if (!(code & NONASCII) && code & BIT8 || code & (EUC | DEC) && code & SJIS && !(code & ASSUME)) { /* * So far, no kanji has been seen, or ambiguous. */ c = guess(str, len); code |= c & (JIS | NONASCII), code &= c | ~BIT8; if (code & NONASCII && code & (EUC | DEC) && code & SJIS) { /* * If ambiguous, store the line in hold buffer. */ if (append(str, len)) { hold = 1; continue; } /* * When buffer is full, assume EUC/DEC. */ code |= ASSUME; } } if (hold) { /* * Flush hold buffer. */ flush(code); hold = 0; } c = out(str, len, code); code |= c & JIS, code &= c | ~BIT8; } if (hold) /* * Assume EUC. */ flush(code |= ASSUME); if (verbose) showcode(code, stderr); } /*--------------------------------------------------------------------- NAME check ---------------------------------------------------------------------*/ void check(fp) FILE *fp; { register unsigned code, c; register int len; char str[LENLINE]; void showcode(); unsigned guess(); code = extend ? BIT8 : BIT8 & ~DEC; gsmode = M_ASCII; insi = inso = innj = ingj = 0; while (len = getstr(str, sizeof str, fp)) { c = guess(str, len); code |= c & (JIS | NONASCII), code &= c | ~BIT8; if (code & NONASCII && !(code & BIT8)) break; } showcode(code, stdout); } /*--------------------------------------------------------------------- NAME showcode ---------------------------------------------------------------------*/ void showcode(code, fp) register unsigned code; register FILE *fp; { char *s; void showjis(); if (filename) if (fprintf(fp, "%s:\t", filename) < 9) putc('\t', fp); if (!(code & NONASCII)) { /* * 7-bit JIS / ASCII. */ if (code & JIS) { showjis('7', fp); putc('\n', fp); } else fputs("ASCII\n", fp); return; } else if (code & (EUC | DEC)) { s = code & EUC ? code & DEC ? "EUC/DEC" : "EUC" : "DEC"; if (code & SJIS) { /* * Ambiguous. */ fprintf(fp, "ambiguous (%s", s); if (code & JIS8) { fputs(code & JIS ? " with 7-bit JIS, or " : ", shift-JIS or ", fp); showjis('8', fp); if (code & ASSUME) fprintf(fp, "; assumed %s", code & JIS ? "the former" : s); fputs(")\n", fp); return; } fputs(" or shift-JIS", fp); if (code & ASSUME) fprintf(fp, "; assumed %s", s); fputs(")", fp); } else /* * EUC/DEC. */ fputs(s, fp); } else if (code & JIS8) { /* * 8-bit JIS / shift-JIS or 8-bit JIS. */ if (!(code & JIS)) fputs("shift-JIS or ", fp); showjis('8', fp); putc('\n', fp); return; } else if (code & SJIS) /* * Shift-JIS. */ fputs("shift-JIS", fp); else { /* * Non-ASCII deteced but neither EUC/DEC nor SJIS. */ fputs("data\n", fp); return; } if (code & JIS) { fputs(" with ", fp); showjis('7', fp); } putc('\n', fp); } /*--------------------------------------------------------------------- NAME showjis ---------------------------------------------------------------------*/ void showjis(bit, fp) int bit; /* 8-bit or 7-bit */ FILE *fp; { bool comma; bool showesc(); fprintf(fp, "%c-bit JIS [", bit); comma = showesc("ESC$", insi, 0, fp); comma = showesc("ESC&@ESC$", innj, comma, fp); comma = showesc("ESC(", inso, comma, fp); showesc("ESC$(", ingj, comma, fp); putc(']', fp); } /*--------------------------------------------------------------------- NAME showesc ---------------------------------------------------------------------*/ bool showesc(str, mask, comma, fp) char *str; register unsigned long mask; bool comma; FILE *fp; { register unsigned long m; register int c; for (m = 1, c = '@'; m; m <<= 1, c++) if (mask & m) { if (comma) fputs(", ", fp); else comma = 1; fputs(str, fp); putc(c, fp); } return (comma); } /*--------------------------------------------------------------------- NAME getstr ---------------------------------------------------------------------*/ int getstr(str, n, fp) char *str; register int n; FILE *fp; { register int c; register char *s; for (s = str; --n > 0 && (c = getc(fp)) != EOF; ) if ((*s++ = c) == '\n') break; return (s - str); } /********************************************************************** * * * Hold Buffer Operations * * * **********************************************************************/ char *holdbuf, *bufend; char *bufp; /*--------------------------------------------------------------------- NAME buffalloc ---------------------------------------------------------------------*/ void buffalloc(len) unsigned len; { if ((bufp = holdbuf = (char *) malloc(len)) == NULL) error("out of memory"); bufend = holdbuf + len; } /*--------------------------------------------------------------------- NAME append ---------------------------------------------------------------------*/ bool append(s, len) register char *s; register int len; { if (bufp + len > bufend) return (0); for (; len; --len) *bufp++ = *(u_char *) s++; return (1); } /*--------------------------------------------------------------------- NAME flush ---------------------------------------------------------------------*/ void flush(code) unsigned code; { unsigned out(); out(holdbuf, bufp - holdbuf, code); bufp = holdbuf; } /********************************************************************** * * * General * * * **********************************************************************/ /*--------------------------------------------------------------------- NAME compare ---------------------------------------------------------------------*/ bool compare(s, str) register char *s, *str; { while (*s) if (*s++ != *str++) return (0); return (1); } /********************************************************************** * * * Guessing * * * **********************************************************************/ /*--------------------------------------------------------------------- NAME guess - distinguish code system ---------------------------------------------------------------------*/ unsigned guess(str, len) char *str; int len; { register char *s; register int euc, sjis, dec; bool jis8; register unsigned code; register int i; enum mode old; euc = sjis = 1; dec = extend ? 1 : 0; jis8 = 1; code = 0; for (s = str; s < str + len; s += i) { i = 1; switch (*(u_char *) s) { case ESC: if (gsmode == M_SO) continue; old = gsmode; if (compare("$B", s + 1) || compare("$@", s + 1)) { gsmode = M_KANJI; /* kanji */ insi |= bitflag(((u_char *) s)[2]); i = 3; } else if (compare("&@\033$B", s + 1)) { gsmode = M_KANJI; /* kanji 1990 */ innj |= bitflag('B'); i = 6; } else if (compare("(B", s + 1) || compare("(J", s + 1) || compare("(H", s + 1)) { gsmode = M_ASCII; /* kanji end */ inso |= bitflag(((u_char *) s)[2]); i = 3; } else if (compare("(I", s + 1)) { gsmode = M_KANJI; /* "ESC(I" */ inso |= bitflag('I'); i = 3; } else if (compare("$(D", s + 1)) { gsmode = M_KANJI; /* gaiji */ ingj |= bitflag('D'); i = 4; } else break; code |= JIS; if (old != M_ASCII) continue; break; case SO: if (gsmode == M_ASCII) { code |= JIS; gsmode = M_SO; break; } continue; case SI: if (gsmode == M_SO) { gsmode = M_ASCII; continue; } /* fall thru */ default: if (gsmode != M_ASCII) continue; break; } if (*(u_char *) s & 0x80) code |= NONASCII; switch (euc) { case 1: /* * EUC first byte. */ if (*(u_char *) s & 0x80) { if (0xa0 < *(u_char *) s && *(u_char *) s < 0xff || !zenkaku && *(u_char *) s == SS2) { euc = 2; break; } if (extend) if (*(u_char *) s == SS3) { euc = 2; break; } else if (*(u_char *) s < 0xa0) break; euc = 0; /* not EUC */ } break; case 2: /* * EUC second byte or third byte of CS3. */ if (((u_char *) s)[-1] == SS2) { if (0xa0 < *(u_char *) s && *(u_char *) s < (extend ? 0xff : 0xe0)) { euc = 1; /* hankaku kana */ break; } } else if (0xa0 < *(u_char *) s && *(u_char *) s < 0xff) { if (((u_char *) s)[-1] != SS3) euc = 1;/* zenkaku */ break; } euc = 0; /* not EUC */ break; } if (extend) switch (dec) { case 1: /* * DEC first byte. */ if (*(u_char *) s & 0x80) { if (0xa0 < *(u_char *) s && *(u_char *) s < 0xff) { dec = 2; break; } else if (*(u_char *) s < 0xa0) break; dec = 0; /* not DEC */ } break; case 2: /* * DEC second byte. */ if (0x20 < (*(u_char *) s & 0x7f) && (*(u_char *) s & 0x7f) < 0x7f) { dec = 1; } else dec = 0; /* not DEC */ break; } switch (sjis) { case 1: /* * shift-JIS first byte. */ if (*(u_char *) s & 0x80) { if (0xa0 < *(u_char *) s && *(u_char *) s < 0xe0) { if (!zenkaku) break; /* hankaku */ } else if (*(u_char *) s != 0x80 && *(u_char *) s != 0xa0 && *(u_char *) s <= (extend ? 0xfc : 0xef)) { sjis = 2; /* zenkaku */ jis8 = 0; break; } sjis = 0; /* not SJIS */ } break; case 2: /* * shift-JIS second byte. */ if (0x40 <= *(u_char *) s && *(u_char *) s != 0x7f && *(u_char *) s <= 0xfc) sjis = 1; else sjis = 0; /* not SJIS */ break; } } if (euc == 1) code |= EUC; if (dec == 1) code |= DEC; if (sjis == 1) code |= zenkaku || !jis8 ? SJIS : SJIS | JIS8; return (code); } /********************************************************************** * * * Output Routines * * * **********************************************************************/ void (*outascii)(), (*outkanji)(), (*outgaiji)(), (*outkana)(); /*--------------------------------------------------------------------- NAME out ---------------------------------------------------------------------*/ unsigned out(str, len, code) char *str; int len; register unsigned code; { register char *s; register int i; void outsjis(); for (s = str; s < str + len; s += i) { i = 1; switch (*(u_char *) s) { case ESC: if (inmode == M_SO) break; if (compare("$B", s + 1) || compare("$@", s + 1)) { inmode = M_KANJI; /* kanji */ insi |= bitflag(((u_char *) s)[2]); i = 3; } else if (compare("&@\033$B", s + 1)) { inmode = M_KANJI; /* kanji 1990 */ innj |= bitflag('B'); i = 6; } else if (compare("(B", s + 1) || compare("(J", s + 1) || compare("(H", s + 1)) { inmode = M_ASCII; /* kanji end */ inso |= bitflag(((u_char *) s)[2]); i = 3; } else if (compare("(I", s + 1)) { inmode = M_ESCI; /* "ESC(I" */ inso |= bitflag('I'); i = 3; } else if (compare("$(D", s + 1)) { inmode = M_GAIJI; /* gaiji */ ingj |= bitflag('D'); i = 4; } else break; code |= JIS; continue; case SO: if (inmode == M_ASCII) { code |= JIS; inmode = M_SO; continue; } break; case SI: if (inmode == M_SO) { inmode = M_ASCII; continue; } break; } if (inmode != M_ASCII) { if (0x20 < ((u_char *) s)[0] && ((u_char *) s)[0] < 0x7f) switch (inmode) { case M_KANJI: (*outkanji)(((u_char *) s)[0], ((u_char *) s)[1] & 0x7f); i = 2; continue; case M_GAIJI: (*outgaiji)(((u_char *) s)[0], ((u_char *) s)[1] & 0x7f); i = 2; continue; case M_SO: case M_ESCI: (*outkana)(((u_char *) s)[0]); continue; } } else if (((u_char *) s)[0] & 0x80) if (code & (EUC | DEC)) { /* * EUC or DEC: */ if (0xa0 < ((u_char *) s)[0] && ((u_char *) s)[0] < 0xff) { if (!(((u_char *) s)[1] & 0x80) && code & DEC) { /* * DEC gaiji: */ code &= ~EUC; /* definitely DEC */ (*outgaiji)(((u_char *) s)[0] & 0x7f, ((u_char *) s)[1]); } else /* * EUC code set 1 (kanji), DEC kanji: */ (*outkanji)(((u_char *) s)[0] & 0x7f, ((u_char *) s)[1] & 0x7f); } else if (((u_char *) s)[0] == SS2 && code & EUC && 0xa0 < ((u_char *) s)[1] && ((u_char *) s)[1] < 0xff) { /* * EUC code set 2 (hankaku kana): */ code &= ~DEC; /* probably EUC */ (*outkana)(((u_char *) s)[1] & 0x7f); } else if (((u_char *) s)[0] == SS3 && code & EUC && 0xa0 < ((u_char *) s)[1] && ((u_char *) s)[1] < 0xff && 0xa0 < ((u_char *) s)[2] && ((u_char *) s)[2] < 0xff) { /* * EUC code set 3 (gaiji): */ code &= ~DEC; /* probably EUC */ (*outgaiji)(((u_char *) s)[1] & 0x7f, ((u_char *) s)[2] & 0x7f); i = 3; continue; } else { /* * Control character (C1): */ if (outcode != SJIS && (outcode != EUC || ((u_char *) s)[0] != SS2 && ((u_char *) s)[0] != SS3)) putchar(((u_char *) s)[0]); continue; } i = 2; continue; } else if (code & (SJIS | JIS8)) { /* * Shift-JIS or JIS8: */ if (!(code & SJIS) || 0xa0 < ((u_char *) s)[0] && ((u_char *) s)[0] < 0xe0) /* * Hankaku kana: */ (*outkana)(((u_char *) s)[0] & 0x7f); else { /* * Shift-JIS kanji: */ code &= ~JIS8; /* definitely shift-JIS */ outsjis(((u_char *) s)[0], ((u_char *) s)[1]); i = 2; } continue; } (*outascii)(((u_char *) s)[0]); } return (code); } /*--------------------------------------------------------------------- NAME outsjis ---------------------------------------------------------------------*/ void outsjis(c1, c2) register int c1, c2; { register int c; c = c1 * 2 - (c1 <= 0x9f ? 0x00e1 : (c1 < 0xf0 ? 0x0161 : 0x01bf)); if (c2 < 0x9f) c2 = c2 - (c2 > 0x7f ? 0x20 : 0x1f); else { c2 = c2 - 0x7e; c++; } (*(c1 <= 0xef ? outkanji : outgaiji))(c, c2); } /********************************************************************** * * * Conversion Routines * * * **********************************************************************/ void outchar(); void jisascii(), jiskanji(), jisgaiji(); void jiskana(), jiskanak(), jiskana8(); void euckanji(), eucgaiji(), euckana(); void sjiskanji(), sjisgaiji(), sjiskana(); void decascii(), deckanji(), decgaiji(), deckana(); int lastkana = 0; /* last hankaku kana for DEC */ /*--------------------------------------------------------------------- NAME setfunc ---------------------------------------------------------------------*/ void setfunc() { switch (outcode) { case EUC: outascii = outchar; outkanji = euckanji; outgaiji = eucgaiji; outkana = euckana; break; case DEC: outascii = decascii; outkanji = deckanji; outgaiji = decgaiji; outkana = deckana; break; case SJIS: outascii = outchar; outkanji = sjiskanji; outgaiji = sjisgaiji; outkana = sjiskana; break; default: outascii = jisascii; outkanji = jiskanji; outgaiji = jisgaiji; switch (outcode) { case JIS: /* mode: M_ASCII M_KANJI M_GAIJI * M_SO */ outkana = jiskana; break; case JIS | ESCI: /* mode: M_ASCII M_KANJI M_GAIJI * M_ESCI */ outkana = jiskanak; break; case JIS | JIS8: /* mode: M_ASCII M_KANJI M_GAIJI */ outkana = jiskana8; break; } break; } } /*--------------------------------------------------------------------- NAME outchar ---------------------------------------------------------------------*/ void outchar(c) register int c; { putchar(c); } /*--------------------------------------------------------------------- NAME jisascii ---------------------------------------------------------------------*/ void jisascii(c) register int c; { switch (outmode) { case M_ASCII: break; case M_SO: putchar(SI); outmode = M_ASCII; break; default: fputs(shiftout, stdout); outmode = M_ASCII; break; } putchar(c); } /*--------------------------------------------------------------------- NAME jiskanji ---------------------------------------------------------------------*/ void jiskanji(c1, c2) register int c1, c2; { if (outmode != M_KANJI) { if (outmode == M_SO) putchar(SI); fputs(shiftin, stdout); outmode = M_KANJI; } putchar(c1); putchar(c2); } /*--------------------------------------------------------------------- NAME jisgaiji ---------------------------------------------------------------------*/ void jisgaiji(c1, c2) register int c1, c2; { if (nogaiji) jiskanji(ZENPAD >> 8, ZENPAD & 0xff); else { if (outmode != M_GAIJI) { if (outmode == M_SO) putchar(SI); fputs("\033$(D", stdout); outmode = M_GAIJI; } putchar(c1); putchar(c2); } } /*--------------------------------------------------------------------- NAME jiskana ---------------------------------------------------------------------*/ void jiskana(c) register int c; { if (outmode != M_SO) { if (outmode != M_ASCII) fputs(shiftout, stdout); putchar(SO); outmode = M_SO; } putchar(!nogaiji || 0x20 < c && c < 0x60 ? c : HANPAD); } /*--------------------------------------------------------------------- NAME jiskanak ---------------------------------------------------------------------*/ void jiskanak(c) register int c; { if (outmode != M_ESCI) { fputs("\033(I", stdout); outmode = M_ESCI; } putchar(!nogaiji || 0x20 < c && c < 0x60 ? c : HANPAD); } /*--------------------------------------------------------------------- NAME jiskana8 ---------------------------------------------------------------------*/ void jiskana8(c) register int c; { if (outmode != M_ASCII) { fputs(shiftout, stdout); outmode = M_ASCII; } putchar((!nogaiji || 0x20 < c && c < 0x60 ? c : HANPAD) | 0x80); } /*--------------------------------------------------------------------- NAME euckanji ---------------------------------------------------------------------*/ void euckanji(c1, c2) register int c1, c2; { putchar(c1 | 0x80); putchar(c2 | 0x80); } /*--------------------------------------------------------------------- NAME eucgaiji ---------------------------------------------------------------------*/ void eucgaiji(c1, c2) register int c1, c2; { if (nogaiji) { putchar(ZENPAD >> 8 | 0x80); putchar(ZENPAD & 0xff | 0x80); } else { putchar(SS3); putchar(c1 | 0x80); putchar(c2 | 0x80); } } /*--------------------------------------------------------------------- NAME euckana ---------------------------------------------------------------------*/ void euckana(c) register int c; { putchar(SS2); putchar((!nogaiji || 0x20 < c && c < 0x60 ? c : HANPAD) | 0x80); } /*--------------------------------------------------------------------- NAME sjiskanji ---------------------------------------------------------------------*/ void sjiskanji(c1, c2) register int c1, c2; { putchar((c1 - 1 >> 1) + (c1 <= 0x5e ? 0x71 : 0xb1)); putchar(c2 + (c1 & 1 ? (c2 < 0x60 ? 0x1f : 0x20) : 0x7e)); } /*--------------------------------------------------------------------- NAME sjisgaiji DESCRIPTION Characters are mapped as follows: 0x2121 to 0x3a7e --> 0xf040 to 0xfcfc 0x3b21 to 0x7e7e --> 0xfcfc ---------------------------------------------------------------------*/ void sjisgaiji(c1, c2) register int c1, c2; { if (nogaiji) sjiskanji(ZENPAD >> 8, ZENPAD & 0xff); else { putchar(c1 < 0x3b ? (c1 - 1 >> 1) + 0xe0 : 0xfc); putchar(c1 < 0x3b ? c2 + (c1 & 1 ? (c2 < 0x60 ? 0x1f : 0x20) : 0x7e) : 0xfc); } } /*--------------------------------------------------------------------- NAME sjiskana ---------------------------------------------------------------------*/ void sjiskana(c) register int c; { putchar(0x20 < c && c < 0x60 ? c | 0x80 : HANPAD | 0x80); } /*--------------------------------------------------------------------- NAME decascii ---------------------------------------------------------------------*/ void decascii(c) register int c; { if (lastkana) { putchar(kanatbl[lastkana] >> 8); putchar(kanatbl[lastkana] & 0xff); lastkana = 0; } putchar(c); } /*--------------------------------------------------------------------- NAME deckanji ---------------------------------------------------------------------*/ void deckanji(c1, c2) register int c1, c2; { if (lastkana) { putchar(kanatbl[lastkana] >> 8); putchar(kanatbl[lastkana] & 0xff); lastkana = 0; } putchar(c1 | 0x80); putchar(c2 | 0x80); } /*--------------------------------------------------------------------- NAME decgaiji ---------------------------------------------------------------------*/ void decgaiji(c1, c2) register int c1, c2; { if (lastkana) { putchar(kanatbl[lastkana] >> 8); putchar(kanatbl[lastkana] & 0xff); lastkana = 0; } if (nogaiji) { putchar(ZENPAD >> 8 | 0x80); putchar(ZENPAD & 0xff | 0x80); } else { putchar(c1 | 0x80); putchar(c2); } } /*--------------------------------------------------------------------- NAME deckana ---------------------------------------------------------------------*/ void deckana(c) register int c; { register int cc; int i; extern unsigned char dakuon[]; if (lastkana) { cc = kanatbl[lastkana]; if ((c == 0x5e || c == 0x5f) && (i = dakuon[lastkana] & (c == 0x5e ? 1 : 2))) { cc += i; c = -1; } putchar(cc >> 8); putchar(cc & 0xff); } if (c < 0x21 || 0x5f < c) { if (c > 0) { putchar(ZENPAD >> 8); putchar(ZENPAD & 0xff); } lastkana = 0; } else lastkana = c - 0x20; } /*--------------------------------------------------------------------- TYPE table NAME katakana, hiragana, dakuon - JIS X0201 kana to JIS kanji in DEC ---------------------------------------------------------------------*/ unsigned short katakana[] = { 0, 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa5f2, 0xa5a1, 0xa5a3, 0xa5a5, 0xa5a7, 0xa5a9, 0xa5e3, 0xa5e5, 0xa5e7, 0xa5c3, 0xa1bc, 0xa5a2, 0xa5a4, 0xa5a6, 0xa5a8, 0xa5aa, 0xa5ab, 0xa5ad, 0xa5af, 0xa5b1, 0xa5b3, 0xa5b5, 0xa5b7, 0xa5b9, 0xa5bb, 0xa5bd, 0xa5bf, 0xa5c1, 0xa5c4, 0xa5c6, 0xa5c8, 0xa5ca, 0xa5cb, 0xa5cc, 0xa5cd, 0xa5ce, 0xa5cf, 0xa5d2, 0xa5d5, 0xa5d8, 0xa5db, 0xa5de, 0xa5df, 0xa5e0, 0xa5e1, 0xa5e2, 0xa5e4, 0xa5e6, 0xa5e8, 0xa5e9, 0xa5ea, 0xa5eb, 0xa5ec, 0xa5ed, 0xa5ef, 0xa5f3, 0xa1ab, 0xa1ac, }; unsigned short hiragana[] = { 0, 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa4f2, 0xa4a1, 0xa4a3, 0xa4a5, 0xa4a7, 0xa4a9, 0xa4e3, 0xa4e5, 0xa4e7, 0xa4c3, 0xa1bc, 0xa4a2, 0xa4a4, 0xa4a6, 0xa4a8, 0xa4aa, 0xa4ab, 0xa4ad, 0xa4af, 0xa4b1, 0xa4b3, 0xa4b5, 0xa4b7, 0xa4b9, 0xa4bb, 0xa4bd, 0xa4bf, 0xa4c1, 0xa4c4, 0xa4c6, 0xa4c8, 0xa4ca, 0xa4cb, 0xa4cc, 0xa4cd, 0xa4ce, 0xa4cf, 0xa4d2, 0xa4d5, 0xa4d8, 0xa4db, 0xa4de, 0xa4df, 0xa4e0, 0xa4e1, 0xa4e2, 0xa4e4, 0xa4e6, 0xa4e8, 0xa4e9, 0xa4ea, 0xa4eb, 0xa4ec, 0xa4ed, 0xa4ef, 0xa4f3, 0xa1ab, 0xa1ac, }; unsigned char dakuon[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; kcc-2.3.orig/kcc.jman100444 0 0 15114 5545536742 12602 0ustar rootroot.\"-- << kanji code converter >> ---- .\" .\" kcc.jman .\" Aug 24 1992 .\" mod: Nov 19 1992 .\"------------------------------------------------ tonooka ------------ .\" @(#)kcc.jman 2.1 (Y.Tonooka) 9/6/93 .TH KCC L "1992年11月19日" "Y. Tonooka" .SH "名前" kcc \- 自動判別機能つき漢字コード変換 .SH "形式" .B kcc [ .BI \- IO chnvxz ] [ .BI \-b " bufsize" ] .RI [ " file " "] .\|.\|." .SH "機能説明" .B kcc は,指定した .I file を順番に読み込み,漢字コードを変換して標準出力に出力するフィルターです。 ファイルの指定がないとき,あるいはファイル名として .B \- が指定されたときには標準入力から読み込みます。入出力の漢字コードはオプシ ョンで指定しますが,入力コードを指定しないとファイルごとの自動判別になり ます。 .LP 使える漢字コードは .SM JIS\s0(7 ビットおよび 8 ビット),シフト .SM JIS\s0,\s-1EUC\s0,\s-1DEC\s0 です。 入力コードは,\s-1EUC\s0,\s-1DEC\s0 あるいはシフト .SM JIS のいずれかと 7 ビット .SM JIS との組み合せに限り,混在が可能です。\s-1JIS\s0 の半角仮名は .BR \s-1SI\s0 / \s-1SO\s0 , \s-1ESC\s0(I ともに認識されます。 .SH "オプション" .TP .BI \- O .PD 0 .TP .BI \- IO .IR I " で入力漢字コードを," O で出力漢字コードを指定します。入力コードの指定がないときには自動判別に, また,どちらも指定しないとき出力コードは 7 ビット .SM JIS になります。 .PD .IP 入力コードを指定する .I I は以下のうちの 1 つです。 .LP .RS 10 .PD 0 .TP .B e .SM EUC\s0(7 ビット .SM JIS 混在可) .TP .B d .SM DEC\s0(7 ビット .SM JIS 混在可) .TP .B s シフト .SM JIS\s0(7 ビット .SM JIS 混在可) .TP .BR j , 7 " または " k 7 ビット .SM JIS .TP .B 8 8 ビット .SM JIS .PD .RE .IP 出力コードを指定する .I O は以下のうちの 1 つです。 .LP .RS 10 .PD 0 .TP .B e .SM EUC .TP .B d .SM DEC .TP .B s シフト .SM JIS .TP .BR j\fIXY " または " 7\fIXY 7 ビット .RB \s-1JIS\s0( \s-1SI\s0 / \s-1SO\s0 による .SM JIS 仮名指示) .TP .BI k XY 7 ビット .RB \s-1JIS\s0( \s-1ESC\s0(I による .SM JIS 仮名指示) .TP .BI 8 XY 8 ビット .SM JIS .PD .RE .IP .I O 中の .I XY で,\s-1JIS\s0 コード出力でのエスケープシークェンスが指定できます。省略 すると .B BJ とみなされます。なお,補助漢字指定は .B \s-1ESC\s0$(D で固定です。 .LP .RS 10 .PD 0 .TP .I X 漢字指定 .RS 5 .TP .B B .BR \s-1ESC\s0$B "(第 2 次規格漢字指示) .TP .B @ .BR \s-1ESC\s0$@ "(第 1 次規格漢字指示) .TP .B + .BR \s-1ESC\s0&@\s-1ESC\s0$B "(第 3 次規格漢字指示) .RE .TP .I Y 英数字指定 .RS 5 .TP .B B .BR \s-1ESC\s0(B "(ASCII 指示) .TP .B J .BR \s-1ESC\s0(J "(JIS ローマ字指示) .TP .B H .BR \s-1ESC\s0(H "(スウェーデン名前用文字指示) .PD .RE .RE .TP .B \-v 入力コードの判別結果を標準エラー出力に出力します。 .TP .B \-x 拡張モード。入力コードの自動判別で,外字や拡張文字領域(\s-1EUC\s0 の外 字・未定義の半角仮名・制御文字 .SM C1 の各領域,およびシフト .SM JIS の拡張文字領域)を認識します。\s-1DEC\s0 と .SM EUC との判別はこのモードでのみ,なされます。 .TP .B \-z 縮小モード。入力コードの自動判別で半角仮名を認識しません(7 ビット .SM JIS を除く)。半角仮名を含まないファイルの場合,これを指定すると判別の確度が 高まります。 .TP .B \-h 半角仮名を .SM DEC に変換すると全角のカタカナに変換されますが,このオプションを指定するとひ らがなになります。 .TP .B \-n 外字・拡張文字・補助漢字領域を“□”に,半角仮名の未定義領域を半角の “・”に変換します。 .TP .BI \-b " bufsize" 入力の判別がつかないあいだ入力をためておくバッファーの大きさを指定しま す。省略時は 8k バイトです。 .TP .B \-c 変換を行わず,入力コードの種類だけを調べ,結果を標準出力に出力します。通 常の自動判別の場合とは異なり,ファイルは最後まで調べられます。ただし,途 中でコード体系に矛盾が見つかった場合には読み込みを中断し“data”と表示し ます。\fB\-x\fR,\fB\-z\fR 以外のオプションは無効になります。 .SH "使用例" .IP "\fB% kcc \-e \fIfile" 入力コード自動判別で出力コードは .SM EUC .IP "\fB% kcc \-sj \fIfile1 file2" シフト .SM JIS のファイル 2 つを .SM JIS へ変換し連結 .IP "\fB% \fIcommand\fB | kcc \-k+J" .I command 出力を .SM JIS\s0(\s-1JIS\s0 第 3 次規格 漢字指示,\s-1JIS\s0 ローマ字指示,\fB\s-1ESC\s0(I\fR による .SM JIS 仮名指示)へ .IP "\fB% kcc \-c \fIfile" .I file のコードを判別する(変換は行わない) .SH "補足説明" 入力コードの自動判別は通常の文書においてはほぼ確実に行えますが,以下のよ うな問題を含んでいます。 .LP 7 ビット .SM JIS はエスケープシークェンスによるモード切り替えによっていて確実に判別されま す。\s-1EUC\s0 と .SM DEC は根本的には同じものです(以下 .SM EUC 系と呼ぶ)。一方,8 ビット .SM JIS の半角仮名はシフト .SM JIS の半角仮名と同じです(同シフト .SM JIS 系)。ところが,共に 8 ビットコードである .SM EUC 系とシフト .SM JIS 系は,領域が広く重なっていて背反しています。つまり,コードの自動判定の問 題点はこの 2 つの判別にあります。 .LP .SM EUC 系/シフト .SM JIS 系の判別は行単位で行い,「シフト .SM JIS 系でない」あるいは「\s-1EUC\s0 系でない」と分かった時点で確定とします。 どちらにも矛盾する行が最初に現れたときには“data”扱いになり,出力内容は 保証されません。 .LP 最初に 8 ビットの漢字コードが現れてから .SM EUC 系/シフト .SM JIS 系の判別がつくまでは,変換を保留し,入力をバッファーにためておきますが, これがいっぱいになると .SM EUC 系であると決めつけて変換を強行します。根拠は以下のとおりです。通常の漢字 入りの文書は .SM JIS 非漢字か .SM JIS 第 1 水準の漢字をまず含んでいると考えられますが,シフト .SM JIS の場合,これらの文字は一部を除いて .SM EUC 系の領域とは重なっていないため,確実に判別されます。つまり,判別できない ときには .SM EUC である可能性が高いわけです。 .LP 8 ビット .SM JIS で,半角仮名が必ず偶数個連続して現れているときは,\s-1EUC\s0 の漢字であ ると誤認されてしまうので注意が必要です。 .LP 入力が半角仮名を含まないときには .B \-z オプションの縮小モードを利用すると判別の確度が高まります。これは重なる領 域が .SM JIS 第 2 水準漢字内に限定されるからです。 .LP シフト .SM JIS の拡張領域・\s-1EUC\s0 の外字領域・\s-1EUC\s0 の制御文字 .SM C1 の領域・\s-1EUC\s0 の半角仮名の未定義領域は,自動判別の認識対象には入ら ないので,これらを含む入力では誤った判別がなされてしまいます。このときは .B \-x オプションで拡張モードを指定するか,入力コードを明示的に指定してくださ い。 .SH "関連項目" .BR cat (1) .SH "その他" 通常,外字・拡張文字・補助漢字領域はそれぞれの対応する領域に投影されま す。ただし,シフト .SM JIS への変換で拡張文字領域からはみ出す文字は,16 進で FCFC になります。 \s-1EUC\s0 と .SM DEC の制御文字領域 .SM C1 は, .SM JIS へ変換する場合はそのままですが,シフト .SM JIS への場合には削除されます。また,半角仮名の未定義領域は,シフト .SM JIS に変換すると,半角の“・”に置き換えられます。半角仮名を .SM DEC に変換すると全角の仮名に変換されます。 .LP .SM JIS コード出力の場合,改行・タブ・抹消などの制御文字や空白(半角)は,英数字 モードで出力されます。 .LP 入力コードの自動判別を誤った場合,また,それぞれの文字セットに未定義の文 字が入力された場合,出力がどうなるかは不定です。 kcc-2.3.orig/COPYING100444 0 0 43077 5545534304 12227 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. kcc-2.3.orig/README100644 0 0 767 5545534712 12020 0ustar rootroot kccは,自動判別機能つき漢字コードフィルターです。 【説明】 日本語EUC,7ビットJIS,8ビットJIS,シフトJISが扱えます。 「半角かな」にも対応しています。 詳しくは日本語オンラインマニュアルで見て下さい。 【インストール】 $ make install で,makeとインストールが行われます。 $ make install.man で,日本語マニュアルのインストールが行われます。 日本語マニュアルのサブディレクトリーが‘japanese’でないときには, $ make JMANDIR=ja.JP_EUC install.man などとしてください。