OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[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)