ldpart.c (72331) | ldpart.c (72442) |
---|---|
1/* 2 * Copyright (c) 2000, 2001 Alexey Zelkin 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 1/* 2 * Copyright (c) 2000, 2001 Alexey Zelkin 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/lib/libc/locale/ldpart.c 72331 2001-02-10 19:57:26Z phantom $ | 26 * $FreeBSD: head/lib/libc/locale/ldpart.c 72442 2001-02-13 15:29:39Z phantom $ |
27 */ 28 29#include "namespace.h" 30#include <sys/types.h> 31#include <sys/stat.h> 32#include <sys/syslimits.h> 33#include <fcntl.h> 34#include "un-namespace.h" --- 5 unchanged lines hidden (view full) --- 40static int split_lines(char *, const char *); 41static void set_from_buf(const char *, int, const char **); 42 43int 44__part_load_locale(const char *name, 45 int* using_locale, 46 char *locale_buf, 47 const char *category_name, | 27 */ 28 29#include "namespace.h" 30#include <sys/types.h> 31#include <sys/stat.h> 32#include <sys/syslimits.h> 33#include <fcntl.h> 34#include "un-namespace.h" --- 5 unchanged lines hidden (view full) --- 40static int split_lines(char *, const char *); 41static void set_from_buf(const char *, int, const char **); 42 43int 44__part_load_locale(const char *name, 45 int* using_locale, 46 char *locale_buf, 47 const char *category_name, |
48 int locale_buf_size, | 48 int locale_buf_size_max, 49 int locale_buf_size_min, |
49 const char **dst_localebuf) { 50 51 static char locale_buf_C[] = "C"; 52 static int num_lines; 53 54 int fd; 55 char * lbuf; 56 char * p; --- 56 unchanged lines hidden (view full) --- 113 if (_close(fd) != 0) 114 goto bad_lbuf; 115 /* 116 ** Parse the locale file into localebuf. 117 */ 118 if (plim[-1] != '\n') 119 goto bad_lbuf; 120 num_lines = split_lines(p, plim); | 50 const char **dst_localebuf) { 51 52 static char locale_buf_C[] = "C"; 53 static int num_lines; 54 55 int fd; 56 char * lbuf; 57 char * p; --- 56 unchanged lines hidden (view full) --- 114 if (_close(fd) != 0) 115 goto bad_lbuf; 116 /* 117 ** Parse the locale file into localebuf. 118 */ 119 if (plim[-1] != '\n') 120 goto bad_lbuf; 121 num_lines = split_lines(p, plim); |
121 if (num_lines >= locale_buf_size) 122 num_lines = locale_buf_size; | 122 if (num_lines >= locale_buf_size_max) 123 num_lines = locale_buf_size_max; 124 else if (num_lines >= locale_buf_size_min) 125 num_lines = locale_buf_size_min; |
123 else 124 goto reset_locale; 125 set_from_buf(lbuf, num_lines, dst_localebuf); 126 /* 127 ** Record the successful parse in the cache. 128 */ 129 locale_buf = lbuf; 130 --- 37 unchanged lines hidden --- | 126 else 127 goto reset_locale; 128 set_from_buf(lbuf, num_lines, dst_localebuf); 129 /* 130 ** Record the successful parse in the cache. 131 */ 132 locale_buf = lbuf; 133 --- 37 unchanged lines hidden --- |