about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LYGlobalDefs.h3
-rw-r--r--src/LYMain.c12
-rw-r--r--src/LYPrint.c4
-rw-r--r--src/LYReadCFG.c14
-rw-r--r--src/UCdomap.c31
5 files changed, 42 insertions, 22 deletions
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 590dbd0f..59e34cf9 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYGlobalDefs.h,v 1.137 2013/10/02 19:03:07 tom Exp $
+ * $LynxId: LYGlobalDefs.h,v 1.138 2014/02/04 01:25:39 tom Exp $
  *
  * global variable definitions
  */
@@ -586,6 +586,7 @@ extern "C" {
 #ifdef USE_LOCALE_CHARSET
     extern BOOLEAN LYLocaleCharset;
 #endif
+    extern BOOLEAN assumed_charset;
 
 #ifndef NO_DUMP_WITH_BACKSPACES
     extern BOOLEAN with_backspaces;
diff --git a/src/LYMain.c b/src/LYMain.c
index 7a2ef0ef..fc4008f9 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMain.c,v 1.251 2013/11/28 11:20:21 tom Exp $
+ * $LynxId: LYMain.c,v 1.252 2014/02/04 01:25:16 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTP.h>
@@ -594,6 +594,7 @@ int justify_max_void_percent = 35;
 #ifdef USE_LOCALE_CHARSET
 BOOLEAN LYLocaleCharset = FALSE;
 #endif
+BOOLEAN assumed_charset = FALSE;
 
 #ifndef NO_DUMP_WITH_BACKSPACES
 BOOLEAN with_backspaces = FALSE;
@@ -2497,13 +2498,14 @@ static int anonymous_fun(char *next_arg GCC_UNUSED)
 /* -assume_charset */
 static int assume_charset_fun(char *next_arg)
 {
+    assumed_charset = TRUE;
     UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
     StrAllocCopy(UCAssume_MIMEcharset,
 		 LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
-/*	   this may be a memory for bogus typo -
-    StrAllocCopy(UCAssume_MIMEcharset, next_arg);
-    LYLowerCase(UCAssume_MIMEcharset);   */
-
+    CTRACE((tfp, "assume_charset_fun %s ->%d ->%s\n",
+	    NonNull(next_arg),
+	    UCLYhndl_for_unspec,
+	    UCAssume_MIMEcharset));
     return 0;
 }
 
diff --git a/src/LYPrint.c b/src/LYPrint.c
index c68faeda..f3bbd235 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYPrint.c,v 1.103 2014/02/03 00:17:07 tom Exp $
+ * $LynxId: LYPrint.c,v 1.104 2014/02/04 01:58:51 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAccess.h>
@@ -148,7 +148,7 @@ static void SetupFilename(bstring **filename,
 	CTRACE((tfp, "... format %s\n", format->name));
 	if (!strcasecomp(format->name, "text/html") ||
 	    !IsUnityEnc(encoding)) {
-	    (*filename)->len = (cp - (*filename)->str);
+	    (*filename)->len = (int) (cp - (*filename)->str);
 	    BStrCat0(*filename, TEXT_SUFFIX);
 	}
     }
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 382591e1..80af9e87 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.c,v 1.182 2013/11/29 00:21:45 tom Exp $
+ * $LynxId: LYReadCFG.c,v 1.183 2014/02/04 01:39:32 tom Exp $
  */
 #ifndef NO_RULES
 #include <HTRules.h>
@@ -557,13 +557,14 @@ typedef struct {
 
 static int assume_charset_fun(char *value)
 {
+    assumed_charset = TRUE;
     UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(value);
     StrAllocCopy(UCAssume_MIMEcharset,
 		 LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
-/*    this may be a memory for bogus typo -
-    StrAllocCopy(UCAssume_MIMEcharset, value);
-    LYLowerCase(UCAssume_MIMEcharset);    */
-
+    CTRACE((tfp, "assume_charset_fun %s ->%d ->%s\n",
+	    NonNull(value),
+	    UCLYhndl_for_unspec,
+	    UCAssume_MIMEcharset));
     return 0;
 }
 
@@ -591,8 +592,9 @@ static int character_set_fun(char *value)
 	    current_char_set = auto_display_charset;
 #endif
 	/* do nothing here: so fallback to userdefs.h */
-    } else
+    } else {
 	current_char_set = i;
+    }
 
     return 0;
 }
diff --git a/src/UCdomap.c b/src/UCdomap.c
index ea429dde..2684ebd6 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: UCdomap.c,v 1.95 2012/02/23 01:05:42 tom Exp $
+ * $LynxId: UCdomap.c,v 1.96 2014/02/04 01:29:44 tom Exp $
  *
  *  UCdomap.c
  *  =========
@@ -1529,7 +1529,7 @@ int UCGetLYhndl_byMIME(const char *value)
     int i;
     int LYhndl = -1;
 
-    if (!value || !(*value)) {
+    if (isEmpty(value)) {
 	CTRACE((tfp,
 		"UCGetLYhndl_byMIME: NULL argument instead of MIME name.\n"));
 	return ucError;
@@ -2468,7 +2468,6 @@ static char *nl_langinfo(nl_item item)
  */
 void LYFindLocaleCharset(void)
 {
-    BOOL found = FALSE;
     char *name;
 
     CTRACE((tfp, "LYFindLocaleCharset(%d)\n", LYLocaleCharset));
@@ -2478,19 +2477,35 @@ void LYFindLocaleCharset(void)
 	int value = UCGetLYhndl_byMIME(name);
 
 	if (value >= 0) {
-	    found = TRUE;
 	    linedrawing_char_set = value;
 	    CTRACE((tfp, "Found name \"%s\" -> %d\n", name, value));
+	    /*
+	     * If no locale was set, we will get the POSIX character set, which
+	     * in Lynx is treated as US-ASCII.  However, Lynx's longstanding
+	     * behavior has been to default to ISO-8859-1.  So we treat that
+	     * encoding specially.  Otherwise, if LOCALE_CHARSET is set, then
+	     * we will use the locale encoding -- unless overridden by the
+	     * ASSUME_CHARSET value and/or command-line option.
+	     */
+	    if (LYLocaleCharset) {
+		CTRACE((tfp, "...prior LocaleCharset '%s'\n", NonNull(UCAssume_MIMEcharset)));
+		if (value == US_ASCII) {
+		    CTRACE((tfp, "...prefer existing charset to ASCII\n"));
+		} else if (assumed_charset) {
+		    CTRACE((tfp, "...already assumed-charset\n"));
+		} else {
+		    current_char_set = linedrawing_char_set;
+		    UCLYhndl_for_unspec = current_char_set;
+		    StrAllocCopy(UCAssume_MIMEcharset, name);
+		    CTRACE((tfp, "...using LocaleCharset '%s'\n", NonNull(UCAssume_MIMEcharset)));
+		}
+	    }
 	} else {
 	    CTRACE((tfp, "Cannot find a handle for MIME name \"%s\"\n", name));
 	}
     } else {
 	CTRACE((tfp, "Cannot find a MIME name for locale\n"));
     }
-
-    if (found && LYLocaleCharset) {
-	current_char_set = linedrawing_char_set;
-    }
 }
 #endif /* USE_LOCALE_CHARSET */