From 6c1c6f4bf73c5f8df97d6d7e20abc759fe90dea5 Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Fri, 19 Aug 2011 02:47:10 +0200
Subject: [PATCH] Encoding fixes: S now works for non-ascii

---
 src/rules.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/rules.c b/src/rules.c
index 4397e9a..cbeaa6a 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -476,48 +476,55 @@ static char *rules_init_conv(char *src, char *dst)
 
 static void rules_init_convs(void)
 {
-	conv_shift = rules_init_conv(conv_source, CONV_SHIFT);
 	conv_vowels = rules_init_conv(conv_source, CONV_VOWELS);
 	conv_right = rules_init_conv(conv_source, CONV_RIGHT);
 	conv_left = rules_init_conv(conv_source, CONV_LEFT);
 
 	if (options.iso8859_1) {
 		conv_source = CONV_SOURCE CHARS_LOWER_ISO_8859_1 CHARS_UPPER_ISO_8859_1;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_ISO_8859_1 CHARS_LOWER_ISO_8859_1);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_ISO_8859_1 CHARS_LOWER_ISO_8859_1);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_ISO_8859_1, CHARS_LOWER CHARS_LOWER_ISO_8859_1);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_ISO_8859_1, CHARS_UPPER CHARS_UPPER_ISO_8859_1);
 	} else if (options.koi8_r) {
 		conv_source = CONV_SOURCE CHARS_LOWER_KOI8_R CHARS_UPPER_KOI8_R;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_KOI8_R CHARS_LOWER_KOI8_R);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_KOI8_R CHARS_LOWER_KOI8_R);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_KOI8_R, CHARS_LOWER CHARS_LOWER_KOI8_R);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_KOI8_R, CHARS_UPPER CHARS_UPPER_KOI8_R);
 	} else if (options.cp1251) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP1251 CHARS_UPPER_CP1251;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP1251 CHARS_LOWER_CP1251);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP1251 CHARS_LOWER_CP1251);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP1251, CHARS_LOWER CHARS_LOWER_CP1251);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP1251, CHARS_UPPER CHARS_UPPER_CP1251);
 	} else if (options.cp866) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP866 CHARS_UPPER_CP866;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP866 CHARS_LOWER_CP866);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP866 CHARS_LOWER_CP866);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP866, CHARS_LOWER CHARS_LOWER_CP866);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP866, CHARS_UPPER CHARS_UPPER_CP866);
 	} else if (options.cp1252) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP1252 CHARS_UPPER_CP1252;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP1252 CHARS_LOWER_CP1252);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP1252 CHARS_LOWER_CP1252);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP1252, CHARS_LOWER CHARS_LOWER_CP1252);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP1252, CHARS_UPPER CHARS_UPPER_CP1252);
 	} else if (options.iso8859_15) {
 		conv_source = CONV_SOURCE CHARS_LOWER_ISO_8859_15 CHARS_UPPER_ISO_8859_15;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_ISO_8859_15 CHARS_LOWER_ISO_8859_15);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_ISO_8859_15 CHARS_LOWER_ISO_8859_15);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_ISO_8859_15, CHARS_LOWER CHARS_LOWER_ISO_8859_15);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_ISO_8859_15, CHARS_UPPER CHARS_UPPER_ISO_8859_15);
 	} else if (options.cp437) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP437 CHARS_UPPER_CP437;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP437 CHARS_LOWER_CP437);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP437 CHARS_LOWER_CP437);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP437, CHARS_LOWER CHARS_LOWER_CP437);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP437, CHARS_UPPER CHARS_UPPER_CP437);
 	} else if (options.cp850) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP850 CHARS_UPPER_CP850;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP850 CHARS_LOWER_CP850);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP850 CHARS_LOWER_CP850);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP850, CHARS_LOWER CHARS_LOWER_CP850);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP850, CHARS_UPPER CHARS_UPPER_CP850);
@@ -526,15 +533,18 @@ static void rules_init_convs(void)
 		conv_toupper[0xD5] = 0x49;
 	} else if (options.cp858) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP858 CHARS_UPPER_CP858;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP858 CHARS_LOWER_CP858);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP858 CHARS_LOWER_CP858);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP858, CHARS_LOWER CHARS_LOWER_CP858);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP858, CHARS_UPPER CHARS_UPPER_CP858);
 	} else if (options.cp737) {
 		conv_source = CONV_SOURCE CHARS_LOWER_CP737 CHARS_UPPER_CP737;
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT CHARS_UPPER_CP737 CHARS_LOWER_CP737);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT CHARS_UPPER_CP737 CHARS_LOWER_CP737);
 		conv_tolower = rules_init_conv(CHARS_UPPER CHARS_UPPER_CP737, CHARS_LOWER CHARS_LOWER_CP737);
 		conv_toupper = rules_init_conv(CHARS_LOWER CHARS_LOWER_CP737, CHARS_UPPER CHARS_UPPER_CP737);
 	} else {
+		conv_shift = rules_init_conv(conv_source, CONV_SHIFT);
 		conv_invert = rules_init_conv(conv_source, CONV_INVERT);
 		conv_tolower = rules_init_conv(CHARS_UPPER, CHARS_LOWER);
 		conv_toupper = rules_init_conv(CHARS_LOWER, CHARS_UPPER);
-- 
1.7.4.1

