improve char conversion
This commit is contained in:
parent
ba07371328
commit
b3608c6a83
@ -693,6 +693,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level, compiler_struct
|
||||
Int sz = (3+src[1])*sizeof(CELL);
|
||||
CELL *dest;
|
||||
|
||||
char *ptr = src+2; int chr;
|
||||
/* use a special list to store the blobs */
|
||||
cglobs->cint.cpc = cglobs->cint.icpc;
|
||||
/* if (IsFloatTerm(t)) {
|
||||
|
@ -592,6 +592,8 @@ ShowOp (char *f, struct PSEUDO *cpc)
|
||||
Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT));
|
||||
} else if (fun == FunctorDouble) {
|
||||
Yap_DebugPlWrite(MkAtomTerm(AtomDOUBLE));
|
||||
} else if (fun == FunctorString) {
|
||||
Yap_DebugPlWrite(MkAtomTerm(AtomSTRING));
|
||||
}
|
||||
} else {
|
||||
Yap_DebugPlWrite (MkAtomTerm(NameOfFunctor(fun)));
|
||||
|
20
C/strings.c
20
C/strings.c
@ -25,7 +25,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static inline char *get_char(char *p, int *c) { *c = *p; return p+1; }
|
||||
static inline unsigned char *get_char(unsigned char *p, int *c) { *c = *p; return p+1; }
|
||||
|
||||
static inline wchar_t *get_wchar(wchar_t *p, int *c) { *c = *p; return p+1; }
|
||||
|
||||
@ -527,9 +527,10 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal USES_REGS)
|
||||
}
|
||||
break;
|
||||
case YAP_CHAR:
|
||||
{ char *s = s0, *lim = s + (max = strnlen(s, max));
|
||||
{ unsigned char *s = s0, *lim = s + (max = strnlen(s0, max));
|
||||
Term t = init_tstring( PASS_REGS1 );
|
||||
char *cp = s, *buf;
|
||||
unsigned char *cp = s;
|
||||
char *buf;
|
||||
|
||||
LOCAL_TERM_ERROR( 2*(lim-s) );
|
||||
buf = buf_from_tstring(H);
|
||||
@ -569,6 +570,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal USES_REGS)
|
||||
out->val.t = t;
|
||||
}
|
||||
}
|
||||
|
||||
return out->val.t;
|
||||
}
|
||||
|
||||
@ -602,8 +604,8 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal USES_REGS)
|
||||
break;
|
||||
}
|
||||
case YAP_CHAR:
|
||||
{ char *s = s0, *lim = s + strnlen(s, max);
|
||||
char *cp = s;
|
||||
{ unsigned char *s = s0, *lim = s + strnlen(s0, max);
|
||||
unsigned char *cp = s;
|
||||
char w[2];
|
||||
w[1] = '\0';
|
||||
|
||||
@ -683,8 +685,8 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal USES_REGS)
|
||||
break;
|
||||
}
|
||||
case YAP_CHAR:
|
||||
{ char *s = s0, *lim = s + strnlen(s, max);
|
||||
char *cp = s;
|
||||
{ unsigned char *s = s0, *lim = s + strnlen(s0, max);
|
||||
unsigned char *cp = s;
|
||||
|
||||
LOCAL_TERM_ERROR( 2*(lim-s) );
|
||||
while (cp < lim) {
|
||||
@ -1280,7 +1282,7 @@ Yap_Splice_Text( int n, size_t cuts[], seq_tv_t *inp, seq_tv_t outv[] USES_REGS
|
||||
|
||||
l1 = l-l0;
|
||||
slice(l0, l, buf, outv+1, enc PASS_REGS);
|
||||
return buf1;
|
||||
return buf0;
|
||||
} else /* if (outv[1].val.t) */ {
|
||||
buf1 = read_Text( buf, outv, &enc1, &minimal1 PASS_REGS );
|
||||
l1 = write_length( buf1, outv, enc1, minimal1 PASS_REGS);
|
||||
@ -1288,7 +1290,7 @@ Yap_Splice_Text( int n, size_t cuts[], seq_tv_t *inp, seq_tv_t outv[] USES_REGS
|
||||
if (cmp_Text( advance_Text(buf, l0, enc), buf1, l1, enc, enc1) == 0)
|
||||
return NULL;
|
||||
slice(0, l0, buf, outv, enc PASS_REGS);
|
||||
return buf0;
|
||||
return buf1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
C/write.c
19
C/write.c
@ -174,21 +174,18 @@ wrpututf8(const char *s, struct write_globs *wglb) /* writes an integer */
|
||||
IOSTREAM *stream = wglb->stream;
|
||||
|
||||
|
||||
int chr;
|
||||
char *ptr = (char *)s;
|
||||
|
||||
if (wglb->Write_strings)
|
||||
wrputc('`', stream);
|
||||
else
|
||||
wrputc('"', stream);
|
||||
if (stream->encoding == ENC_UTF8) {
|
||||
wrputs( s, stream);
|
||||
} else {
|
||||
int chr;
|
||||
char *ptr = (char *)s;
|
||||
do {
|
||||
ptr = utf8_get_char(ptr, &chr);
|
||||
if (chr == '\0') break;
|
||||
wrputc(chr, stream);
|
||||
} while (TRUE);
|
||||
}
|
||||
do {
|
||||
ptr = utf8_get_char(ptr, &chr);
|
||||
if (chr == '\0') break;
|
||||
wrputc(chr, stream);
|
||||
} while (TRUE);
|
||||
if (wglb->Write_strings)
|
||||
wrputc('`', stream);
|
||||
else
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f60caaf8b2134b6a64e4923b2a471cdcd8026c2f
|
||||
Subproject commit 5a72fe49e5a5c651a890a388eb967b83da8e2c52
|
Reference in New Issue
Block a user