[ 
https://issues.apache.org/jira/browse/THRIFT-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12689640#action_12689640
 ] 

Alexander Shigin commented on THRIFT-153:
-----------------------------------------

Oh, there is something wrong with me in past two days. I've missed your 
comments with new patch at all David, sorry.

I'll check the modeline, because I do hate the "comment fix". Perl '\n' was a 
big surprise for me. The absent of test/const-check is even worse. I haven't 
made one :). It's hard for me to create test suite because I have to read a 
manual about automake, autoconf, etc...

Your decision to make get_escaped_string is better than send this to 
const_value.

Here a couple strange things in your patch:
  # we don't need t_php_generator::escape_string anymore;
  # why do you escape ' in html generator?

So, if escaping is right it's lgtm.

> Invalid code generated for string constants containing single quotes (')
> ------------------------------------------------------------------------
>
>                 Key: THRIFT-153
>                 URL: https://issues.apache.org/jira/browse/THRIFT-153
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (C#), Compiler (C++), Compiler (Cocoa), 
> Compiler (Erlang), Compiler (General), Compiler (Haskell), Compiler (Java), 
> Compiler (Perl), Compiler (PHP), Compiler (Python), Compiler (Ruby)
>            Reporter: Dave Engberg
>         Attachments: 
> 0001-THRIFT-153.-Proper-handling-of-strings-with-escapes.patch, 
> 0001-THRIFT-153.-Proper-handling-of-strings-with-escapes.patch, 
> 0002-Make-vim-recognize-that-thriftl.ll-is-Lex-source.patch, 
> t_py_generator.cc.diff, thrift-const-escaping-v2.thrift, 
> thrift-const-escaping.thrift
>
>
> If I declare a constant in a Thrift iDL like this:
> const string HAMMER_TIME = "Can't touch this";
> The generated Python sources generate a constant like this:
> HAMMER_TIME = 'Can't touch this';
> This doesn't work because the apostrophe terminates the string constant.
> Since Python supports string constants using either ' or ", an easy fix is 
> just to use " around Python constants instead:
> Index: compiler/cpp/src/generate/t_py_generator.cc
> ===================================================================
> --- compiler/cpp/src/generate/t_py_generator.cc       (revision 701711)
> +++ compiler/cpp/src/generate/t_py_generator.cc       (working copy)
> @@ -363,7 +363,7 @@
>      t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
>      switch (tbase) {
>      case t_base_type::TYPE_STRING:
> -      out << "'" << value->get_string() << "'";
> +      out << '"' << value->get_string() << '"';
>        break;
>      case t_base_type::TYPE_BOOL:
>        out << (value->get_integer() > 0 ? "True" : "False");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to