]> git.saurik.com Git - apple/libc.git/blob - net/FreeBSD/nsap_addr.c.patch
Libc-391.tar.gz
[apple/libc.git] / net / FreeBSD / nsap_addr.c.patch
1 --- nsap_addr.c.orig 2003-05-20 15:22:14.000000000 -0700
2 +++ nsap_addr.c 2005-02-24 16:48:08.000000000 -0800
3 @@ -18,6 +18,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/net/nsap_addr.c,v 1.9 2002/03/22 21:52:29 obrien Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <sys/types.h>
10 #include <sys/param.h>
11 #include <sys/socket.h>
12 @@ -26,6 +28,7 @@
13 #include <arpa/nameser.h>
14 #include <ctype.h>
15 #include <resolv.h>
16 +#include <stdlib.h>
17
18 static char
19 xtob(c)
20 @@ -42,20 +45,21 @@
21 {
22 u_char c, nib;
23 u_int len = 0;
24 + locale_t loc = __current_locale();
25
26 while ((c = *ascii++) != '\0' && len < (u_int)maxlen) {
27 if (c == '.' || c == '+' || c == '/')
28 continue;
29 if (!isascii(c))
30 return (0);
31 - if (islower(c))
32 - c = toupper(c);
33 - if (isxdigit(c)) {
34 + if (islower_l(c, loc))
35 + c = toupper_l(c, loc);
36 + if (isxdigit_l(c, loc)) {
37 nib = xtob(c);
38 c = *ascii++;
39 if (c != '\0') {
40 - c = toupper(c);
41 - if (isxdigit(c)) {
42 + c = toupper_l(c, loc);
43 + if (isxdigit_l(c, loc)) {
44 *binary++ = (nib << 4) | xtob(c);
45 len++;
46 } else
47 @@ -78,9 +82,14 @@
48 {
49 int nib;
50 int i;
51 - static char tmpbuf[255*3];
52 + static char *tmpbuf = NULL;
53 char *start;
54
55 + if (tmpbuf == NULL) {
56 + tmpbuf = malloc(255*3);
57 + if (tmpbuf == NULL)
58 + return NULL;
59 + }
60 if (ascii)
61 start = ascii;
62 else {