[gimp] Bug 765685: Disambiguates octal-escaped output in c-source image output



commit 207e904d7af4d095695a4ecc34099570daefa2a1
Author: João S. O. Bueno <gwidion gmail com>
Date:   Wed Apr 27 23:46:19 2016 -0300

    Bug 765685: Disambiguates octal-escaped output in c-source image output
    
    Fixes the plug-in output to render decimal digit
    characters as octal escaped, so they can't be acidentally
    combined in preceding escaped sequences. (i.e. the sequence
    of values '255, 49'  is now rendered as '\377\049' instead of
     '\3771')
    
    Thanks Steve Baker for noticing and reporting the issue.

 plug-ins/common/file-csource.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-csource.c b/plug-ins/common/file-csource.c
index 08b97fe..24724e2 100644
--- a/plug-ins/common/file-csource.c
+++ b/plug-ins/common/file-csource.c
@@ -379,9 +379,9 @@ save_uchar (GOutputStream  *output,
         }
     }
 
-  if (d < 33 || d > 126)
+  if (d < 33 || (d >= 48 && d <= 57)  || d > 126)
     {
-      if (! print (output, error, "\\%o", d))
+      if (! print (output, error, "\\%03o", d))
         return FALSE;
 
       *c += 1 + 1 + (d > 7) + (d > 63);
@@ -710,7 +710,7 @@ save_image (GFile   *file,
             success = print (output, error, "\\b");
           else if (*p == '\f')
             success = print (output, error, "\\f");
-          else if (*p >= 32 && *p <= 126)
+          else if (( *p >= 32 && *p <= 47 ) || (*p >= 58 && *p <= 126))
             success = print (output, error, "%c", *p);
           else
             success = print (output, error, "\\%03o", *p);


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