Bram Moolenaar wrote:
Mathias Michaelis wrote:

Patch 7.0.044
Problem:  Perl: setting a buffer line in another buffer may result in
          changing the current buffer.
Solution: Properly change to the buffer to be changed.
Files:    src/if_perl.xs

[...]

Alas, if I want to compile this, I get the following output

---%<---
        "C:\Program Files\ActivePerl\Bin\perl" "C:\Program 
Files\ActivePerl\lib\ExtUtils\xsubpp" -prototypes -typemap "C:\Program 
Files\ActivePerl\lib\ExtUtils\typemap"  -typemap typemap if_perl.xs > if_perl.c
        cl -c /W3 /nologo  -D_MT -MT -I. -Iproto -DHAVE_PATHDEF -DWIN32  
-DFEAT_SNIFF -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG   -DFEAT_XPM_W32   
-DWINVER=0x0500 -D_WIN32_WINNT=0x0500  /Fo.\ObjGOL/ /Ox -DNDEBUG /G6 -DFEAT_OLE 
-DFEAT_MBYTE_IME -DDYNAMIC_IME
-DGLOBAL_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_PERL 
-DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl58.dll\" -DFEAT_HUGE /Zi /Fd.\ObjGOL/ /I 
"C:\Program Files\ActivePerl\Lib\Core" if_perl.c
cl : Command line warning D9002 : ignoring unknown option '/G6'
if_perl.c
if_perl.xs(1075) : error C2275: 'buf_T' : illegal use of this type as an 
expression
        c:\software\vim\vim70\src\structs.h(1133) : see declaration of 'buf_T'
if_perl.xs(1075) : error C2065: 'save_curbuf' : undeclared identifier
if_perl.xs(1088) : warning C4047: '=' : 'buf_T *' differs in levels of 
indirection from 'int'
if_perl.xs(1089) : warning C4047: '=' : 'buf_T *' differs in levels of 
indirection from 'int'
if_perl.xs(1187) : error C2275: 'buf_T' : illegal use of this type as an 
expression
        c:\software\vim\vim70\src\structs.h(1133) : see declaration of 'buf_T'
if_perl.xs(1200) : warning C4047: '=' : 'buf_T *' differs in levels of 
indirection from 'int'
if_perl.xs(1201) : warning C4047: '=' : 'buf_T *' differs in levels of 
indirection from 'int'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
--->%---

I inspected if_perl.xs and if_perl.c and saw that xsubpp simply removed
preprocessor directives such as

!     #ifdef FEAT_AUTOCMD

out of the code without really make a decision between the #if or #else:
Both parts were left.

I missed this, it compiles OK for me even though the code is wrong.
Note that I put some white space before the # to make it work for me.

I then found

http://perldoc.perl.org/perlxs.html#Inserting-POD%2c-Comments-and-C-Preprocessor-Directives

But that mentions that the preprocessor directives are passed on
unmodified...  That isn't so, this documentation is wrong.

Compiling on SuSE 9.3 with gcc 3.3.5 20050117 (prerelease), I also get no messages for if_perl although the # lines are removed and both branches (before and after #else) passed on.

I notice that # directives of all kinds are passed on unmodified elsewhere in the code; but they have the # in column 1 (sometimes with spaces after the #). There is also one "# string" in a /* comment */ which is passed on OK. Maybe xsubpp doesn't recognise lines with spaces before # as 'preprocessor directives' to be passed on?


Your solution to duplicate the functions is not nice.  Further changes
must be made in two places, that's asking for trouble.

I suppose implementing aucmd_prepbuf() for when FEAT_AUTOCMD is not
defined would be a better solution.


Best regards,
Tony.

Reply via email to