fputws.c (2f2c1839f8d6025a050277b9abf31a330100c06d) | fputws.c (1949a3470f29c5edaa5fc2770c2886d653fa68d1) |
---|---|
1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> 28__FBSDID("$FreeBSD$"); 29 30#include "namespace.h" 31#include <errno.h> | 1/*- 2 * Copyright (c) 2002-2004 Tim J. Robbins. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> 28__FBSDID("$FreeBSD$"); 29 30#include "namespace.h" 31#include <errno.h> |
32#include <limits.h> |
|
32#include <stdio.h> 33#include <wchar.h> 34#include "un-namespace.h" 35#include "fvwrite.h" 36#include "libc_private.h" 37#include "local.h" 38#include "mblocal.h" 39 --- 8 unchanged lines hidden (view full) --- 48 FLOCKFILE(fp); 49 ORIENT(fp, 1); 50 if (prepwrite(fp) != 0) 51 goto error; 52 uio.uio_iov = &iov; 53 uio.uio_iovcnt = 1; 54 iov.iov_base = buf; 55 do { | 33#include <stdio.h> 34#include <wchar.h> 35#include "un-namespace.h" 36#include "fvwrite.h" 37#include "libc_private.h" 38#include "local.h" 39#include "mblocal.h" 40 --- 8 unchanged lines hidden (view full) --- 49 FLOCKFILE(fp); 50 ORIENT(fp, 1); 51 if (prepwrite(fp) != 0) 52 goto error; 53 uio.uio_iov = &iov; 54 uio.uio_iovcnt = 1; 55 iov.iov_base = buf; 56 do { |
56 nbytes = __wcsrtombs(buf, &ws, sizeof(buf), | 57 nbytes = __wcsnrtombs(buf, &ws, SIZE_T_MAX, sizeof(buf), |
57 &fp->_extra->mbstate); 58 if (nbytes == (size_t)-1) 59 goto error; 60 iov.iov_len = uio.uio_resid = nbytes; 61 if (__sfvwrite(fp, &uio) != 0) 62 goto error; 63 } while (ws != NULL); 64 FUNLOCKFILE(fp); 65 return (0); 66 67error: 68 FUNLOCKFILE(fp); 69 return (-1); 70} | 58 &fp->_extra->mbstate); 59 if (nbytes == (size_t)-1) 60 goto error; 61 iov.iov_len = uio.uio_resid = nbytes; 62 if (__sfvwrite(fp, &uio) != 0) 63 goto error; 64 } while (ws != NULL); 65 FUNLOCKFILE(fp); 66 return (0); 67 68error: 69 FUNLOCKFILE(fp); 70 return (-1); 71} |