lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev patch: correct charset handling of comments in PSRC mode


From: Vlad Harchev
Subject: lynx-dev patch: correct charset handling of comments in PSRC mode
Date: Mon, 4 Dec 2000 20:01:38 +0400 (SAMT)

 * comments are now correctly converted to display charset in psrc mode

Comments:
 I hope there won't be any problems applying this patch to dev17.

 May be charset conversion of comments is redundant if psrc_view==FALSE (why
unnecessary CPU cycles).

 BTW, is there a function that will directly convert characters to needed
charset, without the need for on-fly conversion to intermediate encoding
(UTF8 in case of Cyrillic)?

 Best regards,
  -Vlad

 This piece of code is right below S_comment:
--- /mnt/fs2/usr/src/lynx2-8-3dev16pre-orig/src/.lib/SGML.c-was Mon Dec  4 
19:35:34 2000
+++ /mnt/fs2/usr/src/lynx2-8-3dev16pre-orig/src/.lib/SGML.c     Mon Dec  4 
19:41:46 2000
@@ -3172,7 +3172,7 @@
                if (psrc_view) {
                    PSRCSTART(comm);
                    PUTC('<');
-                   PUTS(string->data);
+                   PUTS_TR(string->data);
                    PUTC('>');
                    PSRCSTOP(comm);
                } else
@@ -3184,8 +3184,9 @@
                context->state = S_text;
                break;
            }
-           HTChunkPutc(string, c);
-           break;
+           goto S_comment_put_c;
+           //HTChunkPutc(string, c);
+           //break;
        }
        if (!context->first_dash && c == '-') {
            HTChunkPutc(string, c);
@@ -3214,7 +3215,7 @@
                if (psrc_view) {
                    PSRCSTART(comm);
                    PUTC('<');
-                   PUTS(string->data);
+                   PUTS_TR(string->data);
                    PUTC('>');
                    PSRCSTOP(comm);
                } else
@@ -3229,7 +3230,30 @@
        context->first_dash = FALSE;
        if (context->end_comment && !isspace(c))
            context->end_comment = FALSE;
-       HTChunkPutc(string, c);
+           
+       S_comment_put_c:        
+       if (context->T.decode_utf8 &&
+                  *context->utf_buf) {
+           HTChunkPuts(string, context->utf_buf);
+           context->utf_buf_p = context->utf_buf;
+           *(context->utf_buf_p) = '\0';
+       } else if (HTCJK == NOCJK &&
+                  (context->T.output_utf8 ||
+                   context->T.trans_from_uni)) {
+           if (clong == 0xfffd && saved_char_in &&
+               HTPassEightBitRaw &&
+               (unsigned char)saved_char_in >=
+               LYlowest_eightbit[context->outUCLYhndl]) {
+               HTChunkPutUtf8Char(string,
+                                  (0xf000 | (unsigned char)saved_char_in));
+           } else {
+               HTChunkPutUtf8Char(string, clong);
+           }
+       } else if (saved_char_in && context->T.use_raw_char_in) {
+           HTChunkPutc(string, saved_char_in);
+       } else {
+           HTChunkPutc(string, c);
+       }           
        break;
 
     case S_doctype:            /* Expecting DOCTYPE. - FM */


reply via email to

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