Skip to content

Commit fc21ffc

Browse files
committed
Tweaks.
1 parent 687e643 commit fc21ffc

File tree

5 files changed

+62
-10
lines changed

5 files changed

+62
-10
lines changed

sqlite3/libc/math.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
#include_next <math.h> // the system math.h
2+
13
#ifndef _WASM_SIMD128_MATH_H
24
#define _WASM_SIMD128_MATH_H
35

46
#include <wasm_simd128.h>
57

6-
#include_next <math.h> // the system math.h
7-
88
#ifdef __cplusplus
99
extern "C" {
1010
#endif

sqlite3/libc/stdlib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
#include_next <stdlib.h> // the system stdlib.h
2+
13
#ifndef _WASM_SIMD128_STDLIB_H
24
#define _WASM_SIMD128_STDLIB_H
35

4-
#include_next <stdlib.h> // the system stdlib.h
5-
66
#ifdef __cplusplus
77
extern "C" {
88
#endif

sqlite3/libc/string.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
#include_next <string.h> // the system string.h
2+
13
#ifndef _WASM_SIMD128_STRING_H
24
#define _WASM_SIMD128_STRING_H
35

46
#include <stdint.h>
57
#include <wasm_simd128.h>
68
#include <__macro_PAGESIZE.h>
79

8-
#include_next <string.h> // the system string.h
9-
1010
#ifdef __cplusplus
1111
extern "C" {
1212
#endif
@@ -657,6 +657,7 @@ char *strstr(const char *haystk, const char *needle) {
657657
// Simple wrappers already in musl:
658658
// - mempcpy
659659
// - strcat
660+
// - strlcat
660661
// - strdup
661662
// - strndup
662663
// - strnlen
@@ -666,7 +667,6 @@ char *strstr(const char *haystk, const char *needle) {
666667

667668
__attribute__((weak))
668669
void *memccpy(void *__restrict dest, const void *__restrict src, int c, size_t n) {
669-
void *memchr(const void *v, int c, size_t n);
670670
const void *m = memchr(src, c, n);
671671
if (m != NULL) {
672672
n = (char *)m - (char *)src + 1;
@@ -676,6 +676,17 @@ void *memccpy(void *__restrict dest, const void *__restrict src, int c, size_t n
676676
return (void *)m;
677677
}
678678

679+
__attribute__((weak))
680+
size_t strlcpy(char *__restrict dest, const char *__restrict src, size_t n) {
681+
size_t slen = strlen(src);
682+
if (n--) {
683+
if (n > slen) n = slen;
684+
memcpy(dest, src, n);
685+
dest[n] = 0;
686+
}
687+
return slen;
688+
}
689+
679690
__attribute__((weak))
680691
char *strncat(char *__restrict dest, const char *__restrict src, size_t n) {
681692
size_t strnlen(const char *s, size_t n);

sqlite3/libc/strings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include_next <strings.h> // the system strings.h
2+
13
#ifndef _WASM_SIMD128_STRINGS_H
24
#define _WASM_SIMD128_STRINGS_H
35

@@ -7,8 +9,6 @@
79
#include <wasm_simd128.h>
810
#include <__macro_PAGESIZE.h>
911

10-
#include_next <strings.h> // the system strings.h
11-
1212
#ifdef __cplusplus
1313
extern "C" {
1414
#endif
@@ -20,7 +20,7 @@ int bcmp(const void *v1, const void *v2, size_t n) {
2020
return __memcmpeq(v1, v2, n);
2121
}
2222

23-
v128_t __tolower8x16(v128_t v) {
23+
static v128_t __tolower8x16(v128_t v) {
2424
__i8x16 i;
2525
i = v + wasm_i8x16_splat(INT8_MAX - ('Z'));
2626
i = i > wasm_i8x16_splat(INT8_MAX - ('Z' - 'A' + 1));

sqlite3/strcasecmp.patch

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Use strcasecmp and strncasecmp.
2+
--- sqlite3.c.orig
3+
+++ sqlite3.c
4+
@@ -35685,35 +35685,15 @@
5+
return sqlite3StrICmp(zLeft, zRight);
6+
}
7+
SQLITE_PRIVATE int sqlite3StrICmp(const char *zLeft, const char *zRight){
8+
- unsigned char *a, *b;
9+
- int c, x;
10+
- a = (unsigned char *)zLeft;
11+
- b = (unsigned char *)zRight;
12+
- for(;;){
13+
- c = *a;
14+
- x = *b;
15+
- if( c==x ){
16+
- if( c==0 ) break;
17+
- }else{
18+
- c = (int)UpperToLower[c] - (int)UpperToLower[x];
19+
- if( c ) break;
20+
- }
21+
- a++;
22+
- b++;
23+
- }
24+
- return c;
25+
+ return strcasecmp(zLeft, zRight);
26+
}
27+
SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
28+
- register unsigned char *a, *b;
29+
if( zLeft==0 ){
30+
return zRight ? -1 : 0;
31+
}else if( zRight==0 ){
32+
return 1;
33+
}
34+
- a = (unsigned char *)zLeft;
35+
- b = (unsigned char *)zRight;
36+
- while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
37+
- return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];
38+
+ return strncasecmp(zLeft, zRight, N);
39+
}
40+
41+
/*

0 commit comments

Comments
 (0)