File fortune-no-recode.patch of Package fortune

From: Jan Engelhardt <jengelh@inai.de>
Date: 2018-01-09 18:59:13.664773029 +0100

No fortunes except ONE actually uses non-ASCII characters, which is substituted
in short order. This allows dropping the entire librecode use, and we do not
even need to convert it to iconv, though that's likewise trivial.

---
 Makefile              |    2 +-
 datfiles/Makefile     |    1 -
 datfiles/off/Makefile |    1 -
 datfiles/pets         |    2 +-
 fortune/fortune.c     |   33 ---------------------------------
 5 files changed, 2 insertions(+), 37 deletions(-)

Index: fortune-mod-1.99.1/Makefile
===================================================================
--- fortune-mod-1.99.1.orig/Makefile
+++ fortune-mod-1.99.1/Makefile
@@ -62,7 +62,7 @@ REGEXDEFS=-DHAVE_REGEX_H -DBSD_REGEX -DH
 #
 REGEXLIBS=
 
-RECODELIBS=-lrecode
+RECODELIBS=
 
 DEFINES=-DFORTDIR="\"$(COOKIEDIR)\"" -DOFFDIR="\"$(OCOOKIEDIR)\"" -DLOCFORTDIR="\"$(LOCALDIR)\"" -DLOCOFFDIR="\"$(LOCALODIR)\""
 CFLAGS=-O2 $(DEFINES) -Wall -fomit-frame-pointer -pipe -fsigned-char
Index: fortune-mod-1.99.1/datfiles/Makefile
===================================================================
--- fortune-mod-1.99.1.orig/datfiles/Makefile
+++ fortune-mod-1.99.1/datfiles/Makefile
@@ -46,7 +46,6 @@ cookies-stamp:
 	        if [ ! -f $$i.old ] ; then \
 	        	cp $$i $$i.old; \
 		fi; \
-	        recode latin1..u8 $$i ; \
 		$(STRFILE) $$i ; \
 		ln -s $$i $$i.u8 || exit $? ; \
 	    done
Index: fortune-mod-1.99.1/datfiles/off/Makefile
===================================================================
--- fortune-mod-1.99.1.orig/datfiles/off/Makefile
+++ fortune-mod-1.99.1/datfiles/off/Makefile
@@ -30,7 +30,6 @@ recoded-stamp:
 	        if [ ! -f unrotated/$$i.old ]; then \
 	    	    cp unrotated/$$i unrotated/$$i.old ; \
 		fi; \
-		recode latin1..u8 unrotated/$$i; \
 	    done
 	touch recoded-stamp
 	
Index: fortune-mod-1.99.1/datfiles/pets
===================================================================
--- fortune-mod-1.99.1.orig/datfiles/pets
+++ fortune-mod-1.99.1/datfiles/pets
@@ -19,7 +19,7 @@ About the only thing on a farm that has
 All intelligent species own cats.
 %
 Any Member introducing or causing to be introduced a dog into the Society's
-premises shall be liable to a fine of £5 inflicted by the Treasurer. Any animal
+premises shall be liable to a fine of GBP 5 inflicted by the Treasurer. Any animal
 leading a blind person shall be deemed to be a cat. Any animal entering on
 Police business shall be deemed to be a wombat.
 		-- Rule 51, Oxford Union Society
Index: fortune-mod-1.99.1/fortune/fortune.c
===================================================================
--- fortune-mod-1.99.1.orig/fortune/fortune.c
+++ fortune-mod-1.99.1/fortune/fortune.c
@@ -140,7 +140,6 @@ typedef enum
 #include	<errno.h>
 #include	<locale.h>
 #include	<langinfo.h>
-#include 	<recode.h>
 
 
 /* This makes GNU libc to prototype the BSD regex functions */
@@ -253,9 +252,6 @@ regex_t Re_pat;
 
 #endif /* BSD_REGEX */
 
-RECODE_REQUEST request;
-RECODE_OUTER outer;
-
 int add_dir(register FILEDESC *);
 
 char *program_version(void)
@@ -1548,12 +1544,7 @@ void matches_in_list(FILEDESC * list)
 		*sp = '\0';
 		nchar = sp - Fortbuf;
 
-		if (fp->utf8_charset && No_recode == FALSE) 
-		{
-		    output = recode_string (request, Fortbuf);
-		} else {
 		    output = Fortbuf;
-		}
 		/* Should maybe rot13 Fortbuf -allover */
 
                 if(fp->tbl.str_flags & STR_ROTATED)
@@ -1630,20 +1621,9 @@ void display(FILEDESC * fp)
 		    *p = 'a' + (ch - 'a' + 13) % 26;
 	    }
 	}
-	if(fp->utf8_charset && No_recode == FALSE) {
-	    char *output;
-	    output = recode_string (request, line);
-	    fputs(output, stdout);
-	    free(output);
-	}
-	else
 	    fputs(line, stdout);
     }
     fflush(stdout);
-
-    if(fp->utf8_charset) {
-	recode_delete_request(request);
-    }	
 }
 
 /*
@@ -1677,22 +1657,9 @@ int max(register int i, register int j)
 
 int main(int ac, char *av[])
 {
-    char *ctype, *crequest;
     getargs(ac, av);
 
-    outer = recode_new_outer(true);
-    request = recode_new_request (outer);
-
     setlocale(LC_ALL,"");
-    ctype = nl_langinfo(CODESET);
-    if(strcmp(ctype,"ANSI_X3.4-1968") == 0)
-        ctype="ISO-8859-1";
-	
-    crequest = malloc(strlen(ctype) + 7 + 1);
-    sprintf(crequest, "UTF-8..%s", ctype);
-    recode_scan_request (request, crequest);
-    free(crequest);
-
 #ifndef NO_REGEX
     if (Match)
 	exit(find_matches() != 0);
openSUSE Build Service is sponsored by