diff --git a/os/pl-error.c b/os/pl-error.c index 4de1cb131..05452544d 100755 --- a/os/pl-error.c +++ b/os/pl-error.c @@ -207,7 +207,7 @@ PL_get_module_ex(term_t name, module_t *m) } int -PL_unify_bool_ex(term_t t, bool val) +PL_unify_bool_ex(term_t t, int val) { GET_LD bool v; diff --git a/os/pl-file.c b/os/pl-file.c index a0a4e0707..fa7a5c03f 100755 --- a/os/pl-file.c +++ b/os/pl-file.c @@ -347,8 +347,8 @@ initIO(void) streamContext = newHTable(16); PL_register_blob_type(&stream_blob); - if ( false(Sinput, SIO_ISATTY) || - false(Soutput, SIO_ISATTY) ) + if ( False(Sinput, SIO_ISATTY) || + False(Soutput, SIO_ISATTY) ) { /* clear PLFLAG_TTY_CONTROL */ PL_set_prolog_flag("tty_control", PL_BOOL, FALSE); } @@ -1548,7 +1548,7 @@ readLine() reads a line from the terminal. It is used only by the tracer. #define DEL 127 #endif -int +bool readLine(IOSTREAM *in, IOSTREAM *out, char *buffer) { GET_LD int c; @@ -1776,12 +1776,12 @@ set_stream(IOSTREAM *s, term_t stream, atom_t aname, term_t a ARG_LD) if ( !PL_get_atom_ex(a, &type) ) return FALSE; if ( type == ATOM_text ) - { if ( false(s, SIO_TEXT) && Ssetenc(s, LD->encoding, NULL) != 0 ) + { if ( False(s, SIO_TEXT) && Ssetenc(s, LD->encoding, NULL) != 0 ) return PL_error(NULL, 0, NULL, ERR_PERMISSION, ATOM_encoding, ATOM_stream, stream); s->flags |= SIO_TEXT; } else if ( type == ATOM_binary ) - { if ( true(s, SIO_TEXT) && Ssetenc(s, ENC_OCTET, NULL) != 0 ) + { if ( True(s, SIO_TEXT) && Ssetenc(s, ENC_OCTET, NULL) != 0 ) return PL_error(NULL, 0, NULL, ERR_PERMISSION, ATOM_encoding, ATOM_stream, stream); @@ -1922,7 +1922,7 @@ set_stream(IOSTREAM *s, term_t stream, atom_t aname, term_t a ARG_LD) else if ( val == ATOM_dos ) s->newline = SIO_NL_DOS; else if ( val == ATOM_detect ) - { if ( false(s, SIO_INPUT) ) + { if ( False(s, SIO_INPUT) ) return PL_error(NULL, 0, "detect only allowed for input streams", ERR_DOMAIN, ATOM_newline, a); s->newline = SIO_NL_DETECT; @@ -2081,7 +2081,7 @@ PRED_IMPL("set_end_of_stream", 1, set_end_of_stream, 0) extern IOFUNCTIONS Smemfunctions; -int +bool tellString(char **s, size_t *size, IOENC enc) { GET_LD IOSTREAM *stream; @@ -2095,8 +2095,8 @@ tellString(char **s, size_t *size, IOENC enc) } -int -toldString() +bool +toldString(void) { GET_LD IOSTREAM *s = getStream(Scurout); @@ -3384,7 +3384,7 @@ findStreamFromFile(atom_t name, unsigned int flags) { stream_context *ctx = symb->value; if ( ctx->filename == name && - true(ctx, flags) ) + True(ctx, flags) ) { s = symb->name; break; } @@ -4652,7 +4652,7 @@ peek(term_t stream, term_t chr, int how ARG_LD) if ( !getInputStream(stream, how == PL_BYTE ? S_BINARY : S_TEXT, &s) ) return FALSE; - if ( true(s, SIO_NBUF) || (s->bufsize && s->bufsize < PL_MB_LEN_MAX) ) + if ( True(s, SIO_NBUF) || (s->bufsize && s->bufsize < PL_MB_LEN_MAX) ) { releaseStream(s); return PL_error(NULL, 0, "stream is unbuffered", ERR_PERMISSION, ATOM_peek, ATOM_stream, stream); diff --git a/os/pl-file.h b/os/pl-file.h index e8aa1d95a..b86f16c73 100644 --- a/os/pl-file.h +++ b/os/pl-file.h @@ -46,7 +46,7 @@ COMMON(int) streamStatus(IOSTREAM *s); COMMON(int) setFileNameStream(IOSTREAM *s, atom_t name); COMMON(atom_t) fileNameStream(IOSTREAM *s); COMMON(int) getSingleChar(IOSTREAM *s, int signals); -COMMON(int) readLine(IOSTREAM *in, IOSTREAM *out, char *buffer); +COMMON(bool) readLine(IOSTREAM *in, IOSTREAM *out, char *buffer); COMMON(int) LockStream(void); COMMON(int) UnlockStream(void); COMMON(IOSTREAM *) PL_current_input(void); @@ -56,8 +56,8 @@ COMMON(int) pl_seen(void); COMMON(int) seeString(const char *s); COMMON(int) seeingString(void); COMMON(int) seenString(void); -COMMON(int) tellString(char **s, size_t *size, IOENC enc); -COMMON(int) toldString(void); +COMMON(bool) tellString(char **s, size_t *size, IOENC enc); +COMMON(bool) toldString(void); COMMON(void) prompt1(atom_t prompt); COMMON(atom_t) PrologPrompt(void); COMMON(int) streamNo(term_t spec, int mode); diff --git a/os/pl-fmt.c b/os/pl-fmt.c index 3a92c7b8b..db42c80ca 100644 --- a/os/pl-fmt.c +++ b/os/pl-fmt.c @@ -361,6 +361,8 @@ get_chr_from_text(const PL_chars_t *t, int index) return t->text.t[index]&0xff; case ENC_WCHAR: return t->text.w[index]; + case ENC_UTF8: + return t->text.w[index]; default: assert(0); return 0; /* not reached */ diff --git a/os/pl-option.h b/os/pl-option.h index 704e6edba..a9221424b 100644 --- a/os/pl-option.h +++ b/os/pl-option.h @@ -45,7 +45,7 @@ typedef struct int type; /* Type of option */ } opt_spec, *OptSpec; -COMMON(int) scan_options(term_t list, int flags, atom_t name, +COMMON(bool) scan_options(term_t list, int flags, atom_t name, const opt_spec *specs, ...); #endif /*OPTION_H_INCLUDED*/ diff --git a/os/pl-os.c b/os/pl-os.c index 6a096bda9..c98490c7b 100755 --- a/os/pl-os.c +++ b/os/pl-os.c @@ -1847,7 +1847,7 @@ Sread_terminal(void *handle, char *buf, size_t size) int fd = (int)h; source_location oldsrc = LD->read_source; - if ( Soutput && true(Soutput, SIO_ISATTY) ) + if ( Soutput && True(Soutput, SIO_ISATTY) ) { if ( LD->prompt.next && ttymode != TTY_RAW ) PL_write_prompt(TRUE); else diff --git a/os/pl-prologflag.c b/os/pl-prologflag.c index 1b80854d3..7fc0483fa 100755 --- a/os/pl-prologflag.c +++ b/os/pl-prologflag.c @@ -799,17 +799,17 @@ unify_prolog_flag_value(Module m, atom_t key, prolog_flag *f, term_t val) { GET_LD if ( key == ATOM_character_escapes ) - { atom_t v = (true(m, M_CHARESCAPE) ? ATOM_true : ATOM_false); + { atom_t v = (True(m, M_CHARESCAPE) ? ATOM_true : ATOM_false); return PL_unify_atom(val, v); } else if ( key == ATOM_double_quotes ) { atom_t v; - if ( true(m, DBLQ_CHARS) ) + if ( True(m, DBLQ_CHARS) ) v = ATOM_chars; - else if ( true(m, DBLQ_ATOM) ) + else if ( True(m, DBLQ_ATOM) ) v = ATOM_atom; - else if ( true(m, DBLQ_STRING) ) + else if ( True(m, DBLQ_STRING) ) v = ATOM_string; else v = ATOM_codes; diff --git a/os/pl-read.c b/os/pl-read.c index e7948b7d4..278325418 100644 --- a/os/pl-read.c +++ b/os/pl-read.c @@ -1265,7 +1265,7 @@ int process_comment; int rval; atom_t w; read_data rd; -bool charescapes = -1; +int charescapes = -1; atom_t dq = NULL_ATOM; atom_t mname = NULL_ATOM; fid_t fid = PL_open_foreign_frame(); diff --git a/os/pl-write.c b/os/pl-write.c index fe9c1b29a..cdf9b3726 100644 --- a/os/pl-write.c +++ b/os/pl-write.c @@ -400,11 +400,11 @@ pl_write_term3(term_t stream, term_t term, term_t opts) { GET_LD bool quoted = FALSE; bool ignore_ops = FALSE; - bool numbervars = -1; /* not set */ + int numbervars = -1; /* not set */ bool portray = FALSE; term_t gportray = 0; bool bqstring = truePrologFlag(PLFLAG_BACKQUOTED_STRING); - bool charescape = -1; /* not set */ + int charescape = -1; /* not set */ atom_t mname = ATOM_user; atom_t attr = ATOM_nil; atom_t blobs = ATOM_nil; @@ -467,7 +467,7 @@ pl_write_term3(term_t stream, term_t term, term_t opts) if ( charescape == TRUE || (charescape == -1 #ifndef __YAP_PROLOG__ -&& true(options.module, M_CHARESCAPE) +&& True(options.module, M_CHARESCAPE) #endif ) ) options.flags |= PL_WRT_CHARESCAPES; @@ -488,7 +488,7 @@ pl_write_term3(term_t stream, term_t term, term_t opts) if ( bqstring ) options.flags |= PL_WRT_BACKQUOTED_STRING; if ( !cycles ) options.flags |= PL_WRT_NO_CYCLES; - local_varnames = (varnames && false(&options, PL_WRT_NUMBERVARS)); + local_varnames = (varnames && False(&options, PL_WRT_NUMBERVARS)); BEGIN_NUMBERVARS(local_varnames); if ( varnames ) @@ -553,7 +553,7 @@ do_write2(term_t stream, term_t term, int flags) options.module = MODULE_user; if ( options.module #ifndef __YAP_PROLOG__ - && true(options.module, M_CHARESCAPE) + && True(options.module, M_CHARESCAPE) #endif ) options.flags |= PL_WRT_CHARESCAPES;