OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man3 / strverscmp.3
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Japanese Version Copyright (c) 2002 Akihiro MOTOKI
24 .\"         all rights reserved.
25 .\" Translated Sat Sep 21 08:34:42 2002
26 .\"         by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
27 .\"
28 .TH STRVERSCMP 3  2001-12-19 "GNU" "Linux Programmer's Manual"
29 .\"O .SH NAME
30 .SH 名前
31 .\"O strverscmp \- compare two version strings
32 strverscmp \- 2つのバージョン文字列を比較する
33 .\"O .SH SYNOPSIS
34 .SH 書式
35 .nf
36 .\"O .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
37 .BR "#define _GNU_SOURCE" "         /* feature_test_macros(7) 参照 */"
38 .br
39 .B #include <string.h>
40 .sp
41 .BI "int strverscmp(const char *" s1 ", const char *" s2 );
42 .fi
43 .\"O .SH DESCRIPTION
44 .SH 説明
45 .\"O Often one has files
46 .\"O .IR jan1 ", " jan2 ", ..., " jan9 ", " jan10 ", ..."
47 .\"O and it feels wrong when
48 .\"O .BR ls (1)
49 .\"O orders them
50 .\"O .IR jan1 ", " jan10 ", ..., " jan2 ", ..., " jan9 .
51 .IR jan1 ", " jan2 ", ..., " jan9 ", " jan10 ", ..."
52 といった名前のファイルがある状況はよくあるが、
53 .BR ls (1)
54 を実行したときに
55 .IR jan1 ", " jan10 ", ..., " jan2 ", ..., " jan9
56 の順番で表示されるのには違和感がある。
57 .\"O .\" classical solution: "rename jan jan0 jan?"
58 .\" これまでの解決方法: "rename jan jan0 jan?"
59 .\"O In order to rectify this, GNU introduced the
60 .\"O .I \-v
61 .\"O option to
62 .\"O .BR ls (1),
63 .\"O which is implemented using
64 .\"O .BR versionsort (3),
65 .\"O which again uses
66 .\"O .BR strverscmp ().
67 これを修正するために、GNU は
68 .BR ls (1)
69
70 .I \-v
71 オプションを導入した。
72 この機能は
73 .BR versionsort (3)
74 を使って実装されているが、この中で
75 .BR strverscmp ()
76 が使用されている。
77
78 .\"O Thus, the task of
79 .\"O .BR strverscmp ()
80 .\"O is to compare two strings and find the "right" order, while
81 .\"O .BR strcmp (3)
82 .\"O only finds the lexicographic order.
83 .\"O This function does not use
84 .\"O the locale category
85 .\"O .BR LC_COLLATE ,
86 .\"O so is meant mostly for situations
87 .\"O where the strings are expected to be in ASCII.
88 このように
89 .BR strverscmp ()
90 の役目は2つの文字列を比較して「正しい」順序を探すことである。
91 これに対して
92 .BR strcmp (3)
93 は辞書順で比較した結果を返すだけである。
94 関数
95 .BR strverscmp ()
96 はロケールのカテゴリである
97 .B LC_COLLATE
98 を使用しない。
99 このことから、この関数が主にアスキー文字から成る文字列を
100 想定していることが分かる。
101
102 .\"O What this function does is the following.
103 この関数の動作は以下の通りである。
104 .\"O If both strings are equal, return 0.
105 .\"O Otherwise find the position
106 .\"O between two bytes with the property that before it both strings are equal,
107 .\"O while directly after it there is a difference.
108 両方の文字列が等しい場合、0 を返す。
109 それ以外の場合、その直前までは両方の文字列が等しく、
110 その直後のバイトで両者に違いがあるような、バイトの境界を探す。
111 .\"O Find the largest consecutive digit strings containing (or starting at,
112 .\"O or ending at) this position.
113 .\"O If one or both of these is empty,
114 見つかったバイト境界を含む数字列(数字だけの文字列)の最長一致検索を行う。
115 (数字列は境界から始まっていても、境界で終わっていてもよい)。
116 .\"O then return what
117 .\"O .BR strcmp (3)
118 .\"O would have returned (numerical ordering of byte values).
119 2つの文字列から得られた数字列の一方または両方が空であれば、
120 .BR strcmp (3)
121 が返した結果を関数の返り値として返す。
122 すなわち、バイト値を比較した結果を返す。
123 .\"O Otherwise, compare both digit strings numerically, where digit strings with
124 .\"O one or more leading zeros are interpreted as if they have a decimal point
125 .\"O in front (so that in particular digit strings with more leading zeros
126 .\"O come before digit strings with fewer leading zeros).
127 それ以外の(数字列が両方とも空でない)場合、両方の数字列を数字順で比較する。
128 このとき、1つ以上の 0 が先頭にある数字列は、前に小数点がついているものと
129 解釈される。(先頭に 0 が多くある数字列ほど前に来ることになる)
130 .\"O Thus, the ordering is
131 .\"O .IR 000 ", " 00 ", " 01 ", " 010 ", " 09 ", " 0 ", " 1 ", " 9 ", " 10 .
132 この結果、順序は次のようになる:
133 .IR 000 ", " 00 ", " 01 ", " 010 ", " 09 ", " 0 ", " 1 ", " 9 ", " 10
134 .\"O .SH "RETURN VALUE"
135 .SH 返り値
136 .\"O The
137 .\"O .BR strverscmp ()
138 .\"O function returns an integer
139 .\"O less than, equal to, or greater than zero if \fIs1\fP
140 .\"O is found, respectively, to be earlier than, equal to,
141 .\"O or later than \fIs2\fP.
142 関数
143 .BR strverscmp ()
144 は、ゼロよりも
145 1)小さい、2)等しい、3)大きいのいずれかの整数を返す。
146 それぞれは、\fIs1\fP が \fIs2\fP よりも、
147 1)小さい、2)等しい、3)大きい ことを示す。
148 .\"O .SH "CONFORMING TO"
149 .SH 準拠
150 .\"O This function is a GNU extension.
151 この関数は GNU による拡張である。
152 .\"O .SH "SEE ALSO"
153 .SH 関連項目
154 .BR rename (1),
155 .BR strcasecmp (3),
156 .BR strcmp (3),
157 .BR strcoll (3)