Submitted By: Dan Nicholson <dnicholson@linuxfromscratch.org>
Date: 2006-04-04
Initial Package Version: 0.9.8.1
Origin: Upstream CVS http://cvs.sourceforge.net/viewcvs.py/slrn
Upstream Status: Applied, in trunk
Description: Allow slrn to use the S-Lang 2 library.  Changes were supplied
             by S-Lang developer John E. Davis.

diff -Npur slrn-0.9.8.1.orig/src/art.c slrn-0.9.8.1/src/art.c
--- slrn-0.9.8.1.orig/src/art.c	2004-10-06 23:44:02.000000000 +0000
+++ slrn-0.9.8.1/src/art.c	2006-04-04 23:24:19.071911826 +0000
@@ -756,7 +756,11 @@ Slrn_Article_Line_Type *slrn_search_arti
 					     int dir)
   /* dir: 0 is backward, 1 is forward, 2 is "find first" */
 {
+#if SLANG_VERSION < 20000
    SLsearch_Type st;
+#else
+   SLsearch_Type *st = NULL;
+#endif
    Slrn_Article_Line_Type *l;
    Slrn_Article_Type *a;
    char *ptr;
@@ -773,7 +777,20 @@ Slrn_Article_Line_Type *slrn_search_arti
 	if (re == NULL)
 	  return NULL;
      }
+#if SLANG_VERSION < 20000
    else SLsearch_init (string, 1, 0, &st);
+#else
+   else 
+     {
+	unsigned int flags = SLSEARCH_CASELESS;
+	if (Slrn_UTF8_Mode)
+	  flags |= SLSEARCH_UTF8;
+
+	st = SLsearch_new ((SLuchar_Type *) string, flags);
+	if (st == NULL)
+	  return NULL;
+     }
+#endif
 
    a = Slrn_Current_Article;
    if (dir == 2)
@@ -791,10 +808,13 @@ Slrn_Article_Line_Type *slrn_search_arti
 	  {
 	     if (is_regexp)
 	       ptr = (char *) slrn_regexp_match (re, l->buf);
-	     else
-	       ptr = (char *) SLsearch ((unsigned char *) l->buf,
-					(unsigned char *) l->buf + strlen (l->buf),
-					&st);
+#if SLANG_VERSION < 20000
+	     else ptr = (char *) SLsearch ((unsigned char *) l->buf,
+					   (unsigned char *) l->buf + strlen (l->buf),
+					   &st);
+#else
+	     else ptr = (char *)SLsearch_forward (st, (SLuchar_Type *) l->buf, (SLuchar_Type *) l->buf + strlen (l->buf));
+#endif
 	     
 	     if (ptr != NULL)
 	       {
@@ -810,7 +830,11 @@ Slrn_Article_Line_Type *slrn_search_arti
 	  }
 	l = (dir ? l->next : l->prev);
      }
-      
+   
+#if SLANG_VERSION >= 20000
+   if (re != NULL) SLregexp_free (re);
+   if (st != NULL) SLsearch_delete (st);
+#endif
    return l;
 }
 
@@ -2301,7 +2325,7 @@ static Slrn_Article_Type *read_article (
 	if (status == 0)
 	  break;
 	
-	if ((status == -1) || (SLang_Error == USER_BREAK))
+	if ((status == -1) || (SLang_get_error() == USER_BREAK))
 	  {
 	     if (Slrn_Server_Obj->sv_reset != NULL)
 	       Slrn_Server_Obj->sv_reset ();
@@ -2739,7 +2763,7 @@ static char *extract_reply_address (void
  */
 static int check_for_current_article (void)
 {
-   if (SLang_Error)
+   if (SLang_get_error ())
      return -1;
    if (Slrn_Current_Article == NULL)
      {
@@ -2769,7 +2793,12 @@ void slrn_subject_strip_was (char *subje
      {
 	SLRegexp_Type *re;
 	re = *r++;
-	if (NULL != (was = SLang_regexp_match ((unsigned char*) subject, len, re)))
+#if SLANG_VERSION < 20000
+	was = SLang_regexp_match ((unsigned char*) subject, len, re);
+#else
+	was = (unsigned char *)SLregexp_match (re, subject, len);
+#endif
+	if (NULL != was)
 	  {
 	     if (was == (unsigned char*) subject)
 	       was = NULL;
@@ -2806,10 +2835,22 @@ static char *subject_skip_re (char *subj
 	while (*r != NULL)
 	  {
 	     SLRegexp_Type *re = *r;
-	     if (subject == (char*) SLang_regexp_match
-		 ((unsigned char*) subject, len, re))
+	     char *match_pos;
+	     
+#if SLANG_VERSION < 20000
+	     match_pos = SLang_regexp_match ((unsigned char*) subject, len, re);
+#else
+	     match_pos = SLregexp_match (re, subject, len);
+#endif
+	     if (subject == match_pos)
 	       {
+#if SLANG_VERSION < 20000
 		  subject = subject + re->end_matches[0];
+#else
+		  unsigned int ofs, mlen;
+		  (void) SLregexp_nth_match (re, 0, &ofs, &mlen);
+		  subject += mlen;
+#endif
 		  break;
 	       }
 	     r++;
@@ -3964,7 +4005,12 @@ static void next_high_score (void) /*{{{
 static Slrn_Header_Type *Same_Subject_Start_Header;
 static void next_header_same_subject (void) /*{{{*/
 {
+#if SLANG_VERSION < 20000
    SLsearch_Type st;
+#else
+   SLsearch_Type *st;
+   unsigned int flags = SLSEARCH_CASELESS;
+#endif
    Slrn_Header_Type *l;
    static char same_subject[SLRL_DISPLAY_BUFFER_SIZE];
    
@@ -3975,8 +4021,13 @@ static void next_header_same_subject (vo
 	if (slrn_read_input (_("Subject: "), same_subject, NULL, 0, 0) <= 0) return;
 	Same_Subject_Start_Header = Slrn_Current_Header;
      }
+#if SLANG_VERSION < 20000
    SLsearch_init (same_subject, 1, 0, &st);
-   
+#else
+   if (Slrn_UTF8_Mode) flags |= SLSEARCH_UTF8;
+   if (NULL == (st = SLsearch_new ((SLuchar_Type *)same_subject, flags)))
+     return;
+#endif
    l = Slrn_Current_Header->next;
    
    while (l != NULL)
@@ -3987,11 +4038,17 @@ static void next_header_same_subject (vo
 	    ((l->flags & HEADER_READ) == 0) &&
 #endif
 	    (l->subject != NULL)
+#if SLANG_VERSION < 20000
 	    && (NULL != SLsearch ((unsigned char *) l->subject,
 				  (unsigned char *) l->subject + strlen (l->subject),
-				  &st)))
+				  &st))
+#else
+	    && (NULL != SLsearch_forward (st, (SLuchar_Type *)l->subject,
+					  (SLuchar_Type *)l->subject + strlen (l->subject)))
+#endif
+	    )
 	  break;
-	
+
 	l = l->next;
      }
    
@@ -4010,6 +4067,9 @@ static void next_header_same_subject (vo
      {
 	art_pagedn ();
      }
+#if SLANG_VERSION >= 20000
+   SLsearch_delete (st);
+#endif
 }
 
 /*}}}*/
@@ -4352,10 +4412,10 @@ static char *save_article_to_file (char 
 	     if (-1 == save_article_as_unix_mail (Num_Tag_List.headers[i], fp))
 	       {
 		  slrn_smg_refresh ();
-		  if (SLang_Error == SL_USER_BREAK)
+		  if (SLang_get_error() == SL_USER_BREAK)
 		    break;
 
-		  SLang_Error = 0;
+		  SLang_set_error (0);
 		  (void) SLang_input_pending (5);   /* half second delay */
 		  slrn_clear_message ();
 	       }
@@ -4372,7 +4432,7 @@ static char *save_article_to_file (char 
 	     if (-1 == save_article_as_unix_mail (h, fp))
 	       {
 		  slrn_smg_refresh ();
-		  SLang_Error = 0;
+		  SLang_set_error (0);
 		  (void) SLang_input_pending (5);   /* half second delay */
 	       }
 	     else num_saved++;
@@ -4384,7 +4444,7 @@ static char *save_article_to_file (char 
      }
    slrn_fclose (fp);
    
-   if (SLang_Error) return NULL;
+   if (SLang_get_error ()) return NULL;
    
    return Output_Filename;
 }
@@ -4506,7 +4566,7 @@ static void decode_article (void) /*{{{*
 # endif
 	(void) slrn_uudecode_file (file, NULL, 0, NULL);
 
-	if (SLang_Error == 0)
+	if (0 == SLang_get_error ())
 	  {
 	     if (1 == slrn_get_yesno (1, _("Delete %s"), file))
 	       {
@@ -4942,7 +5002,12 @@ static void exchange_mark (void) /*{{{*/
 static void header_generic_search (int dir, int type) /*{{{*/
 {
    static char search_str[SLRL_DISPLAY_BUFFER_SIZE];
+#if SLANG_VERSION < 20000
    SLsearch_Type st;
+#else
+   SLsearch_Type *st;
+   unsigned int flags = SLSEARCH_CASELESS;
+#endif
    Slrn_Header_Type *l;
    char* prompt;
    int ret;
@@ -4955,8 +5020,15 @@ static void header_generic_search (int d
    slrn_free (prompt);
    if (ret <= 0) return;
    
+#if SLANG_VERSION < 20000
    SLsearch_init (search_str, 1, 0, &st);
-   
+#else
+   if (Slrn_UTF8_Mode) flags |= SLSEARCH_UTF8;
+   st = SLsearch_new ((SLuchar_Type *)search_str, flags);
+   if (NULL == st)
+     return;
+#endif
+
    if (dir > 0) l = Slrn_Current_Header->next;
    else l = Slrn_Current_Header->prev;
    
@@ -4965,20 +5037,35 @@ static void header_generic_search (int d
 	if (type == 's')
 	  {
 	     if ((l->subject != NULL)
+#if SLANG_VERSION < 20000
 		 && (NULL != SLsearch ((unsigned char *) l->subject,
 				       (unsigned char *) l->subject + strlen (l->subject),
-				       &st)))
+				       &st))
+#else
+		 && (NULL != SLsearch_forward (st, (SLuchar_Type *) l->subject,
+					       (SLuchar_Type *) l->subject + strlen (l->subject)))
+#endif
+		     )
 	       break;
 	  }
 	else if ((l->from != NULL)
+#if SLANG_VERSION < 20000
 		 && (NULL != SLsearch ((unsigned char *) l->from,
 				       (unsigned char *) l->from + strlen (l->from),
-				       &st)))
+				       &st))
+#else
+		 && (NULL != SLsearch_forward (st, (SLuchar_Type *) l->subject,
+					       (SLuchar_Type *) l->subject + strlen (l->subject)))
+#endif
+		     )
 	  break;
 	
 	if (dir > 0) l = l->next; else l = l->prev;
      }
    
+#if SLANG_VERSION >= 20000
+   SLsearch_delete (st);
+#endif
    if (l == NULL)
      {
 	slrn_error (_("Not found."));
@@ -5219,7 +5306,7 @@ static void score_headers (int apply_kil
    
    slrn_message_now (_("Scoring articles ..."));
    
-   while ((h != NULL) && (SLang_Error != USER_BREAK))
+   while ((h != NULL) && (SLang_get_error() != USER_BREAK))
      {
 	Slrn_Header_Type *prev, *next;
 	prev = h->real_prev;
@@ -5248,10 +5335,10 @@ static void score_headers (int apply_kil
 	  }
 	h = next;
      }
-   if (SLang_Error == USER_BREAK)
+   if (SLang_get_error () == USER_BREAK)
      {
 	slrn_error ("Scoring aborted.");
-	SLang_Error = 0;
+	SLang_set_error (0);
      }
    if (apply_kill)
      Slrn_Current_Header = _art_Headers = Slrn_First_Header;
@@ -5461,7 +5548,7 @@ static int get_add_headers (int min, int
 	
 	while (-1 != (this_num = slrn_read_add_xover(&l)))
 	  {
-	     if (SLang_Error == USER_BREAK)
+	     if (SLang_get_error () == USER_BREAK)
 	       {
 		  if (Slrn_Server_Obj->sv_reset != NULL)
 		    Slrn_Server_Obj->sv_reset ();
@@ -5507,7 +5594,7 @@ static int get_headers (int min, int max
    if (total == 0)
      return 0;
    
-   if (SLang_Error == USER_BREAK)
+   if (SLang_get_error () == USER_BREAK)
      return -1;
 
    if ((reads_per_update = Slrn_Reads_Per_Update) < 5)
@@ -5532,7 +5619,7 @@ static int get_headers (int min, int max
      {
 	int this_num;
 	
-	if (SLang_Error == USER_BREAK)
+	if (SLang_get_error () == USER_BREAK)
 	  {
 	     if (Slrn_Server_Obj->sv_reset != NULL)
 	       Slrn_Server_Obj->sv_reset ();
@@ -5556,7 +5643,7 @@ static int get_headers (int min, int max
 	h = process_xover (&xov);
 
 	if ((1 == (num % reads_per_update))
-	    && (SLang_Error == 0))
+	    && (SLang_get_error () == 0))
 	  {
 	     slrn_message_now (_("%s: headers received: %2d/%d"),
 			       Slrn_Current_Group_Name, num, total);
@@ -7085,27 +7172,26 @@ static void art_mouse (void (*top_status
      {
 	if (Slrn_Highlight_Urls && (c < 255))
 	  {
-	     unsigned short buf[255];
+	     SLsmg_Char_Type buf[256];
 	     char line[512];
 	     char *url = NULL;
 	     unsigned int len, i;
 	     
 	     SLsmg_gotorc (r - 1, 0);
-	     len = SLsmg_read_raw (buf, sizeof (buf));
+	     len = SLsmg_read_raw (buf, 256);
 	     
 	     i = (unsigned int) c;
-	     while (c && (((buf[--c] >> 8) & 0xFF) == URL_COLOR))
+	     while (c && (SLSMG_EXTRACT_COLOR(buf[--c]) == URL_COLOR))
 	       {
-		  line[c] = buf[c] & 0xFF;
+		  line[c] = (char) SLSMG_EXTRACT_CHAR(buf[c]);
 		  url = line + c;
 	       }
-	     
-	     while ((i < len) && ((buf[i] >> 8) & 0xFF) == URL_COLOR)
+	     while ((i < len) && (SLSMG_EXTRACT_COLOR(buf[i]) == URL_COLOR))
 	       {
-		  line[i] = buf[i] & 0xFF;
+		  line[i] = (char) SLSMG_EXTRACT_CHAR(buf[i]);
 		  i++;
 	       }
-	     
+
 	     line[i] = '\0';
 	     
 	     if (url != NULL)
@@ -7501,7 +7587,7 @@ void slrn_init_article_mode (void) /*{{{
 
    SLkm_define_key  ("z", (FVOID_STAR) zoom_article_window, Slrn_Article_Keymap);
    
-   if (SLang_Error) slrn_exit_error (err);
+   if (SLang_get_error ()) slrn_exit_error (err);
 }
 
 /*}}}*/
@@ -7602,7 +7688,7 @@ int slrn_select_article_mode (Slrn_Group
 
 #if SLRN_HAS_SLANG
    slrn_run_hooks (HOOK_PRE_ARTICLE_MODE, 0);
-   if (SLang_Error)
+   if (SLang_get_error ())
      return -1;
 #endif
    
@@ -7755,7 +7841,7 @@ int slrn_select_article_mode (Slrn_Group
    
    if ((status == -1) || SLKeyBoard_Quit)
      {
-	if (SLang_Error == USER_BREAK)
+	if (SLang_get_error () == USER_BREAK)
 	  slrn_error_now (0, _("Group transfer aborted."));
 	else
 	  slrn_error_now (0, _("Server read failed."));
@@ -7781,7 +7867,7 @@ int slrn_select_article_mode (Slrn_Group
 
 	free_kill_lists_and_update ();
 	Slrn_Current_Group_Name = NULL;
-	if ((SLang_Error == USER_BREAK) || (all != 0)) return -1;
+	if ((SLang_get_error () == USER_BREAK) || (all != 0)) return -1;
 	else return -2;
      }
    
@@ -7822,7 +7908,7 @@ int slrn_select_article_mode (Slrn_Group
 #endif
 
    if (Slrn_Startup_With_Article) art_pagedn ();
-   if (SLang_Error == 0)
+   if (SLang_get_error () == 0)
      {
 	if (Perform_Scoring 
 	    /* && (Number_Killed || Number_High_Scored) */
@@ -8162,7 +8248,7 @@ static void write_spoiler (char *buf, in
 
 static void draw_tree (Slrn_Header_Type *h) /*{{{*/
 {
-   SLsmg_Char_Type buf[2];
+   SLwchar_Type buf[2];
 
 #if !defined(IBMPC_SYSTEM)
    if (Graphic_Chars_Mode == 0)
diff -Npur slrn-0.9.8.1.orig/src/art_misc.c slrn-0.9.8.1/src/art_misc.c
--- slrn-0.9.8.1.orig/src/art_misc.c	2004-08-13 21:34:47.000000000 +0000
+++ slrn-0.9.8.1/src/art_misc.c	2006-04-04 23:24:19.073911024 +0000
@@ -130,13 +130,20 @@ static unsigned char *is_matching_line (
    while (*r != NULL)
      {
 	SLRegexp_Type *re;
+	unsigned int match_len;
 
 	re = *r++;
+#if SLANG_VERSION < 20000
 	if ((re->min_length > len) 
 	    || (b != SLang_regexp_match (b, len, re)))
 	  continue;
-	
-	return b + re->end_matches[0];
+	match_len = re->end_matches[0];
+#else
+	if (b != (unsigned char *) SLregexp_match (re, (char *) b, len))
+	  continue;
+	(void) SLregexp_nth_match (re, 0, NULL, &match_len);
+#endif
+	return b + match_len;
      }
    return NULL;
 }
@@ -232,25 +239,37 @@ void slrn_art_mark_spoilers (Slrn_Articl
 static int try_supercite (Slrn_Article_Line_Type *l) /*{{{*/
 {
    Slrn_Article_Line_Type *last, *lsave;
+#if SLANG_VERSION < 20000
    static unsigned char compiled_pattern_buf[256];
-   static SLRegexp_Type re;
+   static SLRegexp_Type re_buf;
+   SLRegexp_Type *re;
+#else
+   static SLRegexp_Type *re = NULL;
+#endif
    unsigned char *b;
    int count;
    char name[32];
    unsigned int len;
+   unsigned int ofs;
    int ret;
 
-   re.pat = (unsigned char *) Super_Cite_Regexp;
-   re.buf = compiled_pattern_buf;
-   re.case_sensitive = 1;
-   re.buf_len = sizeof (compiled_pattern_buf);
+#if SLANG_VERSION < 20000
+   re = &re_buf;
+   re->pat = (unsigned char *) Super_Cite_Regexp;
+   re->buf = compiled_pattern_buf;
+   re->case_sensitive = 1;
+   re->buf_len = sizeof (compiled_pattern_buf);
+   if ((*compiled_pattern_buf == 0) && SLang_regexp_compile (re))
+     return -1;
+#else
+   if ((re == NULL)
+       && (NULL == (re = SLregexp_compile (Super_Cite_Regexp, 0))))
+     return -1;
+#endif
    
    /* skip header --- I should look for Xnewsreader: gnus */
    while ((l != NULL) && (*l->buf != 0)) l = l->next;
-   
-   if ((*compiled_pattern_buf == 0) && SLang_regexp_compile (&re))
-     return -1;
-   
+
    /* look at the first 15 lines on first attempt.
     * After that, scan the whole buffer looking for more citations */
    count = 15;
@@ -262,7 +281,7 @@ static int try_supercite (Slrn_Article_L
 	  {
 	     if ((l->flags & QUOTE_LINE) == 0)
 	       {
-		  if (NULL != slrn_regexp_match (&re, l->buf))
+		  if (NULL != slrn_regexp_match (re, l->buf))
 		    {
 		       l->flags |= QUOTE_LINE;
 		       break;
@@ -275,10 +294,16 @@ static int try_supercite (Slrn_Article_L
 	if ((l == NULL) || (count == 0)) return ret;
 	
 	/* Now find out what is used for citing. */
-	b = (unsigned char *) l->buf + re.beg_matches[1];
-	len = re.end_matches[1];
+#if SLANG_VERSION < 20000
+	ofs = re->beg_matches[1];
+	len = re->end_matches[1];
+#else
+	if (-1 == SLregexp_nth_match (re, 1, &ofs, &len))
+	  return ret;
+#endif
+	b = (unsigned char *) l->buf + ofs;
 	if (len > sizeof (name) - 2) return ret;
-	
+
 	ret = 0;
 	strncpy (name, (char *) b, len); name[len] = 0;
 	
@@ -521,7 +546,11 @@ int _slrn_art_wrap_article (Slrn_Article
 	     else
 	       {
 		  len += 2;
+#if SLANG_VERSION < 20000
 		  if (ch & 0x80) len++;
+#else
+		  if (ch & 0x80) len += 2;
+#endif
 	       }
 
 	     if (len > (unsigned int) SLtt_Screen_Cols)
diff -Npur slrn-0.9.8.1.orig/src/chmap.c slrn-0.9.8.1/src/chmap.c
--- slrn-0.9.8.1.orig/src/chmap.c	2002-03-13 13:02:28.000000000 +0000
+++ slrn-0.9.8.1/src/chmap.c	2006-04-04 23:24:19.074910623 +0000
@@ -40,6 +40,7 @@
 #include <slang.h>
 #include "jdmacros.h"
 
+#include "slrn.h"
 #include "misc.h"
 #include "util.h"
 #include "group.h"
@@ -68,11 +69,21 @@ static void chmap_map_string (char *str,
 
 static void chmap_map_string_from_iso (char *str)
 {
+# if SLANG_VERSION >= 20000
+   /* fixme */
+   if (Slrn_UTF8_Mode)
+     return;
+#endif
    chmap_map_string (str, ChMap_From_Iso_Map);
 }
 
 static void chmap_map_string_to_iso (char *str)
 {
+   /* fixme */
+#if SLANG_VERSION >= 20000
+   if (Slrn_UTF8_Mode)
+     return;
+#endif
    chmap_map_string (str, ChMap_To_Iso_Map);
 }
 
diff -Npur slrn-0.9.8.1.orig/src/editscore.c slrn-0.9.8.1/src/editscore.c
--- slrn-0.9.8.1.orig/src/editscore.c	2003-07-26 21:22:16.000000000 +0000
+++ slrn-0.9.8.1/src/editscore.c	2006-04-04 23:24:19.075910222 +0000
@@ -39,6 +39,7 @@
 #include "misc.h"
 #include "score.h"
 #include "util.h"
+#include "slrn.h"
 
 /* In pathological situations, "Subject" or "From" header fields may include
  * (MIME-encoded) linebreaks that would lead to invalid scorefile entries, so
@@ -61,7 +62,7 @@ int slrn_edit_score (Slrn_Header_Type *h
    char ch = 'e';
    int ich;
    char file[256];
-   char qregexp[2*SLRL_DISPLAY_BUFFER_SIZE], buf[2*SLRL_DISPLAY_BUFFER_SIZE];
+   char qregexp[2*SLRL_DISPLAY_BUFFER_SIZE];
    unsigned int mm = 0, dd = 0, yy = 0;
    int days = 0;
    int use_expired = 0, force_score = 0;
@@ -71,7 +72,12 @@ int slrn_edit_score (Slrn_Header_Type *h
    FILE *fp;
    time_t myclock;
    int file_modified = 0, re_error = 0;
+#if SLANG_VERSION < 20000
    SLRegexp_Type re;
+   char buf[2*SLRL_DISPLAY_BUFFER_SIZE];
+#else
+   SLRegexp_Type *re;
+#endif
    /* Note to translators: The translated string needs to have 10 characters.
     * Each pair becomes a valid response for "Subject", "From", "References",
     * "Edit" and "Cancel" (in that order); you cannot use any of the default
@@ -167,11 +173,14 @@ int slrn_edit_score (Slrn_Header_Type *h
 	slrn_error (_("Unable to open %s"), file);
 	return -1;
      }
-   
+#if SLANG_VERSION < 20000
    re.pat = (unsigned char*) qregexp;
    re.buf = (unsigned char*) buf;
    re.buf_len = sizeof (buf);
    re.case_sensitive = 0;
+#else
+   re = NULL;
+#endif
    
    if (Slrn_Prefix_Arg_Ptr == NULL)
      {
@@ -197,7 +206,12 @@ int slrn_edit_score (Slrn_Header_Type *h
 	
 	if ((NULL == (q = SLregexp_quote_string (line, qregexp, sizeof (qregexp)))) ||
 	    (ch != 's') ||
-	    (0 != SLang_regexp_compile (&re)))
+#if SLANG_VERSION < 20000
+	    (0 != SLang_regexp_compile (&re))
+#else
+	    (NULL == (re = SLregexp_compile (qregexp, SLREGEXP_CASELESS)))
+#endif
+	    )
 	  {
 	     re_error |= (ch == 's');
 	     comment = 1;
@@ -207,12 +221,24 @@ int slrn_edit_score (Slrn_Header_Type *h
 	fprintf (fp, "%c\tSubject: %s\n",
 		 (comment ? '%' : ' '), (q ? q : line));
 	slrn_free (line);
+#if SLANG_VERSION >= 20000
+	if (re != NULL)
+	  {
+	     SLregexp_free (re);
+	     re = NULL;
+	  }
+#endif
 
 	line = slrn_safe_strmalloc (h->from);
 	remove_linebreaks (line);
 	if ((NULL == (q = SLregexp_quote_string (line, qregexp, sizeof (qregexp)))) ||
 	    (ch != 'f') ||
-	    (0 != SLang_regexp_compile (&re)))
+#if SLANG_VERSION < 20000
+	    (0 != SLang_regexp_compile (&re))
+#else
+	    (NULL == (re = SLregexp_compile (qregexp, SLREGEXP_CASELESS)))
+#endif
+	    )
 	  {
 	     re_error |= (ch == 'f');
 	     comment = 1;
@@ -222,10 +248,22 @@ int slrn_edit_score (Slrn_Header_Type *h
 	fprintf (fp, "%c\tFrom: %s\n",
 		 (comment ? '%' : ' '), (q ? q : line));
 	slrn_free (line);
+#if SLANG_VERSION >= 20000
+	if (re != NULL)
+	  {
+	     SLregexp_free (re);
+	     re = NULL;
+	  }
+#endif
 
 	if ((NULL == (q = SLregexp_quote_string (h->msgid, qregexp, sizeof (qregexp)))) ||
 	    (ch != 'r') ||
-	    (0 != SLang_regexp_compile (&re)))
+#if SLANG_VERSION < 20000
+	    (0 != SLang_regexp_compile (&re))
+#else
+	    (NULL == (re = SLregexp_compile (qregexp, SLREGEXP_CASELESS)))
+#endif
+	    )
 	  {
 	     re_error |= (ch == 'r');
 	     comment = 1;
@@ -234,6 +272,13 @@ int slrn_edit_score (Slrn_Header_Type *h
 	  comment = 0;
 	fprintf (fp, "%c\tReferences: %s\n",
 		 (comment ? '%' : ' '), (q ? q : h->msgid));
+#if SLANG_VERSION >= 20000
+	if (re != NULL)
+	  {
+	     SLregexp_free (re);
+	     re = NULL;
+	  }
+#endif
 	
 	if (NULL != (q = SLregexp_quote_string (h->xref, qregexp, sizeof (qregexp))))
 	  {
diff -Npur slrn-0.9.8.1.orig/src/group.c slrn-0.9.8.1/src/group.c
--- slrn-0.9.8.1.orig/src/group.c	2004-08-15 21:09:31.000000000 +0000
+++ slrn-0.9.8.1/src/group.c	2006-04-04 23:24:19.078909019 +0000
@@ -3,7 +3,7 @@
  This file is part of SLRN.
 
  Copyright (c) 1994, 1999 John E. Davis <davis@space.mit.edu>
- Copyright (c) 2001-2003 Thomas Schultz <tststs@gmx.de>
+ Copyright (c) 2001-2004 Thomas Schultz <tststs@gmx.de>
 
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the Free
@@ -776,15 +776,30 @@ static void toggle_group_formats (void)
 
 int slrn_group_search (char *str, int dir) /*{{{*/
 {
+#if SLANG_VERSION < 20000
    SLsearch_Type st;
+#else
+   SLsearch_Type *st = NULL;
+   unsigned int flags;
+#endif
    Slrn_Group_Type *g;
    int found = 0;
    
    g = Slrn_Group_Current_Group;
    if (g == NULL) return 0;
    
+#if SLANG_VERSION < 20000
    SLsearch_init (str, 1, 0, &st);
-   
+#else
+   flags = SLSEARCH_CASELESS;
+   if (Slrn_UTF8_Mode)
+     flags |= SLSEARCH_UTF8;
+
+   st = SLsearch_new ((SLuchar_Type *) str, flags);
+   if (st == NULL)
+     return 0;
+#endif
+
    do
      {
 	if (dir > 0)
@@ -801,6 +816,7 @@ int slrn_group_search (char *str, int di
 	
 	if ((g->flags & GROUP_HIDDEN) == 0)
 	  {
+#if SLANG_VERSION < 20000
 	     if ((NULL != SLsearch ((unsigned char *) g->group_name,
 				    (unsigned char *) g->group_name + strlen (g->group_name),
 				   &st))
@@ -812,10 +828,25 @@ int slrn_group_search (char *str, int di
 		  found = 1;
 		  break;
 	       }
+#else
+	     if ((NULL != SLsearch_forward (st, (unsigned char *) g->group_name,
+					   (unsigned char *) g->group_name + strlen (g->group_name)))
+		 || ((NULL != g->descript)
+		     && (NULL != SLsearch_forward (st, (unsigned char *) g->descript,
+						  (unsigned char *) g->descript + strlen (g->descript)))))
+	       {
+		  found = 1;
+		  break;
+	       }
+#endif
 	  }
      }
    while (g != Slrn_Group_Current_Group);
    
+#if SLANG_VERSION >= 20000
+   SLsearch_delete (st);
+#endif
+
    Slrn_Group_Current_Group = g;
    find_line_num ();
    return found;
@@ -936,17 +967,17 @@ void slrn_select_next_group (void) /*{{{
    if (Slrn_Group_Current_Group == NULL) 
      return;
    
-   while ((SLang_Error == 0) && (1 == slrn_group_down_n (1)))
+   while ((SLang_get_error () == 0) && (1 == slrn_group_down_n (1)))
      {
 	if (Slrn_Group_Current_Group->unread == 0) 
 	  continue;
 	
 	if (0 == slrn_group_select_group ())
 	  break;
-	else if (SLang_Error == INTRINSIC_ERROR)
+	else if (SLang_get_error () == INTRINSIC_ERROR)
 	  /* all articles killed by scorefile, so proceed */
 	  {
-	     SLang_Error = 0;
+	     SLang_set_error (0);
 	     slrn_clear_message ();
 	  }
      }
@@ -958,7 +989,7 @@ void slrn_select_prev_group (void) /*{{{
    if (Slrn_Group_Current_Group == NULL)
      return;
 
-   while ((SLang_Error == 0) && (1 == slrn_group_up_n (1)))
+   while ((SLang_get_error () == 0) && (1 == slrn_group_up_n (1)))
      {
        if (Slrn_Group_Current_Group->unread == 0)
          continue;
@@ -1410,6 +1441,9 @@ static void subscribe (void) /*{{{*/
      }
    find_line_num ();
    Slrn_Full_Screen_Update = 1;
+#if SLANG_VERSION >= 20000
+   SLregexp_free (re);
+#endif
 }
 
 /*}}}*/
@@ -1479,6 +1513,9 @@ static void unsubscribe (void) /*{{{*/
      }
    find_line_num ();
    Slrn_Full_Screen_Update = 1;
+#if SLANG_VERSION >= 20000
+   SLregexp_free (re);
+#endif
 }
 
 /*}}}*/
@@ -1570,6 +1607,9 @@ static void toggle_list_all_groups1 (int
 	       }
 	     g = g->next;
 	  }
+#if SLANG_VERSION >= 20000
+	SLregexp_free (re);
+#endif
      }
    
    g = Slrn_Group_Current_Group;
@@ -1695,7 +1735,7 @@ void slrn_post_cmd (void) /*{{{*/
 
 #if SLRN_HAS_SLANG
    slrn_run_hooks (HOOK_POST, 0);
-   if (SLang_Error)
+   if (SLang_get_error ())
      return;
 #endif
 
@@ -2062,7 +2102,7 @@ void slrn_init_group_mode (void) /*{{{*/
 #if USE_TEST_FUNCTION
    SLkm_define_key  ("y", (FVOID_STAR) test_function, Slrn_Group_Keymap);
 #endif
-   if (SLang_Error) slrn_exit_error (err);
+   if (SLang_get_error ()) slrn_exit_error (err);
 }
 
 /*}}}*/
@@ -2605,7 +2645,10 @@ static int read_and_parse_newsrc_file (v
 	if ((p == pmax) || (p == vline))
 	  continue;
      
-	vline[vlen-1] = 0;	       /* kill \n and NULL terminate */
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0;
+	else
+	  vline[vlen] = 0;
 
 	if (-1 == add_group (vline, (unsigned int) (p - vline),
 			     ((ch == '!') ? GROUP_UNSUBSCRIBED : 0), 0, 0))
diff -Npur slrn-0.9.8.1.orig/src/hooks.c slrn-0.9.8.1/src/hooks.c
--- slrn-0.9.8.1.orig/src/hooks.c	2002-11-01 12:32:34.000000000 +0000
+++ slrn-0.9.8.1/src/hooks.c	2006-04-04 23:24:19.079908618 +0000
@@ -134,7 +134,7 @@ static int my_SLang_run_hooks(char *hook
 {
    unsigned int i;
 
-   if (SLang_Error) return -1;
+   if (SLang_get_error ()) return -1;
   
    if (0 == SLang_is_defined (hook))
      return 0;
@@ -147,7 +147,7 @@ static int my_SLang_run_hooks(char *hook
           break;
      }
 
-   if (SLang_Error) return -1;
+   if (SLang_get_error ()) return -1;
    return SLang_execute_function (hook);
 }
 
diff -Npur slrn-0.9.8.1.orig/src/interp.c slrn-0.9.8.1/src/interp.c
--- slrn-0.9.8.1.orig/src/interp.c	2004-03-07 17:07:51.000000000 +0000
+++ slrn-0.9.8.1/src/interp.c	2006-04-04 23:24:19.081907817 +0000
@@ -110,7 +110,7 @@ static char **pop_argv_list (unsigned in
       
    if (NULL == (argv = (char **) slrn_malloc (sizeof (char *) * (argc + 1), 1, 1)))
      {
-	SLang_Error = SL_MALLOC_ERROR;
+	SLang_set_error (SL_MALLOC_ERROR);
 	return NULL;
      }
    
@@ -531,17 +531,11 @@ static void definekey (char *fun, char *
 	slrn_error (_("definekey: no such keymap."));
 	return;
      }
-   
-   if ((kmap == Slrn_Keymap_RLI->keymap) &&
-       (NULL == SLang_find_key_function(fun, kmap)))
-     {
-	SLKeymap_Function_Type *tmp = kmap->functions;
-	kmap->functions = Slrn_Custom_Readline_Functions;
-	SLang_define_key (convkey, fun, kmap);
-	kmap->functions = tmp;
-     }
+
+   if (kmap == SLrline_get_keymap (Slrn_Keymap_RLI))
+     (void) slrn_rline_setkey (convkey, fun, kmap);
    else
-     SLang_define_key (convkey, fun, kmap);
+     (void) SLang_define_key (convkey, fun, kmap);
 }
 
 /*}}}*/
@@ -901,7 +895,7 @@ static char *generic_article_as_string (
    
    if (NULL == (s = (char *) SLMALLOC (len + 1)))
      {
-	SLang_Error = SL_MALLOC_ERROR;
+	SLang_set_error (SL_MALLOC_ERROR);
 	return NULL;
      }
    
diff -Npur slrn-0.9.8.1.orig/src/menu.c slrn-0.9.8.1/src/menu.c
--- slrn-0.9.8.1.orig/src/menu.c	2002-06-26 16:57:34.000000000 +0000
+++ slrn-0.9.8.1/src/menu.c	2006-04-04 23:24:19.082907416 +0000
@@ -791,7 +791,7 @@ static int init_select_list_mode (int se
 	adapt_shortcuts ();
      }
    
-   if (SLang_Error)
+   if (SLang_get_error ())
      return -1;
    
    Select_List_Mode_Cap.keymap = *kmap;
diff -Npur slrn-0.9.8.1.orig/src/mime.c slrn-0.9.8.1/src/mime.c
--- slrn-0.9.8.1.orig/src/mime.c	2004-08-14 23:09:20.000000000 +0000
+++ slrn-0.9.8.1/src/mime.c	2006-04-04 23:24:19.084906614 +0000
@@ -458,7 +458,7 @@ static char *decode_utf8 (char *dest, ch
    int ch;
    if (utf8_error != NULL)
      *utf8_error = 0;
-   
+
    while (src < srcmax)
      {
 	if (*src & 0x80)
@@ -512,6 +512,10 @@ int slrn_rfc1522_decode_string (char *s)
 /* Even if some user agents still send raw 8bit, it is safe to call
  * decode_utf8() -- if it finds 8bit chars that are not valid UTF-8, it
  * will set ch to 1 and we can leave the line untouched. */
+#if SLANG_VERSION >= 20000
+   if (Slrn_UTF8_Mode == 0)
+     {
+#endif
    len = strlen (s);
    s1 = slrn_safe_malloc(len + 1);
    
@@ -521,7 +525,10 @@ int slrn_rfc1522_decode_string (char *s)
    if (ch == 0)
      strcpy (s, s1); /* safe */
    slrn_free (s1);
-   
+#if SLANG_VERSION >= 20000
+     }
+#endif
+
    while (1)
      {
 	while ((NULL != (s = slrn_strchr (s, '=')))
@@ -591,8 +598,12 @@ int slrn_rfc1522_decode_string (char *s)
 	  s1 = decode_base64 (s1, txt, s);
 	else s1 = decode_quoted_printable (s1, txt, s, 1, 0);
 	
-	if (slrn_case_strncmp((unsigned char *)"utf-8",
+	if ((slrn_case_strncmp((unsigned char *)"utf-8",
 			      (unsigned char *)charset, 5) == 0)
+#if SLANG_VERSION >= 20000
+	    && (Slrn_UTF8_Mode == 0)
+#endif
+	    )
 	  s1 = decode_utf8 (s2, s2, s1, NULL);
 	
 	/* Now move everything over */
@@ -916,6 +927,9 @@ void slrn_mime_process_article (Slrn_Art
      }
    
    if ((a->mime_needs_metamail == 0) &&
+#if SLANG_VERSION >= 20000
+       (Slrn_UTF8_Mode == 0) &&
+#endif
        (Char_Set != NULL) &&
        (slrn_case_strncmp((unsigned char *)"utf-8",
 			  (unsigned char *)Char_Set, 5) == 0))
@@ -1288,7 +1302,7 @@ static int min_encode (unsigned char *fr
 	  {
 	     len = eword - bword;
 	     if ((int)max < len) return -1;
-	     strncpy (dest, bword, len);
+	     strncpy ((char *)dest, (char *)bword, len);
 	     dest += len; max -= len; total += len;
 	     Keyword_Len = 0;
 	  }
@@ -1330,7 +1344,7 @@ static int encode_quoted_string (unsigne
      {
 	int len = end + 1 - *from;
 	if ((int)max <= len) return -1;
-	strncpy (dest, *from, len);
+	strncpy ((char *)dest, (char *)*from, len);
 	dest[len] = '\0';
 	*from = end + 1;
 	return len;
diff -Npur slrn-0.9.8.1.orig/src/misc.c slrn-0.9.8.1/src/misc.c
--- slrn-0.9.8.1.orig/src/misc.c	2004-09-27 21:30:35.000000000 +0000
+++ slrn-0.9.8.1/src/misc.c	2006-04-04 23:24:19.088905010 +0000
@@ -361,7 +361,7 @@ static void verror (char *fmt, va_list a
 	SLang_flush_input ();
      }
    
-   if (SLang_Error == 0) SLang_Error = INTRINSIC_ERROR;
+   if (SLang_get_error () == 0) SLang_set_error (INTRINSIC_ERROR);
 }
 
 /*}}}*/
@@ -446,17 +446,73 @@ void slrn_error_now (unsigned secs, char
 
 /*}}}*/
 
-/* Wrapper around the SLsmg routine. */
+/* Wrapper around the SLsmg routine.
+ * This writes n screen characters (_not_ bytes).
+ * Assumes that s contains at least n screen characters. If the last
+ * character cannot be fully written, pad with spaces instead.
+ */
 void slrn_write_nchars (char *s, unsigned int n) /*{{{*/
 {
-   unsigned char *s1, *smax;
+   unsigned char *s1;
    unsigned int eight_bit;
+   int len = 0;
+   SLuchar_Type *next = (SLuchar_Type *) s;
+   SLuchar_Type *prev;
+
+#if SLANG_VERSION >= 20000
+   if (Slrn_UTF8_Mode)
+     {
+	/* Skip past n characters. */
+	int prevlen;
+	SLwchar_Type w;
+	
+	while (len<n)
+	  {
+	     int consumed;
+	     SLuchar_Type *post = SLutf8_decode (next, next+SLUTF8_MAX_MBLEN,
+						 &w, &consumed);
+	     prev = next;
+	     prevlen = len;
+	     next += consumed;
+	     if (post != NULL)
+	       len += SLwchar_wcwidth (w);
+	     else
+	       len += 1;
+	  }
+	
+	if (len>n) /* We have to truncate the last character */
+	  {
+	     int i;
+	     SLsmg_write_nchars (s, prev-(SLuchar_Type*)s);
+	     for (i = 0; i < (n-prevlen); i++)
+	       SLsmg_write_nchars (" ", 1);
+	  }
+	else
+	  SLsmg_write_nchars (s, next-(SLuchar_Type*)s);
 
+	return;
+     }
+#endif
+   /* Skip past n characters. */
+   while (len<n)
+     {
+	if (*next < 0x20)
+	  len += 2;
+	else
+	  len += 1;
+	next++;
+     }
+   
+   if (len>n) /* We have to omit the last character */
+     {
+	next--;
+	len -= 2;
+     }
+      
    s1 = (unsigned char *) s;
-   smax = s1 + n;
    eight_bit = SLsmg_Display_Eight_Bit;
    
-   while (s1 < smax)
+   while (s1 < next)
      {
 	if ((*s1 & 0x80) && (eight_bit > (unsigned int) *s1))
 	  {
@@ -471,6 +527,52 @@ void slrn_write_nchars (char *s, unsigne
    
    if (s != (char *)s1)
      SLsmg_write_nchars (s, (unsigned int) ((char *)s1 - s));
+   
+   /* If we omitted the last char, pad with a space. */
+   if (len<n)
+     SLsmg_write_nchars (" ", 1);
+}
+/*}}}*/
+
+/* Find out how many characters (columns) a string would use on screen.
+ * If len>=0, only the first len bytes are examined.
+ */
+static int screen_strlen (char *s, int len) /*{{{*/
+{
+   int retval = 0;
+#if SLANG_VERSION >= 20000
+   if (Slrn_UTF8_Mode)
+     {
+	SLwchar_Type w;
+	SLuchar_Type *next = (SLuchar_Type *) s;
+	SLuchar_Type *end = (SLuchar_Type *) (s + ((len<0) ? strlen(s) : len));
+	
+	while (next < end)
+	  {
+	     int consumed;
+	     SLuchar_Type *past = SLutf8_decode (next, end, &w, &consumed);
+	     next += consumed;
+	     if (past != NULL)
+	       retval += SLwchar_wcwidth (w);
+	     else
+	       retval += 1;
+	  }
+     }
+   else
+#endif
+     {
+	int i;
+	if (len<0)
+	  len = strlen(s);
+	retval = len;
+	for (i = 0; i<len; i++)
+	  {
+	     /* S-Lang uses two characters to represent control chars */
+	     if ((unsigned char) s[i] < 0x20)
+	       retval += 1;
+	  }
+     }
+   return retval;
 }
 /*}}}*/
 
@@ -599,9 +701,12 @@ void slrn_custom_printf (char *fmt, PRIN
 	if (color != def_color)
 	  slrn_set_color (color);
 
-	if (len == -1) len = strlen (s);
+	/* In case of UTF-8 characters, it is important to distinguish between
+	 * the length in bytes and the length in characters. */
+	len = screen_strlen (s, len);
 	if (NULL != (p = slrn_strchr (s, '\n')))
-	  len -= strlen (p);
+	  len -= screen_strlen (p, -1);
+	
 	if (field_len != -1)
 	  {
 	     int i;
@@ -610,17 +715,6 @@ void slrn_custom_printf (char *fmt, PRIN
 	       spaces = field_len - len;
 	     else
 	       len = field_len;
-	     
-	     for (i = 0; i < len; i++)
-	       {
-		  /* S-Lang uses two characters to represent control chars */
-		  if ((unsigned char) s[i] < 0x20)
-		    {
-		       if (spaces) spaces--;
-		       else len--;
-		    }
-	       }
-	     if (i == len + 1) spaces = 1;
 	  }
 	if (justify)
 	  {
@@ -1165,8 +1259,11 @@ int slrn_mail_file (char *file, int edit
 	     if (vlen == 0) continue;
 	     
 	     line = slrn_safe_malloc (vlen+512); /* add some for MIME overhead */
-	     slrn_strncpy (line, vline, vlen);
-	     line[vlen-1] = 0;		/* kill \n and NULL terminate */
+	     strncpy (line, vline, vlen);
+	     if (line[vlen-1] == '\n')
+	       line[vlen-1] = 0;
+	     else
+	       line[vlen] = 0;
 
 	     if (header)
 	       {
@@ -1568,6 +1665,7 @@ int slrn_edit_file (char *editor, char *
 
 /*{{{ Get Input From User Related Functions */
 
+#if SLANG_VERSION < 20000
 static void rline_update (unsigned char *buf, int len, int col) /*{{{*/
 {
    slrn_push_suspension (0);
@@ -1580,6 +1678,28 @@ static void rline_update (unsigned char 
 }
 
 /*}}}*/
+#else
+static void rline_update (SLrline_Type *rli, char *prompt, 
+			  char *buf, unsigned int len, unsigned int point,
+			  VOID_STAR client_data)
+{
+   int col;
+
+   (void) client_data;
+   (void) rli;
+   slrn_push_suspension (0);
+   SLsmg_gotorc (SLtt_Screen_Rows - 1, 0);
+   SLsmg_write_string (prompt);
+   SLsmg_write_nchars (buf, point);
+   col = SLsmg_get_column ();
+   SLsmg_write_nchars (buf + point, len - point);
+   SLsmg_erase_eol ();
+   SLsmg_gotorc (SLtt_Screen_Rows - 1, col);
+   slrn_smg_refresh ();
+   slrn_pop_suspension ();
+}
+
+#endif
 
 /* If 1, redraw read_line.  If 2, redraw message */
 static int Reading_Input;
@@ -1596,6 +1716,7 @@ static void redraw_mini_buffer (void) /*
 
 static SLang_RLine_Info_Type *init_readline (void) /*{{{*/
 {
+#if SLANG_VERSION < 20000
    unsigned char *buf;
    SLang_RLine_Info_Type *rli;
    
@@ -1629,6 +1750,19 @@ static SLang_RLine_Info_Type *init_readl
      }
    
    return rli;
+#else				       /* slang 2 */
+   SLrline_Type *rli;
+   unsigned int flags = SL_RLINE_BLINK_MATCH;
+   
+   if (Slrn_UTF8_Mode)
+     flags |= SL_RLINE_UTF8_MODE;
+
+   if (NULL == (rli = SLrline_open (SLtt_Screen_Cols, flags)))
+     return NULL;
+   
+   (void) SLrline_set_update_hook (rli, rline_update, NULL);
+   return rli;
+#endif
 }
 
 /*}}}*/
@@ -1815,21 +1949,89 @@ static void rli_self_insert (void) /*{{{
    char last_char [2];
    last_char[0] = (char) SLang_Last_Key_Char;
    last_char[1] = '\0';
+#if SLANG_VERSION >= 20000
+   (void) SLrline_ins (Slrn_Keymap_RLI, last_char, 1);
+#else
    SLang_rline_insert (last_char);
+#endif
    SLrline_redraw (Slrn_Keymap_RLI);
 }
 /*}}}*/
 
+#if SLANG_VERSION < 20000
+static int SLrline_get_point (SLrline_Type *rli, unsigned int *p)
+{
+   *p = rli->point;
+   return 0;
+}
+static int SLrline_set_point (SLrline_Type *rli, unsigned int p)
+{
+   rli->point = p;
+   return 0;
+}
+
+static char *SLrline_get_line (SLrline_Type *rli)
+{
+   return SLmake_string (rli->buf);
+}
+static int SLrline_set_line (SLrline_Type *rli, char *buf)
+{
+   slrn_strncpy ((char *)rli->buf, buf, rli->buf_len);
+   return 0;
+}
+
+static int SLrline_save_line (SLrline_Type *rli)
+{
+   (void) SLang_rline_save_line (rli);
+   return 0;
+}
+
+static int SLrline_set_echo (SLrline_Type *rli, int state)
+{
+# ifdef SL_RLINE_NO_ECHO
+   if (state == 0)
+     rli->flags |= SL_RLINE_NO_ECHO;
+   else
+     rli->flags &= ~SL_RLINE_NO_ECHO;
+# endif
+   return 0;
+}
+
+static char *SLrline_read_line (SLrline_Type *rli, char *prompt, unsigned int *lenp)
+{
+   int i;
+   
+   rli->prompt = prompt;
+   i = SLang_read_line (rli);
+   if (i < 0)
+     {
+	*lenp = 0;
+	return NULL;
+     }
+   *lenp = i;
+   return SLmake_string (rli->buf);
+}
+
+SLkeymap_Type *SLrline_get_keymap (SLrline_Type *rli)
+{
+   return rli->keymap;
+}
+#endif
+
 static void generic_mini_complete (int cycle) /*{{{*/
 {
    char *pl, *pb;
    char last[SLRN_MAX_PATH_LEN], buf[SLRN_MAX_PATH_LEN];
    static char prev[SLRN_MAX_PATH_LEN], prevcall[SLRN_MAX_PATH_LEN];
-   int n, repeat = 1; /* whether we are called with identical values again */
-   static int flag = 0, lastpoint = 0;  /* when flag goes 0, we call open */
+   int repeat = 1; /* whether we are called with identical values again */
+   unsigned int n;
+   static int flag = 0;  /* when flag goes 0, we call open */
+   static unsigned int lastpoint = 0;
    char **argv = NULL;
    unsigned int argc = 0, maxargc = 0;
-   
+   unsigned int point;
+   char *rli_buf;
+
    if (Complete_Open == NULL)
      {
 	rli_self_insert ();
@@ -1837,19 +2039,29 @@ static void generic_mini_complete (int c
      }
    
    n = sizeof (buf);
-   if (Slrn_Keymap_RLI->point < n)
-     n = Slrn_Keymap_RLI->point + 1;
-   slrn_strncpy (buf, (char *) Slrn_Keymap_RLI->buf, n);
+   (void) SLrline_get_point (Slrn_Keymap_RLI, &point);
+   if (point < n)
+     n = point + 1;
+
+   rli_buf = SLrline_get_line (Slrn_Keymap_RLI);   /* malloced pointer */
+   if (rli_buf == NULL)
+     return;
+
+   slrn_strncpy (buf, rli_buf, n);
    n = 0;
    
-   if (strcmp (Slrn_Keymap_RLI->buf, prevcall) ||
-       (Slrn_Keymap_RLI->point != lastpoint) ||
+   if (strcmp (rli_buf, prevcall) ||
+       (point != lastpoint) ||
        (0 == In_Completion))
      {
-	strcpy (prev, buf); /* safe */ /* save this search context */
+	slrn_strncpy (prev, buf, sizeof(prev));
+	/* strcpy (prev, buf); */ /* safe */ /* save this search context */
 	flag = 0;
 	repeat = 0;
      }
+   
+   SLfree (rli_buf); rli_buf = NULL;
+
    if (In_Completion == 2)
      repeat = 0;
    
@@ -1948,11 +2160,10 @@ static void generic_mini_complete (int c
 		  last[len+1] = 0;
 	       }
 	  }
-	
-	slrn_strncpy ((char *) Slrn_Keymap_RLI->buf, last,
-		      Slrn_Keymap_RLI->buf_len);
-	len = strlen ((char *) Slrn_Keymap_RLI->buf);
-	Slrn_Keymap_RLI->len = Slrn_Keymap_RLI->point = len;
+
+	if (-1 == SLrline_set_line (Slrn_Keymap_RLI, last))
+	  return;
+
 	SLrline_redraw (Slrn_Keymap_RLI);
      }
    else SLtt_beep();
@@ -1962,15 +2173,22 @@ static void generic_mini_complete (int c
    
    slrn_free_argc_argv_list (argc, argv);
    slrn_free ((char *) argv);
-   slrn_strncpy (prevcall, (char *) Slrn_Keymap_RLI->buf, sizeof (prevcall));
-   lastpoint = Slrn_Keymap_RLI->point;
+   rli_buf = SLrline_get_line (Slrn_Keymap_RLI);
+   if (rli_buf == NULL)
+     {
+	In_Completion = 0;
+	return;
+     }
+   slrn_strncpy (prevcall, rli_buf, sizeof (prevcall));
+   SLfree (rli_buf);
+   (void) SLrline_get_point (Slrn_Keymap_RLI, &lastpoint);
    In_Completion = cycle ? 2 : 1;
    
    return;
 }
 
 /*}}}*/
-
+#if SLANG_VERSION < 20000
 static int mini_complete (void)
 {
    generic_mini_complete (0);
@@ -1982,7 +2200,6 @@ static int mini_cycle (void)
    generic_mini_complete (1);
    return 0;
 }
-
 static int rli_del_bol (void) /*{{{*/
 {
    unsigned char *d, *s;
@@ -2026,9 +2243,74 @@ static int rli_del_bow (void) /*{{{*/
 }
 /*}}}*/
 
+#else
+static int mini_complete (SLrline_Type *rli)
+{
+   (void) rli;
+   generic_mini_complete (0);
+   return 0;
+}
+
+static int mini_cycle (SLrline_Type *rli)
+{
+   (void) rli;
+   generic_mini_complete (1);
+   return 0;
+}
+
+static int rli_del_bol (SLrline_Type *rli) /*{{{*/
+{
+   unsigned int point;
+   
+   (void) SLrline_get_point (rli, &point);
+   (void) SLrline_set_point (rli, 0);
+   (void) SLrline_del (rli, point);
+   return 0;
+}
+/*}}}*/
+
+static int rli_del_bow (SLrline_Type *rli) /*{{{*/
+{
+   char *buf, *b;
+   unsigned int point;
+   unsigned int len;
+
+   (void) SLrline_get_point (rli, &point);
+   if (point == 0)
+     return 0;
+
+   if (NULL == (buf = SLrline_get_line (rli)))
+     return -1;
+   
+   b = buf + (point - 1);
+   while ((b > buf) && ((*b == ' ') || (*b == '\t')))
+     b--;
+
+   while (b > buf)
+     {
+	if ((*b == ' ') || (*b == '\t'))
+	  {
+	     b++;
+	     break;
+	  }
+	b--;
+     }
+   
+   len = point;
+   point = b - buf;
+   (void) SLrline_set_point (rli, point);
+   (void) SLrline_del (rli, len - point);
+   
+   SLfree (buf);
+   return 0;
+}
+/*}}}*/
+
+#endif
+
 #define A_KEY(s, f)  {s, (int (*)(void)) f}
 
-SLKeymap_Function_Type Slrn_Custom_Readline_Functions [] =
+static SLKeymap_Function_Type Slrn_Custom_Readline_Functions [] =
 {
    A_KEY("complete", mini_complete),
    A_KEY("cycle", mini_cycle),
@@ -2037,6 +2319,23 @@ SLKeymap_Function_Type Slrn_Custom_Readl
    A_KEY(NULL, NULL)
 };
 
+int slrn_rline_setkey (char *key, char *fun, SLkeymap_Type *kmap)
+{
+   SLKeymap_Function_Type *tmp;
+   int failure;
+
+   if (NULL != SLang_find_key_function(fun, kmap))
+     return SLang_define_key (key, fun, kmap);
+       
+   tmp = kmap->functions;
+   kmap->functions = Slrn_Custom_Readline_Functions;
+   failure = SLang_define_key (key, fun, kmap);
+   kmap->functions = tmp;
+   
+   return failure;
+}
+
+
 /* str needs to have enough space for SLRL_DISPLAY_BUFFER_SIZE characters */
 static int generic_read_input (char *prompt, char *dfl, char *str, int trim_flag, 
 			       int no_echo, int point) /*{{{*/
@@ -2044,6 +2343,7 @@ static int generic_read_input (char *pro
    int i;
    int tt_init_state;
    char prompt_buf[SLRL_DISPLAY_BUFFER_SIZE];
+   char *buf;
    unsigned int len;
    int save_slang_error;
    
@@ -2065,23 +2365,25 @@ static int generic_read_input (char *pro
 
    if ((str == NULL) && (dfl == NULL)) return -1;
    
+#if SLANG_VERSION < 20000
    Slrn_Keymap_RLI->edit_width = SLtt_Screen_Cols - 1;
    if (Slrn_Keymap_RLI->edit_width > Slrn_Keymap_RLI->buf_len)
 	   Slrn_Keymap_RLI->edit_width = Slrn_Keymap_RLI->buf_len;
-
-   Slrn_Keymap_RLI->prompt = prompt;
    *Slrn_Keymap_RLI->buf = 0;
+#else
+   SLrline_set_display_width (Slrn_Keymap_RLI, SLtt_Screen_Cols);
+#endif
+
 
    /* slrn_set_suspension (1); */   
 
    if ((str != NULL) && *str)
      {
-	slrn_strncpy ((char *) Slrn_Keymap_RLI->buf, str,
-		      Slrn_Keymap_RLI->buf_len);
+	if (-1 == SLrline_set_line (Slrn_Keymap_RLI, str))
+	  return -1;
+	
 	if (point == 0)
-	  Slrn_Keymap_RLI->point = 0;
-	else
-	  Slrn_Keymap_RLI->point = strlen (str);
+	  SLrline_set_point (Slrn_Keymap_RLI, 0);
 
 	*str = 0;
      }
@@ -2095,44 +2397,43 @@ static int generic_read_input (char *pro
    slrn_set_display_state (Slrn_TT_Initialized | SLRN_TTY_INIT);
    
    if (no_echo)
-     {
-#ifdef SL_RLINE_NO_ECHO
-	Slrn_Keymap_RLI->flags |= SL_RLINE_NO_ECHO;
-#endif
-     }
+     SLrline_set_echo (Slrn_Keymap_RLI, 0);
    else
-     {
-#ifdef SL_RLINE_NO_ECHO
-	Slrn_Keymap_RLI->flags &= ~SL_RLINE_NO_ECHO;
-#endif
-     }
+     SLrline_set_echo (Slrn_Keymap_RLI, 1);
 
+#if SLANG_VERSION < 20000
    if (tt_init_state & SLRN_SMG_INIT)
      Slrn_Keymap_RLI->update_hook = rline_update;
    else
      Slrn_Keymap_RLI->update_hook = NULL;
-
+#else
+   if (tt_init_state & SLRN_SMG_INIT)
+     (void) SLrline_set_update_hook (Slrn_Keymap_RLI, rline_update, NULL);
+   else
+     (void) SLrline_set_update_hook (Slrn_Keymap_RLI, NULL, NULL);
+#endif
    slrn_enable_mouse (0);
    
    
-   save_slang_error = SLang_Error;
-   SLang_Error = 0;
+   save_slang_error = SLang_get_error ();
+   SLang_set_error (0);
 
    Reading_Input = 1;
    slrn_set_color (MESSAGE_COLOR);
-   i = SLang_read_line (Slrn_Keymap_RLI);
+
+   buf = SLrline_read_line (Slrn_Keymap_RLI, prompt, &len);
    slrn_set_color (0);
    Reading_Input = 0;
    
    slrn_enable_mouse (1);
    
-   if ((i >= 0) && !SLang_Error && !SLKeyBoard_Quit)
+   if ((buf != NULL) && (0 == SLang_get_error ()) && !SLKeyBoard_Quit)
      {
-	char *b = (char *) Slrn_Keymap_RLI->buf;
-	
-	if (*b) 
+	char *b = buf;
+
+	if (*b)
 	  {
-	     if (no_echo == 0) SLang_rline_save_line (Slrn_Keymap_RLI);
+	     if (no_echo == 0) SLrline_save_line (Slrn_Keymap_RLI);
 	     if (trim_flag) 
 	       {
 		  slrn_trim_string (b);
@@ -2143,13 +2444,18 @@ static int generic_read_input (char *pro
 
 	/* b could be equal to dfl and dfl could be equal to str.  If this is
 	 * the case, there is no need to perform the strcpy */
-	if (b != str) strcpy (str, b); /* safe */
+	if (b != str) 
+	  slrn_strncpy (str, b, SLRL_DISPLAY_BUFFER_SIZE); /* safe */
+
 	i = strlen (str);
      }
+   else i = -1;
    
+   SLfree (buf);
+
    if (SLKeyBoard_Quit) i = -1;
    SLKeyBoard_Quit = 0;
-   SLang_Error = save_slang_error;
+   SLang_set_error (save_slang_error);
    
    slrn_set_display_state (tt_init_state);
 
@@ -2242,7 +2548,7 @@ int slrn_init_readline (void) /*{{{*/
        && (NULL == (Slrn_Keymap_RLI = init_readline ())))
      return -1;
    
-   Slrn_RLine_Keymap = Slrn_Keymap_RLI->keymap;
+   Slrn_RLine_Keymap = SLrline_get_keymap (Slrn_Keymap_RLI);
    SLkm_define_key ("\t", (FVOID_STAR) mini_complete, Slrn_RLine_Keymap);   
    SLkm_define_key (" ", (FVOID_STAR) mini_cycle, Slrn_RLine_Keymap);
    SLkm_define_key ("^U", (FVOID_STAR) rli_del_bol, Slrn_RLine_Keymap);
@@ -2312,7 +2618,8 @@ char slrn_get_response (char *valid_char
 		  Reading_Input = 0;
 	     
 		  slrn_clear_message ();
-		  SLang_Error = SLKeyBoard_Quit = 0;
+		  SLang_set_error (0);
+		  SLKeyBoard_Quit = 0;
 	       }
 	  }
 
@@ -2415,8 +2722,8 @@ int slrn_get_yesno_cancel (char *str, ..
    char *responses=_("yYnNcC");
    if (strlen (responses) != 6)
      responses = "";
-   
-   if (SLang_Error) return -1;
+
+   if (SLang_get_error ()) return -1;
    
    va_start(ap, str);
    (void) slrn_vsnprintf(buf, sizeof(buf), str, ap);
@@ -2458,7 +2765,7 @@ void slrn_evaluate_cmd (void) /*{{{*/
 	SLang_load_string (buf);
      }
    
-   SLang_Error = 0;
+   SLang_set_error (0);
 }
 /*}}}*/
 
@@ -2468,6 +2775,7 @@ void slrn_evaluate_cmd (void) /*{{{*/
 
 SLRegexp_Type *slrn_compile_regexp_pattern (char *pat) /*{{{*/
 {
+#if SLANG_VERSION < 20000
    static unsigned char compiled_pattern_buf [512];
    static SLRegexp_Type re;
    
@@ -2482,19 +2790,35 @@ SLRegexp_Type *slrn_compile_regexp_patte
 	return NULL;
      }
    return &re;
+#else
+   SLRegexp_Type *re;
+   unsigned int flags = SLREGEXP_CASELESS;
+
+   if (Slrn_UTF8_Mode) flags |= SLREGEXP_UTF8;
+   if (NULL == (re = SLregexp_compile (pat, flags)))
+     {
+	slrn_error (_("Invalid regular expression or expression too long."));
+	return NULL;
+     }
+   return re;
+#endif
 }
 
 /*}}}*/
 
 unsigned char *slrn_regexp_match (SLRegexp_Type *re, char *str) /*{{{*/
 {
+#if SLANG_VERSION < 20000
    unsigned int len;
-   
+
    if ((str == NULL)
        || (re->min_length > (len = strlen (str))))
      return NULL;
-   
+
    return SLang_regexp_match ((unsigned char *)str, len, re);
+#else
+   return (unsigned char *)SLregexp_match (re, str, strlen (str));
+#endif
 }
 
 /*}}}*/
@@ -2880,3 +3204,15 @@ char *slrn_make_from_string (void)
      }
    return buf;
 }
+
+#if SLANG_VERSION < 20000
+int SLang_get_error (void)
+{
+   return SLang_Error;
+}
+int SLang_set_error (int err)
+{
+   SLang_Error = err;
+   return 0;
+}
+#endif
diff -Npur slrn-0.9.8.1.orig/src/misc.h slrn-0.9.8.1/src/misc.h
--- slrn-0.9.8.1.orig/src/misc.h	2004-03-02 20:48:27.000000000 +0000
+++ slrn-0.9.8.1/src/misc.h	2006-04-04 23:24:19.089904609 +0000
@@ -63,6 +63,7 @@ extern int slrn_check_batch (void);
 
 extern unsigned char *slrn_regexp_match (SLRegexp_Type *, char *);
 extern SLRegexp_Type *slrn_compile_regexp_pattern (char *);
+extern SLRegexp_Type *slrn_free_regexp (SLRegexp_Type *);
 
 #define MAX_HOST_NAME_LEN 256
 typedef struct
@@ -109,9 +110,19 @@ extern void slrn_get_mouse_rc (int *, in
 #ifndef VMS
 extern char *Slrn_SendMail_Command;
 #endif
+
+#if SLANG_VERSION < 20000
+extern int SLang_get_error (void);
+extern int SLang_set_error (int);
+typedef struct SLKeyMap_List_Type SLkeymap_Type;
+typedef SLang_RLine_Info_Type SLrline_Type;
+extern SLkeymap_Type *SLrline_get_keymap (SLrline_Type *);
+typedef unsigned char SLuchar_Type;
+#endif
+
 extern SLKeyMap_List_Type *Slrn_RLine_Keymap;
 extern SLang_RLine_Info_Type *Slrn_Keymap_RLI;
-extern SLKeymap_Function_Type Slrn_Custom_Readline_Functions [];
+extern int slrn_rline_setkey (char *, char *, SLkeymap_Type *);
 
 extern void slrn_va_message (char *, va_list);
 
@@ -139,4 +150,5 @@ extern char *Slrn_Failed_Post_Filename;
 extern char *Slrn_Top_Status_Line;
 
 extern int Slrn_Abort_Unmodified;
+
 #endif				       /* _SLRN_MISC_H */
diff -Npur slrn-0.9.8.1.orig/src/nntp.c slrn-0.9.8.1/src/nntp.c
--- slrn-0.9.8.1.orig/src/nntp.c	2004-08-15 21:07:25.000000000 +0000
+++ slrn-0.9.8.1/src/nntp.c	2006-04-04 23:24:19.090904209 +0000
@@ -73,7 +73,7 @@ static int _nntp_interrupt_handler (void
 {
    (void) slrn_handle_interrupts ();
 
-   if ((SLang_Error == USER_BREAK) || SLKeyBoard_Quit)
+   if ((SLang_get_error () == USER_BREAK) || SLKeyBoard_Quit)
      return -1;
 
    return 0;
@@ -367,16 +367,29 @@ static char * _nntp_get_recom_id (void)
    
    if ((re=slrn_compile_regexp_pattern("<.*@.*\\..*>")) != NULL)
      {
-	char *t, *msgid, *post_rsp;
+	char *t, *msgid = NULL, *post_rsp;
 	post_rsp = NNTP_Server->rspbuf;
+#if SLANG_VERSION < 20000
 	t=(char*)SLang_regexp_match((unsigned char*) post_rsp,
 				    strlen(post_rsp), re);
+#else
+	t = SLregexp_match (re, post_rsp, strlen (post_rsp));
+#endif
 	if (t != NULL)
 	  {
-	     if ((msgid=slrn_strnmalloc(t, re->end_matches[0],1)) == NULL)
-	       return NULL;
-	     return msgid;
+	     unsigned int len;
+#if SLANG_VERSION < 20000
+	     len = re->end_matches[0];
+#else
+	     (void) SLregexp_nth_match (re, 0, NULL, &len);
+#endif
+	     
+	     msgid=slrn_strnmalloc(t, len, 1);
 	  }
+#if SLANG_VERSION >= 20000
+	SLregexp_free (re);
+#endif
+	return msgid;
      }
    return NULL;
 }
diff -Npur slrn-0.9.8.1.orig/src/nntplib.c slrn-0.9.8.1/src/nntplib.c
--- slrn-0.9.8.1.orig/src/nntplib.c	2004-08-15 21:07:43.000000000 +0000
+++ slrn-0.9.8.1/src/nntplib.c	2006-04-04 23:24:19.091903808 +0000
@@ -209,6 +209,7 @@ static int _nntp_try_parse_timeout (char
    /* Some servers now have NLS, so this might fail.
     * I'm trying to handle that case in nntp_server_cmd.
     */
+#if SLANG_VERSION < 20000
    static SLRegexp_Type re;
    unsigned char compiled_pattern_buf[256];
 
@@ -220,8 +221,19 @@ static int _nntp_try_parse_timeout (char
    (void) SLang_regexp_compile (&re);
    if (NULL == SLang_regexp_match ((unsigned char *) str, strlen (str), &re))
      return -1;
-
    return 0;
+#else
+   int status = -1;
+   SLRegexp_Type *re = SLregexp_compile ("time.*out", SLREGEXP_CASELESS);
+   if (re != NULL)
+     {
+	if (NULL != SLregexp_match (re, str, strlen (str)))
+	  status = 0;
+	
+	SLregexp_free (re);
+     }
+   return status;
+#endif
 }
 
 int nntp_get_server_response (NNTP_Type *s)
diff -Npur slrn-0.9.8.1.orig/src/post.c slrn-0.9.8.1/src/post.c
--- slrn-0.9.8.1.orig/src/post.c	2004-09-28 09:05:54.000000000 +0000
+++ slrn-0.9.8.1/src/post.c	2006-04-04 23:24:19.093903006 +0000
@@ -467,7 +467,10 @@ static int cc_file (char *file, char *to
    linenum = 0;
    while ((NULL != (vline = vgets (vp, &vlen))) && (*vline != '\n'))
      {
-	vline[vlen-1] = 0;
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0;
+	else
+	  vline[vlen] = 0;
 	linenum++;
 	if (0 == slrn_case_strncmp ((unsigned char *)vline,
 				    (unsigned char *) "Cc: ", 4))
@@ -540,7 +543,10 @@ static int cc_file (char *file, char *to
 
    while ((NULL != (vline = vgets (vp, &vlen))) && (*vline != '\n'))
      {
-	vline[vlen-1] = 0;
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0;
+	else
+	  vline[vlen] = 0;	
 	linenum++;
 	if (linenum == cc_line) continue;
 	if (is_empty_header (vline)) continue;
@@ -593,7 +599,10 @@ static int cc_file (char *file, char *to
 
    while (NULL != (vline = vgets (vp, &vlen)))
      {
-	vline[vlen-1] = 0;
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0;
+	else
+	  vline[vlen] = 0;	
 	fputs (vline, pp);
 	fputs ("\n", pp);
      }
@@ -1238,7 +1247,7 @@ static int post_user_confirm (char *file
 	     if (filter_hook != 0)
 	       {
                   slrn_run_hooks (HOOK_POST_FILTER, 1, file);
-		  if (SLang_Error)
+		  if (SLang_get_error ())
 		    filter_hook = 0;
 	       }
 #endif
@@ -1331,7 +1340,7 @@ int slrn_post_file (char *file, char *to
    if (1 == slrn_is_hook_defined (HOOK_POST_FILE))
      {
 	(void) slrn_run_hooks (HOOK_POST_FILE, 1, file);
-	if (SLang_Error)
+	if (SLang_get_error ())
 	  {
 	     if (!Slrn_Editor_Uses_Mime_Charset)
 	       slrn_chmap_fix_file (file, 1);
@@ -1411,8 +1420,11 @@ int slrn_post_file (char *file, char *to
 	if (vlen == 0) continue;
 
 	linep = slrn_safe_malloc (vlen+512); /* add some for MIME overhead */
-	slrn_strncpy (linep, vline, vlen);
-	linep[vlen-1] = 0;	/* kill \n and NULL terminate */
+	strncpy (linep, vline, vlen);
+	if (linep[vlen-1] == '\n')
+	  linep[vlen-1] = 0;	/* kill \n and NULL terminate */
+	else
+	  linep[vlen] = 0;
 	
 	if (header)
 	  {
@@ -1531,7 +1543,8 @@ int slrn_post_file (char *file, char *to
 	/* slrn_set_suspension (0); */
 	slrn_smg_refresh ();
 	slrn_sleep (2);
-	slrn_clear_message (); SLang_Error = 0;
+	slrn_clear_message (); 
+	SLang_set_error (0);
 
 	/* Note to translators: Here, "rR" is "repost", "eE" is "edit" and
 	 * "cC" is "cancel". Don't change the length of the string; you
diff -Npur slrn-0.9.8.1.orig/src/score.c slrn-0.9.8.1/src/score.c
--- slrn-0.9.8.1.orig/src/score.c	2003-11-13 09:15:29.000000000 +0000
+++ slrn-0.9.8.1/src/score.c	2006-04-04 23:24:19.095902204 +0000
@@ -116,8 +116,12 @@ PScore_Type;
 
 typedef struct
 {
+#if SLANG_VERSION < 20000
    SLRegexp_Type regexp;
    unsigned char buf[512];	       /* for compiled pattern */
+#else
+   SLRegexp_Type *regexp;
+#endif
 }
 Our_SLRegexp_Type;
 
@@ -132,7 +136,11 @@ typedef struct Score_Regexp_Type
      {
 	int ival;		       /* used by certain headers */
 	Our_SLRegexp_Type re;
+#if SLANG_VERSION < 20000
 	SLsearch_Type se;
+#else
+	SLsearch_Type *se;
+#endif
 	struct Score_Regexp_Type *srt;
      }
    search;
@@ -153,7 +161,11 @@ Score_Type;
 
 typedef struct Group_Score_Name_Type
 {
+#if SLANG_VERSION < 20000
    SLRegexp_Type group_regexp;
+#else
+   SLRegexp_Type *group_regexp;
+#endif
    char name[MAX_GROUP_NAME_LEN];      /* group name or pattern */
    unsigned char buf[MAX_GROUP_REGEXP_SIZE];/* for compiled pattern */
    struct Group_Score_Name_Type *next;
@@ -327,7 +339,7 @@ static int match_srt (Slrn_Header_Type *
           }
 
         len = strlen (s);
-
+#if SLANG_VERSION < 20000
         if (srt->do_osearch)
           {
              SLsearch_Type *se = &srt->search.se;
@@ -350,12 +362,17 @@ static int match_srt (Slrn_Header_Type *
                }
           }
         else
+#endif
           {
              SLRegexp_Type *re;
-
+#if SLANG_VERSION < 20000
              re = &srt->search.re.regexp;
              if ((len < re->min_length)
                  || (NULL == SLang_regexp_match ((unsigned char *)s, len, re)))
+#else
+	     re = srt->search.re.regexp;
+	     if (NULL == SLregexp_match (re, s, len))
+#endif
                {
                   if (srt->not_flag == 0)
                     {
@@ -463,8 +480,6 @@ int slrn_score_header (Slrn_Header_Type 
 static int compile_psrt (PScore_Regexp_Type *psrt, Score_Regexp_Type *srt,
 			 int *generic)
 {
-   SLRegexp_Type *re;
-
    while (psrt != NULL)
      {
         unsigned int flags = psrt->flags;
@@ -497,23 +512,28 @@ static int compile_psrt (PScore_Regexp_T
                }
              else
                {
-                  re = &srt->search.re.regexp;
+#if SLANG_VERSION < 20000
+		  SLRegexp_Type *re = &srt->search.re.regexp;
                   re->pat = psrt->ireg.regexp_str;
                   re->buf = srt->search.re.buf;
                   re->buf_len = sizeof (srt->search.re.buf);
                   re->case_sensitive = 0;
-
-                  if (0 != SLang_regexp_compile(re))
+		  if (0 != SLang_regexp_compile(re))
                     {
                        return -1;
                     }
-
+#else
+		  if (NULL == (srt->search.re.regexp = SLregexp_compile ((char *) psrt->ireg.regexp_str, SLREGEXP_CASELESS)))
+		    return -1;
+#endif
+#if SLANG_VERSION < 20000
                   /* If an ordinary search is ok, use it. */
                   if (re->osearch)
                     {
                        srt->do_osearch = 1;
                        SLsearch_init ((char *) psrt->ireg.regexp_str, 1, 0, &srt->search.se);
                     }
+#endif
                }
           }
 		
@@ -558,14 +578,53 @@ static int chain_group_regexp (PScore_Ty
 
 char *Slrn_Scorefile_Open = NULL;
 
+static void free_srt (Score_Regexp_Type *);
+static void free_srt_internal (Score_Regexp_Type *srt)
+{
+   if (srt == NULL)
+     return;
+
+   switch (srt->header_type)
+     {
+      case SCORE_LINES:
+      case SCORE_BYTES:
+      case SCORE_HAS_BODY:
+      case SCORE_AGE:
+	/* Use integer or boolean comparisons */
+	break;
+
+      case SCORE_SUB_AND:
+      case SCORE_SUB_OR:
+	free_srt (srt->search.srt);
+	break;
+	     
+      case SCORE_SUBJECT:
+      case SCORE_FROM:
+      case SCORE_DATE:
+      case SCORE_MESSAGE_ID:
+      case SCORE_XREF:
+      case SCORE_REFERENCES:
+      case SCORE_NEWSGROUP:
+      case SCORE_GENERIC:
+#if SLANG_VERSION >= 20000
+	if (srt->do_osearch)
+	  {
+	     if (srt->search.se != NULL)
+	       SLsearch_delete (srt->search.se);
+	  }
+	else if (srt->search.re.regexp != NULL)
+	  SLregexp_free (srt->search.re.regexp);
+#endif
+	break;
+     }
+}
+
 static void free_srt (Score_Regexp_Type *srt)
 {
    while (srt != NULL)
      {
 	Score_Regexp_Type *srt_next = srt->next;
-	if ((srt->header_type == SCORE_SUB_AND) || 
-	    (srt->header_type == SCORE_SUB_OR))
-	  free_srt (srt->search.srt);
+	free_srt_internal (srt);
 	SLFREE (srt);
 	srt = srt_next;
      }
@@ -580,9 +639,8 @@ static void free_group_chain (void)
 	Score_Type *next = Score_Root->next;
 	srt = &Score_Root->regexp_list;
 	/* first not malloced; free subscores only: */
-	if ((srt->header_type == SCORE_SUB_AND) ||
-	    (srt->header_type == SCORE_SUB_OR))
-	  free_srt (srt->search.srt);
+	free_srt_internal (srt);
+
 	free_srt (srt->next);
 	SLFREE (Score_Root);
 	Score_Root = next;
@@ -625,10 +683,14 @@ int slrn_open_score (char *group_name)
 	match = 0;
 	while ((gsnt != NULL) && (match == 0))
 	  {
+#if SLANG_VERSION < 20000
 	     SLRegexp_Type *re = &gsnt->group_regexp;
 
 	     match = ((re->min_length <= n)
 		      && (NULL != SLang_regexp_match ((unsigned char *) group_name, n, re)));
+#else
+	     match = (NULL != SLregexp_match (gsnt->group_regexp, group_name, n));
+#endif
 	     gsnt = gsnt->next;
 	  }
 
@@ -725,8 +787,9 @@ static int compile_group_names (char *gr
    comma = group;
    while (comma != NULL)
      {
+#if SLANG_VERSION < 20000
 	SLRegexp_Type *re;
-	
+#endif
 	group = slrn_skip_whitespace (group);
 	
 	comma = slrn_strchr ((char *) group, ',');
@@ -754,6 +817,7 @@ static int compile_group_names (char *gr
 	strncpy (gsnt->name, group, MAX_GROUP_NAME_LEN - 1);
 	/* Note: because of the memset, this string is null terminated. */
    
+#if SLANG_VERSION < 20000
 	re = &gsnt->group_regexp;
 	re->pat = (unsigned char *) slrn_fix_regexp ((char *)group);
 	re->buf = gsnt->buf;
@@ -763,7 +827,10 @@ static int compile_group_names (char *gr
 	  {
 	     return -1;
 	  }
-	
+#else
+	if (NULL == (gsnt->group_regexp = SLregexp_compile (slrn_fix_regexp ((char *)group), SLREGEXP_CASELESS)))
+	  return -1;
+#endif
 	if (comma != NULL)
 	  {
 	     Group_Score_Name_Type *gsnt1;
@@ -870,6 +937,10 @@ static void free_group_scores (void)
 	while (gsnt != NULL)
 	  {
 	     Group_Score_Name_Type *next = gsnt->next;
+#if SLANG_VERSION >= 20000
+	     if (gsnt->group_regexp != NULL) 
+	       SLregexp_free (gsnt->group_regexp);
+#endif
 	     SLFREE (gsnt);
 	     gsnt = next;
 	  }
@@ -936,7 +1007,11 @@ typedef struct 
    int score_has_expired;
    unsigned int pscore_flags;
    PScore_Type *pst;
+#if SLANG_VERSION < 20000
    SLPreprocess_Type pt;
+#else
+   SLprep_Type *pt;
+#endif
 }
 Score_Context_Type;
 
@@ -1004,7 +1079,11 @@ static int phrase_score_file (char *file
 
 	psrt = NULL;
 	
+#if SLANG_VERSION < 20000
 	if (0 == SLprep_line_ok (line, &c->pt))
+#else
+	if (0 == SLprep_line_ok (line, c->pt))
+#endif
 	  continue;
 
 	lp = (unsigned char *) slrn_skip_whitespace (line);
@@ -1328,9 +1407,18 @@ int slrn_read_score_file (char *file)
    sc.group[0] = '*';
    sc.group[1] = 0;
 
-   (void) SLprep_open_prep (&sc.pt);
+#if SLANG_VERSION < 20000
+   if (-1 == SLprep_open_prep (&sc.pt))
+#else
+   if (NULL == (sc.pt = SLprep_new ()))
+#endif
+     return -1;
    status = read_score_file_internal (file, &sc);
+#if SLANG_VERSION < 20000
    SLprep_close_prep (&sc.pt);
+#else
+   SLprep_delete (sc.pt);
+#endif
    
    if (status == -1)
      Slrn_Apply_Score = 0;
diff -Npur slrn-0.9.8.1.orig/src/slrn.c slrn-0.9.8.1/src/slrn.c
--- slrn-0.9.8.1.orig/src/slrn.c	2004-03-08 17:18:26.000000000 +0000
+++ slrn-0.9.8.1/src/slrn.c	2006-04-04 23:24:19.097901402 +0000
@@ -3,7 +3,7 @@
  This file is part of SLRN.
 
  Copyright (c) 1994, 1999 John E. Davis <davis@space.mit.edu>
- Copyright (c) 2001-2003 Thomas Schultz <tststs@gmx.de>
+ Copyright (c) 2001-2004 Thomas Schultz <tststs@gmx.de>
 
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the Free
@@ -111,6 +111,10 @@
 
 /*{{{ Global Variables */
 
+#if SLANG_VERSION >= 20000
+int Slrn_UTF8_Mode = 0;
+#endif
+
 int Slrn_TT_Initialized = 0;
 
 /* If -1, force mouse.  If 1 the mouse will be used on in XTerm.  If 0, 
@@ -136,12 +140,12 @@ int Slrn_Default_Post_Obj = SLRN_DEFAULT
 FILE *Slrn_Debug_Fp = NULL;
 
 /* You need to call slrn_init_graphic_chars before using these */
-SLsmg_Char_Type Graphic_LTee_Char;
-SLsmg_Char_Type Graphic_UTee_Char;
-SLsmg_Char_Type Graphic_LLCorn_Char;
-SLsmg_Char_Type Graphic_HLine_Char;
-SLsmg_Char_Type Graphic_VLine_Char;
-SLsmg_Char_Type Graphic_ULCorn_Char;
+SLwchar_Type Graphic_LTee_Char;
+SLwchar_Type Graphic_UTee_Char;
+SLwchar_Type Graphic_LLCorn_Char;
+SLwchar_Type Graphic_HLine_Char;
+SLwchar_Type Graphic_VLine_Char;
+SLwchar_Type Graphic_ULCorn_Char;
 
 int Graphic_Chars_Mode = ALT_CHAR_SET_MODE;
 
@@ -1010,6 +1014,9 @@ static int main_init_and_parse_args (int
    int dsc_flag = 0;
    int use_active = 0;
    int wait_for_key = 0;
+#if SLANG_VERSION >= 20000
+   int want_utf8 = 1;
+#endif
    FILE *fp;
    char file [SLRN_MAX_PATH_LEN];
    char *init_file = NULL;
@@ -1138,6 +1145,16 @@ static int main_init_and_parse_args (int
    
    if (Slrn_Batch == 0)
      {
+#if SLANG_VERSION >= 20000
+	if (want_utf8)
+	  {
+	     Slrn_UTF8_Mode = SLutf8_enable (-1);
+	     if (Slrn_UTF8_Mode == 0)
+	       SLsmg_utf8_enable (1);
+	     Slrn_UTF8_Mode = 1;
+	  }
+#endif
+	
 	SLtt_get_terminfo ();
 	if (use_color == 1) SLtt_Use_Ansi_Colors = 1;
 	else if (use_color == -1) SLtt_Use_Ansi_Colors = 0;
@@ -1505,7 +1522,7 @@ static void run_winch_functions (int old
      }
 
 #if SLRN_HAS_SLANG
-   if (SLang_Error == 0)
+   if (SLang_get_error() == 0)
      slrn_run_hooks (HOOK_RESIZE_SCREEN, 0);
 #endif
 }
@@ -1628,14 +1645,15 @@ void slrn_do_keymap_key (SLKeyMap_List_T
    key = SLang_do_key (map, slrn_getkey);
    Suspend_Sigtstp_Suspension = 0;
 
-   if (Slrn_Message_Present || SLang_Error) 
+   if (Slrn_Message_Present || SLang_get_error()) 
      {
 #if SLRN_HAS_SLANG
-	if (SLang_Error) SLang_restart (0);
+	if (SLang_get_error()) SLang_restart (0);
 #endif
 	slrn_clear_message ();
      }
-   SLang_Error = SLKeyBoard_Quit = 0;
+   SLKeyBoard_Quit = 0;
+   SLang_set_error (0);
    
    if ((key == NULL) || (key->type == 0))
      {
@@ -1754,7 +1772,7 @@ int main (int argc, char **argv) /*{{{*/
 	
 	(void) slrn_handle_interrupts ();
 
-	if (SLang_Error || !SLang_input_pending(0))
+	if (SLang_get_error() || !SLang_input_pending(0))
 	  {
 	     slrn_update_screen ();
 	  }
diff -Npur slrn-0.9.8.1.orig/src/slrn.h slrn-0.9.8.1/src/slrn.h
--- slrn-0.9.8.1.orig/src/slrn.h	2004-03-08 17:18:36.000000000 +0000
+++ slrn-0.9.8.1/src/slrn.h	2006-04-04 23:24:19.098901001 +0000
@@ -27,6 +27,12 @@ extern int Slrn_TT_Initialized;
 extern int Slrn_Use_Flow_Control;
 extern int Slrn_Simulate_Graphic_Chars;
 extern int Slrn_Saw_Warning;
+#if SLANG_VERSION >= 20000
+extern int Slrn_UTF8_Mode;
+# ifndef SLRL_DISPLAY_BUFFER_SIZE
+#  define SLRL_DISPLAY_BUFFER_SIZE 256
+# endif
+#endif
 
 extern int slrn_getkey (void);
 extern void slrn_quit (int);
@@ -91,12 +97,15 @@ extern FILE *Slrn_Debug_Fp;
 extern int slrn_sys_system (char *);
 
 extern void slrn_init_graphic_chars (void);
-extern SLsmg_Char_Type Graphic_LTee_Char;
-extern SLsmg_Char_Type Graphic_UTee_Char;
-extern SLsmg_Char_Type Graphic_LLCorn_Char;
-extern SLsmg_Char_Type Graphic_HLine_Char;
-extern SLsmg_Char_Type Graphic_VLine_Char;
-extern SLsmg_Char_Type Graphic_ULCorn_Char;
+#if SLANG_VERSION < 20000
+typedef char SLwchar_Type;
+#endif
+extern SLwchar_Type Graphic_LTee_Char;
+extern SLwchar_Type Graphic_UTee_Char;
+extern SLwchar_Type Graphic_LLCorn_Char;
+extern SLwchar_Type Graphic_HLine_Char;
+extern SLwchar_Type Graphic_VLine_Char;
+extern SLwchar_Type Graphic_ULCorn_Char;
 extern int Graphic_Chars_Mode;
 #define ALT_CHAR_SET_MODE	1
 #define SIMULATED_CHAR_SET_MODE	2
diff -Npur slrn-0.9.8.1.orig/src/slrnpull.c slrn-0.9.8.1/src/slrnpull.c
--- slrn-0.9.8.1.orig/src/slrnpull.c	2004-02-28 22:08:17.000000000 +0000
+++ slrn-0.9.8.1/src/slrnpull.c	2006-04-04 23:24:19.101899799 +0000
@@ -91,6 +91,10 @@
 
 static char *Slrnpull_Version = SLRN_VERSION;
 
+#if SLANG_VERSION >= 20000
+int Slrn_UTF8_Mode = 0;
+#endif
+
 #if SLRNPULL_USE_SETGID_POSTS
 # define OUTGOING_DIR_MODE	(0777 | 03000)
 #else
@@ -1647,7 +1651,7 @@ static int get_group_articles (NNTP_Type
 	    || (((unsigned int)server_max <= gmax) && (gmin <= gmax)))
 	  {
 	     log_message (_("%s: no new articles available."), g->name);
-	     return 0;
+	     goto fetch_marked_bodies;
 	  }
 	
 	Num_Duplicates = 0;
@@ -1667,7 +1671,7 @@ static int get_group_articles (NNTP_Type
 	     g->max = g->server_max;
 	     log_message (_("%s: No new articles available."), g->name);
 	     slrn_free ((char *) numbers);
-	     return 0;
+	     goto fetch_marked_bodies;
 	  }
 	
 	log_message (_("%s: %u articles available."), g->name, num_numbers - i);
@@ -1716,7 +1720,8 @@ static int get_group_articles (NNTP_Type
      }
 
    /* Now, fetch marked article bodies. */
-   
+
+   fetch_marked_bodies:
    /* Don't request bodies that are no longer there. */
    if (server_min > 1)
      g->requests = slrn_ranges_remove (g->requests, 1, server_min-1);
@@ -2183,6 +2188,13 @@ int main (int argc, char **argv) /*{{{*/
    bindtextdomain(PACKAGE,LOCALEDIR);
    textdomain(PACKAGE);
 #endif
+
+#if SLANG_VERSION >= 20000
+   Slrn_UTF8_Mode = SLutf8_enable (-1);
+   if (Slrn_UTF8_Mode == 0)
+     SLsmg_utf8_enable (1);
+   Slrn_UTF8_Mode = 1;
+#endif
    
    pgm = argv[0];
    argv++; argc--;
@@ -3273,7 +3285,10 @@ static int read_headers_files (void)
 	
 	if (NULL != (vline = vgets (vp, &vlen)))
 	  {
-	     vline[vlen] = 0; /* make sure line is NULL terminated */
+	     if (vline[vlen-1] == '\n')
+	       vline[vlen-1] = 0; /* make sure line is NULL terminated */
+	     else
+	       vline[vlen] = 0;
 	     group->headers = slrn_ranges_from_newsrc_line (vline);
 	  }
 	
@@ -3382,7 +3397,10 @@ static void read_requests_files (void)
 	     if (NULL == (group = find_group_type (vline)))
 	       continue;
 	     
-	     vline[vlen-1] = 0;	       /* kill \n and NULL terminate */
+	     if (vline[vlen-1] == '\n')
+	       vline[vlen-1] = 0;
+	     else
+	       vline[vlen] = 0;
 	     
 	     r = slrn_ranges_from_newsrc_line (p+1);
 	     group->requests = slrn_ranges_merge (group->requests, r);
diff -Npur slrn-0.9.8.1.orig/src/spool.c slrn-0.9.8.1/src/spool.c
--- slrn-0.9.8.1.orig/src/spool.c	2004-08-15 20:48:13.000000000 +0000
+++ slrn-0.9.8.1/src/spool.c	2006-04-04 23:24:19.103898997 +0000
@@ -158,6 +158,10 @@ static int spool_fclose_local (void)
 
    Spool_fhead=0;
    Spool_fFakingActive=0;
+#if SLANG_VERSION >= 20000
+   if (Spool_Output_Regexp != NULL)
+     SLregexp_free (Spool_Output_Regexp);
+#endif
    Spool_Output_Regexp = NULL;
    Spool_Ignore_Comments=0;
 
@@ -1424,6 +1428,7 @@ static int spool_list_newsgroups (void)
 
 /* Having an independant buffer for the spool code might spare us mysterious
  * bugs, so I'm not simply using slrn_compile_regexp_pattern */
+#if SLANG_VERSION < 20000
 static SLRegexp_Type *spool_compile_regexp_pattern (char *pat)
 {
    static unsigned char compiled_pattern_buf [512];
@@ -1441,13 +1446,23 @@ static SLRegexp_Type *spool_compile_rege
      }
    return &re;
 }
+#endif
 
 static int spool_list_active (char *pat)
 {
    spool_fclose_local();
    Spool_fh_local=fopen (Slrn_Active_File,"r");
    if (pat != NULL)
-     Spool_Output_Regexp=spool_compile_regexp_pattern (slrn_fix_regexp (pat));
+     {
+#if SLANG_VERSION < 20000
+	Spool_Output_Regexp=spool_compile_regexp_pattern (slrn_fix_regexp (pat));
+#else
+	if (Spool_Output_Regexp != NULL)
+	  SLregexp_free (Spool_Output_Regexp);
+	Spool_Output_Regexp = SLregexp_compile (slrn_fix_regexp(pat),0);
+#endif
+     }
+	
    if (!Spool_fh_local)
      {
 	spool_fake_active(Slrn_Spool_Root);
@@ -1757,7 +1772,10 @@ Slrn_Range_Type *slrn_spool_get_no_body_
    
    if (NULL != (vline = vgets (vp, &vlen)))
      {
-	vline[vlen] = 0; /* make sure line is NULL terminated */
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0; /* make sure line is NULL terminated */
+	else
+	  vline[vlen] = 0;
 	retval = slrn_ranges_from_newsrc_line (vline);
      }
    
@@ -1787,8 +1805,11 @@ Slrn_Range_Type *slrn_spool_get_requeste
 	if ((p == pmax) || (p == vline) ||
 	    (strncmp(vline, group, (p-vline))))
 	  continue;
-     
-	vline[vlen-1] = 0;	       /* kill \n and NULL terminate */
+
+	if (vline[vlen-1] == '\n')
+	  vline[vlen-1] = 0;
+	else
+	  vline[vlen] = 0;
 	
 	retval = slrn_ranges_from_newsrc_line (p+1);
 	break;
diff -Npur slrn-0.9.8.1.orig/src/startup.c slrn-0.9.8.1/src/startup.c
--- slrn-0.9.8.1.orig/src/startup.c	2004-03-07 17:08:21.000000000 +0000
+++ slrn-0.9.8.1/src/startup.c	2006-04-04 23:24:19.105898195 +0000
@@ -271,14 +271,8 @@ static int setkey_fun (int argc, SLcmd_C
    else if (!strcmp (map, "readline")) kmap = Slrn_RLine_Keymap;
    else slrn_exit_error (_("%s: line %d:\n%sNo such keymap: %s"), This_File, This_Line_Num, This_Line, map);
    
-   if ((kmap == Slrn_Keymap_RLI->keymap) &&
-       (NULL == SLang_find_key_function(fun, kmap)))
-     {
-	SLKeymap_Function_Type *tmp = kmap->functions;
-	kmap->functions = Slrn_Custom_Readline_Functions;
-	failure = SLang_define_key (key, fun, kmap);
-	kmap->functions = tmp;
-     }
+   if (kmap == SLrline_get_keymap (Slrn_Keymap_RLI))
+     failure = slrn_rline_setkey (key, fun, kmap);
    else
      failure = SLang_define_key (key, fun, kmap);
    
@@ -349,8 +343,9 @@ static int autobaud_fun (int argc, SLcmd
 
 static SLRegexp_Type *compile_quote_regexp (char *str) /*{{{*/
 {
-   unsigned char *compiled_pattern_buf;
    SLRegexp_Type *r;
+#if SLANG_VERSION < 20000
+   unsigned char *compiled_pattern_buf;
    
    compiled_pattern_buf = (unsigned char *) safe_malloc (512);
    r = (SLRegexp_Type *) safe_malloc (sizeof (SLRegexp_Type));
@@ -362,10 +357,17 @@ static SLRegexp_Type *compile_quote_rege
    
    if (SLang_regexp_compile (r))
      {
-	slrn_exit_error (_("%s: line %d:\n%sInvalid regular expression."),
-			 This_File, This_Line_Num, This_Line);
+	SLfree ((char *) r);
+	r = NULL;
      }
-   
+#else
+   r = SLregexp_compile (str, 0);
+#endif
+
+   if (r == NULL)
+     slrn_exit_error (_("%s: line %d:\n%sInvalid regular expression."),
+		      This_File, This_Line_Num, This_Line);
+     
    return r;
 }
 
@@ -387,8 +389,12 @@ void slrn_generic_regexp_fun (int argc, 
 	r = regexp_table[i];
 	if (r != NULL)
 	  {
+#if SLANG_VERSION < 20000
 	     slrn_free ((char *) r->buf);
 	     SLFREE (r);
+#else
+	     SLregexp_free (r);
+#endif
 	     regexp_table[i] = NULL;
 	  }
      }
@@ -1651,7 +1657,11 @@ int slrn_read_startup_file (char *name) 
 {
    FILE *fp;
    char line [512];
+#if SLANG_VERSION < 20000
    SLPreprocess_Type pt;
+#else
+   SLprep_Type *pt;
+#endif
    int save_this_line_num;
    char *save_this_file;
    char *save_this_line;
@@ -1661,7 +1671,11 @@ int slrn_read_startup_file (char *name) 
 	slrn_exit_error (_("Unable to initialize S-Lang readline library."));
      }
    
+#if SLANG_VERSION < 20000
    if (-1 == SLprep_open_prep (&pt))
+#else
+   if (NULL == (pt = SLprep_new()))
+#endif
      {
 	slrn_exit_error (_("Error initializing S-Lang preprocessor."));
      }
@@ -1684,14 +1698,22 @@ int slrn_read_startup_file (char *name) 
    while (NULL != fgets (line, sizeof(line) - 1, fp))
      {
 	This_Line_Num++;
+#if SLANG_VERSION < 20000
 	if (SLprep_line_ok (line, &pt))
+#else
+	if (SLprep_line_ok (line, pt))
+#endif
 	  (void) SLcmd_execute_string (line, &Slrn_Cmd_Table);
 	
-	if (SLang_Error) exit_unknown_object ();
+	if (SLang_get_error()) exit_unknown_object ();
      }
    slrn_fclose (fp);
    
+#if SLANG_VERSION < 20000
    SLprep_close_prep (&pt);
+#else
+   SLprep_delete (pt);
+#endif
    
    if ((Server_Object != NULL)
        && (-1 == (Slrn_Default_Server_Obj = slrn_map_name_to_object_id (0, Server_Object))))
