Gehad's patches

Miika Turkia miika.turkia at gmail.com
Wed Jun 4 20:46:59 PDT 2014


On Wed, Jun 4, 2014 at 11:47 PM, Gehad <gehadelrobey at gmail.com> wrote:

> The attached patch move the quote function to membuffer.c with some
> generalization as suggested.
> some wrapper functions fix up the parameters for both save-xml and
> save-html.
>
> I didn't add save-git to make the function simpler, the quote function in
> save-git is a little bit different, so I think it will complicate things up.
>

White space issues here, I suggest you also install clang-format and run
the whitespace.pl before sending patches (clang-format is not on default
PATH on my Ubuntu, thus the addition to environment when running the
script, shown below):

---8<---
$ PATH=$PATH:/usr/lib/llvm-3.5/bin/ scripts/whitespace.pl `git diff
--name-only origin`
--- membuffer.c.old    2014-06-05 06:35:27.067346290 +0300
+++ membuffer.c    2014-06-05 06:38:44.638087151 +0300
@@ -96,7 +96,7 @@
             return;
         }

-        room = len+1;
+        room = len + 1;
     }
 }

@@ -174,7 +174,7 @@
         udeg = -udeg;
         sign = "-";
     }
-    put_format(b,"%s%s%u.%06u%s", pre, sign, FRACTION(udeg, 1000000),
post);
+    put_format(b, "%s%s%u.%06u%s", pre, sign, FRACTION(udeg, 1000000),
post);
 }

 void put_quoted(struct membuffer *b, const char *text, int is_attribute,
int is_html)
---8<---

also another patch for fixing the path in different platforms.


Good, now we need someone to test the HTML export at least in Windows.

miika

>
>
> On 06/04/2014 07:15 AM, Dirk Hohndel wrote:
>
>> On Tue, Jun 03, 2014 at 09:12:36PM +0300, Miika Turkia wrote:
>>
>>>  From 684bdf422b466763045a25179b0ee022c9cb5cf3 Mon Sep 17 00:00:00 2001
>>> From: Gehad elrobey <gehadelrobey at gmail.com>
>>> Date: Mon, 2 Jun 2014 20:10:54 +0300
>>> Subject: [PATCH 6/7] HTML: Better quoting to the export strings
>>>
>>> Quote the location, buddy, suit, tags and notes.
>>> This prevents JS code from crashing.
>>>
>>> Signed-off-by: Gehad elrobey <gehadelrobey at gmail.com>
>>> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
>>>   -char *replace_char(char *str, char replace, char *replace_by)
>>> +void put_quoted(struct membuffer *b, const char *text)
>>>   {
>>> +       const char *p = text;
>>> +
>>> +       for (;;) {
>>> +               const char *escape;
>>> +
>>> +               switch (*p++) {
>>> +               default:
>>> +                       continue;
>>> +               case 0:
>>> +                       escape = NULL;
>>> +                       break;
>>> +               case 1 ... 8:
>>> +               case 11:
>>> +               case 12:
>>> +               case 14 ... 31:
>>> +                       escape = "?";
>>> +                       break;
>>> +               case '<':
>>> +                       escape = "<";
>>> +                       break;
>>> +               case '>':
>>> +                       escape = ">";
>>> +                       break;
>>> +               case '&':
>>> +                       escape = "&";
>>> +                       break;
>>> +               case '\'':
>>> +                       escape = "'";
>>> +                       break;
>>> +               case '\"':
>>> +                       escape = """;
>>> +                       break;
>>> +               case '\n':
>>> +                       escape = "<br>";
>>> +                       break;
>>> +               }
>>> +               put_bytes(b, text, (p - text - 1));
>>> +               if (!escape)
>>> +                       break;
>>> +               put_string(b, escape);
>>> +               text = p;
>>>         }
>>>
>> This is more or less verbatim the quote() function from save-xml.c.
>> Why not just call that function (or have a wrapper around it)?
>> I hate the idea of having basically identical quote twice.
>>
>> I took the other patches, this one I would like to see redone.
>>
>> /D
>>
>
> --
> Regards,
> Gehad Elrobey
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140605/14797084/attachment.html>


More information about the subsurface mailing list