Re: \n cause error.

[email protected] (Xiao Yafeng)
Newsgroups perl.inline
Message-ID <CABPUXgA5hMG4MiRiuNnC0SPAwX6WDkiPuNs5qwS+nPMM=wP4TA@mail.gmail.com>
lol, another perl pitfall!

On Fri, Jul 13, 2012 at 10:08 PM, Sisyphus <[email protected]>wrote:

>
> ----- Original Message ----- From: "Xiao Yafeng" <[email protected]>
> To: "inline" <[email protected]>; "Sisyphus" <[email protected]>
> Sent: Friday, July 13, 2012 11:00 PM
> Subject: \n cause error.
>
>
>
>  Hi all,
>>
>> I've found a bug(maybe) in Inline C while dig wchar_t. see
>> http://www.perlmonks.org/?**node_id=981427<http://www.perlmonks.org/?node_id=981427>
>>
>> I made a small inline c snippet as rob's suggestion, but throw an error:
>> ....
>> l\lib\CORE"   test_list_pl_f553.c
>> test_list_pl_f553.xs: In function `GetProcessList':
>> test_list_pl_f553.xs:29: error: missing terminating " character
>> test_list_pl_f553.xs:30: error: missing terminating " character
>> test_list_pl_f553.xs:35: error: syntax error before '}' token
>> dmake.exe:  Error code 129, while making 'test_list_pl_f553.o'
>>
>>
>> I've found this error is because inline can't treat \n in printf statement
>> correctly, In xs file,
>> printf("blah blah blah %s \n", sz) will be translated into
>>
>> printf("blah blah blah %s
>> ", sz)                           #two lines!!
>>
>>
>> a bug?
>>
>
> Funnily enough, I struck the same thing when playing around with another
> Inline::C script today.
> It happens when you use double quotes instead of single quotes with the
> heredoc operator. (Is "heredoc operator" the right term ?)
>
> Instead of :
>
> use Inline C => <<"EOC"
>
> you want:
>
> use Inline C => <<'EOC'
>
> The behaviour you observed seems to be standard perl behaviour, so I don't
> think it's a bug:
>
> ############################
> C:\_32\pscrpt>type try.pl
>
> use warnings;
>
> print <<"EOC";
> p"\n"
> EOC
>
> print <<'EOC';
> p"\n"
> EOC
>
> C:\_32\pscrpt>perl try.pl
> p"
> "
> p"\n"
>
> C:\_32\pscrpt>
> ############################
>
> Cheers,
> Rob
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.