lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LYNX-DEV recent localfile-related patch


From: Leonid Pauzner
Subject: LYNX-DEV recent localfile-related patch
Date: Wed, 18 Feb 1998 13:12:46 +0300 (MSK)

> Would prefer that you post patches to the list.  (We'll all try to
> look at your code, not the spelling.  Sorry about that.  It would
> be nice to see it before it becomes fact, however.)
>
> __Henry


There is my recent patch for prepending meta charset to the source,
it was already incorporated in ac114, but FYI (its structure
come from prepending base to the source with respective changes):

Leonid.




diff -c -r OLD/htfwrite.c ./htfwrite.c
*** OLD/htfwrite.c      Wed Jan 28 02:39:48 1998
--- ./htfwrite.c        Wed Feb 18 12:39:26 1998
***************
*** 890,895 ****
--- 890,919 ----
                anchor->address, (temp ? temp : anchor->address));
        FREE(temp);
      }
+         if (LYPrependCharsetToSource &&
+       !strncasecomp(pres->rep->name, "text/html", 9) &&
+       !anchor->content_encoding) {
+       /*
+        *  Add the document's charset as a META CHARSET tag
+        *  at the top of the file, so HTTP charset header
+        *  will not be forgotten when a document saved as local file.
+        *  We add this line only(!) if HTTP charset present. - LP
+        *  Note that the markup will be technically invalid if a DOCTYPE
+        *  declaration, or HTML or HEAD tags, are present, and thus the
+        *  file may need editing for perfection. - FM
+        */
+       char *temp = NULL;
+
+       if (anchor->charset && *anchor->charset) {
+           StrAllocCopy(temp, anchor->charset);
+           collapse_spaces(temp);
+               fprintf(ret_obj->fp,
+               "<META HTTP-EQUIV=\"Content-Type\" "
+               "CONTENT=\"text/html; charset=%s\">\n\n",
+               temp);
+       }
+       FREE(temp);
+     }
      return ret_obj;
  }

diff -c -r OLD/lyglobal.h ./lyglobal.h
*** OLD/lyglobal.h      Wed Jan 28 03:39:48 1998
--- ./lyglobal.h        Mon Feb  9 18:11:24 1998
***************
*** 326,331 ****
--- 326,332 ----
  extern BOOLEAN LYNoCc;
  extern BOOLEAN LYPreparsedSource;     /* Show source as preparsed?     */
  extern BOOLEAN LYPrependBaseToSource;
+ extern BOOLEAN LYPrependCharsetToSource;

  #ifdef RAWDOSKEYHACK
  extern BOOLEAN raw_dos_key_hack; /* Turn on and off DOS key hack */
diff -c -r OLD/lymain.c ./lymain.c
*** OLD/lymain.c        Thu Feb  5 08:25:26 1998
--- ./lymain.c  Mon Feb  9 18:12:06 1998
***************
*** 366,371 ****
--- 366,372 ----
  PUBLIC BOOLEAN LYNoCc = FALSE;
  PUBLIC BOOLEAN LYPreparsedSource = FALSE;     /* Show source as preparsed?    
 */
  PUBLIC BOOLEAN LYPrependBaseToSource = TRUE;
+ PUBLIC BOOLEAN LYPrependCharsetToSource = FALSE;

  /* These are declared in cutil.h for current freeWAIS libraries. - FM */
  #ifdef DECLARE_WAIS_LOGFILES
diff -c -r OLD/lynx.cfg ./lynx.cfg
*** OLD/lynx.cfg        Mon Feb  9 14:02:22 1998
--- ./lynx.cfg  Mon Feb  9 18:12:38 1998
***************
*** 254,259 ****
--- 254,274 ----
  #
  #ASSUME_LOCAL_CHARSET:iso-8859-1

+ # If PREPEND_CHARSET_TO_SOURCE is set to TRUE, Lynx will prepend a
+ # META CHARSET to text/html source files when
+ # they are retrieved for 'd'ownloading or passed to 'p'rint functions.
+ # For 'd'ownload option charset will be added only if HTTP charset present.
+ # The compilation default is FALSE.
+ # It is generally desired to have charset information for every
+ # local html file, but META CHARSET string may cause
+ # compatibility problems with other browsers, so
+ # if you use all CHARACTER_SET, ASSUME_CHARSET, ASSUME_LOCAL_CHARSET
+ # unchanged from theirs default value iso-8859-1 you usually
+ # need not change the compilation default for PREPEND_CHARSET_TO_SOURCE.
+ # Note that the prepending is not done for -source dumps.
+ #
+ #PREPEND_CHARSET_TO_SOURCE:FALSE
+
  # If Lynx encounters a charset parameter it doesn't recognize, it will
  # replace the value given by ASSUME_UNREC_CHARSET (or a corresponding
  # -assume_unrec_charset command line option) for it.  This can be used
diff -c -r OLD/lyprint.c ./lyprint.c
*** OLD/lyprint.c       Wed Jan 28 02:39:48 1998
--- ./lyprint.c Sat Feb 14 12:12:02 1998
***************
*** 464,469 ****
--- 464,502 ----
                            "<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n",
                            newdoc->address, content_base);
                }
+
+               if (LYPrependCharsetToSource && HTisDocumentSource()) {
+                   /*
+                    *  Added the document's charset as a META CHARSET tag
+                    *  to the top of the file.  May create
+                    *  technically invalid HTML, but will help to resolve
+                    *  properly the document converted via chartrans:
+                    *  printed document correspond to a display charset
+                    *  and we *should* override both assume_local_charset
+                    *  and original document's META CHARSET (if any).
+                    *
+                    *  Currently, if several META CHARSET found
+                    *  Lynx use the first only, and it is opposite to BASE
+                    *  where original BASE in the <HEAD>
+                    *  override ones from the top.
+                    *
+                    *  Like in print-to-email we write charset only if
+                    *  the document has 8-bit characters, and
+                    *  we have no CJK or an inofficial "x-" charset.
+                    *
+                    */
+                       use_cte = HTLoadedDocumentEightbit();
+                       disp_charset = LYCharSet_UC[current_char_set].MIMEname;
+                       if (!use_cte || LYHaveCJKCharacterSet ||
+                           strncasecomp(disp_charset, "x-", 2) == 0) {
+                       } else {
+                       fprintf(outfile_fp,
+                               "<META HTTP-EQUIV=\"Content-Type\" "
+                               "CONTENT=\"text/html; charset=%s\">\n\n",
+                               disp_charset);
+                       }
+               }
+
                print_wwwfile_to_fd(outfile_fp,0);
                if (keypad_mode)
                    printlist(outfile_fp,FALSE);
diff -c -r OLD/lyreadcf.c ./lyreadcf.c
*** OLD/lyreadcf.c      Wed Jan 28 03:39:48 1998
--- ./lyreadcf.c        Mon Feb  9 18:13:18 1998
***************
*** 1047,1052 ****
--- 1047,1055 ----
        } else if (!strncasecomp(buffer, "PREPEND_BASE_TO_SOURCE:", 23)) {
            LYPrependBaseToSource = is_true(buffer+23);

+       } else if (!strncasecomp(buffer, "PREPEND_CHARSET_TO_SOURCE:", 26)) {
+           LYPrependCharsetToSource = is_true(buffer+26);
+
        } else if (!strncasecomp(buffer, "PRINTER:", 8)) {
            add_printer_to_list(&buffer[8], &printers);
        }
Only in .: meta-ch
Only in .: old

reply via email to

[Prev in Thread] Current Thread [Next in Thread]