Skip to content

Commit

Permalink
resolve #29: utf substr bug fix
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 1521d94518b8686a67444cd04a51697c43fef0cf034327919c227c8048357092
  • Loading branch information
pmacdona committed Oct 23, 2020
1 parent 89e996f commit 73f457f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Jsi is a **javascript**-ish interpreter with builtin websocket-server, sqlite and **C**-extensibility.


- Sites: [Docs](https://docs.jsish.org) | [jsish.org](https://jsish.org) | [github.com](https://github.com/pcmacdon/jsish)
- Links: [Start](./lib/www/md/Start.md) | [Index](./lib/www/md/Index.md) | [Issues](https://github.com/pcmacdon/jsish/issues)
[Docs](https://docs.jsish.org) | [Docs-alt](https://jsish.org/docs/ "Alternate non-js docs") | [Issues](https://github.com/pcmacdon/jsish/issues "Issue tracker on github") | [jsish.org](https://jsish.org)

### Quick-Start

Expand Down
2 changes: 1 addition & 1 deletion lib/www/docs/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,6 @@ Jsish.css('app.css');

} catch(e) {
document.getElementById('app').innerText= 'ERROR (redirecting in 8 secs): '+e;
setTimeout(function() { location.href = 'https://jsish.org/docs'; }, 8000);
setTimeout(function() { location.href = 'https://jsish.org/docs/'; }, 8000);

}
2 changes: 1 addition & 1 deletion src/jsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ JSI_EXTERN uint Jsi_UtfToUniChar(const char *utf, Jsi_UniChar *ch); /*STUB = 76*
JSI_EXTERN uint Jsi_UtfToUniCharCase(const char *utf, Jsi_UniChar *ch, int upper); /*STUB = 77*/
JSI_EXTERN uint Jsi_UtfDecode(const char *str, char* oututf); /*STUB = 78*/
JSI_EXTERN uint Jsi_UtfEncode(const char *utf, char *outstr); /*STUB = 79*/
JSI_EXTERN char* Jsi_UtfSubstr(const char *str, int n, int len, Jsi_DString *dStr); /*STUB = 80*/
JSI_EXTERN char* Jsi_UtfSubstr(const char *str, int bLen, int n, int len, Jsi_DString *dStr); /*STUB = 80*/
JSI_EXTERN int Jsi_UtfIndexToOffset(const char *utf, int index); /*STUB = 81*/
/* -- */

Expand Down
6 changes: 3 additions & 3 deletions src/jsiStubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#endif


#define JSI_STUBS_MD5 "35c36c383d326b0ea9203585674dc009"
#define JSI_STUBS_MD5 "71408ed876f077893cd984b2f9f21794"

#undef JSI_EXTENSION_INI
#define JSI_EXTENSION_INI Jsi_Stubs *jsiStubsPtr = NULL;
Expand Down Expand Up @@ -108,7 +108,7 @@ typedef struct Jsi_Stubs {
uint(*_Jsi_UtfToUniCharCase)(const char *utf, Jsi_UniChar *ch, int upper);
uint(*_Jsi_UtfDecode)(const char *str, char* oututf);
uint(*_Jsi_UtfEncode)(const char *utf, char *outstr);
char*(*_Jsi_UtfSubstr)(const char *str, int n, int len, Jsi_DString *dStr);
char*(*_Jsi_UtfSubstr)(const char *str, int bLen, int n, int len, Jsi_DString *dStr);
int(*_Jsi_UtfIndexToOffset)(const char *utf, int index);
Jsi_Obj*(*_Jsi_ObjNew)(Jsi_Interp* interp);
Jsi_Obj*(*_Jsi_ObjNewType)(Jsi_Interp* interp, Jsi_otype type);
Expand Down Expand Up @@ -976,7 +976,7 @@ extern Jsi_Stubs* jsiStubsPtr;
#define Jsi_UtfToUniCharCase(n0,n1,n2) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfToUniCharCase(n0,n1,n2))
#define Jsi_UtfDecode(n0,n1) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfDecode(n0,n1))
#define Jsi_UtfEncode(n0,n1) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfEncode(n0,n1))
#define Jsi_UtfSubstr(n0,n1,n2,n3) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfSubstr(n0,n1,n2,n3))
#define Jsi_UtfSubstr(n0,n1,n2,n3,n4) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfSubstr(n0,n1,n2,n3,n4))
#define Jsi_UtfIndexToOffset(n0,n1) JSISTUBCALL(jsiStubsPtr, _Jsi_UtfIndexToOffset(n0,n1))
#define Jsi_ObjNew(n0) JSISTUBCALL(jsiStubsPtr, _Jsi_ObjNew(n0))
#define Jsi_ObjNewType(n0,n1) JSISTUBCALL(jsiStubsPtr, _Jsi_ObjNewType(n0,n1))
Expand Down
6 changes: 3 additions & 3 deletions src/jsiUtf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint Jsi_UtfGetIndex(const char *str, int index, char cbuf[5]) {
#endif
}

char* Jsi_UtfSubstr(const char *str, int n, int len, Jsi_DString *dStr) {
char* Jsi_UtfSubstr(const char *str, int bLen, int n, int len, Jsi_DString *dStr) {
int ulen, ustart;
if (n<0) {
int lenofa = Jsi_NumUtfChars(str, -1);
Expand Down Expand Up @@ -121,11 +121,11 @@ char* Jsi_UtfSubstr(const char *str, int n, int len, Jsi_DString *dStr) {
}
}
#endif
if (ulen>len) {
if (ulen>(bLen-ustart)) {
#if JSI__MEMDEBUG
fprintf(stderr, "TODO: fix utf substr\n");
#endif
ulen = len;
ulen = (bLen-ustart);
}
Jsi_DSAppendLen(dStr, str+ustart, ulen);
return Jsi_DSValue(dStr);
Expand Down

0 comments on commit 73f457f

Please sign in to comment.