Discussion:
\n cause error.
Xiao Yafeng
2012-07-13 13:00:36 UTC
Permalink
Hi all,

I've found a bug(maybe) in Inline C while dig wchar_t. see
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?
Sisyphus
2012-07-13 14:08:49 UTC
Permalink
----- Original Message -----
From: "Xiao Yafeng" <xyf.xiao-***@public.gmane.org>
To: "inline" <inline-***@public.gmane.org>; "Sisyphus" <sisyphus1-sFbbPxZDHXw0n/***@public.gmane.org>
Sent: Friday, July 13, 2012 11:00 PM
Subject: \n cause error.
Post by Xiao Yafeng
Hi all,
I've found a bug(maybe) in Inline C while dig wchar_t. see
http://www.perlmonks.org/?node_id=981427
....
l\lib\CORE" test_list_pl_f553.c
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
Xiao Yafeng
2012-07-13 15:57:44 UTC
Permalink
lol, another perl pitfall!
Post by Sisyphus
Sent: Friday, July 13, 2012 11:00 PM
Subject: \n cause error.
Hi all,
Post by Xiao Yafeng
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>
....
l\lib\CORE" test_list_pl_f553.c
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 ?)
use Inline C => <<"EOC"
use Inline C => <<'EOC'
The behaviour you observed seems to be standard perl behaviour, so I don't
############################
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
Nicholas Clark
2012-07-13 16:01:10 UTC
Permalink
Post by Xiao Yafeng
lol, another perl pitfall!
Post by Sisyphus
The behaviour you observed seems to be standard perl behaviour, so I don't
No, not a bug. It's what one would expect from how double quoted interpolation
behaviour is defined.

Nicholas Clark

Continue reading on narkive:
Loading...