FreeBSD Bugzilla – Attachment 8447 Details for
Bug 17694
wcstombs(), mbstowcs() not complying with standard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.08 KB, created by
mikko
on 2000-03-30 18:50:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
mikko
Created:
2000-03-30 18:50:01 UTC
Size:
1.08 KB
patch
obsolete
>--- ansi.c.org Thu Mar 30 18:45:34 2000 >+++ ansi.c Thu Mar 30 18:44:57 2000 >@@ -103,16 +103,22 @@ > size_t n; > { > char const *e; >+ wchar_t wc; > int cnt = 0; > >- if (!pwcs || !s) >+ if (!s) > return (-1); > >- while (n-- > 0) { >- *pwcs = sgetrune(s, MB_LEN_MAX, &e); >- if (*pwcs == _INVALID_RUNE) >+ for (;;) { >+ wc = sgetrune(s, MB_LEN_MAX, &e); >+ if (wc == _INVALID_RUNE) > return (-1); >- if (*pwcs++ == 0) >+ if (pwcs) { >+ if (n-- <= 0) >+ break; >+ *pwcs++ = wc; >+ } >+ if (wc == 0) > break; > s = e; > ++cnt; >@@ -129,23 +135,27 @@ > char *e; > int cnt, nb; > >- if (!pwcs || !s || n > INT_MAX) >+ if (!pwcs || n > INT_MAX) > return (-1); > >- nb = n; > cnt = 0; >- while (nb > 0) { >+ for (;;) { > if (*pwcs == 0) { >- *s = 0; >+ if (s) >+ *s = 0; > break; > } >- if (!sputrune(*pwcs++, s, nb, &e)) >+ if (!(nb = sputrune(*pwcs++, s, nb, &e))) > return (-1); /* encoding error */ > if (!e) /* too long */ > return (cnt); >- cnt += e - s; >- nb -= e - s; >- s = e; >+ cnt += nb; >+ n -= nb; >+ if (s) { >+ if (n <= 0) >+ break; >+ s = e; >+ } > } > return (cnt); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 17694
: 8447