qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs unihex.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs unihex.c
Date: Wed, 15 Mar 2017 03:38:58 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/03/15 03:38:58

Modified files:
        .              : unihex.c 

Log message:
        unihex: fix crash bug
        - fix crash bug in initialization code
        - prevent display of invalid code points

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/unihex.c?cvsroot=qemacs&r1=1.34&r2=1.35

Patches:
Index: unihex.c
===================================================================
RCS file: /sources/qemacs/qemacs/unihex.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- unihex.c    23 Dec 2016 19:51:48 -0000      1.34
+++ unihex.c    15 Mar 2017 07:38:58 -0000      1.35
@@ -2,7 +2,7 @@
  * Unicode Hexadecimal mode for QEmacs.
  *
  * Copyright (c) 2000-2001 Fabrice Bellard.
- * Copyright (c) 2002-2016 Charlie Gordon.
+ * Copyright (c) 2002-2017 Charlie Gordon.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -42,10 +42,10 @@
             maxc = max(maxc, c);
         }
 
-        s->dump_width = 32 / s->unihex_mode;
         s->hex_mode = 1;
         s->hex_nibble = 0;
         s->unihex_mode = snprintf(NULL, 0, "%x", maxc);
+        s->dump_width = 32 / s->unihex_mode;
         s->insert = 0;
         s->wrap = WRAP_TRUNCATE;
     }
@@ -54,10 +54,9 @@
 
 static int unihex_to_disp(int c)
 {
-    /* Do not allow characters in range 127-160 to show as graphics
-     * nor characters beyond the BMP plane
-     */
-    if (c < ' ' || c == 127 || (c >= 128 && c < 160) || c > 0xFFFF)
+    /* Prevent display of C1 control codes and invalid code points */
+    if (c < ' ' || c == 127 || (c >= 128 && c < 160)
+    ||  (c >= 0xD800 && c <= 0xDFFF) || c > 0x10FFFF)
         c = '.';
     return c;
 }



reply via email to

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