Skip to content

Commit 5bb930b

Browse files
committed
Fixed error in strcasecompu
1 parent f5ed8aa commit 5bb930b

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
12 September 2025
2+
Fixed error in strcasecompu. (Case insensitive string compare)
3+
14
4 April 2025
25
VIS option on call to lst$ affixes all unvisited binary nodes with {}.
36
(Compile with -DUNVISITED.)

WebAssembly/emscriptenHowToHTML.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.9
22
# Without WebAssembly:
33
##emcc ../src/*.c --pre-js pre.js -s EXPORTED_RUNTIME_METHODS='["cwrap", "intArrayFromString"]' -s "EXPORTED_FUNCTIONS=['_main','_oneShot','_malloc']" -s "MODULARIZE=0" -O0 -o potuC.html -s "WASM=0"
4-
emcc ../src/*.c --pre-js pre.js -s EXPORTED_RUNTIME_METHODS='["stringToNewUTF8", "cwrap", "intArrayFromString","stackAlloc"]' -s "EXPORTED_FUNCTIONS=['_main','_oneShot','_malloc']" -s "MODULARIZE=0" -O0 -o potuC.html -s "WASM=0"
4+
# emcc ../src/*.c --pre-js pre.js -s EXPORTED_RUNTIME_METHODS='["stringToNewUTF8", "cwrap", "intArrayFromString","stackAlloc"]' -s "EXPORTED_FUNCTIONS=['_main','_oneShot','_malloc']" -s "MODULARIZE=0" -O0 -o potuC.html -s "WASM=0"
55
# With WebAssembly
66
# Note that you probably need to run from a web server. You can do `python3 -m http.server' and then load http://localhost:8000/bracmatJS.html in your browser.
77
# See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing
8-
#emcc ../src/*.c --pre-js pre.js -s EXPORTED_RUNTIME_METHODS='["stringToNewUTF8", "cwrap", "intArrayFromString","stackAlloc"]' -s "EXPORTED_FUNCTIONS=['_main','_oneShot','_malloc']" -s "MODULARIZE=0" -O0 -o potuC.html
8+
emcc ../src/*.c --pre-js pre.js -s EXPORTED_RUNTIME_METHODS='["stringToNewUTF8", "cwrap", "intArrayFromString","stackAlloc"]' -s "EXPORTED_FUNCTIONS=['_main','_oneShot','_malloc']" -s "MODULARIZE=0" -O0 -o potuC.html
99
bracmat "get'\"edit-potuC.html.bra\""

src/encoding.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,34 +302,37 @@ int hasUTF8MultiByteCharacters(const char* s)
302302
return ret == 0 ? multiByteCharSeen : 0;
303303
}
304304

305-
int strcasecompu(char** S, char** P, char* cutoff)
305+
int strcasecompu(const char* s, const char* p, const char* cutoff)
306306
/* Additional argument cutoff */
307307
{
308308
int sutf = 1;
309309
int putf = 1;
310-
char* s = *S;
311-
char* p = *P;
312310
while(s < cutoff && *s && *p)
313311
{
314312
int diff;
315-
char* ns = s;
316-
char* np = p;
313+
const char* ns = s;
314+
const char* np = p;
317315
int ks = getCodePoint2((const char**)&ns, &sutf);
318316
int kp = getCodePoint2((const char**)&np, &putf);
319317
assert(ks >= 0 && kp >= 0);
320318
diff = toLowerUnicode(ks) - toLowerUnicode(kp);
321319
if(diff)
322320
{
323-
*S = s;
324-
*P = p;
325-
return diff;
321+
return ONCE;
326322
}
327323
s = ns;
328324
p = np;
329325
}
330-
*S = s;
331-
*P = p;
332-
return (s < cutoff ? (int)(unsigned char)*s : 0) - (int)(unsigned char)*p;
326+
if(*p == 0)
327+
if(s == cutoff)
328+
return TRUE | ONCE;
329+
else
330+
return FALSE;
331+
else
332+
if(*s == 0)
333+
return ONCE;
334+
else
335+
return FALSE;
333336
}
334337

335338
int strcasecomp(const char* s, const char* p)

src/encoding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ unsigned char* putCodePoint(ULONG val, unsigned char* s);
1919
int getCodePoint(const char** ps);
2020
int hasUTF8MultiByteCharacters(const char* s);
2121
int getCodePoint2(const char** ps, int* isutf);
22-
int strcasecompu(char** S, char** P, char* cutoff);
22+
int strcasecompu(const char* S, const char* P, const char* cutoff);
2323
int strcasecomp(const char* s, const char* p);
2424

2525
#endif

src/equal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ int scompare(char* s, char* cutoff, psk p
548548

549549
if((Flgs & (NOT | FRACTION | NUMBER | GREATER_THAN | SMALLER_THAN)) == (NOT | GREATER_THAN | SMALLER_THAN))
550550
{ /* Case insensitive match: ~<> means "not different" */
551-
Sign = strcasecompu(&s, &P, cutoff); /* Additional argument cutoff */
551+
return strcasecompu(s, P, cutoff); /* Additional argument cutoff */
552552
}
553553
else
554554
{

src/potu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
email: bartj@hum.ku.dk
2121
*/
2222

23-
#define DATUM "4 April 2025"
24-
#define VERSION "6.29.0"
25-
#define BUILD "316"
23+
#define DATUM "12 September 2025"
24+
#define VERSION "6.30.0"
25+
#define BUILD "317"
2626
/*
2727
COMPILATION
2828
-----------

valid.bra

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8117,6 +8117,9 @@ string line 2\"
81178117
| Out
81188118
$ "Error: number containing a dot is not properly string matched."
81198119
)
8120+
( @(👨:~<>👨 ?c)&!c:
8121+
| Out$"Error in case-insensitive matching of UTF8"
8122+
)
81208123
& out
81218124
$ ( str
81228125
$ ( "Done. "

0 commit comments

Comments
 (0)