diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-10-14 01:46:18 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-10-14 01:46:18 +0000 |
| commit | d891f26821bc380745d2223d76f5f4353fa46282 (patch) | |
| tree | 045a5fb48e7a8c1798b2435a1c8253c49f40b6e7 | |
| parent | 4d752b01b4b98237298bcd8c6ae630756b8a97c3 (diff) | |
Notes
| -rw-r--r-- | lib/libc/locale/mskanji.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/libc/locale/mskanji.c b/lib/libc/locale/mskanji.c index 4d1df6416b2f..31102990f727 100644 --- a/lib/libc/locale/mskanji.c +++ b/lib/libc/locale/mskanji.c @@ -67,22 +67,25 @@ _MSKanji_sgetrune(string, n, result) { rune_t rune = 0; - if (n < 1 ) { - rune = _INVALID_RUNE; - } else { - rune = *( string++ ) & 0xff; - if ( ( rune > 0x80 && rune < 0xa0 ) - || ( rune >= 0xe0 && rune < 0xfa ) ) { - if ( n < 2 ) { - rune = (rune_t)_INVALID_RUNE; - --string; - } else { - rune = ( rune << 8 ) | ( *( string++ ) & 0xff ); - } - } + if (n < 1) { + if (result != NULL) + *result = string; + return (_INVALID_RUNE); + } + + rune = *string++ & 0xff; + if ((rune > 0x80 && rune < 0xa0) || + (rune >= 0xe0 && rune < 0xfa)) { + if (n < 2) { + rune = _INVALID_RUNE; + --string; + } else + rune = (rune << 8) | (*string++ & 0xff); } - if (result) *result = string; - return rune; + if (result != NULL) + *result = string; + + return (rune); } int @@ -91,16 +94,18 @@ _MSKanji_sputrune(c, string, n, result) char *string, **result; size_t n; { - int len, i; + int len, i; - len = ( c > 0x100 ) ? 2 : 1; - if ( n < len ) { - if ( result ) *result = (char *) 0; + len = (c > 0x100) ? 2 : 1; + if (n < len) { + if (result != NULL) + *result = NULL; } else { - if ( result ) *result = string + len; - for ( i = len; i-- > 0; ) { - *( string++ ) = c >> ( i << 3 ); - } + if (result != NULL) + *result = string + len; + for (i = len; i-- > 0; ) + *string++ = c >> (i << 3); } - return len; + + return (len); } |
