]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/ldpart.c.patch
Libc-594.9.5.tar.gz
[apple/libc.git] / locale / FreeBSD / ldpart.c.patch
1 --- ldpart.c.orig 2008-06-03 18:15:42.000000000 -0700
2 +++ ldpart.c 2008-06-18 13:23:20.000000000 -0700
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/ldpart.c,v 1.15 2004/04/25 19:56:50 ache Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include "namespace.h"
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 @@ -44,9 +46,9 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
13
14 static int split_lines(char *, const char *);
15
16 -int
17 +__private_extern__ int
18 __part_load_locale(const char *name,
19 - int *using_locale,
20 + unsigned char *using_locale,
21 char **locale_buf,
22 const char *category_filename,
23 int locale_buf_size_max,
24 @@ -60,20 +62,6 @@ __part_load_locale(const char *name,
25 struct stat st;
26 size_t namesize, bufsize;
27
28 - /* 'name' must be already checked. */
29 - if (strcmp(name, "C") == 0 || strcmp(name, "POSIX") == 0) {
30 - *using_locale = 0;
31 - return (_LDP_CACHE);
32 - }
33 -
34 - /*
35 - * If the locale name is the same as our cache, use the cache.
36 - */
37 - if (*locale_buf != NULL && strcmp(name, *locale_buf) == 0) {
38 - *using_locale = 1;
39 - return (_LDP_CACHE);
40 - }
41 -
42 /*
43 * Slurp the locale file into the cache.
44 */
45 @@ -115,9 +103,7 @@ __part_load_locale(const char *name,
46 num_lines = split_lines(p, plim);
47 if (num_lines >= locale_buf_size_max)
48 num_lines = locale_buf_size_max;
49 - else if (num_lines >= locale_buf_size_min)
50 - num_lines = locale_buf_size_min;
51 - else {
52 + else if (num_lines < locale_buf_size_min) {
53 errno = EFTYPE;
54 goto bad_lbuf;
55 }
56 @@ -164,3 +150,9 @@ split_lines(char *p, const char *plim)
57 return (i);
58 }
59
60 +__private_extern__ void
61 +__ldpart_free_extra(struct __xlocale_st_ldpart *lp)
62 +{
63 + if (lp)
64 + free(lp->_locale_buf);
65 +}