OSDN Git Service

Update document and help.
authorNARUSE, Yui <naruse@users.sourceforge.jp>
Mon, 19 Jan 2009 07:36:39 +0000 (16:36 +0900)
committerNARUSE, Yui <naruse@users.sourceforge.jp>
Mon, 19 Jan 2009 07:36:39 +0000 (16:36 +0900)
NKF.mod/NKF.pm
nkf.c

index c63340b..614a8b4 100644 (file)
@@ -1,25 +1,24 @@
-## Copyright (C) 1996,1998
-## Copyright (C) 2002
-## Ï¢ÍíÀ衧 Î°µåÂç³Ø¾ðÊ󹩳زʠ²ÏÌî ¿¿¼£  mime/X0208 support
-## ¡ÊE-Mail Address: kono@ie.u-ryukyu.ac.jp¡Ë
-## Ï¢ÍíÀ衧 COW for DOS & Win16 & Win32 & OS/2
-## ¡ÊE-Mail Address: GHG00637@niftyserve.or.p¡Ë
-##    
-##    ¤³¤Î¥½¡¼¥¹¤Î¤¤¤«¤Ê¤ëÊ£¼Ì¡¤²þÊÑ¡¤½¤Àµ¤âµöÂú¤·¤Þ¤¹¡£¤¿¤À¤·¡¢
-##    ¤½¤ÎºÝ¤Ë¤Ï¡¢Ã¯¤¬¹×¸¥¤·¤¿¤ò¼¨¤¹¤³¤ÎÉôʬ¤ò»Ä¤¹¤³¤È¡£
-##    ºÆÇÛÉۤ仨»ï¤ÎÉÕÏ¿¤Ê¤É¤ÎÌ䤤¹ç¤ï¤»¤âɬÍפ¢¤ê¤Þ¤»¤ó¡£
-##    ±ÄÍøÍøÍѤâ¾åµ­¤ËÈ¿¤·¤Ê¤¤ÈϰϤǵö²Ä¤·¤Þ¤¹¡£
-##    ¥Ð¥¤¥Ê¥ê¤ÎÇÛÉۤκݤˤÏversion message¤òÊݸ¤¹¤ë¤³¤È¤ò¾ò·ï¤È¤·¤Þ¤¹¡£
-##    ¤³¤Î¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤Æ¤ÏÆä˲¿¤ÎÊݾڤ⤷¤Ê¤¤¡¢°­¤·¤«¤é¤º¡£
-##    
-##    Everyone is permitted to do anything on this program
-##    including copying, modifying, improving, 
-##    as long as you don't try to pretend that you wrote it.
-##    i.e., the above copyright notice has to appear in all copies.  
-##    Binar y distribution requires original version messages.
-##    You don't have to ask before copying, redistribution or publishing.
-##    THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
-
+# Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
+# Copyright (c) 1996-2009, The nkf Project.
+# All rights reserved.
+#
+# This software is provided 'as-is', without any express or implied
+# warranty. In no event will the authors be held liable for any damages
+# arising from the use of this software.
+#
+# Permission is granted to anyone to use this software for any purpose,
+# including commercial applications, and to alter it and redistribute it
+# freely, subject to the following restrictions:
+#
+# 1. The origin of this software must not be misrepresented; you must not
+# claim that you wrote the original software. If you use this software
+# in a product, an acknowledgment in the product documentation would be
+# appreciated but is not required.
+#
+# 2. Altered source versions must be plainly marked as such, and must not be
+# misrepresented as being the original software.
+#
+# 3. This notice may not be removed or altered from any source distribution.
 
 package NKF;
 
@@ -128,9 +127,9 @@ This is the default.
 
 =item B<-S>
 
-Assume Shift_JIS and X0201 kana input.
+Assume Shift_JIS and JIS X 0201 kana input.
 EUC-JP is recognized as X0201 kana. Without B<-x> flag,
-X0201 kana (halfwidth kana) is converted into X0208.
+JIS X 0201 Katakana (a.k.a.halfwidth kana) is converted into JIS X 0208.
 
 =item B<-E>
 
@@ -144,11 +143,21 @@ No conversion.
 
 =item B<-i[@B]>
 
-Specify the Esc Seq for JIS X 0208-1978/83. (DEFAULT B)
+Specify the escape sequence for JIS X 0208.
+
+=over
+
+=item B<-i@>
+
+Use ESC ( @. (JIS X 0208-1978)
+
+=item B<-iB>
 
-=item B<-o[BJH]>
+Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)
 
-Specify the Esc Seq for ASCII/Roman. (DEFAULT B)
+=item B<-o[BJ]>
+
+Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)
 
 =item B<-r>
 
@@ -461,13 +470,9 @@ Ignore rest of -option.
 
 =head1 AUTHOR
 
-Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),
-
-Copyright (C) 2000 S. Kono, COW.
-
-Copyright (C) 2002-2009 Kono, Furukawa, Naruse, mastodon.
+Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
 
-The nkf Project https://sourceforge.jp/projects/nkf
+Copyright (c) 1996-2009, The nkf Project.  http://sourceforge.jp/projects/nkf
 
 =begin
 
diff --git a/nkf.c b/nkf.c
index 0743e5d..4357fbe 100644 (file)
--- a/nkf.c
+++ b/nkf.c
@@ -501,7 +501,7 @@ static nkf_char
 no_connection2(nkf_char c2, nkf_char c1, nkf_char c0)
 {
     fprintf(stderr,"nkf internal module connection failure.\n");
-    exit(1);
+    exit(EXIT_FAILURE);
     return 0; /* LINT */
 }
 
@@ -872,56 +872,38 @@ static void
 usage(void)
 {
     fprintf(HELP_OUTPUT,
-           "USAGE:  nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n"
-           "Flags:\n"
-           "b,u      Output is buffered (DEFAULT),Output is unbuffered\n"
-           "j,s,e,w  Output code is ISO-2022-JP, Shift JIS, EUC-JP, UTF-8N\n"
+           "Usage:  nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n"
+           " j,s,e,w  Output code is ISO-2022-JP, Shift JIS, EUC-JP, UTF-8N\n"
 #ifdef UTF8_OUTPUT_ENABLE
-           "         After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]\n"
+           "          After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]\n"
 #endif
-           "J,S,E,W  Input assumption is JIS 7 bit , Shift JIS, EUC-JP, UTF-8\n"
+           " J,S,E,W  Input assumption is JIS 7 bit , Shift JIS, EUC-JP, UTF-8\n"
 #ifdef UTF8_INPUT_ENABLE
-           "         After 'W' you can add more options. -W[ 8, 16 [BL] ] \n"
+           "          After 'W' you can add more options. -W[ 8, 16 [BL] ] \n"
 #endif
-           "t        no conversion\n"
            );
     fprintf(HELP_OUTPUT,
-           "i[@B]    Specify the Esc Seq for JIS X 0208-1978/83 (DEFAULT B)\n"
-           "o[BJH]   Specify the Esc Seq for ASCII/Roman        (DEFAULT B)\n"
-           "r        {de/en}crypt ROT13/47\n"
-           "h        1 katakana->hiragana, 2 hiragana->katakana, 3 both\n"
-           "m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:non-strict,0:no decode]\n"
-           "M[BQ]    MIME encode [B:base64 Q:quoted]\n"
-           "l        ISO8859-1 (Latin-1) support\n"
-           "f/F      Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n"
+           " m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:non-strict,0:no decode]\n"
+           " M[BQ]    MIME encode [B:base64 Q:quoted]\n"
+           " f/F      Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n"
            );
     fprintf(HELP_OUTPUT,
-           "Z[0-4]   Default/0: Convert JISX0208 Alphabet to ASCII\n"
-           "         1: Kankaku to one space  2: to two spaces  3: HTML Entity\n"
-           "         4: JISX0208 Katakana to JISX0201 Katakana\n"
-           "X,x      Assume X0201 kana in MS-Kanji, -x preserves X0201\n"
-           "B[0-2]   Broken input  0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NL\n"
+           " Z[0-4]   Default/0: Convert JISX0208 Alphabet to ASCII\n"
+           "          1: Kankaku to one space  2: to two spaces  3: HTML Entity\n"
+           "          4: JISX0208 Katakana to JISX0201 Katakana\n"
+           " X,x      Assume X0201 kana in MS-Kanji, -x preserves X0201\n"
            );
     fprintf(HELP_OUTPUT,
-#ifdef MSDOS
-           "T        Text mode output\n"
-#endif
-           "O        Output to File (DEFAULT 'nkf.out')\n"
-           "I        Convert non ISO-2022-JP charactor to GETA\n"
-           "d,c      Convert line breaks  -d: LF  -c: CRLF\n"
-           "-L[uwm]  line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n"
-           "v, V     Show this usage. V: show configuration\n"
-           "\n");
+           " O        Output to File (DEFAULT 'nkf.out')\n"
+           " L[uwm]   Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n"
+           " v/V      Show version / show configuration\n"
+           );
     fprintf(HELP_OUTPUT,
            "Long name options\n"
            " --ic=<input codeset>  --oc=<output codeset>\n"
            "                   Specify the input or output codeset\n"
-           " --fj  --unix --mac  --windows\n"
-           " --jis  --euc  --sjis  --utf8  --utf16  --mime  --base64\n"
-           "                   Convert for the system or code\n"
            " --hiragana  --katakana  --katakana-hiragana\n"
            "                   To Hiragana/Katakana Conversion\n"
-           " --prefix=         Insert escape before troublesome characters of Shift_JIS\n"
            );
     fprintf(HELP_OUTPUT,
 #ifdef INPUT_OPTION
@@ -937,14 +919,12 @@ usage(void)
            );
     fprintf(HELP_OUTPUT,
 #ifdef OVERWRITE
-           " --in-place[=SUFFIX]  --overwrite[=SUFFIX]\n"
-           "                   Overwrite original listed files by filtered result\n"
-           "                   --overwrite preserves timestamp of original files\n"
+           " --in-place[=SUF]  Overwrite original listed files by filtered result\n"
+           " --overwrite[=SUF] in-place and preserve timestamp of original files\n"
 #endif
-           " -g  --guess       Guess the input code\n"
-           " --help  --version Show this help/the version\n"
-           "                   For more information, see also man nkf\n"
-           "\n");
+           " -g --guess        Guess the input code\n"
+           " --help/--version  Show this help / version\n"
+           );
     version();
 }
 
@@ -1142,7 +1122,7 @@ static const struct {
     {"euc","e"},
     {"euc-input","E"},
     {"fj","jm"},
-    {"help","v"},
+    {"help",""},
     {"jis","j"},
     {"jis-input","J"},
     {"mac","sLm"},
@@ -5862,6 +5842,10 @@ options(unsigned char *cp)
                cp_back = cp;
                cp = (unsigned char *)long_option[i].alias;
            }else{
+               if (strcmp(long_option[i].name, "help") == 0){
+                   usage();
+                   exit(EXIT_SUCCESS);
+               }
                if (strcmp(long_option[i].name, "ic=") == 0){
                    enc = nkf_enc_find((char *)p);
                    if (!enc) continue;
@@ -6110,7 +6094,8 @@ options(unsigned char *cp)
            if (*cp=='@'||*cp=='B')
                kanji_intro = *cp++;
            continue;
-       case 'o':           /* ASCII IN ESC-(-J/B */
+       case 'o':           /* ASCII IN ESC-(-J/B/H */
+           /* ESC ( H was used in initial JUNET messages */
            if (*cp=='J'||*cp=='B'||*cp=='H')
                ascii_intro = *cp++;
            continue;
@@ -6135,11 +6120,11 @@ options(unsigned char *cp)
 #ifndef PERL_XS
        case 'V':
            show_configuration();
-           exit(1);
+           exit(EXIT_SUCCESS);
            break;
        case 'v':
-           usage();
-           exit(1);
+           version();
+           exit(EXIT_SUCCESS);
            break;
 #endif
 #ifdef UTF8_OUTPUT_ENABLE