sprinkle in _DIAGASSERT() as appropriate

This commit is contained in:
lukem 2001-01-03 15:23:26 +00:00
parent 4469b35a09
commit 2e9d6ac8c1
14 changed files with 345 additions and 35 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: big5.c,v 1.4 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: big5.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c) 1993
@ -41,10 +41,11 @@
#if 0
static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: big5.c,v 1.4 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: big5.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -86,6 +87,8 @@ _BIG5_init(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_BIG5State) > sizeof(mbstate_t))
return (EINVAL);
@ -131,6 +134,11 @@ _BIG5_mbrtowc(rl, pwcs, s, n, state)
rune_t rune;
int c;
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -198,6 +206,10 @@ _BIG5_wcrtomb(rl, s, n, wc, state)
{
int l;
/* rl appears to be unused */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
/* check invalid sequence */
if (wc & ~0xffff) {
errno = EILSEQ;
@ -239,6 +251,7 @@ _BIG5_initstate(rl, s)
{
_BIG5State *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -252,6 +265,10 @@ _BIG5_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_BIG5State));
return;
}
@ -263,6 +280,10 @@ _BIG5_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_BIG5State));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: euc.c,v 1.5 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: euc.c,v 1.6 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c) 1993
@ -41,12 +41,13 @@
#if 0
static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: euc.c,v 1.5 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: euc.c,v 1.6 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -95,6 +96,8 @@ _EUC_init(rl)
int x;
char *v, *e;
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_EUCState) > sizeof(mbstate_t))
return (EINVAL);
@ -173,6 +176,11 @@ _EUC_mbrtowc(rl, pwcs, s, n, state)
rune_t rune;
int c, set, len;
_DIAGASSERT(rl != NULL);
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -243,10 +251,17 @@ _EUC_wcrtomb(rl, s, n, wc, state)
const rune_t wc;
void *state;
{
rune_t m = wc & CEI(rl)->mask;
rune_t nm = wc & ~m;
rune_t m, nm;
int set, i, len;
_DIAGASSERT(rl != NULL);
/* pwcs appears to be unused */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
m = wc & CEI(rl)->mask;
nm = wc & ~m;
for (set = 0;
set < sizeof(CEI(rl)->count)/sizeof(CEI(rl)->count[0]);
set++) {
@ -292,6 +307,7 @@ _EUC_initstate(rl, s)
{
_EUCState *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -305,6 +321,10 @@ _EUC_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_EUCState));
return;
}
@ -316,6 +336,10 @@ _EUC_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_EUCState));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: euctw.c,v 1.6 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: euctw.c,v 1.7 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -30,11 +30,12 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: euctw.c,v 1.6 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: euctw.c,v 1.7 2001/01/03 15:23:26 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -74,6 +75,8 @@ _EUCTW_init(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_EUCTWState) > sizeof(mbstate_t))
return (EINVAL);
@ -130,6 +133,11 @@ _EUCTW_mbrtowc(rl, pwcs, s, n, state)
rune_t rune;
int c, set;
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -211,6 +219,10 @@ _EUCTW_wcrtomb(rl, s, n, wc, state)
rune_t v;
int i, len, clen;
/* rl appears to be unused */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
clen = 1;
if (wc & 0x00007f00)
clen = 2;
@ -270,6 +282,7 @@ _EUCTW_initstate(rl, s)
{
_EUCTWState *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -283,6 +296,10 @@ _EUCTW_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_EUCTWState));
return;
}
@ -294,6 +311,10 @@ _EUCTW_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_EUCTWState));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso2022.c,v 1.8 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: iso2022.c,v 1.9 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: iso2022.c,v 1.8 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: iso2022.c,v 1.9 2001/01/03 15:23:26 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
/*
@ -51,6 +51,7 @@ __RCSID("$NetBSD: iso2022.c,v 1.8 2000/12/30 05:05:57 itojun Exp $");
#include <sys/types.h>
#include <machine/limits.h>
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -135,6 +136,10 @@ getcs(p, cs)
char *p;
_Iso2022Charset *cs;
{
_DIAGASSERT(p != NULL);
_DIAGASSERT(cs != NULL);
if (!strncmp(p, "94$", 3) && p[3] && !p[4]) {
cs->final = (u_char)(p[3] & 0xff);
cs->interm = '\0';
@ -185,6 +190,8 @@ F_SI, F_SO, F_LS0, F_LS1, F_LS2, F_LS3,
F_LS1R, F_LS2R, F_LS3R, F_SS2, F_SS3, F_SS2R, F_SS3R, 0 };
_Iso2022Charset cs;
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_Iso2022State) > sizeof(mbstate_t))
return (EINVAL);
@ -345,6 +352,8 @@ _ISO2022_init_stream(rl)
size_t s;
_Iso2022State *pst;
_DIAGASSERT(rl != NULL);
s = FOPEN_MAX * 2 * (sizeof(void *) + sizeof(_Iso2022State));
_StreamStateTable = malloc(s);
if (!_StreamStateTable)
@ -417,6 +426,9 @@ seqmatch(s, n, sp)
{
const int *p;
_DIAGASSERT(s != NULL);
_DIAGASSERT(sp != NULL);
p = sp->chars;
while (p - sp->chars < n && p - sp->chars < sp->len) {
switch (*p) {
@ -471,6 +483,10 @@ _ISO2022_sgetrune(rl, string, n, result, state)
int nmatch;
int i;
_DIAGASSERT(rl != NULL);
_DIAGASSERT(string != NULL);
/* result may be NULL */
while (1) {
/* SI/SO */
if (1 <= n && string[0] == '\017') {
@ -551,6 +567,7 @@ _ISO2022_sgetrune(rl, string, n, result, state)
}
/* LS1/2/3R */
/* XXX: { for vi showmatch */
if (2 <= n && string[0] == '\033'
&& string[1] && strchr("~}|", string[1])) {
CES(rl)->gr = 3 - (string[1] - '|');
@ -736,6 +753,9 @@ recommendation(rl, cs)
int i, j;
_Iso2022Charset *recommend;
_DIAGASSERT(rl != NULL);
_DIAGASSERT(cs != NULL);
/* first, try a exact match. */
for (i = 0; i < 4; i++) {
recommend = CEI(rl)->recommend[i];
@ -800,6 +820,11 @@ _ISO2022_sputrune(rl, c, string, n, result, state)
u_char mask;
int bit8;
_DIAGASSERT(rl != NULL);
_DIAGASSERT(string != NULL);
/* result may be NULL */
/* state appears to be unused */
if (iscntl(c & 0xff)) {
/* go back to ASCII on control chars */
cs.type = CS94;
@ -964,6 +989,11 @@ _ISO2022_mbrtowc(rl, pwcs, s, n, state)
const char *p, *result;
int c;
_DIAGASSERT(rl != NULL);
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/*
@ -1036,7 +1066,6 @@ output:
return 0;
else
return c;
}
/* s is non-null */
@ -1052,6 +1081,10 @@ _ISO2022_wcrtomb(rl, s, n, wc, state)
char *result;
int len;
_DIAGASSERT(rl != NULL);
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
/* XXX state will be modified after this operation... */
len = _ISO2022_sputrune(rl, wc, buf, sizeof(buf), &result, state);
if (sizeof(buf) < len || n < len) {
@ -1076,6 +1109,8 @@ _ISO2022_initstate(rl, s)
_Iso2022State *state;
size_t i;
_DIAGASSERT(rl != NULL);
if (!s)
return;
state = s;
@ -1101,6 +1136,10 @@ _ISO2022_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_Iso2022State));
return;
}
@ -1112,6 +1151,10 @@ _ISO2022_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_Iso2022State));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mskanji.c,v 1.4 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: mskanji.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*
* ja_JP.SJIS locale table for BSD4.4/rune
@ -38,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
#else
__RCSID("$NetBSD: mskanji.c,v 1.4 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: mskanji.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -101,6 +102,8 @@ _MSKanji_init(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_MSKanjiState) > sizeof(mbstate_t))
return (EINVAL);
@ -127,6 +130,11 @@ _MSKanji_mbrtowc(rl, pwcs, s, n, state)
rune_t rune;
int len;
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -191,6 +199,10 @@ _MSKanji_wcrtomb(rl, s, n, wc, state)
void *state;
{
/* rl appears to be unused */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
/* check invalid sequence */
if (wc & ~0xffff) {
errno = EILSEQ;
@ -230,6 +242,8 @@ _MSKanji_initstate(rl, s)
{
_MSKanjiState *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -243,6 +257,10 @@ _MSKanji_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_MSKanjiState));
return;
}
@ -254,6 +272,10 @@ _MSKanji_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_MSKanjiState));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte.c,v 1.6 2000/12/30 05:05:57 itojun Exp $ */
/* $NetBSD: multibyte.c,v 1.7 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c) 1993
@ -41,15 +41,16 @@
#if 0
static char sccsid[] = "@(#)ansi.c 8.1 (Berkeley) 6/27/93";
#else
__RCSID("$NetBSD: multibyte.c,v 1.6 2000/12/30 05:05:57 itojun Exp $");
__RCSID("$NetBSD: multibyte.c,v 1.7 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include "rune.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <errno.h>
#include "rune.h"
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "rune_local.h"
@ -105,6 +106,8 @@ _mbstate_get_locale(ps)
{
_RuneLocale *rl;
_DIAGASSERT(ps != NULL);
rl = *(_RuneLocale **)ps;
if (!rl)
rl = _CurrentRuneLocale;
@ -117,6 +120,9 @@ _mbstate_set_locale(ps, rl)
const _RuneLocale *rl;
{
_DIAGASSERT(ps != NULL);
/* XXX: can rl be NULL ? */
*(const _RuneLocale **)ps = rl;
}
@ -126,6 +132,9 @@ _mbstate_init_locale(ps, rl)
const _RuneLocale *rl;
{
_DIAGASSERT(ps != NULL);
/* rl may be NULL */
if (!rl)
rl = _CurrentRuneLocale;
if (*(_RuneLocale **)ps != rl) {
@ -146,6 +155,8 @@ mbsinit(ps)
void *state = NULL;
int r = 1;
/* ps may be NULL */
if (!ps)
return r;
@ -174,6 +185,9 @@ mbrlen(s, n, ps)
{
static mbstate_t ls;
/* XXX: s may be NULL ? */
/* ps may be NULL */
if (!ps) {
_mbstate_init_locale(&ls, NULL);
ps = &ls;
@ -188,6 +202,8 @@ mblen(s, n)
{
static mbstate_t ls;
/* XXX: s may be NULL ? */
_mbstate_init_locale(&ls, NULL);
return mbrlen(s, n, &ls);
}
@ -206,6 +222,10 @@ mbrtowc(pwc, s, n, ps)
void *state = NULL;
size_t siz;
/* pwc may be NULL */
/* s may be NULL */
/* ps may be NULL */
if (!ps) {
_mbstate_init_locale(&ls, NULL);
ps = &ls;
@ -238,6 +258,9 @@ mbtowc(pwc, s, n)
{
static mbstate_t ls;
/* pwc may be NULL */
/* s may be NULL */
_mbstate_init_locale(&ls, NULL);
return mbrtowc(pwc, s, n, &ls);
}
@ -256,6 +279,9 @@ wcrtomb(s, wchar, ps)
char buf[MB_LEN_MAX];
size_t siz;
/* s may be NULL */
/* ps may be NULL */
if (!ps) {
_mbstate_init_locale(&ls, NULL);
ps = &ls;
@ -286,6 +312,8 @@ wctomb(s, wchar)
{
static mbstate_t ls;
/* s may be NULL */
_mbstate_init_locale(&ls, NULL);
return wcrtomb(s, wchar, &ls);
}
@ -305,6 +333,10 @@ mbsrtowcs(pwcs, s, n, ps)
void *state = NULL;
size_t siz;
/* pwcs may be NULL */
/* s may be NULL */
/* ps may be NULL */
if (!ps) {
_mbstate_init_locale(&ls, NULL);
ps = &ls;
@ -373,6 +405,9 @@ mbstowcs(pwcs, s, n)
{
static mbstate_t ls;
/* pwcs may be NULL */
/* s may be NULL */
_mbstate_init_locale(&ls, NULL);
return mbsrtowcs(pwcs, &s, n, &ls);
}
@ -393,6 +428,10 @@ wcsrtombs(s, pwcs, n, ps)
char buf[MB_LEN_MAX];
size_t siz;
/* s may be NULL */
/* pwcs may be NULL */
/* ps may be NULL */
if (!ps) {
_mbstate_init_locale(&ls, NULL);
ps = &ls;
@ -452,6 +491,9 @@ wcstombs(s, pwcs, n)
{
static mbstate_t ls;
/* s may be NULL */
/* pwcs may be NULL */
_mbstate_init_locale(&ls, NULL);
return wcsrtombs(s, &pwcs, n, &ls);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte_sb.c,v 1.1 2000/12/25 23:30:58 itojun Exp $ */
/* $NetBSD: multibyte_sb.c,v 1.2 2001/01/03 15:23:26 lukem Exp $ */
/*
* Copyright (c) 1991 The Regents of the University of California.
@ -38,7 +38,7 @@
#if 0
static char *sccsid = "from: @(#)multibyte.c 5.1 (Berkeley) 2/18/91";
#else
__RCSID("$NetBSD: multibyte_sb.c,v 1.1 2000/12/25 23:30:58 itojun Exp $");
__RCSID("$NetBSD: multibyte_sb.c,v 1.2 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -70,6 +70,8 @@ mbrlen(s, n, ps)
mbstate_t *ps;
{
/* ps appears to be unused */
if (s == NULL || *s == '\0')
return 0;
if (n == 0)
@ -83,6 +85,8 @@ mblen(s, n)
size_t n;
{
/* s may be NULL */
return mbrlen(s, n, NULL);
}
@ -95,6 +99,10 @@ mbrtowc(pwc, s, n, ps)
mbstate_t *ps;
{
/* pwc may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
if (n == 0)
@ -111,6 +119,9 @@ mbtowc(pwc, s, n)
size_t n;
{
/* pwc may be NULL */
/* s may be NULL */
return mbrtowc(pwc, s, n, NULL);
}
@ -122,6 +133,9 @@ wcrtomb(s, wchar, ps)
mbstate_t *ps;
{
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
@ -135,6 +149,8 @@ wctomb(s, wchar)
wchar_t wchar;
{
/* s may be NULL */
return wcrtomb(s, wchar, NULL);
}
@ -148,6 +164,10 @@ mbsrtowcs(pwcs, s, n, ps)
{
int count = 0;
/* pwcs may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (!s || !*s)
return 0;
@ -177,6 +197,9 @@ mbstowcs(pwcs, s, n)
size_t n;
{
/* pwcs may be NULL */
/* s may be NULL */
return mbsrtowcs(pwcs, &s, n, NULL);
}
@ -190,7 +213,10 @@ wcsrtombs(s, pwcs, n, ps)
{
int count = 0;
_DIAGASSERT(pwcs != NULL);
/* s may be NULL */
/* pwcs may be NULL */
/* ps appears to be unused */
if (pwcs == NULL || *pwcs == NULL)
return (0);
@ -218,5 +244,8 @@ wcstombs(s, pwcs, n)
size_t n;
{
/* s may be NULL */
/* pwcs may be NULL */
return wcsrtombs(s, &pwcs, n, NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rune.c,v 1.4 2000/12/26 00:34:49 itojun Exp $ */
/* $NetBSD: rune.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -67,11 +67,12 @@
#if 0
static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: rune.c,v 1.4 2000/12/26 00:34:49 itojun Exp $");
__RCSID("$NetBSD: rune.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "rune.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -91,6 +92,12 @@ readrange(_RuneLocale *rl, _RuneRange *rr, _FileRuneRange *frr, void *lastp,
_RuneEntry *re;
_FileRuneEntry fre;
_DIAGASSERT(rl != NULL);
_DIAGASSERT(rr != NULL);
_DIAGASSERT(frr != NULL);
_DIAGASSERT(lastp != NULL);
_DIAGASSERT(fp != NULL);
re = (_RuneEntry *)rl->__rune_variable;
rr->__nranges = ntohl(frr->__nranges);
@ -123,6 +130,9 @@ readentry(_RuneRange *rr, FILE *fp)
size_t l, i, j;
int error;
_DIAGASSERT(rr != NULL);
_DIAGASSERT(fp != NULL);
re = rr->__rune_ranges;
for (i = 0; i < rr->__nranges; i++) {
if (re[i].__map != 0) {
@ -166,6 +176,8 @@ _freeentry(_RuneRange *rr)
_RuneEntry *re;
int i;
_DIAGASSERT(rr != NULL);
re = rr->__rune_ranges;
for (i = 0; i < rr->__nranges; i++) {
if (re[i].__rune_types)
@ -188,6 +200,8 @@ _Read_RuneMagi(fp)
struct stat sb;
int x;
_DIAGASSERT(fp != NULL);
if (fstat(fileno(fp), &sb) < 0)
return NULL;
@ -279,6 +293,9 @@ void
_NukeRune(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
_freeentry(&rl->__runetype_ext);
free(rl);
}
@ -305,6 +322,8 @@ _Read_CTypeAsRune(fp)
struct stat sb;
int x;
_DIAGASSERT(fp != NULL);
if (fstat(fileno(fp), &sb) < 0)
return NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: runeglue.c,v 1.4 2000/12/28 05:27:35 itojun Exp $ */
/* $NetBSD: runeglue.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -35,10 +35,11 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: runeglue.c,v 1.4 2000/12/28 05:27:35 itojun Exp $");
__RCSID("$NetBSD: runeglue.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#define _CTYPE_PRIVATE
#include <assert.h>
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
@ -62,6 +63,8 @@ __runetable_to_netbsd_ctype(locale)
unsigned char *new_ctype;
short *new_toupper, *new_tolower;
_DIAGASSERT(locale != NULL);
/* set to C locale, to ease failure case handling */
if (_ctype_ != _C_ctype_) {
/* LINTED const castaway */

View File

@ -1,4 +1,4 @@
/* $NetBSD: runenone.c,v 1.4 2000/12/28 05:22:27 itojun Exp $ */
/* $NetBSD: runenone.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c) 1993
@ -41,10 +41,11 @@
#if 0
static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: runenone.c,v 1.4 2000/12/28 05:22:27 itojun Exp $");
__RCSID("$NetBSD: runenone.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include "rune.h"
@ -69,6 +70,9 @@ int
_none_init(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
rl->__rune_mbrtowc = _none_mbrtowc;
rl->__rune_wcrtomb = _none_wcrtomb;
@ -88,6 +92,11 @@ _none_mbrtowc(rl, pwcs, s, n, state)
void *state;
{
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
if (n < 1)
return (size_t)-2;
if (pwcs)
@ -108,6 +117,10 @@ _none_wcrtomb(rl, s, n, wc, state)
void *state;
{
/* rl appears to be unused */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
if (wc & ~0xff) {
errno = EILSEQ;
return (size_t)-1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: setlocale_sb.c,v 1.4 2000/12/21 11:29:48 itojun Exp $ */
/* $NetBSD: setlocale_sb.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -48,6 +48,8 @@ setlocale(category, locale)
const char *locale;
{
/* locale may be NULL */
__mb_len_max_runtime = 1;
return __setlocale(category, locale);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: setrunelocale.c,v 1.6 2000/12/30 05:05:25 itojun Exp $ */
/* $NetBSD: setrunelocale.c,v 1.7 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -100,10 +100,11 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: setrunelocale.c,v 1.6 2000/12/30 05:05:25 itojun Exp $");
__RCSID("$NetBSD: setrunelocale.c,v 1.7 2001/01/03 15:23:26 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include "rune.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
@ -160,6 +161,9 @@ char *cp;
{
int i, n;
_DIAGASSERT(dewey != NULL);
_DIAGASSERT(cp != NULL);
for (n = 0, i = 0; i < MAXDEWEY; i++) {
if (*cp == '\0')
break;
@ -187,6 +191,9 @@ int n1, n2;
{
register int i;
_DIAGASSERT(d1 != NULL);
_DIAGASSERT(d2 != NULL);
for (i = 0; i < n1 && i < n2; i++) {
if (d1[i] < d2[i])
return -1;
@ -219,10 +226,16 @@ int *majorp, *minorp;
int len;
char *lname;
static char path[PATH_MAX];
int major = *majorp, minor = *minorp;
int major, minor;
const char *search_dirs[1];
const int n_search_dirs = 1;
_DIAGASSERT(name != NULL);
_DIAGASSERT(majorp != NULL);
_DIAGASSERT(minorp != NULL);
major = *majorp;
minor = *minorp;
path[0] = '\0';
search_dirs[0] = _PathModule;
len = strlen(name);
@ -306,6 +319,9 @@ findfunc(handle, sym)
char name[PATH_MAX];
void *p;
_DIAGASSERT(handle != NULL);
_DIAGASSERT(sym != NULL);
p = dlsym(handle, sym);
if (!p) {
/* a.out case */
@ -325,6 +341,9 @@ loadrunemodule(_RuneLocale *rl, void **rhandle)
int (*init) __P((_RuneLocale *));
int (*initstream) __P((_RuneLocale *));
_DIAGASSERT(rl != NULL);
_DIAGASSERT(rhandle != NULL);
if (_PathModule == NULL) {
/* "/libencoding.so.###" */
const size_t offset = 4 + sizeof(rl->__encoding) + 7;
@ -382,6 +401,8 @@ _findrunelocale(path)
{
struct localetable *lt;
_DIAGASSERT(path != NULL);
/* ones which we have seen already */
for (lt = localetable.next; lt; lt = lt->next)
if (strcmp(path, lt->path) == 0)
@ -399,6 +420,8 @@ _newrunelocale(path)
_RuneLocale *rl;
int ret;
/* path may be NULL (actually, it's checked below) */
ret = 0;
if (!path || strlen(path) + 1 > sizeof(lt->path))
@ -496,6 +519,8 @@ delrunelocale(path)
struct localetable *lt, *prev;
_RuneLocale *rl;
_DIAGASSERT(path != NULL);
prev = NULL;
for (lt = localetable.next; lt; prev = lt, lt = prev->next)
if (strcmp(path, lt->path) == 0)
@ -529,6 +554,8 @@ _xpg4_setrunelocale(encoding)
_RuneLocale *rl;
int error;
_DIAGASSERT(encoding != NULL);
if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
rl = &_DefaultRuneLocale;
goto found;

View File

@ -1,4 +1,4 @@
/* $NetBSD: utf2.c,v 1.4 2000/12/30 05:05:58 itojun Exp $ */
/* $NetBSD: utf2.c,v 1.5 2001/01/03 15:23:26 lukem Exp $ */
/*-
* Copyright (c) 1993
@ -41,10 +41,11 @@
#if 0
static char sccsid[] = "@(#)utf2.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: utf2.c,v 1.4 2000/12/30 05:05:58 itojun Exp $");
__RCSID("$NetBSD: utf2.c,v 1.5 2001/01/03 15:23:26 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -83,6 +84,8 @@ _UTF2_init(rl)
_RuneLocale *rl;
{
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_UTF2State) > sizeof(mbstate_t))
return (EINVAL);
@ -109,6 +112,11 @@ _UTF2_mbrtowc(rl, pwcs, s, n, state)
rune_t rune;
int c;
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -179,6 +187,10 @@ _UTF2_wcrtomb(rl, s, n, wc, state)
void *state;
{
/* rl appears to be unused */
_DIAGASSERT(s != NULL);
/* state appears to be unused */
/* check invalid sequence */
if (wc & ~0xffff) {
errno = EILSEQ;
@ -227,6 +239,8 @@ _UTF2_initstate(rl, s)
{
_UTF2State *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -240,6 +254,10 @@ _UTF2_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_UTF2State));
return;
}
@ -251,6 +269,10 @@ _UTF2_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_UTF2State));
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: utf8.c,v 1.6 2000/12/30 05:06:03 itojun Exp $ */
/* $NetBSD: utf8.c,v 1.7 2001/01/03 15:23:27 lukem Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@ -69,11 +69,12 @@
#if 0
static char sccsid[] = "@(#)utf2.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: utf8.c,v 1.6 2000/12/30 05:06:03 itojun Exp $");
__RCSID("$NetBSD: utf8.c,v 1.7 2001/01/03 15:23:27 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include "rune.h"
#include <stddef.h>
@ -118,6 +119,8 @@ _UTF8_init(rl)
{
int i;
_DIAGASSERT(rl != NULL);
/* sanity check to avoid overruns */
if (sizeof(_UTF8State) > sizeof(mbstate_t))
return (EINVAL);
@ -173,6 +176,11 @@ _UTF8_mbrtowc(rl, pwcs, s, n, state)
int c;
int i;
/* rl appears to be unused */
/* pwcs may be NULL */
_DIAGASSERT(s != NULL);
_DIAGASSERT(state != NULL);
ps = state;
/* make sure we have the first byte in the buffer */
@ -249,6 +257,10 @@ _UTF8_wcrtomb(rl, s, n, wc, state)
int cnt, i;
rune_t c;
/* rl appears to be unused */
/* s may be NULL (actually, it's checked below) */
/* state appears to be unused */
cnt = findlen(wc);
if (cnt <= 0 || cnt > 6) {
/* invalid UCS4 value */
@ -286,6 +298,8 @@ _UTF8_initstate(rl, s)
{
_UTF8State *state;
/* rl appears to be unused */
if (!s)
return;
state = s;
@ -299,6 +313,10 @@ _UTF8_packstate(rl, dst, src)
void* src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_UTF8State));
return;
}
@ -310,6 +328,10 @@ _UTF8_unpackstate(rl, dst, src)
const mbstate_t *src;
{
/* rl appears to be unused */
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
memcpy((caddr_t)dst, (caddr_t)src, sizeof(_UTF8State));
return;
}