summaryrefslogtreecommitdiff
path: root/localedata/tests-mbwc/tst_types.h
blob: 3d1827941192591b8c6e5b9f9eb14446c197f68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/*
 *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
 *
 *	 FILE:	tst_types.h
 *
 *	 Definitions of data types for each test function
 */


#ifndef TST_TYPES_H
#define TST_TYPES_H

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "tst_funcs.h"
#include "tgn_funcdef.h"

#define MBSSIZE		   24
#define WCSSIZE		   12
#define MONFMTSIZE	   16
#define MONSIZE		   64
#define USE_MBCURMAX	   99	/* well, but ... */
#define TST_DBL_EPS	   2.22153e-16
#define WCSTOK_SEQNUM	   3
#define MBLEN_SEQNUM	   3
#define MBTOWC_SEQNUM	   3
#define MBSTOWCS_SEQNUM	   3
#define WCTOMB_SEQNUM	   3
#define WCSTOMBS_SEQNUM	   3
#define MBRLEN_SEQNUM	   3
#define MBRTOWC_SEQNUM	   3
#define MBSRTOWCS_SEQNUM   3
#define WCRTOMB_SEQNUM	   3
#define WCSRTOMBS_SEQNUM   3

/* Maximum numbers of test in one of the _loc arrays.  */
#define MAX_LOC_TEST		300


/*----------------------------------------------------------------------*/
/*  FUNCTION								*/
/*----------------------------------------------------------------------*/

typedef struct
{
  char *func_str;
  int func_id;
}
TST_FID;

typedef struct
{
  int func_id;
  const char *locale;
}
TST_HEAD;

typedef struct
{
  TST_HEAD *head;
}
TST_FUNCS;


/*----------------------------------------------------------------------*/
/*  ISW*: int isw* (wchar_t wc)						*/
/*----------------------------------------------------------------------*/

TST_ISW_STRUCT (ALNUM, alnum);
TST_ISW_STRUCT (ALPHA, alpha);
TST_ISW_STRUCT (CNTRL, cntrl);
TST_ISW_STRUCT (DIGIT, digit);
TST_ISW_STRUCT (GRAPH, graph);
TST_ISW_STRUCT (LOWER, lower);
TST_ISW_STRUCT (PRINT, print);
TST_ISW_STRUCT (PUNCT, punct);
TST_ISW_STRUCT (SPACE, space);
TST_ISW_STRUCT (UPPER, upper);
TST_ISW_STRUCT (XDIGIT, xdigit);

typedef struct
{
  wint_t wc;
  const char *ts;
}
TIN_ISWCTYPE_REC;

typedef
TEX_ERRET_REC (int)
  TEX_ISWCTYPE_REC;
TMD_RECHEAD (ISWCTYPE);


/*----------------------------------------------------------------------*/
/*  MBLEN: int mblen (const char *s, size_t n)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  char s_flg;
  char s[MBSSIZE];
  size_t n;
}
TIN_MBLEN_REC;

typedef TEX_ERRET_REC (int) TEX_MBLEN_REC;
TMD_RECHEAD (MBLEN);


/*----------------------------------------------------------------------*/
/*  MBRLEN: size_t mbrlen (const char *s, size_t n, mbstate_t *ps)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  struct
  {
    int s_flg;
    char s[MBSSIZE];
    size_t n;
    int t_flg;
    int t_init;
  }
  seq[WCSTOK_SEQNUM];
}
TIN_MBRLEN_REC;

typedef TEX_ERRET_REC_SEQ (size_t, MBRLEN_SEQNUM) TEX_MBRLEN_REC;
TMD_RECHEAD (MBRLEN);


/*----------------------------------------------------------------------*/
/*  MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n,	*/
/*			     mbstate_t *ps)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  struct
  {
    int w_flg;
    int s_flg;
    char s[MBSSIZE];
    size_t n;
    int t_flg;
    int t_init;
  }
  seq[MBRTOWC_SEQNUM];
}
TIN_MBRTOWC_REC;

typedef struct
{
  struct
  {
    TMD_ERRET (size_t);
    wchar_t wc;
  }
  seq[MBRTOWC_SEQNUM];
}
TEX_MBRTOWC_REC;

TMD_RECHEAD (MBRTOWC);


/*----------------------------------------------------------------------*/
/*  MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n, */
/*				 mbstate_t *ps )			*/
/*----------------------------------------------------------------------*/

typedef struct
{
  struct
  {
    int w_flg;
    char s[MBSSIZE];
    size_t n;
    int t_flg;
    int t_init;
  }
  seq[MBSRTOWCS_SEQNUM];
}
TIN_MBSRTOWCS_REC;

typedef struct
{
  struct
  {
    TMD_ERRET (size_t);
    wchar_t ws[WCSSIZE];
  }
  seq[MBSRTOWCS_SEQNUM];
}
TEX_MBSRTOWCS_REC;

TMD_RECHEAD (MBSRTOWCS);


/*----------------------------------------------------------------------*/
/*  MBSTOWCS: size_t mbstowcs (wchar_t *ws, const char *s, size_t n)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  struct
  {
    int w_flg;
    int s_flg;
    const char *s;
    size_t n;
  }
  seq[MBSTOWCS_SEQNUM];
}
TIN_MBSTOWCS_REC;

typedef TEX_MBSRTOWCS_REC TEX_MBSTOWCS_REC;
/* MBSRTOWCS_SEQNUM == MBSTOWCS_SEQNUM */
TMD_RECHEAD (MBSTOWCS);


/*----------------------------------------------------------------------*/
/*  MBTOWC: int mbtowc (wchar_t *wc, const char *s, size_t n)		*/
/*----------------------------------------------------------------------*/

typedef TIN_MBSTOWCS_REC TIN_MBTOWC_REC;
/* MBTOWC_SEQNUM == MBSTOWCS_SEQNUM */

typedef struct
{
  struct
  {
    TMD_ERRET (int);
    wchar_t wc;
  }
  seq[MBTOWC_SEQNUM];
}
TEX_MBTOWC_REC;

TMD_RECHEAD (MBTOWC);


/*----------------------------------------------------------------------*/
/*  STRCOLL: int strcoll (const char *s1, const char *s2)		*/
/*----------------------------------------------------------------------*/

typedef struct
{
  char s1[MBSSIZE];
  char s2[MBSSIZE];
}
TIN_STRCOLL_REC;

typedef TEX_ERRET_REC (int) TEX_STRCOLL_REC;
TMD_RECHEAD (STRCOLL);


/*----------------------------------------------------------------------*/
/*  STRFMON: size_t strfmon (char *buf, size_t nbytes,			*/
/*			     const char *fmt, ... )			*/
/*----------------------------------------------------------------------*/

typedef struct
{
  int nbytes;
  char fmt[MONFMTSIZE];
  double val;
}
TIN_STRFMON_REC;

typedef struct
{
  TMD_ERRET (size_t);
  char mon[MONSIZE];
}
TEX_STRFMON_REC;

TMD_RECHEAD (STRFMON);


/*----------------------------------------------------------------------*/
/*  STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  char org1[MBSSIZE];
  char org2[MBSSIZE];
  size_t n1, n2;
}
TIN_STRXFRM_REC;

typedef TEX_ERRET_REC (size_t) TEX_STRXFRM_REC;	/* only for org2[] */
TMD_RECHEAD (STRXFRM);


/*----------------------------------------------------------------------*/
/*  SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws[WCSSIZE * 3];
  wchar_t fmt[WCSSIZE * 3];
  int wch;
}
TIN_SWSCANF_REC;

typedef struct
{
  TMD_ERRET (int);
  int val_int;		/* %d */
  unsigned val_uns;	/* %u */
  float val_flt;		/* %f */
  int val_c;		/* %c */
  char val_s[MBSSIZE * 2];	/* %s */
  wchar_t val_S[WCSSIZE * 2];	/* %lc, %ls, %C, %S */
}
TEX_SWSCANF_REC;

TMD_RECHEAD (SWSCANF);


/*----------------------------------------------------------------------*/
/*  TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc)		*/
/*----------------------------------------------------------------------*/

typedef TIN_ISWCTYPE_REC TIN_TOWCTRANS_REC;
typedef TEX_ERRET_REC (wint_t) TEX_TOWCTRANS_REC;
TMD_RECHEAD (TOWCTRANS);


/*----------------------------------------------------------------------*/
/*  TOW*ER: wint_t tow*er (wint_t wc)					*/
/*----------------------------------------------------------------------*/

TST_TOW_STRUCT (LOWER, lower);
TST_TOW_STRUCT (UPPER, upper);


/*----------------------------------------------------------------------*/
/*  WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  int s_flg;
  wchar_t wc;
  int t_flg;
  int t_init;
}
TIN_WCRTOMB_REC;

typedef struct
{
  TMD_ERRET (wchar_t);
  char s[MBSSIZE];
}
TEX_WCRTOMB_REC;

TMD_RECHEAD (WCRTOMB);


/*----------------------------------------------------------------------*/
/*  WCSCAT: wchar_t *wcscat (wchar_t *ws1, wchar_t *ws2)		*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws1[WCSSIZE];
  wchar_t ws2[WCSSIZE];
}
TIN_WCSCAT_REC;

typedef struct
{
  TMD_ERRET (wchar_t *);
  wchar_t ws[WCSSIZE];
}
TEX_WCSCAT_REC;

TMD_RECHEAD (WCSCAT);


/*----------------------------------------------------------------------*/
/*  WCSCHR: wchar_t *wcschr (wchar_t *ws, wchar_t wc);			*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws[WCSSIZE];
  wchar_t wc;
}
TIN_WCSCHR_REC;

typedef TEX_ERRET_REC (wchar_t *) TEX_WCSCHR_REC;
TMD_RECHEAD (WCSCHR);


/*----------------------------------------------------------------------*/
/*  WCSCMP: int wcscmp (const wchar_t *ws1, const wchar_t *ws2)		*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCAT_REC TIN_WCSCMP_REC;
typedef TEX_ERRET_REC (int) TEX_WCSCMP_REC;
TMD_RECHEAD (WCSCMP);


/*----------------------------------------------------------------------*/
/*  WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2)	*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCMP_REC TIN_WCSCOLL_REC;
typedef struct
{
  TMD_ERRET (int);
  int cmp_flg;
}
TEX_WCSCOLL_REC;
TMD_RECHEAD (WCSCOLL);


/*----------------------------------------------------------------------*/
/*  WCSCPY: wchar_t *wcscpy (wchar_t *ws1, const wchar_t *ws2)		*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws[WCSSIZE];	/* ws2: original string */
}
TIN_WCSCPY_REC;

typedef TEX_WCSCAT_REC TEX_WCSCPY_REC;
TMD_RECHEAD (WCSCPY);


/*----------------------------------------------------------------------*/
/*  WCSCSPN: size_t wcscspn (const wchar_t *ws1, const wchar_t *ws2)	*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCAT_REC TIN_WCSCSPN_REC;
typedef TEX_ERRET_REC (size_t) TEX_WCSCSPN_REC;
TMD_RECHEAD (WCSCSPN);


/*----------------------------------------------------------------------*/
/*  WCSLEN: size_t wcslen (const wchar_t *ws)				*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCPY_REC TIN_WCSLEN_REC;
typedef TEX_ERRET_REC (size_t) TEX_WCSLEN_REC;
TMD_RECHEAD (WCSLEN);


/*----------------------------------------------------------------------*/
/*  WCSNCAT: wchar_t *wcsncat (wchar_t *ws1, const wchar_t *ws2,	*/
/*			       size_t n)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws1[WCSSIZE];
  wchar_t ws2[WCSSIZE];
  size_t n;
}
TIN_WCSNCAT_REC;

typedef TEX_WCSCAT_REC TEX_WCSNCAT_REC;
TMD_RECHEAD (WCSNCAT);


/*----------------------------------------------------------------------*/
/*  WCSNCMP: int *wcsncmp (const wchar_t *ws1, const wchar_t *ws2,	*/
/*			   size_t n)					*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSNCAT_REC TIN_WCSNCMP_REC;
typedef TEX_ERRET_REC (int) TEX_WCSNCMP_REC;
TMD_RECHEAD (WCSNCMP);


/*----------------------------------------------------------------------*/
/*  WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2,	*/
/*			       size_t n)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t ws[WCSSIZE];	/* ws2: original string */
  size_t n;
}
TIN_WCSNCPY_REC;

typedef TEX_WCSCPY_REC TEX_WCSNCPY_REC;
TMD_RECHEAD (WCSNCPY);


/*----------------------------------------------------------------------*/
/*  WCSPBRK: wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2)	*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCSPN_REC TIN_WCSPBRK_REC;

typedef struct
{
  TMD_ERRET (wchar_t *);
  wchar_t wc;
}
TEX_WCSPBRK_REC;

TMD_RECHEAD (WCSPBRK);


/*----------------------------------------------------------------------*/
/*  WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n, */
/*				 mbstate_t *ps)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  int s_flg;
  int w_flg;		/* don't need this */
  wchar_t ws[WCSSIZE];
  size_t n;
  int t_flg;
  int t_init;
}
TIN_WCSRTOMBS_REC;

typedef struct
{
  TMD_ERRET (size_t);
  char s[MBSSIZE];
}
TEX_WCSRTOMBS_REC;

TMD_RECHEAD (WCSRTOMBS);


/*----------------------------------------------------------------------*/
/*  WCSSPN: size_t wcsspn (const wchar_t *ws1, const wchar_t *ws2)	*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCSPN_REC TIN_WCSSPN_REC;
typedef TEX_WCSCSPN_REC TEX_WCSSPN_REC;
TMD_RECHEAD (WCSSPN);


/*----------------------------------------------------------------------*/
/*  WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2)	*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSCSPN_REC TIN_WCSSTR_REC;
typedef TEX_ERRET_REC (wchar_t *) TEX_WCSSTR_REC;
TMD_RECHEAD (WCSSTR);


/*----------------------------------------------------------------------*/
/*  WCSTOD: double wcstod (const wchar_t *np, wchar_t **endp)		*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t np[WCSSIZE];
}
TIN_WCSTOD_REC;

typedef struct
{
  TMD_ERRET (double);
  double val;
  wchar_t fwc;
}
TEX_WCSTOD_REC;

TMD_RECHEAD (WCSTOD);


/*----------------------------------------------------------------------*/
/*  WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm,		*/
/*			     wchar_t **pt)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  struct
  {
    int w_flg;
    wchar_t ws[WCSSIZE];
    wchar_t dt[WCSSIZE];	/* delimiter */
  }
  seq[WCSTOK_SEQNUM];
}
TIN_WCSTOK_REC;

typedef struct
{
  struct
  {
    TMD_ERRET (wchar_t *);
    wchar_t ws[WCSSIZE];
  }
  seq[WCSTOK_SEQNUM];
}
TEX_WCSTOK_REC;

TMD_RECHEAD (WCSTOK);


/*----------------------------------------------------------------------*/
/*  WCSTOMBS: size_t wcstombs (char s, const wchar_t *ws, size_t n)	*/
/*----------------------------------------------------------------------*/

typedef struct
{
  int s_flg;
  int w_flg;		/* currently we don't need it. */
  wchar_t ws[WCSSIZE];
  size_t n;
}
TIN_WCSTOMBS_REC;

typedef struct
{
  TMD_ERRET (size_t);
  char s[MBSSIZE];
}
TEX_WCSTOMBS_REC;

TMD_RECHEAD (WCSTOMBS);


/*----------------------------------------------------------------------*/
/*  WCSWIDTH: int wcswidth (const wchar_t *ws, size_t n)		*/
/*----------------------------------------------------------------------*/

typedef TIN_WCSNCPY_REC TIN_WCSWIDTH_REC;
typedef TEX_ERRET_REC (int) TEX_WCSWIDTH_REC;
TMD_RECHEAD (WCSWIDTH);


/*----------------------------------------------------------------------*/
/*  WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n)*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t org1[WCSSIZE];
  wchar_t org2[WCSSIZE];
  int n1, n2;
}
TIN_WCSXFRM_REC;

typedef TEX_ERRET_REC (size_t) TEX_WCSXFRM_REC;	/* only for org2[] */
TMD_RECHEAD (WCSXFRM);


/*----------------------------------------------------------------------*/
/*  WCTOB: int wctob (wint_t wc)					*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wint_t wc;
}
TIN_WCTOB_REC;

typedef TEX_ERRET_REC (int) TEX_WCTOB_REC;
TMD_RECHEAD (WCTOB);


/*----------------------------------------------------------------------*/
/*  WCTOMB: int wctomb (char *s, wchar_t wc)				*/
/*----------------------------------------------------------------------*/

typedef struct
{
  int s_flg;
  wchar_t wc;
}
TIN_WCTOMB_REC;

typedef struct
{
  TMD_ERRET (int);
  char s[MBSSIZE];
}
TEX_WCTOMB_REC;

TMD_RECHEAD (WCTOMB);


/*----------------------------------------------------------------------*/
/*  WCTRANS: wctrans_t wctrans (const char *charclass)			*/
/*----------------------------------------------------------------------*/

typedef struct
{
  char class[MBSSIZE];
}
TIN_WCTRANS_REC;

typedef TEX_ERRET_REC (wctrans_t) TEX_WCTRANS_REC;
TMD_RECHEAD (WCTRANS);


/*----------------------------------------------------------------------*/
/*  WCTYPE: wctype_t wctype (const char *class)				*/
/*----------------------------------------------------------------------*/

typedef TIN_WCTRANS_REC TIN_WCTYPE_REC;
typedef TEX_ERRET_REC (wctype_t) TEX_WCTYPE_REC;
TMD_RECHEAD (WCTYPE);


/*----------------------------------------------------------------------*/
/*  WCWIDTH: int wcwidth (wchar_t wc)					*/
/*----------------------------------------------------------------------*/

typedef struct
{
  wchar_t wc;
}
TIN_WCWIDTH_REC;

typedef TEX_ERRET_REC (int) TEX_WCWIDTH_REC;
TMD_RECHEAD (WCWIDTH);

#endif /* TST_TYPES_H */