The S-Lang API underwent a number of changes for version 2. In particular, the following interfaces have been affected:
Detailed information about these changes is given below. Other changes include:
SLsmg SLregexp SLsearch SLrline SLprep slang interpreter modules
SLang_Error variable is nolonger part of the API. Change code
SLang_Error = foo; if (SLang_Error == bar) ...
SLang_set_error (foo); if (bar == SLang_get_error ()) ...
The changes to these functions were dictated by the new UTF-8 support. For the most part, the changes should be transparent but some functions and variables have been changed.
SLsmg_write_charwere changed to use wide characters (SLwchar_Type).
SLsmg_Char_Typewas changed from an
unsigned shortto a structure. This change was necessary in order to support combining characters and double width unicode characters. This change may affect the use of the following functions:
SLsmg_char_at SLsmg_read_raw SLsmg_write_raw SLsmg_write_color_chars
SLSMG_BUILD_CHARmacro has been removed. The
SLSMG_EXTRACT_CHARmacro will continue to work as long as combining characters are not present.
SLsmg_char_atwas changed to
int SLsmg_char_at (SLsmg_Char_Type *);
SLsearch_Type is now an opaque type. Code such as
which searches forward in
SLsearch_Type st; SLsearch_init (string, 1, 0, &st); . . s = SLsearch (buf, bufmax, &st);
stringmust be changed to
SLsearch_Type *st = SLsearch_open (string, SLSEARCH_CASELESS); if (st == NULL) return; . . s = SLsearch_forward (st, buf, bufmax); . . SLsearch_close (st);
The slang v1 regular expression API has been redesigned in order to facilitate the incorporation of third party regular expression engines.
New functions include:
SLregexp_compile SLregexp_free SLregexp_match SLregexp_nth_match SLregexp_get_hints
The plan is to migrate to the use of the PCRE regular expressions for version 2.2. As such, you may find it convenient to adopt the PCRE library now instead of updating to the changed S-Lang API.
The readline interface has changed in order to make it easier to use. Using it now is as simple as:
See how it is used in
SLrline_Type *rli; rli = SLrline_open (SLtt_Screen_Cols, flags); buf = SLrline_read_line (rli, prompt, &len); /* Use buf */ . . SLfree (buf); SLrline_close (rli);
SLPreprocess_Type was renamed to SLprep_Type and made opaque. New functions include:
If you currently use:
SLprep_new SLprep_delete SLprep_set_flags SLprep_set_comment SLprep_set_prefix SLprep_set_exists_hook SLprep_set_eval_hook
Then change it to:
SLPreprocess_Type pt; SLprep_open_prep (&pt); . . SLprep_close_prep (&pt);
SLprep_Type *pt; pt = SLprep_new (); . . SLprep_delete (pt);
SLang_pop_doublehas been changed to be more like the other
SLang_pop_*functions. Now, it may be used as:
double x; if (-1 == SLang_pop_double (&x)) . .
SLtypewas typedefed to be an
unsigned char, but now it is an
SLang_Class_Typeobject is now an opaque type. If you were previously accessing its fields directly, then you will have to change the code to use one of the accessor functions.
init_<module>_modulefunction is no longer supported because it did not support namespaces. Use the