gnucash maint: Bug 796982 - Import Bills & Invoices: change in un_escape() routine...

John Ralls jralls at code.gnucash.org
Wed Dec 19 00:32:16 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/f2976420 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2524482b (commit)



commit f29764202ec9f7ace6eb726c246799cb19ad5c1a
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Dec 18 21:29:53 2018 -0800

    Bug 796982 - Import Bills & Invoices: change in un_escape() routine...
    
    causes description and notes fields to be mangled.
    
    Simple error, but rewrote the function to be more idiomatic, resisting
    temptation to abuse the ternary operator.

diff --git a/gnucash/import-export/bi-import/dialog-bi-import.c b/gnucash/import-export/bi-import/dialog-bi-import.c
index 5b46e84..6aabcc3 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import.c
@@ -876,30 +876,26 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
  * @param char* String to be modified
  * @return char* Modified string.
 */
-static char * un_escape(char *str)
+static char*
+un_escape(char *str)
 {
     gchar quote = '"';
     gchar *newStr = NULL, *tmpstr = str;
     int n = 0;
+
     newStr = g_malloc(strlen(str)+1); // This must be freed in the calling code.
     while(*tmpstr != '\0')
     {
         if(*tmpstr == quote)
-        {
-            tmpstr++;
-            if(*tmpstr == quote)
-            {
-                newStr[n] = quote;
-            }
-        }
+            // We always want the character after a quote.
+            newStr[n] = *(++tmpstr);
         else
-        {
-            newStr[n] = *str;
-        }
-            tmpstr++;
-            n++;
+            newStr[n] = *tmpstr;
+        ++tmpstr;
+        ++n;
     }
+
     g_free (str);
-	newStr[n] = '\0'; //ending the character array
+    newStr[n] = '\0'; //ending the character array
     return newStr;
 }



Summary of changes:
 gnucash/import-export/bi-import/dialog-bi-import.c | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)



More information about the gnucash-changes mailing list