AbdullZ7 / pdfium

Automatically exported from code.google.com/p/pdfium
0 stars 0 forks source link

FX_WSTRC is being called on FX_WCHAR pointers #96

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Recent changes to FX_WSTRC made it so that it could only be called on arrays, 
not on pointers. This is useful because calling it on pointers would give 
incorrect results, and now this incorrect code will fail to compile.

While merging the FX_WSTRC to the XFA branch I hit compile errors in 
xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp, in lines like:

wsResultBuf << FX_WSTRC(strName[QUOT]);

Because strName[] contains FX_WCHAR pointers this code needs to use 
FXSYS_wcslen.

The current behavior is that FX_WSTRC will always report a length of 1 in 
32-bit builds and a length of 3 in 64-bit builds.

This source file also contains a lot of (FX_WCHAR *) casts that are unnecessary.

These compile errors can be seen by applying the patch in CL 
https://codereview.chromium.org/818193004.

Original issue reported on code.google.com by brucedaw...@chromium.org on 23 Dec 2014 at 9:36

GoogleCodeExporter commented 9 years ago
The compile errors (five of them) are:

d:\src\pdfium\xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp(4142) : error C2784: 
'char (&ArraySizeHelper(T (&)[N]))[N]' : could not deduce template argument for 
'T (&)[N]' from 'FX_WCHAR *'
        d:\src\pdfium\core\include\fxcrt\fx_basic.h(35) : see declaration of 'ArraySizeHelper'
d:\src\pdfium\xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp(4147) : error C2784: 
'char (&ArraySizeHelper(T (&)[N]))[N]' : could not deduce template argument for 
'T (&)[N]' from 'FX_WCHAR *'
        d:\src\pdfium\core\include\fxcrt\fx_basic.h(35) : see declaration of 'ArraySizeHelper'
d:\src\pdfium\xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp(4152) : error C2784: 
'char (&ArraySizeHelper(T (&)[N]))[N]' : could not deduce template argument for 
'T (&)[N]' from 'FX_WCHAR *'
        d:\src\pdfium\core\include\fxcrt\fx_basic.h(35) : see declaration of 'ArraySizeHelper'
d:\src\pdfium\xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp(4157) : error C2784: 
'char (&ArraySizeHelper(T (&)[N]))[N]' : could not deduce template argument for 
'T (&)[N]' from 'FX_WCHAR *'
        d:\src\pdfium\core\include\fxcrt\fx_basic.h(35) : see declaration of 'ArraySizeHelper'
d:\src\pdfium\xfa\src\fxfa\src\fm2js\xfa_fm2jscontext.cpp(4162) : error C2784: 
'char (&ArraySizeHelper(T (&)[N]))[N]' : could not deduce template argument for 
'T (&)[N]' from 'FX_WCHAR *'
        d:\src\pdfium\core\include\fxcrt\fx_basic.h(35) : see declaration of 'ArraySizeHelper'

Original comment by brucedaw...@chromium.org on 23 Dec 2014 at 9:47

GoogleCodeExporter commented 9 years ago

Original comment by bo...@foxitsoftware.com on 23 Dec 2014 at 9:55