.\" Copyright (c) Bruno Haible .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" References consulted: .\" GNU glibc-2 source code and manual .\" Dinkumware C library reference http://www.dinkumware.com/ .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html .\" ISO/IEC 9899:1999 .\" .\" About this Japanese page, please contact to JM Project .\" Translated Sat Oct 23 17:53:50 JST 1999 .\" by FUJIWARA Teruyoshi .\" .TH WCSTOK 3 2011-09-28 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O wcstok \- split wide-character string into tokens wcstok \- ワイド文字文字列をトークンに分割する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "wchar_t *wcstok(wchar_t *" wcs ", const wchar_t *" delim \ ", wchar_t **" ptr ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR wcstok () .\"O function is the wide-character equivalent of the .\"O .BR strtok (3) .\"O function, .\"O with an added argument to make it multithread-safe. It can be used .\"O to split a wide-character string \fIwcs\fP into tokens, where a token is .\"O defined as a substring not containing any wide-characters from \fIdelim\fP. .BR wcstok () 関数は、 .BR strtok (3) 関数に対応するワイド文字関数に、 マルチスレッドセーフの動作をさせるための引き数を追加したものである。 この関数を用いて、ワイド文字文字列 \fIwcs\fP をトークンに分解すること ができる。ここで、トークンは \fIdelim\fP に列挙されている文字を含まな い部分文字列として定義される。 .PP .\"O The search starts at \fIwcs\fP, if \fIwcs\fP is not NULL, .\"O or at \fI*ptr\fP, if \fIwcs\fP is NULL. .\"O First, any delimiter wide-characters are skipped, that is, the .\"O pointer is advanced beyond any wide-characters which occur in \fIdelim\fP. 検索は \fIwcs\fP が NULL でなければ \fIwcs\fP から開始され、\fIwcs\fP が NULL ならば \fI*ptr\fP から開始される。まず、全ての区切りワイド文字 がスキップされる。つまり、\fIdelim\fP に含まれるワイド文字を超えるよう にポインタが前に進められる。 .\"O If the end of the wide-character string is now reached, .\"O .BR wcstok () .\"O returns NULL, to indicate that no tokens .\"O were found, and stores an appropriate value in \fI*ptr\fP, .\"O so that subsequent calls to .\"O .BR wcstok () .\"O will continue to return NULL. .\"O Otherwise, the .\"O .BR wcstok () .\"O function recognizes the beginning of a token .\"O and returns a pointer to it, but before doing that, it zero-terminates the .\"O token by replacing the next wide-character which occurs in \fIdelim\fP with .\"O a null wide character (L\(aq\\0\(aq), .\"O and it updates \fI*ptr\fP so that subsequent calls will .\"O continue searching after the end of recognized token. ワイド文字文字列の終わりに達したら、 .BR wcstok () は NULL を返して トークンが全く見つからなかったことを示し、この後に .BR wcstok () を呼び 出しても NULL が返されるように \fI*ptr\fP に適切な値を設定する。それ 以外の場合には、 .BR wcstok () 関数はトークンの先頭を識別し、これを指す ポインタを返す。ただしこれを行う前に、トークンの後にある、\fIdelim\fP に含まれている文字を NULL ワイド文字 (L\(aq\\0\(aq) に置き換えること によってトークンを 0 で終端させる。さらに \fI*ptr\fP を更新し、後で .BR wcstok () を呼び出した 際に、識別されたトークンの続きから検索できるようにする。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR wcstok () .\"O function returns a pointer to the next token, .\"O or NULL if no further token was found. .BR wcstok () 関数は次のトークンへのポインタを返す。トークンが見つから なければ NULL を返す。 .\"O .SH "CONFORMING TO" .SH 準拠 C99. .\"O .SH NOTES .SH 注意 .\"O The original \fIwcs\fP wide-character string is destructively modified during .\"O the operation. 関数に与えたワイド文字列 \fIwcs\fP は、関数の動作によって完全に書き換 えられる。 .\"O .SH EXAMPLE .SH 例 .\"O The following code loops over the tokens contained in a wide-character string. 以下のコードは、ワイド文字文字列に含まれるトークンを取り出しながら ループする。 .sp .nf wchar_t *wcs = ...; wchar_t *token; wchar_t *state; for (token = wcstok(wcs, " \\t\\n", &state); token != NULL; token = wcstok(NULL, " \\t\\n", &state)) { ... } .fi .\"O .SH "SEE ALSO" .SH 関連項目 .BR strtok (3), .BR wcschr (3)