1 # This file is part of ltrace.
2 # Copyright (C) 2013 Petr Machata, Red Hat Inc.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 set bin [ltraceCompile {} [ltraceSource c {
30 int main(int argc, char *argv[])
32 setlocale(LC_ALL, "");
34 FILE *rd_stream, *wr_stream, *wr_stream_2;
38 rd_stream = fdopen (fds[0], "r");
39 wr_stream = fdopen (fds[1], "w");
40 wr_stream_2 = fdopen (fds[1], "w");
43 wcslen(L"Вот это да!");
45 fprintf(wr_stream_2, "something %s\n", "something");
46 fprintf(wr_stream_2, "something %ls\n", L"что-то");
48 fputwc(L'Ф', wr_stream);
49 putwc(L'Д', wr_stream);
52 ungetwc(getwc(rd_stream), rd_stream);
54 fputws(L"Что-то.\n", wr_stream);
57 fgetws(wbuf, 64, rd_stream);
59 fwprintf(wr_stream, L"Какое-то %ls %s.\n", L"что-то", "something");
60 swprintf(wbuf, 64, L"zwölf große %ls %zd", L"Boxkämpfe", wcslen(wbuf));
62 int i = iswalnum(L'1');
85 i = mbrlen("что", sizeof "что", NULL);
88 i = mbrtowc(&wc, "что", sizeof "что", NULL);
90 const char *str = "что";
91 i = mbsrtowcs(wbuf, &str, 64, NULL);
94 i = towlower(towupper(L'ы')) == L'ы';
99 wcrtomb(buf, L'ơ', NULL);
102 i = wcscmp(wcschr(wcsncat(wcscat(wbuf, L"žluťoučký "),
103 L"kůň", 64), L'ů'), L"ůň");
105 i = wcsncmp(wbuf, L"žluťák", 4);
108 i = wcscoll(wcscpy(wbuf, L"/ˈɪŋɡlɪʃ/"), L"/dɔɪ̯ʧ/");
110 i = wcsspn(wbuf, L"/");
112 i = wcscspn(wbuf, L"ˈ");
114 *wcsrchr(wcspbrk(wbuf, L"ɪ"), L'ɪ') = L'i';
117 gettimeofday(&tv, NULL);
118 struct tm *tm = gmtime(&tv.tv_sec);
120 wcsftime(wbuf, 64, L"«%F • %T»", tm);
121 { const wchar_t *ptr = wbuf; wcsrtombs(buf, &ptr, 64, NULL); }
122 { wchar_t *ptr = NULL; wcstod(wcsstr(wbuf, L"•") + 2, &ptr); }
123 wcsncpy(wbuf, L"1234•", 64);
124 { wchar_t *ptr = NULL; wcstof(wbuf, &ptr); }
125 { wchar_t *ptr = NULL; wcstold(wbuf, &ptr); }
126 { wchar_t *ptr = NULL; wcstol(wbuf, &ptr, 10); }
127 { wchar_t *ptr = NULL; wcstoll(wbuf, &ptr, 10); }
128 { wchar_t *ptr = NULL; wcstoul(wbuf, &ptr, 10); }
129 { wchar_t *ptr = NULL; wcstoull(wbuf, &ptr, 10); }
130 i = wmemcmp(wmemchr(wbuf, L'•', 64), L"•", 2);
133 i = wcswidth(L"你好") + wcwidth(L'你') + wctob(L'1');;
134 assert(i == 6 + '1');
136 i = iswctype(L'Ш', wctype("alpha"));
139 wmemcpy(wbuf, L"Dobrý den", 6);
140 wmemmove(wbuf, L" ", 2);
141 { wchar_t *ptr = NULL; wmemset(wcstok(wbuf, L" ", &ptr), L'я', 5); }
147 ltraceMatch [ltraceRun -F $srcdir/../etc/ -- $bin] {
148 {{^fprintf\(.*, "something %s\\n", "something"\)} == 1}
149 {{^fprintf\(.*, "something %ls\\n", "что-то"\)} == 1}
150 {{^fputwc\('Ф', .*\).*= 'Ф'} == 1}
151 {{^putwc\('Д', .*\).*= 'Д'} == 1}
152 {{^fgetwc\(.*\).*= 'Ф'} == 1}
153 {{^getwc\(.*\).*= 'Д'} == 1}
154 {{^ungetwc\('Д', .*\).*= 'Д'} == 1}
155 {{^fputws\("Что-то.\\n", .*\)} == 1}
156 {{^fgetws\("ДЧто-то.\\n", 64, .*\).*= "ДЧто-то.\\n"} == 1}
157 {{^fwprintf\(.*, "Какое-то %ls %s.\\n", "что-то", "something"\).*= 27} == 1}
158 {{^wcslen\("ДЧто-то.\\n"\).*= 9} == 1}
159 {{^swprintf\("zwölf große Boxkämpfe 9", 64, "zwölf große %ls %zd", "Boxkämpfe", 9\).*= 23} == 1}
160 {{^iswalnum\('1'\).*= 8} == 1}
161 {{^iswalpha\('A'\).*= 1024} == 1}
162 {{^iswcntrl\('\\t'\).*= 2} == 1}
163 {{^iswdigit\('1'\).*= 1} == 1}
164 {{^iswgraph\('='\).*= 32768} == 1}
165 {{^iswlower\('ц'\).*= 1} == 1}
166 {{^iswupper\('Ц'\).*= 1} == 1}
167 {{^iswprint\('☻'\).*= 1} == 1}
168 {{^iswpunct\('•'\).*= 1} == 1}
169 {{^iswspace\('\\t'\).*= 8192} == 1}
170 {{^iswxdigit\('A'\).*= 4096} == 1}
171 {{^mbrtowc\('ч', ".*", 7, nil\)} == 1}
172 {{^mbsrtowcs\("что", nil, 64, nil\).*= 3} == 1}
173 {{^towupper\('ы'\).*= 'Ы'} == 1}
174 {{^towlower\('Ы'\).*= 'ы'} == 1}
175 {{^wctomb\(".*", 'ư'\)} == 1}
176 {{^wcrtomb\(".*", 'ơ', nil\)} == 1}
177 {{^wcscat\("", "žluťoučký "\).*= "žluťoučký "} == 1}
178 {{^wcsncat\("žluťoučký ", "kůň", 64\).*= "žluťoučký kůň"} == 1}
179 {{^wcschr\("žluťoučký kůň", 'ů'\).*= "ůň"} == 1}
180 {{^wcscmp\("ůň", "ůň"\).*= 0} == 1}
181 {{^wcsncmp\("žluť", "žluť", 4\).*= 0} == 1}
182 {{^wcscpy\(.*, "/ˈɪŋɡlɪʃ/"\).*= .*} == 1}
183 {{^wcscoll\("/ˈɪŋɡlɪʃ/", "/dɔɪ̯ʧ/"\).*= 10} == 1}
184 {{^wcsspn\("/ˈɪŋɡlɪʃ/", "/"\).*= 1} == 1}
185 {{^wcscspn\("/ˈɪŋɡlɪʃ/", "ˈ"\).*= 1} == 1}
186 {{^wcspbrk\("/ˈɪŋɡlɪʃ/", "ɪ"\).*= "ɪŋɡlɪʃ/"} == 1}
187 {{^wcsrchr\("ɪŋɡlɪʃ/", 'ɪ'\).*= "ɪʃ/"} == 1}
188 {{^gettimeofday\(.*, nil\).*= 0} == 1}
189 {{^gmtime\(.*\).*= .*} == 1}
190 {{^wcsftime\("«.* • .*»", 64, "«%F • %T»", .*\)} == 1}
191 {{^wcsrtombs\(".*", nil, 64, nil\)} == 1}
192 {{^wcsstr\("«.* • .*»", "•"\).*= "• .*»"} == 1}
193 {{^wcstod\(".*»", ".*»"\).*= [0-9]+} == 1}
194 {{^wcsncpy\(.*, "1234•", 64\).*= .*} == 1}
195 {{^wcstof\("1234•", "•"\).*= 1234} == 1}
196 {{^wcstold\("1234•", "•"\).*= 1234} == 1}
197 {{^wcstol\("1234•", "•", 10\).*= 1234} == 1}
198 {{^wcstoll\("1234•", "•", 10\).*= 1234} == 1}
199 {{^wcstoul\("1234•", "•", 10\).*= 1234} == 1}
200 {{^wcstoull\("1234•", "•", 10\).*= 1234} == 1}
201 {{^wmemchr\("1234•", '•', 64\).*= "•"} == 1}
202 {{^wmemcmp\("•", "•", 2\).*= 0} == 1}
203 {{^wcswidth\("你好", .*\).*= 4} == 1}
204 {{^wcwidth\('你'\).*= 2} == 1}
205 {{^wctob\('1'\).*= 49} == 1}
206 {{^wctype\("alpha"\).*= .*} == 1}
207 {{^iswctype\('Ш', .*\).*= 1} == 1}
208 {{^wmemcpy\(.*, "Dobrý ", 6\).*= "Dobrý "} == 1}
209 {{^wmemmove\(.*, " ", 2\).*= " "} == 1}
210 {{^wcstok\(" brý ", " ", ""\).*= "brý"} == 1}
211 {{^wmemset\(.*, 'я', 5\).*= "яяяяя"} == 1}