summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freebsd/0001-Patch-the-FreeBSD-strto-u-ll-functions-to-work-insid.patch
blob: ac7580d5c454b0a445fd2d2ff5566c7cb076ea21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From 81a2d1a38becdeed2cd8b963e190aedf197e39c6 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Thu, 2 Oct 2014 22:03:19 -0700
Subject: [PATCH 1/1] Patch the FreeBSD strto(u)ll functions to work inside
 QtCore

Changes:
 - remove the #includes and the SCCSID
 - rename from strtoxx_l to qt_strtoxx (merging the two functions)
 - remove __restrict
 - remove the locale_t parameter and use ascii_isspace instead of isspace_l

Change-Id: I1e522e12da90eb35eefcf4025102dc11b22c60a5
---
 src/3rdparty/freebsd/strtoll.c  | 27 +++++----------------------
 src/3rdparty/freebsd/strtoull.c | 27 +++++----------------------
 2 files changed, 10 insertions(+), 44 deletions(-)

diff --git a/src/3rdparty/freebsd/strtoll.c b/src/3rdparty/freebsd/strtoll.c
index 16a8196..0ded267 100644
--- a/src/3rdparty/freebsd/strtoll.c
+++ b/src/3rdparty/freebsd/strtoll.c
@@ -32,18 +32,6 @@
  * SUCH DAMAGE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoq.c	8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include "xlocale_private.h"
-
 /*
  * Convert a string to a long long integer.
  *
@@ -51,15 +39,15 @@ __FBSDID("$FreeBSD$");
  * alphabets and digits are each contiguous.
  */
 long long
-strtoll_l(const char * __restrict nptr, char ** __restrict endptr, int base,
-		locale_t locale)
+qt_strtoll(const char * nptr, char **endptr, int base)
 {
 	const char *s;
 	unsigned long long acc;
 	char c;
 	unsigned long long cutoff;
 	int neg, any, cutlim;
-	FIX_LOCALE(locale);
 
 	/*
 	 * Skip white space and pick up leading +/- sign if any.
@@ -69,7 +55,7 @@ strtoll_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 	s = nptr;
 	do {
 		c = *s++;
-	} while (isspace_l((unsigned char)c, locale));
+	} while (ascii_isspace(c));
 	if (c == '-') {
 		neg = 1;
 		c = *s++;
@@ -141,13 +127,8 @@ strtoll_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 noconv:
 		errno = EINVAL;
 	} else if (neg)
-		acc = -acc;
+		acc = (unsigned long long) -(long long)acc;
 	if (endptr != NULL)
 		*endptr = (char *)(any ? s - 1 : nptr);
 	return (acc);
 }
-long long
-strtoll(const char * __restrict nptr, char ** __restrict endptr, int base)
-{
-	return strtoll_l(nptr, endptr, base, __get_locale());
-}
diff --git a/src/3rdparty/freebsd/strtoull.c b/src/3rdparty/freebsd/strtoull.c
index dc40e0e..cb04adb 100644
--- a/src/3rdparty/freebsd/strtoull.c
+++ b/src/3rdparty/freebsd/strtoull.c
@@ -32,18 +32,6 @@
  * SUCH DAMAGE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtouq.c	8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include "xlocale_private.h"
-
 /*
  * Convert a string to an unsigned long long integer.
  *
@@ -51,15 +39,15 @@ __FBSDID("$FreeBSD$");
  * alphabets and digits are each contiguous.
  */
 unsigned long long
-strtoull_l(const char * __restrict nptr, char ** __restrict endptr, int base,
-		locale_t locale)
+qt_strtoull(const char * nptr, char **endptr, int base)
 {
 	const char *s;
 	unsigned long long acc;
 	char c;
 	unsigned long long cutoff;
 	int neg, any, cutlim;
-	FIX_LOCALE(locale);
 
 	/*
 	 * See strtoq for comments as to the logic used.
@@ -67,7 +53,7 @@ strtoull_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 	s = nptr;
 	do {
 		c = *s++;
-	} while (isspace_l((unsigned char)c, locale));
+	} while (ascii_isspace(c));
 	if (c == '-') {
 		neg = 1;
 		c = *s++;
@@ -119,13 +105,8 @@ strtoull_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 noconv:
 		errno = EINVAL;
 	} else if (neg)
-		acc = -acc;
+		acc = (unsigned long long) -(long long)acc;
 	if (endptr != NULL)
 		*endptr = (char *)(any ? s - 1 : nptr);
 	return (acc);
 }
-unsigned long long
-strtoull(const char * __restrict nptr, char ** __restrict endptr, int base)
-{
-	return strtoull_l(nptr, endptr, base, __get_locale());
-}
-- 
1.8.4.5