OSDN Git Service

Update release for LDP 3.67
[linuxjm/LDP_man-pages.git] / release / man3 / duplocale.3
1 .\" t
2 .\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .TH DUPLOCALE 3 2014\-03\-12 Linux "Linux Programmer's Manual"
32 .SH 名前
33 duplocale \- ロケールオブジェクトを複製する
34 .SH 書式
35 .nf
36 \fB#include <locale.h>\fP
37
38 \fBlocale_t duplocale(locale_t \fP\fIlocobj\fP\fB);\fP
39 .fi
40 .sp
41 .in -4n
42 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
43 .in
44 .sp
45 \fBduplocale\fP():
46 .PD 0
47 .RS 4
48 .TP 
49 glibc 2.10 以降:
50 _XOPEN_SOURCE\ >=\ 700
51 .TP 
52 glibc 2.10 より前:
53 _GNU_SOURCE
54 .RE
55 .PD
56 .SH 説明
57 \fBduplocale\fP() 関数は \fIlocobj\fP が参照するロケールオブジェクトの複製を作成する。
58
59 \fIlocobj\fP が \fBLC_GLOBAL_LOCALE\fP の場合、 \fBduplocale\fP() は \fBsetlocale\fP(3)
60 により判定されたグローバルロケールのコピーを含むロケールオブジェクトを作成する。
61 .SH 返り値
62 成功すると、 \fBduplocale\fP() は新しいロケールオブジェクトのハンドルを返す。 エラーの場合、 \fI(locale_t)\ 0\fP を返し、
63 \fIerrno\fP にエラーの原因を示す値を設定する。
64 .SH エラー
65 .TP 
66 \fBENOMEM\fP
67 ロケールオブジェクトの複製を作成するのに十分なメモリがない。
68 .SH バージョン
69 \fBduplocale\fP() 関数は GNU C ライブラリのバージョン 2.3 で初めて登場した。
70 .SH 準拠
71 POSIX.1\-2008.
72 .SH 注意
73 ロケールの複製は以下のことを行う際に役立つ。
74 .IP * 3
75 ロケールオブジェクトのコピーを作成し、  (\fBnewlocale\fP(3) を使って) いくつかのカテゴリだけを変更する。
76 .IP *
77 現在のロケールに対するハンドルを取得する。 このハンドルはロケールハンドルを受け取る他の関数 (\fBtoupper_l\fP(3) など) で使用できる。
78 これを行うには、 以下の呼び出しが返した値を \fBduplocale\fP() に渡せばよい。
79
80     loc = uselocale((locale_t) 0);
81
82 .IP
83 上記の \fBuselocale\fP(3) の呼び出しは値 \fBLC_GLOBAL_LOCALE\fP を返すことがあり、 この値を
84 \fBtoupper_l\fP(3) などの関数に渡した場合の動作は不定なので、 この方法は必要である。 \fBduplocale\fP()
85 を呼び出すことで、確実に \fBLC_GLOBAL_LOCALE\fP が使用可能なロケールオブジェクトに変換することができる。 下記の「例」を参照。
86 .PP
87 \fBduplocale\fP() で作成された各ロケールオブジェクトは \fBfreelocale\fP(3) を使って解放すべきである。
88 .SH 例
89 以下のプログラムでは、 \fBtoupper_l\fP(3) に渡す現在のロケールのハンドルを取得するのに \fBuselocale\fP(3) と
90 \fBduplocale\fP() を使用する。
91 このプログラムはコマンドライン引き数として文字列を一つ取る。この文字列は、大文字に変換され、標準出力に表示される。 以下は使用例である。
92 .in +4n
93 .nf
94
95 $ \fB./a.out abc\fP
96 ABC
97 .fi
98 .in
99 .SS プログラムのソース
100 .nf
101 #define _XOPEN_SOURCE 700
102 #include <ctype.h>
103 #include <stdio.h>
104 #include <stdlib.h>
105 #include <locale.h>
106
107 #define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \e
108                         } while (0)
109
110 int
111 main(int argc, char *argv[])
112 {
113     locale_t loc, nloc;
114     char *p;
115
116     if (argc != 2) {
117         fprintf(stderr, "Usage: %s string\en", argv[0]);
118         exit(EXIT_FAILURE);
119     }
120
121     /* この一連の処理は必要である。 uselocale() は toupper_l() の
122        引き数として渡すことができない値 LC_GLOBAL_LOCALE を返す
123        可能性があるからである。 */
124
125     loc = uselocale((locale_t) 0);
126     if (loc == (locale_t) 0)
127         errExit("uselocale");
128
129     nloc = duplocale(loc);
130     if (nloc == (locale_t) 0)
131         errExit("duplocale");
132
133     for (p = argv[1]; *p; p++)
134         putchar(toupper_l(*p, nloc));
135
136     printf("\en");
137
138     freelocale(nloc);
139
140     exit(EXIT_SUCCESS);
141 }
142 .fi
143 .SH 関連項目
144 \fBfreelocale\fP(3), \fBnewlocale\fP(3), \fBsetlocale\fP(3), \fBuselocale\fP(3),
145 \fBlocale\fP(5), \fBlocale\fP(7)
146 .SH この文書について
147 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
148 である。プロジェクトの説明とバグ報告に関する情報は
149 http://www.kernel.org/doc/man\-pages/ に書かれている。