Next Previous Contents

11. S-Lang 2 API NEWS and UPGRADE information

The S-Lang API underwent a number of changes for version 2. In particular, the following interfaces have been affected:

    SLsmg
    SLregexp
    SLsearch
    SLrline
    SLprep
    slang interpreter modules
Detailed information about these changes is given below. Other changes include: See the relevant chapters in this manual for more information.

11.1 SLang_Error

The SLang_Error variable is nolonger part of the API. Change code such as

      SLang_Error = foo;
      if (SLang_Error == bar) ...
to
      SLang_set_error (foo);
      if (bar == SLang_get_error ()) ...

11.2 SLsmg/SLtt Functions

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.

11.3 SLsearch Functions

SLsearch_Type is now an opaque type. Code such as

      SLsearch_Type st;
      SLsearch_init (string, 1, 0, &st);
         .
         .
      s = SLsearch (buf, bufmax, &st);
which searches forward in buf for string must be changed to
      SLsearch_Type *st = SLsearch_open (string, SLSEARCH_CASELESS);
      if (st == NULL)
        return;
         .
         .
      s = SLsearch_forward (st, buf, bufmax);
         .
         .
      SLsearch_close (st);

11.4 Regular Expression Functions

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.

11.5 Readline Functions

The readline interface has changed in order to make it easier to use. Using it now is as simple as:

      SLrline_Type *rli;
      rli = SLrline_open (SLtt_Screen_Cols, flags);
      buf = SLrline_read_line (rli, prompt, &len);
      /* Use buf */
         .
         .
      SLfree (buf);
      SLrline_close (rli);
See how it is used in slsh/readline.c.

11.6 Preprocessor Interface

SLPreprocess_Type was renamed to SLprep_Type and made opaque. New functions include:

      SLprep_new
      SLprep_delete
      SLprep_set_flags
      SLprep_set_comment
      SLprep_set_prefix
      SLprep_set_exists_hook
      SLprep_set_eval_hook
If you currently use:
      SLPreprocess_Type pt;
      SLprep_open_prep (&pt);
         .
         .
      SLprep_close_prep (&pt);
Then change it to:
      SLprep_Type *pt;
      pt = SLprep_new ();
         .
         .
      SLprep_delete (pt);

11.7 Functions dealing with the interpreter C API

11.8 Modules


Next Previous Contents