mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-25 16:13:17 +00:00
Reset internal conversion state after triggering conversion errors;
the state is undefined according to the standards, and our undefined behaviour has changed.
This commit is contained in:
parent
ca2dae426e
commit
3a8bdd99cb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128005
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Tim J. Robbins
|
||||
* Copyright (c) 2002-2004 Tim J. Robbins
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -69,6 +69,7 @@ main(int argc, char *argv[])
|
||||
/* Incomplete character sequence. */
|
||||
buf[0] = '\0';
|
||||
assert(mblen(buf, 0) == -1);
|
||||
assert(mblen(NULL, 0) == 0);
|
||||
|
||||
/*
|
||||
* Japanese (EUC) locale.
|
||||
@ -92,12 +93,14 @@ main(int argc, char *argv[])
|
||||
/* Incomplete character sequence. */
|
||||
buf[0] = '\0';
|
||||
assert(mblen(buf, 0) == -1);
|
||||
assert(mblen(NULL, 0) == 0);
|
||||
|
||||
/* Incomplete character sequence (truncated double-byte). */
|
||||
memset(buf, 0xcc, sizeof(buf));
|
||||
buf[0] = 0xa3;
|
||||
buf[1] = 0x00;
|
||||
assert(mblen(buf, 1) == -1);
|
||||
assert(mblen(NULL, 0) == 0);
|
||||
|
||||
/* Same as above, but complete. */
|
||||
buf[1] = 0xc1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Tim J. Robbins
|
||||
* Copyright (c) 2002-2004 Tim J. Robbins
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -74,6 +74,7 @@ main(int argc, char *argv[])
|
||||
buf[0] = '\0';
|
||||
assert(mbtowc(&wc, buf, 0) == -1);
|
||||
assert(wc == L'z');
|
||||
assert(mbtowc(NULL, NULL, 0) == 0);
|
||||
|
||||
/*
|
||||
* Japanese (EUC) locale.
|
||||
@ -99,6 +100,7 @@ main(int argc, char *argv[])
|
||||
buf[0] = '\0';
|
||||
assert(mbtowc(&wc, buf, 0) == -1);
|
||||
assert(wc == L'z');
|
||||
assert(mbtowc(NULL, NULL, 0) == 0);
|
||||
|
||||
/* Incomplete character sequence (truncated double-byte). */
|
||||
memset(buf, 0xcc, sizeof(buf));
|
||||
@ -107,6 +109,7 @@ main(int argc, char *argv[])
|
||||
wc = L'z';
|
||||
assert(mbtowc(&wc, buf, 1) == -1);
|
||||
assert(wc == L'z');
|
||||
assert(mbtowc(NULL, NULL, 0) == 0);
|
||||
|
||||
/* Same as above, but complete. */
|
||||
buf[1] = 0xc1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Tim J. Robbins
|
||||
* Copyright (c) 2002-2004 Tim J. Robbins
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -72,6 +72,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Invalid code. */
|
||||
assert(wctomb(buf, UCHAR_MAX + 1) == -1);
|
||||
assert(wctomb(NULL, 0) == 0);
|
||||
|
||||
/*
|
||||
* Japanese (EUC) locale.
|
||||
|
Loading…
Reference in New Issue
Block a user