summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-10-28 08:24:46 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-10-28 08:24:46 +0000
commitc5929b304ef89212025c25b72a9b035777159820 (patch)
tree89211f3df1b854343a8ab5c55df5f6568856af88 /lib/libc
parent8c847e90204ab7c9dc603237111cb43898be806a (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/locale/mblen.c7
-rw-r--r--lib/libc/locale/mbtowc.c7
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c
index a54e05111b59..ad5edb393be9 100644
--- a/lib/libc/locale/mblen.c
+++ b/lib/libc/locale/mblen.c
@@ -47,13 +47,12 @@ mblen(const char *s, size_t n)
{
const char *e;
- if (s == NULL || *s == '\0')
+ if (s == NULL)
/* No support for state dependent encodings. */
return (0);
-
if (sgetrune(s, n, &e) == _INVALID_RUNE) {
errno = EILSEQ;
- return (s - e);
+ return (-1);
}
- return (e - s);
+ return (*s == '\0' ? 0 : e - s);
}
diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c
index a690bec171dc..27bebcfa612a 100644
--- a/lib/libc/locale/mbtowc.c
+++ b/lib/libc/locale/mbtowc.c
@@ -48,15 +48,14 @@ mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
const char *e;
rune_t r;
- if (s == NULL || *s == '\0')
+ if (s == NULL)
/* No support for state dependent encodings. */
return (0);
-
if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) {
errno = EILSEQ;
- return (s - e);
+ return (-1);
}
if (pwc != NULL)
*pwc = r;
- return (e - s);
+ return (r == 0 ? 0 : e - s);
}