|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...);
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define TST_FUNCTION swscanf
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include "tsp_common.c"
|
|
Packit |
6c4009 |
#include "dat_swscanf.c"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
tst_swscanf (FILE * fp, int debug_flg)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
TST_DECL_VARS (int);
|
|
Packit |
6c4009 |
wchar_t *ws;
|
|
Packit |
6c4009 |
wchar_t *fmt;
|
|
Packit |
6c4009 |
int val_int1;
|
|
Packit |
6c4009 |
unsigned val_int2;
|
|
Packit |
6c4009 |
float val_flt;
|
|
Packit |
6c4009 |
char val_c;
|
|
Packit |
6c4009 |
char val_s[MBSSIZE * 3];
|
|
Packit |
6c4009 |
wchar_t val_S[WCSSIZE * 3], *exp_S;
|
|
Packit |
6c4009 |
int i;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
TST_DO_TEST (swscanf)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
TST_HEAD_LOCALE (swscanf, S_SWSCANF);
|
|
Packit |
6c4009 |
TST_DO_REC (swscanf)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
TST_GET_ERRET (swscanf);
|
|
Packit |
6c4009 |
ws = TST_INPUT (swscanf).ws;
|
|
Packit |
6c4009 |
fmt = TST_INPUT (swscanf).fmt;
|
|
Packit |
6c4009 |
val_int1 = val_int2 = val_flt = val_c = 0;
|
|
Packit |
6c4009 |
memset (val_s, 0, sizeof (val_s));
|
|
Packit |
6c4009 |
memset (val_S, 0, sizeof (val_S));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
TST_CLEAR_ERRNO;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (TST_INPUT (swscanf).wch)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
ret = swscanf (ws, fmt, val_S);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
ret =
|
|
Packit |
6c4009 |
swscanf (ws, fmt, &val_int1, &val_int2, &val_flt, &val_c, val_s);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
TST_SAVE_ERRNO;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (debug_flg)
|
|
Packit |
6c4009 |
{ /* seems fprintf doesn't update errno */
|
|
Packit |
6c4009 |
fprintf (stdout, "swscanf() [ %s : %d ] ret = %d\n", locale,
|
|
Packit |
6c4009 |
rec + 1, ret);
|
|
Packit |
6c4009 |
fprintf (stdout, " errno = %d\n",
|
|
Packit |
6c4009 |
errno_save);
|
|
Packit |
6c4009 |
fprintf (stdout, " collate = %s\n",
|
|
Packit |
6c4009 |
(setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
|
|
Packit |
6c4009 |
NULL) : "");
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (TST_INPUT (swscanf).wch)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
fprintf (stdout, " val_S[ 0 ] = 0x%lx\n",
|
|
Packit |
6c4009 |
(unsigned long int) val_S[0]);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
fprintf (stdout, " val_int1 = %d\n",
|
|
Packit |
6c4009 |
val_int1);
|
|
Packit |
6c4009 |
fprintf (stdout, " val_int2 = %d\n",
|
|
Packit |
6c4009 |
val_int2);
|
|
Packit |
6c4009 |
fprintf (stdout, " val_flt = %f\n",
|
|
Packit |
6c4009 |
val_flt);
|
|
Packit |
6c4009 |
fprintf (stdout, " val_c = %c\n",
|
|
Packit |
6c4009 |
val_c);
|
|
Packit |
6c4009 |
fprintf (stdout, " val_s = %s\n",
|
|
Packit |
6c4009 |
val_s);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
TST_IF_RETURN (S_SWSCANF)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (errno == 0 && TST_INPUT (swscanf).wch)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
for (exp_S = TST_EXPECT (swscanf).val_S, i = 0; i < WCSSIZE * 3;
|
|
Packit |
6c4009 |
i++)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (val_S[i] == L'\0' || exp_S[i] == L'\0')
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (val_S[i] != exp_S[i] && TST_INPUT (swscanf).wch == 'C')
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
err_count++;
|
|
Packit |
6c4009 |
Result (C_FAILURE, S_SWSCANF, CASE_4,
|
|
Packit |
6c4009 |
"the converted wide-char string is different"
|
|
Packit |
6c4009 |
" from an expected value.");
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (val_S[i] != exp_S[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
err_count++;
|
|
Packit |
6c4009 |
Result (C_FAILURE, S_SWSCANF, CASE_4,
|
|
Packit |
6c4009 |
"the converted wide-char string is different from"
|
|
Packit |
6c4009 |
" an expected value.");
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
Result (C_SUCCESS, S_SWSCANF, CASE_4, MS_PASSED);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (errno == 0 && !TST_INPUT (swscanf).wch)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (val_int1 != TST_EXPECT (swscanf).val_int ||
|
|
Packit |
6c4009 |
val_int2 != TST_EXPECT (swscanf).val_uns ||
|
|
Packit |
6c4009 |
val_flt != TST_EXPECT (swscanf).val_flt ||
|
|
Packit |
6c4009 |
val_c != TST_EXPECT (swscanf).val_c ||
|
|
Packit |
6c4009 |
strcmp (val_s, TST_EXPECT (swscanf).val_s))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
err_count++;
|
|
Packit |
6c4009 |
Result (C_FAILURE, S_SWSCANF, CASE_3,
|
|
Packit |
6c4009 |
"the converted values are different from expected values.");
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
Result (C_SUCCESS, S_SWSCANF, CASE_3, MS_PASSED);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return err_count;
|
|
Packit |
6c4009 |
}
|