none.c (129179) | none.c (129707) |
---|---|
1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved. 3 * Copyright (c) 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Paul Borman at Krystal Technologies. 8 * --- 25 unchanged lines hidden (view full) --- 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37 38#if defined(LIBC_SCCS) && !defined(lint) 39static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; 40#endif /* LIBC_SCCS and not lint */ 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved. 3 * Copyright (c) 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Paul Borman at Krystal Technologies. 8 * --- 25 unchanged lines hidden (view full) --- 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37 38#if defined(LIBC_SCCS) && !defined(lint) 39static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; 40#endif /* LIBC_SCCS and not lint */ 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/lib/libc/locale/none.c 129179 2004-05-13 11:20:27Z tjr $"); | 42__FBSDID("$FreeBSD: head/lib/libc/locale/none.c 129707 2004-05-25 10:45:24Z tjr $"); |
43 44#include <errno.h> 45#include <limits.h> 46#include <runetype.h> 47#include <stddef.h> 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> --- 92 unchanged lines hidden (view full) --- 143 144size_t 145_none_wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, 146 size_t len, mbstate_t * __restrict ps __unused) 147{ 148 const wchar_t *s; 149 size_t nchr; 150 | 43 44#include <errno.h> 45#include <limits.h> 46#include <runetype.h> 47#include <stddef.h> 48#include <stdio.h> 49#include <stdlib.h> 50#include <string.h> --- 92 unchanged lines hidden (view full) --- 143 144size_t 145_none_wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, 146 size_t len, mbstate_t * __restrict ps __unused) 147{ 148 const wchar_t *s; 149 size_t nchr; 150 |
151 if (dst == NULL) 152 return (wcslen(*src)); | 151 if (dst == NULL) { 152 for (s = *src; *s != L'\0'; s++) { 153 if (*s < 0 || *s > UCHAR_MAX) { 154 errno = EILSEQ; 155 return ((size_t)-1); 156 } 157 } 158 return (s - *src); 159 } |
153 154 s = *src; 155 nchr = 0; 156 while (len-- > 0) { 157 if (*s < 0 || *s > UCHAR_MAX) { 158 errno = EILSEQ; 159 return ((size_t)-1); 160 } 161 if ((*dst++ = *s++) == '\0') { 162 *src = NULL; 163 return (nchr); 164 } 165 nchr++; 166 } 167 *src = s; 168 return (nchr); 169} | 160 161 s = *src; 162 nchr = 0; 163 while (len-- > 0) { 164 if (*s < 0 || *s > UCHAR_MAX) { 165 errno = EILSEQ; 166 return ((size_t)-1); 167 } 168 if ((*dst++ = *s++) == '\0') { 169 *src = NULL; 170 return (nchr); 171 } 172 nchr++; 173 } 174 *src = s; 175 return (nchr); 176} |