more PR/36938

- don't re-initialize internal-state when current locale is stateless encoding.
- fix testcase filedir problem.
This commit is contained in:
tnozaki 2007-11-26 16:09:50 +00:00
parent 1b601e0085
commit 0d66ddd732
2 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.1 2007/09/18 15:12:08 tnozaki Exp $
# $NetBSD: Makefile,v 1.2 2007/11/26 16:09:50 tnozaki Exp $
NOMAN= #defined
@ -8,6 +8,7 @@ TESTCASES= en_US.UTF-8 \
ja_JP.ISO2022-JP ja_JP.SJIS ja_JP.eucJP \
zh_CN.GB18030 \
zh_TW.Big5 zh_TW.eucTW
CPPFLAGS+= -DFILEDIR=\"${.CURDIR}\"
regress: ${PROG}
./${PROG} ${TESTCASES}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbtowc_test.c,v 1.1 2007/09/18 15:12:09 tnozaki Exp $ */
/* $NetBSD: mbtowc_test.c,v 1.2 2007/11/26 16:09:50 tnozaki Exp $ */
/*-
* Copyright (c)2007 Citrus Project,
@ -29,6 +29,7 @@
#include <assert.h>
#include <errno.h>
#include <locale.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -38,6 +39,7 @@ main(int argc, char *argv[])
{
int i;
const char *testcase;
char path[PATH_MAX + 1];
char *s;
size_t stateful, n, ret;
FILE *fp;
@ -53,7 +55,8 @@ main(int argc, char *argv[])
ret = mbtowc(NULL, NULL, 0);
assert(stateful ? ret : !ret);
fp = fopen(testcase, "r");
snprintf(path, sizeof(path), FILEDIR"/%s", testcase);
fp = fopen(path, "r");
assert(fp != NULL);
/* illegal multibyte sequence case */
@ -62,9 +65,12 @@ main(int argc, char *argv[])
ret = mbtowc(NULL, s, n - 1);
assert(ret == (size_t)-1 && errno == EILSEQ);
/* re-initialize internal state */
ret = mbtowc(NULL, NULL, 0);
assert(stateful ? ret : !ret);
/* if this is stateless encoding, this re-initialization is not required. */
if (stateful) {
/* re-initialize internal state */
ret = mbtowc(NULL, NULL, 0);
assert(stateful ? ret : !ret);
}
/* valid multibyte sequence case */
s = fgetln(fp, &n);