Thu Nov 12 00:43:53 2009 UTC ()
Do not use \." for comments, always use .\". Discussed with uwe@.


(joerg)
diff -r1.11 -r1.12 src/lib/libintl/gettext.3
diff -r1.17 -r1.18 src/usr.bin/tr/tr.1

cvs diff -r1.11 -r1.12 src/lib/libintl/gettext.3 (switch to unified diff)

--- src/lib/libintl/gettext.3 2004/11/10 13:46:14 1.11
+++ src/lib/libintl/gettext.3 2009/11/12 00:43:52 1.12
@@ -1,407 +1,407 @@ @@ -1,407 +1,407 @@
1.\" $NetBSD: gettext.3,v 1.11 2004/11/10 13:46:14 wiz Exp $ 1.\" $NetBSD: gettext.3,v 1.12 2009/11/12 00:43:52 joerg Exp $
2.\" 2.\"
3.\" Copyright (c) 2000 Citrus Project, 3.\" Copyright (c) 2000 Citrus Project,
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE. 25.\" SUCH DAMAGE.
26.\" 26.\"
27.Dd November 10, 2004 27.Dd November 10, 2004
28.Dt GETTEXT 3 28.Dt GETTEXT 3
29.Os 29.Os
30.Sh NAME 30.Sh NAME
31.Nm gettext , 31.Nm gettext ,
32.Nm dgettext , 32.Nm dgettext ,
33.Nm ngettext , 33.Nm ngettext ,
34.Nm dngettext , 34.Nm dngettext ,
35.Nm textdomain , 35.Nm textdomain ,
36.Nm bindtextdomain , 36.Nm bindtextdomain ,
37.Nm bind_textdomain_codeset , 37.Nm bind_textdomain_codeset ,
38.Nm dcgettext , 38.Nm dcgettext ,
39.Nm dcngettext 39.Nm dcngettext
40.Nd message handling functions 40.Nd message handling functions
41.Sh LIBRARY 41.Sh LIBRARY
42.Lb libintl 42.Lb libintl
43.Sh SYNOPSIS 43.Sh SYNOPSIS
44.In libintl.h 44.In libintl.h
45.Ft char * 45.Ft char *
46.Fn gettext "const char *msgid" 46.Fn gettext "const char *msgid"
47.Ft char * 47.Ft char *
48.Fn dgettext "const char *domainname" "const char *msgid" 48.Fn dgettext "const char *domainname" "const char *msgid"
49.Ft char * 49.Ft char *
50.Fn ngettext "const char *msgid1" "const char *msgid2" "unsigned long int n" 50.Fn ngettext "const char *msgid1" "const char *msgid2" "unsigned long int n"
51.Ft char * 51.Ft char *
52.Fn dngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n" 52.Fn dngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n"
53.Ft char * 53.Ft char *
54.Fn textdomain "const char *domainname" 54.Fn textdomain "const char *domainname"
55.Ft char * 55.Ft char *
56.Fn bindtextdomain "const char *domainname" "const char *dirname" 56.Fn bindtextdomain "const char *domainname" "const char *dirname"
57.Ft char * 57.Ft char *
58.Fn bind_textdomain_codeset "const char *domainname" "const char *codeset" 58.Fn bind_textdomain_codeset "const char *domainname" "const char *codeset"
59.In libintl.h 59.In libintl.h
60.In locale.h 60.In locale.h
61.Ft char * 61.Ft char *
62.Fn dcgettext "const char *domainname" "const char *msgid" "int category" 62.Fn dcgettext "const char *domainname" "const char *msgid" "int category"
63.Ft char * 63.Ft char *
64.Fn dcngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n" "int category" 64.Fn dcngettext "const char *domainname" "const char *msgid1" "const char *msgid2" "unsigned long int n" "int category"
65.Sh DESCRIPTION 65.Sh DESCRIPTION
66The 66The
67.Fn gettext , 67.Fn gettext ,
68.Fn dgettext , 68.Fn dgettext ,
69and 69and
70.Fn dcgettext 70.Fn dcgettext
71functions attempt to retrieve a 71functions attempt to retrieve a
72target string based on the specified 72target string based on the specified
73.Fa msgid 73.Fa msgid
74argument within the context of a 74argument within the context of a
75specific domain and the current locale. 75specific domain and the current locale.
76The length of strings returned by 76The length of strings returned by
77.Fn gettext , 77.Fn gettext ,
78.Fn dgettext , 78.Fn dgettext ,
79and 79and
80.Fn dcgettext 80.Fn dcgettext
81is undetermined until the function is 81is undetermined until the function is
82called. 82called.
83The 83The
84.Fa msgid 84.Fa msgid
85argument is a nul-terminated string. 85argument is a nul-terminated string.
86.Pp 86.Pp
87The 87The
88.Fn ngettext , 88.Fn ngettext ,
89.Fn dngettext , 89.Fn dngettext ,
90and 90and
91.Fn dcngettext 91.Fn dcngettext
92functions are equivalent to 92functions are equivalent to
93.Fn gettext , 93.Fn gettext ,
94.Fn dgettext , 94.Fn dgettext ,
95and 95and
96.Fn dcgettext , 96.Fn dcgettext ,
97respectively, except for the handling of 97respectively, except for the handling of
98plural forms. 98plural forms.
99The 99The
100.Fn ngettext , 100.Fn ngettext ,
101.Fn dngettext , 101.Fn dngettext ,
102and 102and
103.Fn dcngettext 103.Fn dcngettext
104functions search for the 104functions search for the
105message string using the 105message string using the
106.Fa msgid1 106.Fa msgid1
107argument as the key, using the argument 107argument as the key, using the argument
108.Fa n 108.Fa n
109to 109to
110determine the plural form. 110determine the plural form.
111If no message catalogs are found, 111If no message catalogs are found,
112.Fa msgid1 112.Fa msgid1
113is returned 113is returned
114if 114if
115.Fa n Li == 1 , 115.Fa n Li == 1 ,
116otherwise 116otherwise
117.Fa msgid2 117.Fa msgid2
118is returned. 118is returned.
119.Pp 119.Pp
120The 120The
121.Dv LANGUAGE 121.Dv LANGUAGE
122environment variable is examined first to determine the message 122environment variable is examined first to determine the message
123catalogs to be used. 123catalogs to be used.
124The value of the 124The value of the
125.Dv LANGUAGE 125.Dv LANGUAGE
126environment variable is a list 126environment variable is a list
127of locale names separated by colon (:) character. 127of locale names separated by colon (:) character.
128If the 128If the
129.Dv LANGUAGE 129.Dv LANGUAGE
130environment 130environment
131variable is defined, each locale name is tried in the specified order and if a 131variable is defined, each locale name is tried in the specified order and if a
132message catalog containing the requested message is found, the message is 132message catalog containing the requested message is found, the message is
133returned. 133returned.
134If the 134If the
135.Dv LANGUAGE 135.Dv LANGUAGE
136environment variable is defined but failed to locate 136environment variable is defined but failed to locate
137a message catalog, the 137a message catalog, the
138.Fa msgid 138.Fa msgid
139string will be returned. 139string will be returned.
140.Pp 140.Pp
141If the 141If the
142.Dv LANGUAGE 142.Dv LANGUAGE
143environment variable is not defined, 143environment variable is not defined,
144.Dv LC_ALL , 144.Dv LC_ALL ,
145.Dv LC_xxx , 145.Dv LC_xxx ,
146and 146and
147.Dv LANG 147.Dv LANG
148environment variables are examined to locate the message catalog, 148environment variables are examined to locate the message catalog,
149following the convention used by the 149following the convention used by the
150.Xr setlocale 3 150.Xr setlocale 3
151function. 151function.
152.Pp 152.Pp
153The pathname used to locate the message catalog is 153The pathname used to locate the message catalog is
154.Pa dirname/locale/category/domainname.mo , 154.Pa dirname/locale/category/domainname.mo ,
155where dirname is the directory specified by 155where dirname is the directory specified by
156.Fn bindtextdomain , 156.Fn bindtextdomain ,
157locale is a locale name determined by the definition of environment variables, 157locale is a locale name determined by the definition of environment variables,
158.Fa category 158.Fa category
159is 159is
160.Dv LC_MESSAGES 160.Dv LC_MESSAGES
161if 161if
162.Fn gettext , 162.Fn gettext ,
163.Fn ngettext , 163.Fn ngettext ,
164.Fn dgettext , 164.Fn dgettext ,
165or 165or
166.Fn dngettext 166.Fn dngettext
167is 167is
168called, otherwise 168called, otherwise
169.Dv LC_xxx 169.Dv LC_xxx
170where the name is the same as the locale category name 170where the name is the same as the locale category name
171specified by the 171specified by the
172.Fa category 172.Fa category
173argument of 173argument of
174.Fn dcgettext 174.Fn dcgettext
175or 175or
176.Fn dcngettext . 176.Fn dcngettext .
177.Fa domainname 177.Fa domainname
178is the name of the domain specified by 178is the name of the domain specified by
179.Fn textdomain 179.Fn textdomain
180or the 180or the
181.Fa domainname 181.Fa domainname
182argument of 182argument of
183.Fn dgettext , 183.Fn dgettext ,
184.Fn dngettext , 184.Fn dngettext ,
185.Fn dcgettext , 185.Fn dcgettext ,
186or 186or
187.Fn dcngettext . 187.Fn dcngettext .
188.Pp 188.Pp
189For 189For
190.Fn gettext 190.Fn gettext
191and 191and
192.Fn ngettext , 192.Fn ngettext ,
193the domain used is set by the last valid call to 193the domain used is set by the last valid call to
194.Fn textdomain . 194.Fn textdomain .
195If a valid call to 195If a valid call to
196.Fn textdomain 196.Fn textdomain
197has not been made, the default 197has not been made, the default
198domain (called messages) is used. 198domain (called messages) is used.
199.Pp 199.Pp
200For 200For
201.Fn dgettext , 201.Fn dgettext ,
202.Fn dngettext , 202.Fn dngettext ,
203.Fn dcgettext , 203.Fn dcgettext ,
204and 204and
205.Fn dcngettext , 205.Fn dcngettext ,
206the domain used is 206the domain used is
207specified by the 207specified by the
208.Fa domainname 208.Fa domainname
209argument. 209argument.
210The 210The
211.Fa domainname 211.Fa domainname
212argument is equivalent in 212argument is equivalent in
213syntax and meaning to the 213syntax and meaning to the
214.Fa domainname 214.Fa domainname
215argument to 215argument to
216.Fn textdomain , 216.Fn textdomain ,
217except that the 217except that the
218selection of the domain is valid only for the duration of the 218selection of the domain is valid only for the duration of the
219.Fn dgettext , 219.Fn dgettext ,
220.Fn dngettext , 220.Fn dngettext ,
221.Fn dcgettext , 221.Fn dcgettext ,
222or 222or
223.Fn dcngettext 223.Fn dcngettext
224function call. 224function call.
225.Pp 225.Pp
226The 226The
227.Fn dcgettext 227.Fn dcgettext
228and 228and
229.Fn dcngettext 229.Fn dcngettext
230functions require additional argument 230functions require additional argument
231.Fa category 231.Fa category
232for retrieving message string for other than 232for retrieving message string for other than
233.Dv LC_MESSAGES 233.Dv LC_MESSAGES
234category. 234category.
235Available value for the 235Available value for the
236.Fa category 236.Fa category
237argument are 237argument are
238.Dv LC_CTYPE , 238.Dv LC_CTYPE ,
239.Dv LC_COLLATE , 239.Dv LC_COLLATE ,
240.Dv LC_MESSAGES , 240.Dv LC_MESSAGES ,
241.Dv LC_MONETARY , 241.Dv LC_MONETARY ,
242.Dv LC_NUMERIC , 242.Dv LC_NUMERIC ,
243and 243and
244.Dv LC_TIME . 244.Dv LC_TIME .
245The call of 245The call of
246.Fn dcgettext "domainname" "msgid" "LC_MESSAGES" 246.Fn dcgettext "domainname" "msgid" "LC_MESSAGES"
247is equivalent to 247is equivalent to
248.Fn dgettext "domainname" "msgid" . 248.Fn dgettext "domainname" "msgid" .
249Note that 249Note that
250.Dv LC_ALL 250.Dv LC_ALL
251must not be used. 251must not be used.
252.Pp 252.Pp
253The 253The
254.Fn textdomain 254.Fn textdomain
255function sets or queries the name of the current domain of the 255function sets or queries the name of the current domain of the
256active 256active
257.Dv LC_MESSAGES 257.Dv LC_MESSAGES
258locale category. 258locale category.
259The 259The
260.Fa domainname 260.Fa domainname
261argument is a 261argument is a
262nul-terminated string that can contain only the characters allowed in legal 262nul-terminated string that can contain only the characters allowed in legal
263filenames. 263filenames.
264.Pp 264.Pp
265The 265The
266.Fa domainname 266.Fa domainname
267argument is the unique name of a domain on the system. 267argument is the unique name of a domain on the system.
268If there 268If there
269are multiple versions of the same domain on one system, namespace collisions 269are multiple versions of the same domain on one system, namespace collisions
270can be avoided by using 270can be avoided by using
271.Fn bindtextdomain . 271.Fn bindtextdomain .
272If 272If
273.Fn textdomain 273.Fn textdomain
274is not called, a 274is not called, a
275default domain is selected. 275default domain is selected.
276The setting of domain made by the last valid call 276The setting of domain made by the last valid call
277to 277to
278.Fn textdomain 278.Fn textdomain
279remains valid across subsequent calls to 279remains valid across subsequent calls to
280.Xr setlocale 3 , 280.Xr setlocale 3 ,
281and 281and
282.Fn gettext . 282.Fn gettext .
283.Pp 283.Pp
284The 284The
285.Fa domainname 285.Fa domainname
286argument is applied to the currently active LC_MESSAGES locale. 286argument is applied to the currently active LC_MESSAGES locale.
287.Pp 287.Pp
288The current setting of the domain can be queried without affecting the current 288The current setting of the domain can be queried without affecting the current
289state of the domain by calling 289state of the domain by calling
290.Fn textdomain 290.Fn textdomain
291with 291with
292.Fa domainname 292.Fa domainname
293set to the 293set to the
294.Dv NULL 294.Dv NULL
295pointer. 295pointer.
296Calling 296Calling
297.Fn textdomain 297.Fn textdomain
298with a 298with a
299.Fa domainname 299.Fa domainname
300argument of a 300argument of a
301.Dv NULL 301.Dv NULL
302string sets 302string sets
303the domain to the default domain 303the domain to the default domain
304.Pq messages . 304.Pq messages .
305.Pp 305.Pp
306The 306The
307.Fn bindtextdomain 307.Fn bindtextdomain
308function binds the path predicate for a message domain 308function binds the path predicate for a message domain
309.Fa domainname 309.Fa domainname
310to the value contained in dirname. 310to the value contained in dirname.
311If 311If
312.Fa domainname 312.Fa domainname
313is a non-empty 313is a non-empty
314string and has not been bound previously, 314string and has not been bound previously,
315.Fn bindtextdomain 315.Fn bindtextdomain
316binds 316binds
317.Fa domainname 317.Fa domainname
318with 318with
319.Fa dirname . 319.Fa dirname .
320.Pp 320.Pp
321If 321If
322.Fa domainname 322.Fa domainname
323is a non-empty string and has been bound previously, 323is a non-empty string and has been bound previously,
324.Fn bindtextdomain 324.Fn bindtextdomain
325replaces the old binding with dirname. 325replaces the old binding with dirname.
326The dirname argument 326The dirname argument
327can be an absolute pathname being resolved when 327can be an absolute pathname being resolved when
328.Fn gettext , 328.Fn gettext ,
329.Fn ngettext , 329.Fn ngettext ,
330.Fn dgettext , 330.Fn dgettext ,
331.Fn dngettext , 331.Fn dngettext ,
332.Fn dcgettext , 332.Fn dcgettext ,
333or 333or
334.Fn dcngettext 334.Fn dcngettext
335are called. 335are called.
336If 336If
337.Fa domainname 337.Fa domainname
338is a 338is a
339.Dv NULL 339.Dv NULL
340pointer or an empty string, 340pointer or an empty string,
341.Fn bindtextdomain 341.Fn bindtextdomain
342returns a 342returns a
343.Dv NULL 343.Dv NULL
344pointer. 344pointer.
345If 345If
346.Fn bindtextdomain 346.Fn bindtextdomain
347is not called, implementation-defined default directory is used. 347is not called, implementation-defined default directory is used.
348.Pp 348.Pp
349The 349The
350.Fn bind_textdomain_codeset 350.Fn bind_textdomain_codeset
351function can be used to specify the output 351function can be used to specify the output
352.Fa codeset 352.Fa codeset
353for message catalogs for domain 353for message catalogs for domain
354.Fa domainname . 354.Fa domainname .
355The 355The
356.Fa codeset 356.Fa codeset
357argument must 357argument must
358be a valid codeset name which can be used for the 358be a valid codeset name which can be used for the
359.Xr iconv_open 3 359.Xr iconv_open 3
360function. 360function.
361.Pp 361.Pp
362If the 362If the
363.Fa codeset 363.Fa codeset
364argument is the 364argument is the
365.Dv NULL 365.Dv NULL
366pointer, 366pointer,
367.Fn bind_textdomain_codeset 367.Fn bind_textdomain_codeset
368returns the currently selected 368returns the currently selected
369.Fa codeset 369.Fa codeset
370for the domain with the name 370for the domain with the name
371.Fa domainname . 371.Fa domainname .
372It returns a 372It returns a
373.Dv NULL 373.Dv NULL
374pointer if no 374pointer if no
375.Fa codeset 375.Fa codeset
376has yet been selected. 376has yet been selected.
377.Pp 377.Pp
378The 378The
379.Fn bind_textdomain_codeset 379.Fn bind_textdomain_codeset
380function can be used several times. 380function can be used several times.
381If used multiple times, with the same 381If used multiple times, with the same
382.Fa domainname 382.Fa domainname
383argument, 383argument,
384the later call overrides the 384the later call overrides the
385settings made by the earlier one. 385settings made by the earlier one.
386.Pp 386.Pp
387The 387The
388.Fn bind_textdomain_codeset 388.Fn bind_textdomain_codeset
389function returns a pointer to a string containing 389function returns a pointer to a string containing
390the name of the selected 390the name of the selected
391.Fa codeset . 391.Fa codeset .
392.\".Sh "RETURN VALUES" 392.\".Sh "RETURN VALUES"
393.\".Sh EXAMPLES 393.\".Sh EXAMPLES
394.Sh SEE ALSO 394.Sh SEE ALSO
395.Xr setlocale 3 , 395.Xr setlocale 3 ,
396.Xr nls 7 396.Xr nls 7
397.\".Sh STANDARDS 397.\".Sh STANDARDS
398.Sh HISTORY 398.Sh HISTORY
399The functions are implemented by Citrus project, 399The functions are implemented by Citrus project,
400based on the documentations for GNU gettext. 400based on the documentations for GNU gettext.
401.Sh BUGS 401.Sh BUGS
402\." The text was ripped off from Annex C of 402.\" The text was ripped off from Annex C of
403\." .Dq LI18NUX 2000 Globalization Specification Version 1.0 . 403.\" .Dq LI18NUX 2000 Globalization Specification Version 1.0 .
404\." .Pp 404.\" .Pp
405.Fn bind_textdomain_codeset 405.Fn bind_textdomain_codeset
406does not work at this moment 406does not work at this moment
407.Pq it always fails . 407.Pq it always fails .

cvs diff -r1.17 -r1.18 src/usr.bin/tr/tr.1 (switch to unified diff)

--- src/usr.bin/tr/tr.1 2009/08/22 00:23:02 1.17
+++ src/usr.bin/tr/tr.1 2009/11/12 00:43:53 1.18
@@ -1,350 +1,350 @@ @@ -1,350 +1,350 @@
1.\" $NetBSD: tr.1,v 1.17 2009/08/22 00:23:02 joerg Exp $ 1.\" $NetBSD: tr.1,v 1.18 2009/11/12 00:43:53 joerg Exp $
2.\" 2.\"
3.\" Copyright (c) 1991, 1993 3.\" Copyright (c) 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to Berkeley by 6.\" This code is derived from software contributed to Berkeley by
7.\" the Institute of Electrical and Electronics Engineers, Inc. 7.\" the Institute of Electrical and Electronics Engineers, Inc.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the 15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution. 16.\" documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors 17.\" 3. Neither the name of the University nor the names of its contributors
18.\" may be used to endorse or promote products derived from this software 18.\" may be used to endorse or promote products derived from this software
19.\" without specific prior written permission. 19.\" without specific prior written permission.
20.\" 20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" @(#)tr.1 8.1 (Berkeley) 6/6/93 33.\" @(#)tr.1 8.1 (Berkeley) 6/6/93
34.\" 34.\"
35.Dd March 23, 2004 35.Dd March 23, 2004
36.Dt TR 1 36.Dt TR 1
37.Os 37.Os
38.Sh NAME 38.Sh NAME
39.Nm tr 39.Nm tr
40.Nd translate characters 40.Nd translate characters
41.Sh SYNOPSIS 41.Sh SYNOPSIS
42.Nm 42.Nm
43.Op Fl cs 43.Op Fl cs
44.Ar string1 string2 44.Ar string1 string2
45.Nm 45.Nm
46.Op Fl c 46.Op Fl c
47.Fl d 47.Fl d
48.Ar string1 48.Ar string1
49.Nm 49.Nm
50.Op Fl c 50.Op Fl c
51.Fl s 51.Fl s
52.Ar string1 52.Ar string1
53.Nm 53.Nm
54.Op Fl c 54.Op Fl c
55.Fl ds 55.Fl ds
56.Ar string1 string2 56.Ar string1 string2
57.Sh DESCRIPTION 57.Sh DESCRIPTION
58The 58The
59.Nm 59.Nm
60utility copies the standard input to the standard output with substitution 60utility copies the standard input to the standard output with substitution
61or deletion of selected characters. 61or deletion of selected characters.
62.Pp 62.Pp
63The following options are available: 63The following options are available:
64.Bl -tag -width Ds 64.Bl -tag -width Ds
65.It Fl c 65.It Fl c
66Complements the set of characters in 66Complements the set of characters in
67.Ar string1 , 67.Ar string1 ,
68that is 68that is
69.Fl c Ar \&ab 69.Fl c Ar \&ab
70includes every character except for 70includes every character except for
71.Sq a 71.Sq a
72and 72and
73.Sq b . 73.Sq b .
74.It Fl d 74.It Fl d
75The 75The
76.Fl d 76.Fl d
77option causes characters to be deleted from the input. 77option causes characters to be deleted from the input.
78.It Fl s 78.It Fl s
79The 79The
80.Fl s 80.Fl s
81option squeezes multiple occurrences of the characters listed in the last 81option squeezes multiple occurrences of the characters listed in the last
82operand (either 82operand (either
83.Ar string1 83.Ar string1
84or 84or
85.Ar string2 ) 85.Ar string2 )
86in the input into a single instance of the character. 86in the input into a single instance of the character.
87This occurs after all deletion and translation is completed. 87This occurs after all deletion and translation is completed.
88.El 88.El
89.Pp 89.Pp
90In the first synopsis form, the characters in 90In the first synopsis form, the characters in
91.Ar string1 91.Ar string1
92are translated into the characters in 92are translated into the characters in
93.Ar string2 93.Ar string2
94where the first character in 94where the first character in
95.Ar string1 95.Ar string1
96is translated into the first character in 96is translated into the first character in
97.Ar string2 97.Ar string2
98and so on. 98and so on.
99If 99If
100.Ar string1 100.Ar string1
101is longer than 101is longer than
102.Ar string2 , 102.Ar string2 ,
103the last character found in 103the last character found in
104.Ar string2 104.Ar string2
105is duplicated until 105is duplicated until
106.Ar string1 106.Ar string1
107is exhausted. 107is exhausted.
108.Pp 108.Pp
109In the second synopsis form, the characters in 109In the second synopsis form, the characters in
110.Ar string1 110.Ar string1
111are deleted from the input. 111are deleted from the input.
112.Pp 112.Pp
113In the third synopsis form, the characters in 113In the third synopsis form, the characters in
114.Ar string1 114.Ar string1
115are compressed as described for the 115are compressed as described for the
116.Fl s 116.Fl s
117option. 117option.
118.Pp 118.Pp
119In the fourth synopsis form, the characters in 119In the fourth synopsis form, the characters in
120.Ar string1 120.Ar string1
121are deleted from the input, and the characters in 121are deleted from the input, and the characters in
122.Ar string2 122.Ar string2
123are compressed as described for the 123are compressed as described for the
124.Fl s 124.Fl s
125option. 125option.
126.Pp 126.Pp
127The following conventions can be used in 127The following conventions can be used in
128.Ar string1 128.Ar string1
129and 129and
130.Ar string2 130.Ar string2
131to specify sets of characters: 131to specify sets of characters:
132.Bl -tag -width [:equiv:] 132.Bl -tag -width [:equiv:]
133.It character 133.It character
134Any character not described by one of the following conventions 134Any character not described by one of the following conventions
135represents itself. 135represents itself.
136.It \eoctal 136.It \eoctal
137A backslash followed by 1, 2 or 3 octal digits represents a character 137A backslash followed by 1, 2 or 3 octal digits represents a character
138with that encoded value. 138with that encoded value.
139To follow an octal sequence with a digit as a character, left zero-pad 139To follow an octal sequence with a digit as a character, left zero-pad
140the octal sequence to the full 3 octal digits. 140the octal sequence to the full 3 octal digits.
141.It \echaracter 141.It \echaracter
142A backslash followed by certain special characters maps to special 142A backslash followed by certain special characters maps to special
143values. 143values.
144.sp 144.sp
145.Bl -column cc 145.Bl -column cc
146.It \ea \*[Lt]alert character\*[Gt] 146.It \ea \*[Lt]alert character\*[Gt]
147.It \eb \*[Lt]backspace\*[Gt] 147.It \eb \*[Lt]backspace\*[Gt]
148.It \ef \*[Lt]form-feed\*[Gt] 148.It \ef \*[Lt]form-feed\*[Gt]
149.It \en \*[Lt]newline\*[Gt] 149.It \en \*[Lt]newline\*[Gt]
150.It \er \*[Lt]carriage return\*[Gt] 150.It \er \*[Lt]carriage return\*[Gt]
151.It \et \*[Lt]tab\*[Gt] 151.It \et \*[Lt]tab\*[Gt]
152.It \ev \*[Lt]vertical tab\*[Gt] 152.It \ev \*[Lt]vertical tab\*[Gt]
153.El 153.El
154.sp 154.sp
155A backslash followed by any other character maps to that character. 155A backslash followed by any other character maps to that character.
156.It c-c 156.It c-c
157Represents the range of characters between the range endpoints, inclusively. 157Represents the range of characters between the range endpoints, inclusively.
158.It [:class:] 158.It [:class:]
159Represents all characters belonging to the defined character class. 159Represents all characters belonging to the defined character class.
160Class names are: 160Class names are:
161.sp 161.sp
162.Bl -column xdigit 162.Bl -column xdigit
163.It alnum \*[Lt]alphanumeric characters\*[Gt] 163.It alnum \*[Lt]alphanumeric characters\*[Gt]
164.It alpha \*[Lt]alphabetic characters\*[Gt] 164.It alpha \*[Lt]alphabetic characters\*[Gt]
165.It blank \*[Lt]blank characters\*[Gt] 165.It blank \*[Lt]blank characters\*[Gt]
166.It cntrl \*[Lt]control characters\*[Gt] 166.It cntrl \*[Lt]control characters\*[Gt]
167.It digit \*[Lt]numeric characters\*[Gt] 167.It digit \*[Lt]numeric characters\*[Gt]
168.It graph \*[Lt]graphic characters\*[Gt] 168.It graph \*[Lt]graphic characters\*[Gt]
169.It lower \*[Lt]lower-case alphabetic characters\*[Gt] 169.It lower \*[Lt]lower-case alphabetic characters\*[Gt]
170.It print \*[Lt]printable characters\*[Gt] 170.It print \*[Lt]printable characters\*[Gt]
171.It punct \*[Lt]punctuation characters\*[Gt] 171.It punct \*[Lt]punctuation characters\*[Gt]
172.It space \*[Lt]space characters\*[Gt] 172.It space \*[Lt]space characters\*[Gt]
173.It upper \*[Lt]upper-case characters\*[Gt] 173.It upper \*[Lt]upper-case characters\*[Gt]
174.It xdigit \*[Lt]hexadecimal characters\*[Gt] 174.It xdigit \*[Lt]hexadecimal characters\*[Gt]
175.El 175.El
176.Pp 176.Pp
177\." All classes may be used in 177.\" All classes may be used in
178\." .Ar string1 , 178.\" .Ar string1 ,
179\." and in 179.\" and in
180\." .Ar string2 180.\" .Ar string2
181\." when both the 181.\" when both the
182\." .Fl d 182.\" .Fl d
183\." and 183.\" and
184\." .Fl s 184.\" .Fl s
185\." options are specified. 185.\" options are specified.
186\." Otherwise, only the classes ``upper'' and ``lower'' may be used in 186.\" Otherwise, only the classes ``upper'' and ``lower'' may be used in
187\." .Ar string2 187.\" .Ar string2
188\." and then only when the corresponding class (``upper'' for ``lower'' 188.\" and then only when the corresponding class (``upper'' for ``lower''
189\." and vice-versa) is specified in the same relative position in 189.\" and vice-versa) is specified in the same relative position in
190\." .Ar string1 . 190.\" .Ar string1 .
191\." .Pp 191.\" .Pp
192With the exception of the 192With the exception of the
193.Dq upper 193.Dq upper
194and 194and
195.Dq lower 195.Dq lower
196classes, characters in the classes are in unspecified order. 196classes, characters in the classes are in unspecified order.
197In the 197In the
198.Dq upper 198.Dq upper
199and 199and
200.Dq lower 200.Dq lower
201classes, characters are entered in ascending order. 201classes, characters are entered in ascending order.
202.Pp 202.Pp
203For specific information as to which ASCII characters are included 203For specific information as to which ASCII characters are included
204in these classes, see 204in these classes, see
205.Xr ctype 3 205.Xr ctype 3
206and related manual pages. 206and related manual pages.
207.It [=equiv=] 207.It [=equiv=]
208Represents all characters or collating (sorting) elements belonging to 208Represents all characters or collating (sorting) elements belonging to
209the same equivalence class as 209the same equivalence class as
210.Ar equiv . 210.Ar equiv .
211If there is a secondary ordering within the equivalence class, the 211If there is a secondary ordering within the equivalence class, the
212characters are ordered in ascending sequence. 212characters are ordered in ascending sequence.
213Otherwise, they are ordered after their encoded values. 213Otherwise, they are ordered after their encoded values.
214An example of an equivalence class might be 214An example of an equivalence class might be
215.Dq \&c 215.Dq \&c
216and 216and
217.Dq \&ch 217.Dq \&ch
218in Spanish; 218in Spanish;
219English has no equivalence classes. 219English has no equivalence classes.
220.It [#*n] 220.It [#*n]
221Represents 221Represents
222.Ar n 222.Ar n
223repeated occurrences of the character represented by 223repeated occurrences of the character represented by
224.Ar # . 224.Ar # .
225This 225This
226expression is only valid when it occurs in 226expression is only valid when it occurs in
227.Ar string2 . 227.Ar string2 .
228If 228If
229.Ar n 229.Ar n
230is omitted or is zero, it is interpreted as large enough to extend 230is omitted or is zero, it is interpreted as large enough to extend
231.Ar string2 231.Ar string2
232sequence to the length of 232sequence to the length of
233.Ar string1 . 233.Ar string1 .
234If 234If
235.Ar n 235.Ar n
236has a leading zero, it is interpreted as an octal value, otherwise, 236has a leading zero, it is interpreted as an octal value, otherwise,
237it's interpreted as a decimal value. 237it's interpreted as a decimal value.
238.El 238.El
239.Sh EXIT STATUS 239.Sh EXIT STATUS
240.Nm 240.Nm
241exits 0 on success, and \*[Gt]0 if an error occurs. 241exits 0 on success, and \*[Gt]0 if an error occurs.
242.Sh EXAMPLES 242.Sh EXAMPLES
243The following examples are shown as given to the shell: 243The following examples are shown as given to the shell:
244.Pp 244.Pp
245Create a list of the words in 245Create a list of the words in
246.Ar file1 , 246.Ar file1 ,
247one per line, where a word is taken to be a maximal string of letters: 247one per line, where a word is taken to be a maximal string of letters:
248.sp 248.sp
249.D1 Li "tr -cs \*q[:alpha:]\*q \*q\en\*q \*[Lt] file1" 249.D1 Li "tr -cs \*q[:alpha:]\*q \*q\en\*q \*[Lt] file1"
250.sp 250.sp
251Translate the contents of 251Translate the contents of
252.Ar file1 252.Ar file1
253to upper-case: 253to upper-case:
254.sp 254.sp
255.D1 Li "tr \*q[:lower:]\*q \*q[:upper:]\*q \*[Lt] file1" 255.D1 Li "tr \*q[:lower:]\*q \*q[:upper:]\*q \*[Lt] file1"
256.sp 256.sp
257Strip out non-printable characters from 257Strip out non-printable characters from
258.Ar file1 : 258.Ar file1 :
259.sp 259.sp
260.D1 Li "tr -cd \*q[:print:]\*q \*[Lt] file1" 260.D1 Li "tr -cd \*q[:print:]\*q \*[Lt] file1"
261.Sh COMPATIBILITY 261.Sh COMPATIBILITY
262.At V 262.At V
263has historically implemented character ranges using the syntax 263has historically implemented character ranges using the syntax
264.Dq [c-c] 264.Dq [c-c]
265instead of the 265instead of the
266.Dq c-c 266.Dq c-c
267used by historic 267used by historic
268.Bx 268.Bx
269implementations and standardized by POSIX. 269implementations and standardized by POSIX.
270.At V 270.At V
271shell scripts should work under this implementation as long as 271shell scripts should work under this implementation as long as
272the range is intended to map in another range, i.e. the command 272the range is intended to map in another range, i.e. the command
273.Pp 273.Pp
274.Ic "tr [a-z] [A-Z]" 274.Ic "tr [a-z] [A-Z]"
275.Pp 275.Pp
276will work as it will map the 276will work as it will map the
277.Sq \&[ 277.Sq \&[
278character in 278character in
279.Ar string1 279.Ar string1
280to the 280to the
281.Sq \&[ 281.Sq \&[
282character in 282character in
283.Ar string2 . 283.Ar string2 .
284However, if the shell script is deleting or squeezing characters as in 284However, if the shell script is deleting or squeezing characters as in
285the command 285the command
286.Pp 286.Pp
287.Ic "tr -d [a-z]" 287.Ic "tr -d [a-z]"
288.Pp 288.Pp
289the characters 289the characters
290.Sq \&[ 290.Sq \&[
291and 291and
292.Sq \&] 292.Sq \&]
293will be included in the deletion or compression list which would 293will be included in the deletion or compression list which would
294not have happened under an historic 294not have happened under an historic
295.At V 295.At V
296implementation. 296implementation.
297Additionally, any scripts that depended on the sequence 297Additionally, any scripts that depended on the sequence
298.Dq a-z 298.Dq a-z
299to represent the three characters 299to represent the three characters
300.Sq \&a , 300.Sq \&a ,
301.Sq \&- , 301.Sq \&- ,
302and 302and
303.Sq \&z 303.Sq \&z
304will have to be rewritten as 304will have to be rewritten as
305.Dq a\e-z . 305.Dq a\e-z .
306.Pp 306.Pp
307The 307The
308.Nm 308.Nm
309utility has historically not permitted the manipulation of NUL bytes in 309utility has historically not permitted the manipulation of NUL bytes in
310its input and, additionally, stripped NUL's from its input stream. 310its input and, additionally, stripped NUL's from its input stream.
311This implementation has removed this behavior as a bug. 311This implementation has removed this behavior as a bug.
312.Pp 312.Pp
313The 313The
314.Nm 314.Nm
315utility has historically been extremely forgiving of syntax errors, 315utility has historically been extremely forgiving of syntax errors,
316for example, the 316for example, the
317.Fl c 317.Fl c
318and 318and
319.Fl s 319.Fl s
320options were ignored unless two strings were specified. 320options were ignored unless two strings were specified.
321This implementation will not permit illegal syntax. 321This implementation will not permit illegal syntax.
322.Sh STANDARDS 322.Sh STANDARDS
323The 323The
324.Nm 324.Nm
325utility is expected to be 325utility is expected to be
326.St -p1003.2 326.St -p1003.2
327compatible. 327compatible.
328It should be noted that the feature wherein the last character of 328It should be noted that the feature wherein the last character of
329.Ar string2 329.Ar string2
330is duplicated if 330is duplicated if
331.Ar string2 331.Ar string2
332has less characters than 332has less characters than
333.Ar string1 333.Ar string1
334is permitted by POSIX but is not required. 334is permitted by POSIX but is not required.
335Shell scripts attempting to be portable to other POSIX systems should use 335Shell scripts attempting to be portable to other POSIX systems should use
336the 336the
337.Dq [#*] 337.Dq [#*]
338convention instead of relying on this behavior. 338convention instead of relying on this behavior.
339.Sh BUGS 339.Sh BUGS
340.Nm 340.Nm
341was originally designed to work with 341was originally designed to work with
342.Tn US-ASCII . 342.Tn US-ASCII .
343Its use with character sets that do not share all the properties of 343Its use with character sets that do not share all the properties of
344.Tn US-ASCII , 344.Tn US-ASCII ,
345e.g., a symmetric set of upper and lower case characters 345e.g., a symmetric set of upper and lower case characters
346that can be algorithmically converted one to the other, 346that can be algorithmically converted one to the other,
347may yield unpredictable results. 347may yield unpredictable results.
348.Pp 348.Pp
349.Nm 349.Nm
350should be internationalized. 350should be internationalized.