- 0 char (from P Moura);

- stack shifting
- uninitialized pointers in jpl
This commit is contained in:
Vítor Santos Costa 2019-05-21 20:37:16 +01:00
parent e7535dd2ee
commit 1a6e97655b
6 changed files with 42 additions and 25 deletions

View File

@ -632,8 +632,8 @@ overflow:
*pt0 = to_visit->oldv;
}
#endif
reset_trail(TR0);
pop_text_stack(lvl);
clean_dirty_tr(TR0 PASS_REGS);
pop_text_stack(lvl);
return -1;
trail_overflow:

View File

@ -293,8 +293,11 @@ static void *codes2buf(Term t0, void *b0, bool get_codes,
Yap_ThrowError(REPRESENTATION_ERROR_CHARACTER_CODE, hd,
"scanning list of character codes, found %d", code);
return NULL;
}
}else if (code == 0) {
length += 2;
} else {
length += put_utf8(ar, code);
}
t = TailOfTerm(t);
if (IsVarTerm(t)) {
Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes");
@ -320,8 +323,11 @@ static void *codes2buf(Term t0, void *b0, bool get_codes,
if (code < 0) {
Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of atoms");
return NULL;
}
} else if (code == 0) {
length += 2;
} else {
length += strlen(code);
}
t = TailOfTerm(t);
if (IsVarTerm(t)) {
Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes");
@ -348,6 +354,11 @@ static void *codes2buf(Term t0, void *b0, bool get_codes,
Term hd = HeadOfTerm(t);
Int code = IntegerOfTerm(hd);
if (code == 0) {
st[0] = 0xC0;
st[1] = 0x80;
st +=2;
} else
st = st + put_utf8(st, code);
t = TailOfTerm(t);
}

View File

@ -43,6 +43,10 @@ INLINE_ONLY utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr,
INLINE_ONLY utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr,
size_t n,
utf8proc_int32_t *valp) {
if (ptr[0] == 0xC0 && ptr[1] == 0x80) {
*valp = 0;
return 2;
}
utf8proc_ssize_t rc = utf8proc_iterate(ptr, n, valp);
if (rc < 0) {
// LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_IN_CHARACTER_CODE;

View File

@ -641,16 +641,18 @@ X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */
return 0;
}
src = (char *)RepAtom(AtomOfTerm(t))->StrOfAE;
if (!a)
if (!src)
return 0;
if (*a && *a != src)
strcpy(*a, src);
else
if ( !*a ) {
*a = src;
} else if (src[0] == '\0') {
(*a)[0] = src[0];
} else {
strcpy(*a, src);
}
return 1;
}
/** @brief *a is assigned the string representation of the atom in term ts, and
/** @brief *a is assigned the string representation of the atom in term ts, and
* *len its size, or the operation fails
*
*/

View File

@ -2600,7 +2600,7 @@ jni_func_1_plc(
jobject j; /* " */
/* jlong jl; // " */
void *p1; /* temp for converted (JVM) arg */
char *c1; /* " */
char *c1 = NULL; /* " */
int i1; /* " */
/* jlong l1; // " */
/* double d1; // " */
@ -2950,8 +2950,8 @@ jni_func_3_plc(
void *p2; /* " */
void *p3; /* " */
/* char *c1; // " */
char *c2; /* " */
char *c3; /* " */
char *c2 = NULL; /* " */
char *c3 = NULL; /* " */
int i1; /* " */
/* int i2; // " */
/* int i3; // " */
@ -3297,7 +3297,7 @@ jpl_do_jpl_init( /* to be called once only, after PL init, before any JPL calls
{
jclass tc; /* temporary class ref */
jobject ta; /* temporary array ref */
char *msg; /* error message for exceptions thrown here */
char *msg = NULL; /* error message for exceptions thrown here */
int i; /* loop counter */
jobject to; /* temporary (String) object ref */