diff --git a/H/Yap.h b/H/Yap.h index 2cc391574..996722ee2 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -849,27 +849,6 @@ LOG0(const char *f, int l, const char *fmt, ...) // YAP lexicon -/* Character types for tokenizer and write.c */ - -typedef enum char_kind_t { - BG = 0, /* initial state */ - UC = 1, /* Upper case */ - UL = 2, /* Underline */ - LC = 3, /* Lower case */ - NU = 4, /* digit */ - QT = 5, /* single quote */ - DC = 6, /* double quote */ - SY = 7, /* Symbol character */ - SL = 8, /* Solo character */ - BK = 9, /* Brackets & friends */ - BS = 10, /* Blank */ - EF = 11, /* End of File marker */ - CC = 12 /* comment,char % */ -} charkind_t; - -#ifndef __ANDROID__ -#define __android_log_print( ... ) -#endif #include "GitSHA1.h" diff --git a/H/YapText.h b/H/YapText.h index 2bf898114..1d9337b2b 100644 --- a/H/YapText.h +++ b/H/YapText.h @@ -31,95 +31,230 @@ #include "Yap.h" #include "utf8proc.h" -inline static utf8proc_ssize_t get_utf8(utf8proc_uint8_t * ptr, utf8proc_int32_t *valp) { return utf8proc_iterate( ptr, -1, valp ); } +/* Character types for tokenizer and write.c */ -inline static utf8proc_ssize_t put_utf8(utf8proc_uint8_t * ptr, utf8proc_int32_t val) { return utf8proc_encode_char( val, ptr ); } +/****************** character definition table **************************/ -inline static utf8proc_uint8_t *skip_utf8( utf8proc_uint8_t * pt, utf8proc_ssize_t n) { +#define NUMBER_OF_CHARS 256 +extern char *Yap_chtype; + +typedef enum { + BG = 0, /* initial state */ + UC = 1, /* Upper case */ + UL = 2, /* Underline */ + LC = 3, /* Lower case */ + NU = 4, /* digit */ + QT = 5, /* single quote */ + DC = 6, /* double quote */ + SY = 7, /* Symbol character */ + SL = 8, /* Solo character */ + BK = 9, /* Brackets & friends */ + BS = 10, /* Blank */ + EF = 11, /* End of File marker */ + CC = 12 /* comment,char % */ +} char_kind_t; + +extern char_kind_t Yap_chtype0[]; + +#define Yap_chtype (Yap_chtype0+1) + +char_kind_t Yap_wide_chtype(int ch); + +INLINE_ONLY EXTERN inline char_kind_t Yap_wide_chtype(int ch) { + if (ch < 256) + return Yap_chtype[ch]; + switch (utf8proc_category(ch)) { + case UTF8PROC_CATEGORY_CN: /**< Other, not assigned */ + return BG; + case UTF8PROC_CATEGORY_LU: /**< Letter, uppercase */ + return UC; + case UTF8PROC_CATEGORY_LL: /**< Letter, lowercase */ + return LC; + case UTF8PROC_CATEGORY_LT: /**< Letter, titlecase */ + return UC; + case UTF8PROC_CATEGORY_LM: /**< Letter, modifier */ + return LC; + case UTF8PROC_CATEGORY_LO: /**< Letter, other */ + return LC; + case UTF8PROC_CATEGORY_MN: /**< Mark, nonspacing */ + return BG; + case UTF8PROC_CATEGORY_MC: /**< Mark, spacing combining */ + return BK; + case UTF8PROC_CATEGORY_ME: /**< Mark, enclosing */ + return BK; + case UTF8PROC_CATEGORY_ND: /**< Number, decimal digit */ + return NU; + case UTF8PROC_CATEGORY_NL: /**< Number, letter */ + return NU; + case UTF8PROC_CATEGORY_NO: /**< Number, other */ + return NU; + case UTF8PROC_CATEGORY_PC: /**< Punctuation, connector */ + return SL; + case UTF8PROC_CATEGORY_PD: /**< Punctuation, dash */ + return SY; + case UTF8PROC_CATEGORY_PS: /**< Punctuation, open */ + return BK; + case UTF8PROC_CATEGORY_PE: /**< Punctuation, close */ + return BK; + case UTF8PROC_CATEGORY_PI: /**< Punctuation, initial quote */ + return QT; + case UTF8PROC_CATEGORY_PF: /**< Punctuation, final quote */ + return QT; + case UTF8PROC_CATEGORY_PO: /**< Punctuation, other */ + return SL; + case UTF8PROC_CATEGORY_SM: /**< Symbol, math */ + return SY; + case UTF8PROC_CATEGORY_SC: /**< Symbol, currency */ + return SY; + case UTF8PROC_CATEGORY_SK: /**< Symbol, modifier + + unsure in YAP, let's assume a,c us treated as aƧ + */ + return LC; + case UTF8PROC_CATEGORY_SO: /**< Symbol, other */ + return SL; + case UTF8PROC_CATEGORY_ZS: /**< Separator, space */ + return BS; + case UTF8PROC_CATEGORY_ZL: /**< Separator, line */ + return BS; + case UTF8PROC_CATEGORY_ZP: /**< Separator, paragraph */ + return BS; + case UTF8PROC_CATEGORY_CC: /**< Other, control */ + return BG; + case UTF8PROC_CATEGORY_CF: /**< Other, format */ + return BG; + case UTF8PROC_CATEGORY_CS: /**< Other, surrogate */ + return BG; + case UTF8PROC_CATEGORY_CO: /**< Other, private use */ + return BG; + } + return BS; +} + +INLINE_ONLY EXTERN inline char_kind_t chtype(Int ch) { + if (ch < NUMBER_OF_CHARS) + return Yap_chtype[ch]; + return Yap_wide_chtype(ch); +} + +#ifndef __ANDROID__ +#define __android_log_print(...) +#endif + +inline static utf8proc_ssize_t get_utf8(utf8proc_uint8_t *ptr, + utf8proc_int32_t *valp) { + return utf8proc_iterate(ptr, -1, valp); +} + +inline static utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr, + utf8proc_int32_t val) { + return utf8proc_encode_char(val, ptr); +} + +inline static utf8proc_uint8_t *skip_utf8(utf8proc_uint8_t *pt, + utf8proc_ssize_t n) { utf8proc_ssize_t i; utf8proc_int32_t b; - for (i=0;i< n; i++) { - utf8proc_ssize_t l = utf8proc_iterate( pt, -1, &b ); - if (b==0) return pt; + for (i = 0; i < n; i++) { + utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b); + if (b == 0) + return pt; pt += l; } return pt; } -inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t * pt) { - utf8proc_ssize_t rc =0; +inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) { + utf8proc_ssize_t rc = 0; utf8proc_int32_t b; while (true) { - utf8proc_ssize_t l = utf8proc_iterate( pt, -1, &b ); - if (b==0) return rc; + utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b); + if (b == 0) + return rc; pt += l; rc += l; } return rc; } -inline static utf8proc_ssize_t strlen_latin_utf8(const unsigned char * pt) { - utf8proc_ssize_t rc =0; +inline static utf8proc_ssize_t strlen_latin_utf8(const unsigned char *pt) { + utf8proc_ssize_t rc = 0; utf8proc_uint8_t b; while (true) { - utf8proc_ssize_t l = utf8proc_encode_char( *pt, &b ); - if (b==0) return rc; + utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); + if (b == 0) + return rc; pt++; rc += l; } return rc; } -inline static utf8proc_ssize_t strnlen_latin_utf8(const unsigned char * pt, size_t max) { - utf8proc_ssize_t rc =0; +inline static utf8proc_ssize_t strnlen_latin_utf8(const unsigned char *pt, + size_t max) { + utf8proc_ssize_t rc = 0; utf8proc_uint8_t b; while (true) { - utf8proc_ssize_t l = utf8proc_encode_char( *pt, &b ); - if (b==0) return rc; + utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); + if (b == 0) + return rc; pt++; rc += l; - if (--max == 0) return rc; + if (--max == 0) + return rc; } return rc; } -inline static utf8proc_ssize_t strlen_ucs2_utf8(const wchar_t * pt) { - utf8proc_ssize_t rc =0; +inline static utf8proc_ssize_t strlen_ucs2_utf8(const wchar_t *pt) { + utf8proc_ssize_t rc = 0; utf8proc_uint8_t b; while (true) { - utf8proc_ssize_t l = utf8proc_encode_char( *pt, &b ); - if (b==0) return rc; - pt ++; + utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); + if (b == 0) + return rc; + pt++; rc += l; } return rc; } -inline static utf8proc_ssize_t strnlen_ucs2_utf8(const wchar_t * pt, size_t max) { - utf8proc_ssize_t rc =0; +inline static utf8proc_ssize_t strnlen_ucs2_utf8(const wchar_t *pt, + size_t max) { + utf8proc_ssize_t rc = 0; utf8proc_uint8_t b; while (true) { - utf8proc_ssize_t l = utf8proc_encode_char( *pt, &b ); - if (b==0) return rc; - pt ++; + utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b); + if (b == 0) + return rc; + pt++; rc += l; - if (--max == 0) return rc; + if (--max == 0) + return rc; } return rc; } -inline static int cmpn_utf8(const utf8proc_uint8_t * pt1, const utf8proc_uint8_t * pt2, utf8proc_ssize_t n) { +inline static int cmpn_utf8(const utf8proc_uint8_t *pt1, + const utf8proc_uint8_t *pt2, utf8proc_ssize_t n) { utf8proc_ssize_t i; utf8proc_int32_t b; - for (i=0;i< n; i++) { - if (pt1[0] != pt2[0]) return pt1[0]- pt2[0]; - utf8proc_ssize_t l = utf8proc_iterate( pt1, -1, &b ); - if (l == 2) { if (pt1[1] != pt2[1]) return pt1[1]- pt2[1]; } - else if (l == 3) { if (pt1[2] != pt2[2]) return pt1[2]- pt2[2]; } - else if (l == 4) { if (pt1[3] != pt2[3]) return pt1[3]- pt2[3]; } + for (i = 0; i < n; i++) { + if (pt1[0] != pt2[0]) + return pt1[0] - pt2[0]; + utf8proc_ssize_t l = utf8proc_iterate(pt1, -1, &b); + if (l == 2) { + if (pt1[1] != pt2[1]) + return pt1[1] - pt2[1]; + } else if (l == 3) { + if (pt1[2] != pt2[2]) + return pt1[2] - pt2[2]; + } else if (l == 4) { + if (pt1[3] != pt2[3]) + return pt1[3] - pt2[3]; + } pt1 += l; pt2 += l; - } return 0; } @@ -129,115 +264,107 @@ const char *Yap_tokRep(TokEntry *tokptr); // standard strings typedef enum { - YAP_STRING_STRING = 0x1, /// target is a string term - YAP_STRING_CODES = 0x2, /// target is a list of integer codes - YAP_STRING_ATOMS = 0x4, /// target is a list of kength-1 atom + YAP_STRING_STRING = 0x1, /// target is a string term + YAP_STRING_CODES = 0x2, /// target is a list of integer codes + YAP_STRING_ATOMS = 0x4, /// target is a list of kength-1 atom YAP_STRING_ATOMS_CODES = 0x6, /// targt is list of atoms or codes - YAP_STRING_CHARS = 0x8, /// target is a buffer, with byte-sized units - YAP_STRING_WCHARS = 0x10, /// target is a buffer of wide chars - YAP_STRING_ATOM = 0x20, /// tarfet is an ayom - YAP_STRING_INT = 0x40, /// target is an integer term - YAP_STRING_FLOAT = 0x80, /// target is a floar term - YAP_STRING_BIG = 0x100, /// target is an big num term - YAP_STRING_DATUM = 0x200, /// associated with previous 3, use actual object if type, not tern - YAP_STRING_LENGTH = 0x400, /// input: length is fixed; output: return integer with length - YAP_STRING_NTH = 0x800, /// input: ignored; output: nth char - YAP_STRING_TERM = 0x1000, // Generic term, if nothing else given - YAP_STRING_DIFF = 0x2000, // difference list - YAP_STRING_NCHARS = 0x4000, // size of input/result - YAP_STRING_TRUNC = 0x8000, // truncate on maximum size of input/result - YAP_STRING_WQ = 0x10000, // output with write_quote - YAP_STRING_WC = 0x20000, // output with write_canonical - YAP_STRING_WITH_BUFFER = 0x40000, // output on existing buffer - YAP_STRING_MALLOC = 0x80000 // output on malloced buffer + YAP_STRING_CHARS = 0x8, /// target is a buffer, with byte-sized units + YAP_STRING_WCHARS = 0x10, /// target is a buffer of wide chars + YAP_STRING_ATOM = 0x20, /// tarfet is an ayom + YAP_STRING_INT = 0x40, /// target is an integer term + YAP_STRING_FLOAT = 0x80, /// target is a floar term + YAP_STRING_BIG = 0x100, /// target is an big num term + YAP_STRING_DATUM = + 0x200, /// associated with previous 3, use actual object if type, not tern + YAP_STRING_LENGTH = + 0x400, /// input: length is fixed; output: return integer with length + YAP_STRING_NTH = 0x800, /// input: ignored; output: nth char + YAP_STRING_TERM = 0x1000, // Generic term, if nothing else given + YAP_STRING_DIFF = 0x2000, // difference list + YAP_STRING_NCHARS = 0x4000, // size of input/result + YAP_STRING_TRUNC = 0x8000, // truncate on maximum size of input/result + YAP_STRING_WQ = 0x10000, // output with write_quote + YAP_STRING_WC = 0x20000, // output with write_canonical + YAP_STRING_WITH_BUFFER = 0x40000, // output on existing buffer + YAP_STRING_MALLOC = 0x80000 // output on malloced buffer } enum_seq_type_t; - - typedef UInt seq_type_t; #define YAP_TYPE_MASK 0x0FFF typedef union { - Float f; - Int i; + Float f; + Int i; MP_INT *b; const char *c0; const wchar_t *w0; char *c; unsigned char *uc; wchar_t *w; - Atom a; + Atom a; size_t l; int d; - Term t;// depends on other flags -} -seq_val_t; + Term t; // depends on other flags +} seq_val_t; typedef struct text_cvt { seq_type_t type; seq_val_t val; - Term mod; // optional - size_t sz; // fixed sz, or -1 - Term dif; // diff-list, usually TermNil - size_t max; // max_size + Term mod; // optional + size_t sz; // fixed sz, or -1 + Term dif; // diff-list, usually TermNil + size_t max; // max_size encoding_t enc; } seq_tv_t; // string construction #ifdef HR -static inline Term -init_tstring( USES_REGS1 ) { +static inline Term init_tstring(USES_REGS1) { Term t = AbsAppl(HR); HR[0] = (CELL)FunctorString; return t; } -static inline unsigned char * -buf_from_tstring( CELL *p ) { +static inline unsigned char *buf_from_tstring(CELL *p) { unsigned char *out = (unsigned char *)(p + 2); return out; } -static inline void -close_tstring( unsigned char *p USES_REGS ) { - CELL *szp = HR+1; - HR = (CELL *)ALIGN_BY_TYPE( p ,CELL); - *szp = (HR - szp)-1; +static inline void close_tstring(unsigned char *p USES_REGS) { + CELL *szp = HR + 1; + HR = (CELL *)ALIGN_BY_TYPE(p, CELL); + *szp = (HR - szp) - 1; *HR++ = EndSpecials; } #endif // string type depends on current module -static inline seq_type_t -mod_to_type( Term mod USES_REGS ) -{ - +static inline seq_type_t mod_to_type(Term mod USES_REGS) { + // see pl-incl.h unsigned int flags = Yap_GetModuleEntry(mod)->flags; if (flags & DBLQ_ATOM) { return YAP_STRING_ATOM; } else if (flags & DBLQ_STRING) { return YAP_STRING_STRING; - } else if (flags & DBLQ_CHARS) { + } else if (flags & DBLQ_CHARS) { return YAP_STRING_ATOMS; } return YAP_STRING_CODES; } // string type depends on current module -static inline seq_type_t -mod_to_bqtype( Term mod USES_REGS ) -{ - +static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) { + // see pl-incl.h unsigned int flags = Yap_GetModuleEntry(mod)->flags; if (flags & BCKQ_ATOM) { return YAP_STRING_ATOM; } else if (flags & BCKQ_STRING) { return YAP_STRING_STRING; - } else if (flags & BCKQ_CHARS) { + } else if (flags & BCKQ_CHARS) { return YAP_STRING_ATOMS; } return YAP_STRING_CODES; @@ -245,44 +372,45 @@ mod_to_bqtype( Term mod USES_REGS ) // the routines -extern void *Yap_readText( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *lengp USES_REGS); -extern int write_Text( void *inp, seq_tv_t *out, encoding_t enc, int minimal, size_t leng USES_REGS); -extern int Yap_CVT_Text( seq_tv_t *inp, seq_tv_t *out USES_REGS); -extern void *Yap_Concat_Text( int n, seq_tv_t inp[], seq_tv_t *out USES_REGS); -extern void *Yap_Splice_Text( int n, size_t cuts[], seq_tv_t *inp, encoding_t encv[], seq_tv_t outv[] USES_REGS); +extern void *Yap_readText(void *buf, seq_tv_t *inp, encoding_t *enc, + int *minimal, size_t *lengp USES_REGS); +extern int write_Text(void *inp, seq_tv_t *out, encoding_t enc, int minimal, + size_t leng USES_REGS); +extern int Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS); +extern void *Yap_Concat_Text(int n, seq_tv_t inp[], seq_tv_t *out USES_REGS); +extern void *Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, + encoding_t encv[], seq_tv_t outv[] USES_REGS); // user friendly interface -static inline size_t -Yap_AtomicToLength(Term t0 USES_REGS) -{ +static inline size_t Yap_AtomicToLength(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_CODES|YAP_STRING_ATOMS|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | + YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_LENGTH; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_AtomicToListOfAtoms(Term t0 USES_REGS) -{ +static inline Term Yap_AtomicToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_AtomicToListOfCodes(Term t0 USES_REGS) -{ +static inline Term Yap_AtomicToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_CODES; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -290,12 +418,11 @@ Yap_AtomicToListOfCodes(Term t0 USES_REGS) return out.val.t; } -static inline Atom -Yap_AtomicToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_AtomicToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -303,9 +430,7 @@ Yap_AtomicToAtom(Term t0 USES_REGS) return out.val.a; } -static inline size_t -Yap_AtomToLength(Term t0 USES_REGS) -{ +static inline size_t Yap_AtomToLength(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOM; @@ -316,9 +441,7 @@ Yap_AtomToLength(Term t0 USES_REGS) return out.val.l; } -static inline Term -Yap_AtomToListOfAtoms(Term t0 USES_REGS) -{ +static inline Term Yap_AtomToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOM; @@ -329,13 +452,13 @@ Yap_AtomToListOfAtoms(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_AtomSWIToListOfAtoms(Term t0 USES_REGS) -{ +static inline Term Yap_AtomSWIToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_ATOM|YAP_STRING_STRING|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_ATOMS; @@ -344,10 +467,7 @@ Yap_AtomSWIToListOfAtoms(Term t0 USES_REGS) return out.val.t; } - -static inline Term -Yap_AtomToListOfCodes(Term t0 USES_REGS) -{ +static inline Term Yap_AtomToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOM; @@ -358,22 +478,19 @@ Yap_AtomToListOfCodes(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_AtomToNumber(Term t0 USES_REGS) -{ +static inline Term Yap_AtomToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOM; out.val.uc = NULL; - out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + out.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_AtomToString(Term t0 USES_REGS) -{ +static inline Term Yap_AtomToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; @@ -386,13 +503,12 @@ Yap_AtomToString(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_AtomSWIToString(Term t0 USES_REGS) -{ +static inline Term Yap_AtomSWIToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_ATOM|YAP_STRING_STRING|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES; + inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -401,13 +517,12 @@ Yap_AtomSWIToString(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_AtomicToString(Term t0 USES_REGS) -{ +static inline Term Yap_AtomicToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -416,43 +531,39 @@ Yap_AtomicToString(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_AtomicToTDQ(Term t0, Term mod USES_REGS) -{ +static inline Term Yap_AtomicToTDQ(Term t0, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_type(mod PASS_REGS); - + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Term -Yap_AtomicToTBQ(Term t0, Term mod USES_REGS) -{ +static inline Term Yap_AtomicToTBQ(Term t0, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_bqtype(mod PASS_REGS); - + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Atom -Yap_CharsToAtom( const char *s, encoding_t enc USES_REGS ) -{ +static inline Atom Yap_CharsToAtom(const char *s, encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -466,9 +577,8 @@ Yap_CharsToAtom( const char *s, encoding_t enc USES_REGS ) return out.val.a; } -static inline Term -Yap_CharsToListOfAtoms( const char *s, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToListOfAtoms(const char *s, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -482,9 +592,8 @@ Yap_CharsToListOfAtoms( const char *s, encoding_t enc USES_REGS ) return out.val.t; } -static inline Term -Yap_CharsToListOfCodes( const char *s, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToListOfCodes(const char *s, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -498,9 +607,7 @@ Yap_CharsToListOfCodes( const char *s, encoding_t enc USES_REGS ) return out.val.t; } -static inline Term -Yap_UTF8ToListOfCodes( const char *s USES_REGS ) -{ +static inline Term Yap_UTF8ToListOfCodes(const char *s USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -513,9 +620,8 @@ Yap_UTF8ToListOfCodes( const char *s USES_REGS ) return out.val.t; } -static inline Term -Yap_CharsToDiffListOfCodes( const char *s, Term tail, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -523,23 +629,22 @@ Yap_CharsToDiffListOfCodes( const char *s, Term tail, encoding_t enc USES_REGS ) inp.enc = enc; inp.type = YAP_STRING_CHARS; out.val.uc = NULL; - out.type = YAP_STRING_DIFF|YAP_STRING_CODES; + out.type = YAP_STRING_DIFF | YAP_STRING_CODES; out.dif = tail; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_UTF8ToDiffListOfCodes( const char *s, Term tail USES_REGS ) -{ +static inline Term Yap_UTF8ToDiffListOfCodes(const char *s, + Term tail USES_REGS) { seq_tv_t inp, out; - + inp.val.c0 = s; inp.sz = 0; inp.type = YAP_STRING_CHARS; inp.enc = ENC_ISO_UTF8; - out.type = YAP_STRING_DIFF|YAP_STRING_CODES; + out.type = YAP_STRING_DIFF | YAP_STRING_CODES; out.val.uc = NULL; out.dif = tail; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -547,15 +652,14 @@ Yap_UTF8ToDiffListOfCodes( const char *s, Term tail USES_REGS ) return out.val.t; } -static inline Term -Yap_WCharsToDiffListOfCodes( const wchar_t *s, Term tail USES_REGS ) -{ +static inline Term Yap_WCharsToDiffListOfCodes(const wchar_t *s, + Term tail USES_REGS) { seq_tv_t inp, out; - + inp.val.w0 = s; inp.sz = 0; inp.type = YAP_STRING_WCHARS; - out.type = YAP_STRING_DIFF|YAP_STRING_CODES; + out.type = YAP_STRING_DIFF | YAP_STRING_CODES; out.val.uc = NULL; out.dif = tail; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -563,9 +667,7 @@ Yap_WCharsToDiffListOfCodes( const wchar_t *s, Term tail USES_REGS ) return out.val.t; } -static inline Term -Yap_CharsToString( const char *s, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToString(const char *s, encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; @@ -579,9 +681,7 @@ Yap_CharsToString( const char *s, encoding_t enc USES_REGS ) return out.val.t; } -static inline char * -Yap_AtomToUTF8Text( Atom at, const char *s USES_REGS ) -{ +static inline char *Yap_AtomToUTF8Text(Atom at, const char *s USES_REGS) { seq_tv_t inp, out; inp.val.a = at; @@ -601,11 +701,10 @@ Yap_AtomToUTF8Text( Atom at, const char *s USES_REGS ) return out.val.c; } -static inline Term -Yap_CharsToTDQ( const char *s, Term mod, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToTDQ(const char *s, Term mod, + encoding_t enc USES_REGS) { seq_tv_t inp, out; - + inp.val.c0 = s; inp.sz = 0; inp.type = YAP_STRING_CHARS; @@ -616,15 +715,14 @@ Yap_CharsToTDQ( const char *s, Term mod, encoding_t enc USES_REGS ) if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a ); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Term -Yap_CharsToTBQ( const char *s, Term mod, encoding_t enc USES_REGS ) -{ +static inline Term Yap_CharsToTBQ(const char *s, Term mod, + encoding_t enc USES_REGS) { seq_tv_t inp, out; - + inp.val.c0 = s; inp.sz = 0; inp.type = YAP_STRING_CHARS; @@ -635,13 +733,11 @@ Yap_CharsToTBQ( const char *s, Term mod, encoding_t enc USES_REGS ) if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a ); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Atom -Yap_ListOfAtomsToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_ListOfAtomsToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOMS; @@ -652,22 +748,19 @@ Yap_ListOfAtomsToAtom(Term t0 USES_REGS) return out.val.a; } -static inline Term -Yap_ListOfAtomsToNumber(Term t0 USES_REGS) -{ +static inline Term Yap_ListOfAtomsToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOMS; - out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + out.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_ListOfAtomsToString(Term t0 USES_REGS) -{ +static inline Term Yap_ListOfAtomsToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_ATOMS; @@ -678,9 +771,7 @@ Yap_ListOfAtomsToString(Term t0 USES_REGS) return out.val.t; } -static inline Atom -Yap_ListOfCodesToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_ListOfCodesToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_CODES; @@ -691,22 +782,18 @@ Yap_ListOfCodesToAtom(Term t0 USES_REGS) return out.val.a; } -static inline Term -Yap_ListOfCodesToNumber(Term t0 USES_REGS) -{ +static inline Term Yap_ListOfCodesToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_CODES; - out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG; + out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_ListOfCodesToString(Term t0 USES_REGS) -{ +static inline Term Yap_ListOfCodesToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.type = YAP_STRING_CODES; @@ -717,12 +804,11 @@ Yap_ListOfCodesToString(Term t0 USES_REGS) return out.val.t; } -static inline Atom -Yap_ListToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_ListToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM|YAP_STRING_ATOM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM | + YAP_STRING_ATOM; out.val.uc = NULL; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -730,42 +816,36 @@ Yap_ListToAtom(Term t0 USES_REGS) return out.val.a; } -static inline Term -Yap_ListToAtomic(Term t0 USES_REGS) -{ +static inline Term Yap_ListToAtomic(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; - out.type = YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_ListToNumber(Term t0 USES_REGS) -{ +static inline Term Yap_ListToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES; out.val.uc = NULL; - out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG; + out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } - -static inline Term -Yap_ListToString(Term t0 USES_REGS) -{ +static inline Term Yap_ListToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -774,14 +854,13 @@ Yap_ListToString(Term t0 USES_REGS) return out.val.t; } - -static inline Term -Yap_ListSWIToString(Term t0 USES_REGS) -{ +static inline Term Yap_ListSWIToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_ATOMS_CODES|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_ATOMS_CODES | + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | + YAP_STRING_TERM; out.val.uc = NULL; out.type = YAP_STRING_STRING; @@ -790,51 +869,45 @@ Yap_ListSWIToString(Term t0 USES_REGS) return out.val.t; } - -static inline Term -YapListToTDQ(Term t0, Term mod USES_REGS) -{ +static inline Term YapListToTDQ(Term t0, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_type(mod PASS_REGS); - + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) { - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); } return out.val.t; } -static inline Term -YapListToTBQ(Term t0, Term mod USES_REGS) -{ +static inline Term YapListToTBQ(Term t0, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM; out.val.uc = NULL; out.type = mod_to_bqtype(mod PASS_REGS); - + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) { - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); } return out.val.t; } -static inline Atom -Yap_NCharsToAtom( const char *s, size_t len, encoding_t enc USES_REGS ) -{ +static inline Atom Yap_NCharsToAtom(const char *s, size_t len, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; inp.sz = len; - inp.type = YAP_STRING_CHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; inp.enc = enc; out.type = YAP_STRING_ATOM; out.val.uc = NULL; @@ -844,30 +917,27 @@ Yap_NCharsToAtom( const char *s, size_t len, encoding_t enc USES_REGS ) return out.val.a; } -static inline Term -Yap_CharsToDiffListOfAtoms( const char *s, encoding_t enc, Term tail USES_REGS ) -{ +static inline Term Yap_CharsToDiffListOfAtoms(const char *s, encoding_t enc, + Term tail USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; inp.type = YAP_STRING_CHARS; inp.enc = enc; - out.type = YAP_STRING_ATOMS|YAP_STRING_DIFF; + out.type = YAP_STRING_ATOMS | YAP_STRING_DIFF; out.dif = tail; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } - -static inline Term -Yap_NCharsToListOfCodes( const char *s, size_t len, encoding_t enc USES_REGS ) -{ +static inline Term Yap_NCharsToListOfCodes(const char *s, size_t len, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; inp.sz = len; - inp.type = YAP_STRING_CHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; inp.enc = enc; out.type = YAP_STRING_CODES; out.max = len; @@ -876,15 +946,14 @@ Yap_NCharsToListOfCodes( const char *s, size_t len, encoding_t enc USES_REGS ) return out.val.t; } -static inline Term -Yap_NCharsToString( const char *s, size_t len, encoding_t enc USES_REGS ) -{ +static inline Term Yap_NCharsToString(const char *s, size_t len, + encoding_t enc USES_REGS) { seq_tv_t inp, out; inp.val.c0 = s; inp.sz = len; inp.enc = enc; - inp.type = YAP_STRING_CHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; out.type = YAP_STRING_STRING; out.max = len; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -892,13 +961,12 @@ Yap_NCharsToString( const char *s, size_t len, encoding_t enc USES_REGS ) return out.val.t; } -static inline Term -Yap_NCharsToTDQ( const char *s, size_t len, encoding_t enc, Term mod USES_REGS ) -{ +static inline Term Yap_NCharsToTDQ(const char *s, size_t len, encoding_t enc, + Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.c0 = s; - inp.type = YAP_STRING_CHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; inp.sz = len; inp.enc = enc; inp.mod = mod; @@ -907,17 +975,16 @@ Yap_NCharsToTDQ( const char *s, size_t len, encoding_t enc, Term mod USES_REGS ) if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a ); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Term -Yap_NCharsToTBQ( const char *s, size_t len, encoding_t enc, Term mod USES_REGS ) -{ +static inline Term Yap_NCharsToTBQ(const char *s, size_t len, encoding_t enc, + Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.c0 = s; - inp.type = YAP_STRING_CHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS; inp.sz = len; inp.enc = enc; inp.mod = mod; @@ -926,81 +993,74 @@ Yap_NCharsToTBQ( const char *s, size_t len, encoding_t enc, Term mod USES_REGS if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a ); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Atom -Yap_NumberToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_NumberToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.a; } -static inline Term -Yap_NumberToListOfAtoms(Term t0 USES_REGS) -{ +static inline Term Yap_NumberToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_NumberToListOfCodes(Term t0 USES_REGS) -{ +static inline Term Yap_NumberToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_CODES; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_NumberToString(Term t0 USES_REGS) -{ +static inline Term Yap_NumberToString(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inp.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.type = YAP_STRING_STRING; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Atom -Yap_NWCharsToAtom( const wchar_t *s, size_t len USES_REGS ) -{ - seq_tv_t inp, out; - - inp.val.w0 = s; - inp.sz = len; - inp.type = YAP_STRING_WCHARS|YAP_STRING_NCHARS; - out.type = YAP_STRING_ATOM; - out.max = len; - if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return 0L; - return out.val.a; -} - -static inline Term -Yap_NWCharsToListOfAtoms( const wchar_t *s, size_t len USES_REGS ) -{ +static inline Atom Yap_NWCharsToAtom(const wchar_t *s, size_t len USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; inp.sz = len; - inp.type = YAP_STRING_WCHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_WCHARS | YAP_STRING_NCHARS; + out.type = YAP_STRING_ATOM; + out.max = len; + if (!Yap_CVT_Text(&inp, &out PASS_REGS)) + return 0L; + return out.val.a; +} + +static inline Term Yap_NWCharsToListOfAtoms(const wchar_t *s, + size_t len USES_REGS) { + seq_tv_t inp, out; + + inp.val.w0 = s; + inp.sz = len; + inp.type = YAP_STRING_WCHARS | YAP_STRING_NCHARS; out.type = YAP_STRING_ATOMS; out.max = len; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1008,14 +1068,13 @@ Yap_NWCharsToListOfAtoms( const wchar_t *s, size_t len USES_REGS ) return out.val.t; } -static inline Term -Yap_NWCharsToListOfCodes( const wchar_t *s, size_t len USES_REGS ) -{ +static inline Term Yap_NWCharsToListOfCodes(const wchar_t *s, + size_t len USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; inp.sz = len; - inp.type = YAP_STRING_WCHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_WCHARS | YAP_STRING_NCHARS; out.type = YAP_STRING_CODES; out.val.uc = NULL; out.max = len; @@ -1024,14 +1083,12 @@ Yap_NWCharsToListOfCodes( const wchar_t *s, size_t len USES_REGS ) return out.val.t; } -static inline Term -Yap_NWCharsToString( const wchar_t *s, size_t len USES_REGS ) -{ +static inline Term Yap_NWCharsToString(const wchar_t *s, size_t len USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; inp.sz = len; - inp.type = YAP_STRING_WCHARS|YAP_STRING_NCHARS; + inp.type = YAP_STRING_WCHARS | YAP_STRING_NCHARS; out.val.uc = NULL; out.type = YAP_STRING_STRING; out.max = len; @@ -1040,9 +1097,7 @@ Yap_NWCharsToString( const wchar_t *s, size_t len USES_REGS ) return out.val.t; } -static inline Atom -Yap_StringToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_StringToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; @@ -1054,13 +1109,13 @@ Yap_StringToAtom(Term t0 USES_REGS) return out.val.a; } -static inline Atom -Yap_StringSWIToAtom(Term t0 USES_REGS) -{ +static inline Atom Yap_StringSWIToAtom(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_ATOM; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1068,23 +1123,20 @@ Yap_StringSWIToAtom(Term t0 USES_REGS) return out.val.a; } -static inline size_t -Yap_StringToAtomic(Term t0 USES_REGS) -{ +static inline size_t Yap_StringToAtomic(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; inp.type = YAP_STRING_STRING; - out.type = YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | + YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline size_t -Yap_StringToLength(Term t0 USES_REGS) -{ +static inline size_t Yap_StringToLength(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; @@ -1096,9 +1148,7 @@ Yap_StringToLength(Term t0 USES_REGS) return out.val.l; } -static inline size_t -Yap_StringToListOfAtoms(Term t0 USES_REGS) -{ +static inline size_t Yap_StringToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; @@ -1110,13 +1160,13 @@ Yap_StringToListOfAtoms(Term t0 USES_REGS) return out.val.t; } -static inline size_t -Yap_StringSWIToListOfAtoms(Term t0 USES_REGS) -{ +static inline size_t Yap_StringSWIToListOfAtoms(Term t0 USES_REGS) { seq_tv_t inp, out; inp.sz = 0; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_ATOMS; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1124,9 +1174,7 @@ Yap_StringSWIToListOfAtoms(Term t0 USES_REGS) return out.val.t; } -static inline size_t -Yap_StringToListOfCodes(Term t0 USES_REGS) -{ +static inline size_t Yap_StringToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.sz = 0; @@ -1138,12 +1186,12 @@ Yap_StringToListOfCodes(Term t0 USES_REGS) return out.val.t; } -static inline size_t -Yap_StringSWIToListOfCodes(Term t0 USES_REGS) -{ +static inline size_t Yap_StringSWIToListOfCodes(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; - inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM; + inp.type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES | + YAP_STRING_TERM; out.type = YAP_STRING_CODES; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) @@ -1151,23 +1199,20 @@ Yap_StringSWIToListOfCodes(Term t0 USES_REGS) return out.val.t; } -static inline Term -Yap_StringToNumber(Term t0 USES_REGS) -{ +static inline Term Yap_StringToNumber(Term t0 USES_REGS) { seq_tv_t inp, out; inp.val.t = t0; inp.sz = 0; inp.type = YAP_STRING_STRING; - out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + out.type = + YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; out.val.uc = NULL; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; return out.val.t; } -static inline Term -Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) -{ +static inline Term Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; inp.sz = 0; @@ -1179,11 +1224,9 @@ Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS) return out.val.t; } -static inline Term -Yap_WCharsToTDQ( wchar_t *s, Term mod USES_REGS ) -{ +static inline Term Yap_WCharsToTDQ(wchar_t *s, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.w0 = s; inp.type = YAP_STRING_WCHARS; inp.sz = 0; @@ -1193,15 +1236,13 @@ Yap_WCharsToTDQ( wchar_t *s, Term mod USES_REGS ) if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Term -Yap_WCharsToTBQ( wchar_t *s, Term mod USES_REGS ) -{ +static inline Term Yap_WCharsToTBQ(wchar_t *s, Term mod USES_REGS) { seq_tv_t inp, out; - + inp.val.w = s; inp.type = YAP_STRING_WCHARS; inp.sz = 0; @@ -1211,13 +1252,11 @@ Yap_WCharsToTBQ( wchar_t *s, Term mod USES_REGS ) if (!Yap_CVT_Text(&inp, &out PASS_REGS)) return 0L; if (out.type == YAP_STRING_ATOM) - return MkAtomTerm( out.val.a); + return MkAtomTerm(out.val.a); return out.val.t; } -static inline Term -Yap_WCharsToString(const wchar_t *s USES_REGS) -{ +static inline Term Yap_WCharsToString(const wchar_t *s USES_REGS) { seq_tv_t inp, out; inp.val.w0 = s; inp.sz = 0; @@ -1229,9 +1268,7 @@ Yap_WCharsToString(const wchar_t *s USES_REGS) return out.val.t; } -static inline Atom -Yap_ConcatAtoms(Term t1, Term t2 USES_REGS) -{ +static inline Atom Yap_ConcatAtoms(Term t1, Term t2 USES_REGS) { seq_tv_t inpv[2], out; inpv[0].val.t = t1; inpv[0].type = YAP_STRING_ATOM; @@ -1246,15 +1283,15 @@ Yap_ConcatAtoms(Term t1, Term t2 USES_REGS) return out.val.a; } -static inline Atom -Yap_ConcatAtomics(Term t1, Term t2 USES_REGS) -{ +static inline Atom Yap_ConcatAtomics(Term t1, Term t2 USES_REGS) { seq_tv_t inpv[2], out; inpv[0].val.t = t1; - inpv[0].type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inpv[0].type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; inpv[0].sz = 0; inpv[1].val.t = t2; - inpv[1].type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM; + inpv[1].type = YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | + YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM; inpv[1].sz = 0; out.type = YAP_STRING_ATOM; out.val.uc = NULL; @@ -1263,9 +1300,7 @@ Yap_ConcatAtomics(Term t1, Term t2 USES_REGS) return out.val.a; } -static inline Term -Yap_ConcatStrings(Term t1, Term t2 USES_REGS) -{ +static inline Term Yap_ConcatStrings(Term t1, Term t2 USES_REGS) { seq_tv_t inpv[2], out; inpv[0].val.t = t1; inpv[0].type = YAP_STRING_STRING; @@ -1280,10 +1315,8 @@ Yap_ConcatStrings(Term t1, Term t2 USES_REGS) return out.val.t; } - -static inline Atom -Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, size_t max USES_REGS) -{ +static inline Atom Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, + size_t max USES_REGS) { seq_tv_t outv[2], inp; size_t cuts[2]; cuts[0] = cut; @@ -1302,9 +1335,7 @@ Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, size_t max USES_REGS) return ats[0]; } -static inline Atom -Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) -{ +static inline Atom Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) { seq_tv_t outv[2], inp; inp.type = YAP_STRING_ATOM; inp.val.t = t1; @@ -1315,15 +1346,13 @@ Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) outv[1].type = YAP_STRING_ATOM; outv[1].val.t = 0; outv[1].sz = 0; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, + outv PASS_REGS)) return (Atom)NULL; return outv[1].val.a; } - -static inline Atom -Yap_SubtractTailAtom(Term t1, Term th USES_REGS) -{ +static inline Atom Yap_SubtractTailAtom(Term t1, Term th USES_REGS) { seq_tv_t outv[2], inp; inp.type = YAP_STRING_ATOM; inp.val.t = t1; @@ -1333,14 +1362,14 @@ Yap_SubtractTailAtom(Term t1, Term th USES_REGS) outv[0].sz = 0; outv[1].type = YAP_STRING_ATOM; outv[1].val.t = th; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, + outv PASS_REGS)) return (Atom)NULL; return outv[0].val.a; } -static inline Term -Yap_SpliceString(Term t1, Term ts[], size_t cut, size_t max USES_REGS) -{ +static inline Term Yap_SpliceString(Term t1, Term ts[], size_t cut, + size_t max USES_REGS) { seq_tv_t outv[2], inp; size_t cuts[2]; inp.type = YAP_STRING_STRING; @@ -1351,16 +1380,14 @@ Yap_SpliceString(Term t1, Term ts[], size_t cut, size_t max USES_REGS) outv[1].sz = 0; cuts[0] = cut; cuts[1] = max; - if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS)) return 0L; ts[0] = outv[0].val.t; ts[1] = outv[1].val.t; return ts[0]; } -static inline Term -Yap_SubtractHeadString(Term t1, Term th USES_REGS) -{ +static inline Term Yap_SubtractHeadString(Term t1, Term th USES_REGS) { seq_tv_t outv[2], inp; inp.type = YAP_STRING_STRING; inp.val.t = t1; @@ -1371,14 +1398,13 @@ Yap_SubtractHeadString(Term t1, Term th USES_REGS) outv[1].type = YAP_STRING_STRING; outv[1].val.t = 0; outv[1].sz = 0; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, + outv PASS_REGS)) return 0L; return outv[1].val.t; } -static inline Term -Yap_SubtractTailString(Term t1, Term th USES_REGS) -{ +static inline Term Yap_SubtractTailString(Term t1, Term th USES_REGS) { seq_tv_t outv[2], inp; inp.type = YAP_STRING_STRING; inp.val.t = t1; @@ -1388,7 +1414,8 @@ Yap_SubtractTailString(Term t1, Term th USES_REGS) outv[0].sz = 0; outv[1].type = YAP_STRING_STRING; outv[1].val.t = th; - if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, + outv PASS_REGS)) return 0L; return outv[0].val.t; }