fix get_num
This commit is contained in:
parent
fab0075f9b
commit
2726fb279c
@ -1119,10 +1119,9 @@ Term Yap_scan_num(StreamDesc *inp) {
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL;
|
||||
return 0;
|
||||
}
|
||||
while (iswblank( ch = getchr(inp) ));
|
||||
TokEntry *tokptr = (TokEntry *)AllocScannerMemory(sizeof(TokEntry));
|
||||
tokptr->TokPos = GetCurInpPos(inp);
|
||||
while ((ch = getchr(inp)) == BS)
|
||||
;
|
||||
if (ch == '-') {
|
||||
sign = -1;
|
||||
ch = getchr(inp);
|
||||
@ -1133,7 +1132,7 @@ Term Yap_scan_num(StreamDesc *inp) {
|
||||
cherr = '\0';
|
||||
if (ASP - HR < 1024) {
|
||||
Yap_clean_tokenizer(old_tr, NULL, NULL);
|
||||
LOCAL_ErrorMessage = "Stack Overflow";
|
||||
LOCAL_ErrorMessage = "Stack Overflow";
|
||||
LOCAL_Error_TYPE = RESOURCE_ERROR_STACK;
|
||||
return 0;
|
||||
}
|
||||
|
10
C/text.c
10
C/text.c
@ -41,7 +41,11 @@ void *buf__, *cur__;
|
||||
void *ov__ = TR, *ocur__ = LOCAL_ScannerStack; \
|
||||
if (!LOCAL_ScannerStack) LOCAL_ScannerStack = (char *)TR
|
||||
|
||||
#define protect_stack(s)
|
||||
#define mark_stack() \
|
||||
void *otr__ = TR; void * ost__ = LOCAL_ScannerStack; TR =(tr_fr_ptr)LOCAL_ScannerStack
|
||||
|
||||
#define restore_stack() \
|
||||
TR = otr__; LOCAL_ScannerStack = ost__
|
||||
|
||||
#define export_buf(s) {}
|
||||
|
||||
@ -672,15 +676,19 @@ static size_t write_length(const unsigned char *s0, seq_tv_t *out,
|
||||
static Term write_number( unsigned char *s, seq_tv_t *out, int size
|
||||
USES_REGS) {
|
||||
Term t;
|
||||
mark_stack();
|
||||
t = Yap_StringToNumberTerm((char *)s, &out->enc);
|
||||
restore_stack();
|
||||
return t;
|
||||
}
|
||||
|
||||
static Term string_to_term(void *s, seq_tv_t *out, size_t leng USES_REGS) {
|
||||
Term o;
|
||||
mark_stack();
|
||||
o = out->val.t =
|
||||
Yap_StringToTerm(s, strlen(s) + 1, &out->enc,
|
||||
GLOBAL_MaxPriority, NULL);
|
||||
restore_stack();
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,6 @@ Term Yap_StringToNumberTerm(const char *s, encoding_t *encp) {
|
||||
#ifdef __ANDROID__
|
||||
while (*s && isblank(*s) && Yap_wide_chtype(*s) == BS)
|
||||
s++;
|
||||
#else
|
||||
while (*s && iswblank(*s++))
|
||||
;
|
||||
#endif
|
||||
t = Yap_scan_num(GLOBAL_Stream + sno);
|
||||
if (LOCAL_Error_TYPE == SYNTAX_ERROR)
|
||||
|
Reference in New Issue
Block a user