{"comment":{"url":"https://api.github.com/repos/balabit/syslog-ng/comments/12415013","html_url":"https://github.com/balabit/syslog-ng/commit/df52a7b120a61e26cb71c519ee532b81ac3f33df#commitcomment-12415013","id":12415013,"user":{"login":"bazsi","id":714102,"avatar_url":"https://avatars.githubusercontent.com/u/714102?v=3","gravatar_id":"","url":"https://api.github.com/users/bazsi","html_url":"https://github.com/bazsi","followers_url":"https://api.github.com/users/bazsi/followers","following_url":"https://api.github.com/users/bazsi/following{/other_user}","gists_url":"https://api.github.com/users/bazsi/gists{/gist_id}","starred_url":"https://api.github.com/users/bazsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazsi/subscriptions","organizations_url":"https://api.github.com/users/bazsi/orgs","repos_url":"https://api.github.com/users/bazsi/repos","events_url":"https://api.github.com/users/bazsi/events{/privacy}","received_events_url":"https://api.github.com/users/bazsi/received_events","type":"User","site_admin":false},"position":169,"line":169,"path":"lib/utf8utils.c","commit_id":"df52a7b120a61e26cb71c519ee532b81ac3f33df","created_at":"2015-07-29T08:42:26Z","updated_at":"2015-07-29T08:42:26Z","body":"Could work. I also noticed the duplication, but I have felt that:\n\n* I rarely expect either to change\n* if one changes the other one doesn't change at the same type\n* using parameters could slow this down\n* and I already spent a lot of time figuring out the right solution. The\nearlier escaping attempts had a number of issues.\n\nAnyway you know my preference of clean, well structured code, but I think I\nwould find much worse offenders in the code. I continued with a large scale\nrefactor of dbparser instead.\n\nIf you have strong feelings about making this leaner, go ahead. There are\ntests, but I would concentrate elsewhere.\nOn Jul 27, 2015 2:01 PM, \"Budai Laszlo\" <notifications@github.com> wrote:\n\n> Hi,\n>\n> these two functions are almost identical (the difference is around two\n> format strings).\n> What if we would have\n>\n>    - ConverterOptions (FormatterOptions?) struct which could store these\n>    format strings\n>    - a text_converter_options_init\n>    - a binary_converter_options_init\n>    - append_unsafe_utf8\n>\n> In that case:\n>\n> voidappend_unsafe_utf8_as_escaped_text(GString *escaped_string, const gchar *str, const gchar *unsafe_chars)\n> {\n>   ConverterOptions text_converter;\n>   text_converter_init(&text_converter);\n>   append_unsafe_utf8(&text_converter, escaped_string, str, unsafe_chars);\n>  }\n> voidappend_unsafe_utf8_as_escaped_text(GString *escaped_string, const gchar *str, const gchar *unsafe_chars)\n> {\n>   ConverterOptions binary_converter;\n>   binary_converter_init(&binary_converter);\n>   append_unsafe_utf8(&binary_converter, escaped_string, str, unsafe_chars);\n>  }\n>\n> What do you think?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/balabit/syslog-ng/commit/df52a7b120a61e26cb71c519ee532b81ac3f33df#commitcomment-12370395>\n> .\n>\n"}}