Deleted Added
full compact
wcscoll.c (122104) wcscoll.c (127998)
1/*-
2 * Copyright (c) 2002 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

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002 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

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libc/string/wcscoll.c 122104 2003-11-05 08:07:00Z tjr $");
28__FBSDID("$FreeBSD: head/lib/libc/string/wcscoll.c 127998 2004-04-07 09:47:56Z tjr $");
29
30#include <errno.h>
31#include <stdlib.h>
32#include <string.h>
33#include <wchar.h>
34#include "collate.h"
35
36static char *__mbsdup(const wchar_t *);

--- 37 unchanged lines hidden (view full) ---

74 errno = sverrno;
75
76 return (diff);
77}
78
79static char *
80__mbsdup(const wchar_t *ws)
81{
29
30#include <errno.h>
31#include <stdlib.h>
32#include <string.h>
33#include <wchar.h>
34#include "collate.h"
35
36static char *__mbsdup(const wchar_t *);

--- 37 unchanged lines hidden (view full) ---

74 errno = sverrno;
75
76 return (diff);
77}
78
79static char *
80__mbsdup(const wchar_t *ws)
81{
82 static const mbstate_t initial;
83 mbstate_t st;
82 const wchar_t *wcp;
83 size_t len;
84 char *mbs;
85
86 wcp = ws;
84 const wchar_t *wcp;
85 size_t len;
86 char *mbs;
87
88 wcp = ws;
87 if ((len = wcsrtombs(NULL, &wcp, 0, NULL)) == (size_t)-1)
89 st = initial;
90 if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1)
88 return (NULL);
89 if ((mbs = malloc(len + 1)) == NULL)
90 return (NULL);
91 return (NULL);
92 if ((mbs = malloc(len + 1)) == NULL)
93 return (NULL);
91 wcsrtombs(mbs, &ws, len + 1, NULL);
94 st = initial;
95 wcsrtombs(mbs, &ws, len + 1, &st);
92
93 return (mbs);
94}
96
97 return (mbs);
98}