Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 8ab13b8

Browse files
committed
macOS porting issues, merged from wowdube.
1 parent 4fe6f1d commit 8ab13b8

File tree

5 files changed

+146
-146
lines changed

5 files changed

+146
-146
lines changed

amx/amx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include <sys/mman.h>
4444
#endif
4545
#endif
46-
#if defined __LCC__ || defined __LINUX__
46+
#if !defined AMX_ANSIONLY && (defined __LCC__ || defined __LINUX__ || defined __APPLE__)
4747
#include <wchar.h> /* for wcslen() */
4848
#endif
4949

compiler/lstring.c

Lines changed: 124 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,124 @@
1-
/* Safe string copying and concatenation
2-
* These routines are originally distributed in two separate files. I have
3-
* copied the files verbatim in this single source file, including all comments.
4-
* The only change is that the second set of include files is commented out
5-
* (there is no need to include the same files twice).
6-
*/
7-
8-
#include "lstring.h"
9-
10-
#if !defined HAVE_SAFESTR
11-
12-
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
13-
14-
/*
15-
* Copyright (c) 1998 Todd C. Miller <[email protected]>
16-
*
17-
* Permission to use, copy, modify, and distribute this software for any
18-
* purpose with or without fee is hereby granted, provided that the above
19-
* copyright notice and this permission notice appear in all copies.
20-
*
21-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
22-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
23-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
24-
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26-
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27-
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28-
*/
29-
30-
/*
31-
#include <sys/types.h> already included through lstring.h
32-
*/
33-
#include <string.h> /* for strlen() */
34-
35-
/*
36-
* Copy src to string dst of size siz. At most siz-1 characters
37-
* will be copied. Always NUL terminates (unless siz == 0).
38-
* Returns strlen(src); if retval >= siz, truncation occurred.
39-
*/
40-
size_t
41-
strlcpy(char *dst, const char *src, size_t siz)
42-
{
43-
char *d = dst;
44-
const char *s = src;
45-
size_t n = siz;
46-
47-
/* Copy as many bytes as will fit */
48-
if (n != 0 && --n != 0) {
49-
do {
50-
if ((*d++ = *s++) == 0)
51-
break;
52-
} while (--n != 0);
53-
}
54-
55-
/* Not enough room in dst, add NUL and traverse rest of src */
56-
if (n == 0) {
57-
if (siz != 0)
58-
*d = '\0'; /* NUL-terminate dst */
59-
while (*s++)
60-
;
61-
}
62-
63-
return(s - src - 1); /* count does not include NUL */
64-
}
65-
66-
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
67-
68-
/*
69-
* Copyright (c) 1998 Todd C. Miller <[email protected]>
70-
*
71-
* Permission to use, copy, modify, and distribute this software for any
72-
* purpose with or without fee is hereby granted, provided that the above
73-
* copyright notice and this permission notice appear in all copies.
74-
*
75-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
76-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
77-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
78-
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
79-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
80-
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
81-
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
82-
*/
83-
84-
/*
85-
#include <sys/types.h> already included
86-
#include <string.h> already included
87-
*/
88-
89-
/*
90-
* Appends src to string dst of size siz (unlike strncat, siz is the
91-
* full size of dst, not space left). At most siz-1 characters
92-
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
93-
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
94-
* If retval >= siz, truncation occurred.
95-
*/
96-
size_t
97-
strlcat(char *dst, const char *src, size_t siz)
98-
{
99-
char *d = dst;
100-
const char *s = src;
101-
size_t n = siz;
102-
size_t dlen;
103-
104-
/* Find the end of dst and adjust bytes left but don't go past end */
105-
while (n-- != 0 && *d != '\0')
106-
d++;
107-
dlen = d - dst;
108-
n = siz - dlen;
109-
110-
if (n == 0)
111-
return(dlen + strlen(s));
112-
while (*s != '\0') {
113-
if (n != 1) {
114-
*d++ = *s;
115-
n--;
116-
}
117-
s++;
118-
}
119-
*d = '\0';
120-
121-
return(dlen + (s - src)); /* count does not include NUL */
122-
}
123-
124-
#endif /* #if !defined HAVE_SAFESTR */
1+
/* Safe string copying and concatenation
2+
* These routines are originally distributed in two separate files. I have
3+
* copied the files verbatim in this single source file, including all comments.
4+
* The only change is that the second set of include files is commented out
5+
* (there is no need to include the same files twice).
6+
*/
7+
8+
#include "lstring.h"
9+
10+
#if !defined HAVE_SAFESTR && !defined __APPLE__
11+
12+
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
13+
14+
/*
15+
* Copyright (c) 1998 Todd C. Miller <[email protected]>
16+
*
17+
* Permission to use, copy, modify, and distribute this software for any
18+
* purpose with or without fee is hereby granted, provided that the above
19+
* copyright notice and this permission notice appear in all copies.
20+
*
21+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
22+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
23+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
24+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28+
*/
29+
30+
/*
31+
#include <sys/types.h> already included through lstring.h
32+
*/
33+
#include <string.h> /* for strlen() */
34+
35+
/*
36+
* Copy src to string dst of size siz. At most siz-1 characters
37+
* will be copied. Always NUL terminates (unless siz == 0).
38+
* Returns strlen(src); if retval >= siz, truncation occurred.
39+
*/
40+
size_t
41+
strlcpy(char *dst, const char *src, size_t siz)
42+
{
43+
char *d = dst;
44+
const char *s = src;
45+
size_t n = siz;
46+
47+
/* Copy as many bytes as will fit */
48+
if (n != 0 && --n != 0) {
49+
do {
50+
if ((*d++ = *s++) == 0)
51+
break;
52+
} while (--n != 0);
53+
}
54+
55+
/* Not enough room in dst, add NUL and traverse rest of src */
56+
if (n == 0) {
57+
if (siz != 0)
58+
*d = '\0'; /* NUL-terminate dst */
59+
while (*s++)
60+
;
61+
}
62+
63+
return(s - src - 1); /* count does not include NUL */
64+
}
65+
66+
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
67+
68+
/*
69+
* Copyright (c) 1998 Todd C. Miller <[email protected]>
70+
*
71+
* Permission to use, copy, modify, and distribute this software for any
72+
* purpose with or without fee is hereby granted, provided that the above
73+
* copyright notice and this permission notice appear in all copies.
74+
*
75+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
76+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
77+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
78+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
79+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
80+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
81+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
82+
*/
83+
84+
/*
85+
#include <sys/types.h> already included
86+
#include <string.h> already included
87+
*/
88+
89+
/*
90+
* Appends src to string dst of size siz (unlike strncat, siz is the
91+
* full size of dst, not space left). At most siz-1 characters
92+
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
93+
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
94+
* If retval >= siz, truncation occurred.
95+
*/
96+
size_t
97+
strlcat(char *dst, const char *src, size_t siz)
98+
{
99+
char *d = dst;
100+
const char *s = src;
101+
size_t n = siz;
102+
size_t dlen;
103+
104+
/* Find the end of dst and adjust bytes left but don't go past end */
105+
while (n-- != 0 && *d != '\0')
106+
d++;
107+
dlen = d - dst;
108+
n = siz - dlen;
109+
110+
if (n == 0)
111+
return(dlen + strlen(s));
112+
while (*s != '\0') {
113+
if (n != 1) {
114+
*d++ = *s;
115+
n--;
116+
}
117+
s++;
118+
}
119+
*d = '\0';
120+
121+
return(dlen + (s - src)); /* count does not include NUL */
122+
}
123+
124+
#endif /* #if !defined HAVE_SAFESTR */

compiler/lstring.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
/* prototypes for strlcpy() and strlcat() */
2-
3-
#include <stddef.h>
4-
5-
#if defined __WATCOMC__ && __WATCOMC__ >= 1240
6-
/* OpenWatcom introduced BSD "safe string functions" with version 1.4 */
7-
#define HAVE_SAFESTR
8-
#endif
9-
10-
#if !defined HAVE_SAFESTR
11-
12-
size_t
13-
strlcpy(char *dst, const char *src, size_t siz);
14-
15-
size_t
16-
strlcat(char *dst, const char *src, size_t siz);
17-
18-
#endif
1+
/* prototypes for strlcpy() and strlcat() */
2+
3+
#include <stddef.h>
4+
5+
#if defined __WATCOMC__ && __WATCOMC__ >= 1240
6+
/* OpenWatcom introduced BSD "safe string functions" with version 1.4 */
7+
#define HAVE_SAFESTR
8+
#endif
9+
10+
#if !defined HAVE_SAFESTR && !defined __APPLE__
11+
12+
size_t
13+
strlcpy(char *dst, const char *src, size_t siz);
14+
15+
size_t
16+
strlcat(char *dst, const char *src, size_t siz);
17+
18+
#endif

compiler/pawndisasm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: pawndisasm.c 6130 2020-04-29 12:35:51Z thiadmer $
17+
* Version: $Id: pawndisasm.c 6969 2023-07-26 12:26:41Z thiadmer $
1818
*/
1919
#include <assert.h>
2020
#include <inttypes.h>
@@ -523,7 +523,7 @@ static void addchars(char *str,int64_t value,int pos)
523523
*str='\0';
524524
}
525525

526-
#if defined _MSC_VER || defined __GNUC__ || defined __clang__
526+
#if (defined _MSC_VER || defined __GNUC__ || defined __clang__) && !defined __APPLE__
527527
/* Copy src to string dst of size siz.
528528
* At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0).
529529
* Returns strlen(src); if retval >= siz, truncation occurred .

compiler/stategraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void node_deleteall(void)
146146
}
147147
}
148148

149-
#if defined _MSC_VER || defined __GNUC__ || defined __clang__
149+
#if (defined _MSC_VER || defined __GNUC__ || defined __clang__) && !defined __APPLE__
150150
/* Copy src to string dst of size siz.
151151
* At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0).
152152
* Returns strlen(src); if retval >= siz, truncation occurred .

0 commit comments

Comments
 (0)