diff options
author | tjr <tjr@FreeBSD.org> | 2002-10-27 10:41:21 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-10-27 10:41:21 +0000 |
commit | dd9e331ae288a8ca739bb13755c0849aa4793249 (patch) | |
tree | fac23295d346506f8efe21b089d1944170c3db0c /lib/libc | |
parent | c9805dcdfb391e619bc3f9a1ae0dcde7c19b3711 (diff) | |
download | FreeBSD-src-dd9e331ae288a8ca739bb13755c0849aa4793249.zip FreeBSD-src-dd9e331ae288a8ca739bb13755c0849aa4793249.tar.gz |
Style sweep.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/locale/mblen.c | 13 | ||||
-rw-r--r-- | lib/libc/locale/mbstowcs.c | 15 | ||||
-rw-r--r-- | lib/libc/locale/mbtowc.c | 14 | ||||
-rw-r--r-- | lib/libc/locale/wcstombs.c | 17 | ||||
-rw-r--r-- | lib/libc/locale/wctomb.c | 13 |
5 files changed, 32 insertions, 40 deletions
diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c index b5b92d1..a54e051 100644 --- a/lib/libc/locale/mblen.c +++ b/lib/libc/locale/mblen.c @@ -38,19 +38,18 @@ __FBSDID("$FreeBSD$"); #include <errno.h> -#include <stdlib.h> #include <stddef.h> +#include <stdlib.h> #include <rune.h> int -mblen(s, n) - const char *s; - size_t n; +mblen(const char *s, size_t n) { - char const *e; + const char *e; - if (s == 0 || *s == 0) - return (0); /* No support for state dependent encodings. */ + if (s == NULL || *s == '\0') + /* No support for state dependent encodings. */ + return (0); if (sgetrune(s, n, &e) == _INVALID_RUNE) { errno = EILSEQ; diff --git a/lib/libc/locale/mbstowcs.c b/lib/libc/locale/mbstowcs.c index 3657c83..a9adb8a 100644 --- a/lib/libc/locale/mbstowcs.c +++ b/lib/libc/locale/mbstowcs.c @@ -44,22 +44,20 @@ __FBSDID("$FreeBSD$"); #include <rune.h> size_t -mbstowcs(pwcs, s, n) - wchar_t * __restrict pwcs; - const char * __restrict s; - size_t n; +mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n) { - char const *e; - int cnt = 0; + const char *e; + int cnt; rune_t r; - if (!s) { + if (s == NULL) { errno = EINVAL; return (-1); } if (pwcs == NULL) { /* Convert and count only, do not store. */ + cnt = 0; while ((r = sgetrune(s, MB_LEN_MAX, &e)) != _INVALID_RUNE && r != 0) { s = e; @@ -72,13 +70,14 @@ mbstowcs(pwcs, s, n) } /* Convert, store and count characters. */ + cnt = 0; while (n-- > 0) { *pwcs = sgetrune(s, MB_LEN_MAX, &e); if (*pwcs == _INVALID_RUNE) { errno = EILSEQ; return (-1); } - if (*pwcs++ == 0) + if (*pwcs++ == L'\0') break; s = e; ++cnt; diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c index 206a3a3..a690bec 100644 --- a/lib/libc/locale/mbtowc.c +++ b/lib/libc/locale/mbtowc.c @@ -43,22 +43,20 @@ __FBSDID("$FreeBSD$"); #include <rune.h> int -mbtowc(pwc, s, n) - wchar_t * __restrict pwc; - const char * __restrict s; - size_t n; +mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) { - char const *e; + const char *e; rune_t r; - if (s == 0 || *s == 0) - return (0); /* No support for state dependent encodings. */ + if (s == NULL || *s == '\0') + /* No support for state dependent encodings. */ + return (0); if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) { errno = EILSEQ; return (s - e); } - if (pwc) + if (pwc != NULL) *pwc = r; return (e - s); } diff --git a/lib/libc/locale/wcstombs.c b/lib/libc/locale/wcstombs.c index 25652a8..796e3c2 100644 --- a/lib/libc/locale/wcstombs.c +++ b/lib/libc/locale/wcstombs.c @@ -44,16 +44,13 @@ __FBSDID("$FreeBSD$"); #include <rune.h> size_t -wcstombs(s, pwcs, n) - char * __restrict s; - const wchar_t * __restrict pwcs; - size_t n; +wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n) { char buf[MB_LEN_MAX]; char *e; int cnt, nb; - if (!pwcs || n > INT_MAX) { + if (pwcs == NULL || n > INT_MAX) { errno = EINVAL; return (-1); } @@ -63,7 +60,7 @@ wcstombs(s, pwcs, n) if (s == NULL) { /* Convert and count only, do not store. */ while (*pwcs != L'\0') { - if (!sputrune(*pwcs++, buf, MB_LEN_MAX, &e)) { + if (sputrune(*pwcs++, buf, MB_LEN_MAX, &e) == 0) { errno = EILSEQ; return (-1); } @@ -75,15 +72,15 @@ wcstombs(s, pwcs, n) /* Convert, store and count characters. */ nb = n; while (nb > 0) { - if (*pwcs == 0) { - *s = 0; + if (*pwcs == L'\0') { + *s = '\0'; break; } - if (!sputrune(*pwcs++, s, nb, &e)) { + if (sputrune(*pwcs++, s, nb, &e) == 0) { errno = EILSEQ; return (-1); } - if (!e) /* too long */ + if (e == NULL) /* too long */ return (cnt); cnt += e - s; nb -= e - s; diff --git a/lib/libc/locale/wctomb.c b/lib/libc/locale/wctomb.c index 2a225f4..da934b2 100644 --- a/lib/libc/locale/wctomb.c +++ b/lib/libc/locale/wctomb.c @@ -44,17 +44,16 @@ __FBSDID("$FreeBSD$"); #include <rune.h> int -wctomb(s, wchar) - char *s; - wchar_t wchar; +wctomb(char *s, wchar_t wchar) { char *e; - if (s == 0) - return (0); /* No support for state dependent encodings. */ + if (s == NULL) + /* No support for state dependent encodings. */ + return (0); - if (wchar == 0) { - *s = 0; + if (wchar == L'\0') { + *s = '\0'; return (1); } |