Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
On Sat, Apr 16, 2016 at 10:52 PM, Nick Wellnhofer 
wrote:

> On 16/04/2016 22:41, Sylvain Pointeau wrote:
>
>> for reference I compile libxml this way:
>> cscript.exe configure.js iconv=no ftp=no http=no compiler=msvc
>> cruntime=/MT
>>   debug=yes  prefix="build_debug_static_mt" static=yes
>>
>
> When compiling a DLL, /MD should be used instead of /MT. Simply remove
> "cruntime=/MT" and "static=yes".
>
>
Thank you very much, I did not know, it works now.

I used the following (debug):
cscript.exe configure.js iconv=no ftp=no http=no legacy=no compiler=msvc
cruntime=/MDd debug=yes prefix="build_debug_MDd" static=no

I would like to make another dll, my own dll, using libxml, would you
recommend to link statically or dynamically?
(knowing that the end program could use also libxml apart of my dll)


> additionally I removed iconv (iconv=no), do you confirm that reading UTF-8
>> and
>> UTF-16 will still work?
>>
>
> Yes, the UTF encodings work without iconv.
>
>
Excellent thank you for the confirmation.


> Nick
>
>
Best regards,
Sylvain
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Nick Wellnhofer

On 16/04/2016 22:41, Sylvain Pointeau wrote:

for reference I compile libxml this way:
cscript.exe configure.js iconv=no ftp=no http=no compiler=msvc cruntime=/MT
  debug=yes  prefix="build_debug_static_mt" static=yes


When compiling a DLL, /MD should be used instead of /MT. Simply remove 
"cruntime=/MT" and "static=yes".



additionally I removed iconv (iconv=no), do you confirm that reading UTF-8 and
UTF-16 will still work?


Yes, the UTF encodings work without iconv.

Nick
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
Hello,

It works if I link (statically) to libxml2_a_dll.lib or libxml2_a.lib

what is the difference between the two libs?

for reference I compile libxml this way:
cscript.exe configure.js iconv=no ftp=no http=no compiler=msvc cruntime=/MT
 debug=yes  prefix="build_debug_static_mt" static=yes

I am not sure about the flag static=yes... it seems there is no effect, do
you confirm?

additionally I removed iconv (iconv=no), do you confirm that reading UTF-8
and UTF-16 will still work?

do you have any idea why the dynamic linking is not working?

Best regards,
Sylvain






On Sat, Apr 16, 2016 at 5:44 PM, Sylvain Pointeau <
sylvain.point...@gmail.com> wrote:

> Hello,
>
> it also fails when creating the FILE *f = (FILE*) xmlFileOpen(
> "C:\\test_data\\testxml.xml");
> or using the file descriptor:
>
> int fd = _open("C:\\test_data\\testxml.xml", _O_CREAT | _O_RDWR);
>
> xmlOutputBufferPtr output = xmlOutputBufferCreateFd(fd, NULL);
>
> Does anyone have an idea on where the issue could be?
>
> Best regards,
> Sylvain
>
> On Sat, Apr 16, 2016 at 11:59 AM, Sylvain Pointeau <
> sylvain.point...@gmail.com> wrote:
>
>> hello again,
>>
>> I investigated a bit more with my own compiled libxml2 in debug mode, the
>> stack trace is:
>>
>>   libxml2.dll!_invalid_parameter(const wchar_t * const expression, const
>> wchar_t * const function_name, const wchar_t * const file_name, const
>> unsigned int line_number, const unsigned int reserved) Line 91 C++
>>   libxml2.dll!_invalid_parameter_noinfo() Line 97 C++
>>   libxml2.dll!_write(int fh, const void * buffer, unsigned int size)
>> Line 48 C++
>> > libxml2.dll!__acrt_stdio_flush_nolock(_iobuf * public_stream) Line 152
>> C++
>>   libxml2.dll!_fflush_nolock(_iobuf * public_stream) Line 114 C++
>>   libxml2.dll!fflush(_iobuf * stream) Line 94 C++
>>   libxml2.dll!xmlFileFlush(void * context) Line 1104 C
>>   libxml2.dll!xmlOutputBufferClose(_xmlOutputBuffer * out) Line 2606 C
>>
>> Best regards,
>> Sylvain
>>
>>
>>
>> On Sat, Apr 16, 2016 at 11:25 AM, Sylvain Pointeau <
>> sylvain.point...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> using
>>> xmlOutputBufferPtr output = xmlOutputBufferCreateFilename("C
>>> :\\myfolder\testdata.xml", 0, 0);
>>> works...
>>>
>>> what can be wrong with xmlOutputBufferCreateFile?
>>>
>>> Best regards,
>>> Sylvain
>>>
>>> On Sat, Apr 16, 2016 at 10:23 AM, Sylvain Pointeau <
>>> sylvain.point...@gmail.com> wrote:
>>>
 Hello,

 porting my program on windows, I noticed that xmlOutputBufferCreateFile
 raised a message  I/O error : Bad file descriptor. Below is the sample
 program that crashes for me:

 FILE *f = fopen("C:\\myfolder\testdata.xml", "w");

 xmlOutputBufferPtr output = xmlOutputBufferCreateFile(f, NULL);

 xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");

 xmlOutputBufferClose(output); <- at this moment it displays I/O error
 : Bad file descriptor

 fclose(f);

 I linked on libs pre-compiled for win32,
 I also tried with the lib I compiled myself, it even crashes in this
 case (it does not display IO error)

 Please note that the parsing (SAX) runs well.

 Do you have any idea? is it a bug or something I am not doing well?

 Best regards,
 Sylvain

>>>
>>>
>>
>
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
Hello,

it also fails when creating the FILE *f = (FILE*) xmlFileOpen(
"C:\\test_data\\testxml.xml");
or using the file descriptor:

int fd = _open("C:\\test_data\\testxml.xml", _O_CREAT | _O_RDWR);

xmlOutputBufferPtr output = xmlOutputBufferCreateFd(fd, NULL);

Does anyone have an idea on where the issue could be?

Best regards,
Sylvain

On Sat, Apr 16, 2016 at 11:59 AM, Sylvain Pointeau <
sylvain.point...@gmail.com> wrote:

> hello again,
>
> I investigated a bit more with my own compiled libxml2 in debug mode, the
> stack trace is:
>
>   libxml2.dll!_invalid_parameter(const wchar_t * const expression, const
> wchar_t * const function_name, const wchar_t * const file_name, const
> unsigned int line_number, const unsigned int reserved) Line 91 C++
>   libxml2.dll!_invalid_parameter_noinfo() Line 97 C++
>   libxml2.dll!_write(int fh, const void * buffer, unsigned int size) Line
> 48 C++
> > libxml2.dll!__acrt_stdio_flush_nolock(_iobuf * public_stream) Line 152
> C++
>   libxml2.dll!_fflush_nolock(_iobuf * public_stream) Line 114 C++
>   libxml2.dll!fflush(_iobuf * stream) Line 94 C++
>   libxml2.dll!xmlFileFlush(void * context) Line 1104 C
>   libxml2.dll!xmlOutputBufferClose(_xmlOutputBuffer * out) Line 2606 C
>
> Best regards,
> Sylvain
>
>
>
> On Sat, Apr 16, 2016 at 11:25 AM, Sylvain Pointeau <
> sylvain.point...@gmail.com> wrote:
>
>> Hello,
>>
>> using
>> xmlOutputBufferPtr output = xmlOutputBufferCreateFilename("C
>> :\\myfolder\testdata.xml", 0, 0);
>> works...
>>
>> what can be wrong with xmlOutputBufferCreateFile?
>>
>> Best regards,
>> Sylvain
>>
>> On Sat, Apr 16, 2016 at 10:23 AM, Sylvain Pointeau <
>> sylvain.point...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> porting my program on windows, I noticed that xmlOutputBufferCreateFile
>>> raised a message  I/O error : Bad file descriptor. Below is the sample
>>> program that crashes for me:
>>>
>>> FILE *f = fopen("C:\\myfolder\testdata.xml", "w");
>>>
>>> xmlOutputBufferPtr output = xmlOutputBufferCreateFile(f, NULL);
>>>
>>> xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
>>>
>>> xmlOutputBufferClose(output); <- at this moment it displays I/O error :
>>> Bad file descriptor
>>>
>>> fclose(f);
>>>
>>> I linked on libs pre-compiled for win32,
>>> I also tried with the lib I compiled myself, it even crashes in this
>>> case (it does not display IO error)
>>>
>>> Please note that the parsing (SAX) runs well.
>>>
>>> Do you have any idea? is it a bug or something I am not doing well?
>>>
>>> Best regards,
>>> Sylvain
>>>
>>
>>
>
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
On Sat, Apr 16, 2016 at 1:02 PM, gait.boxman 
wrote:

> You're missing a backslash in the path..
>
> --Gait
>
> Verzonden vanaf mijn Samsung Galaxy-smartphone.
>  Oorspronkelijk bericht 
> Van: Sylvain Pointeau 
> Datum: 16-04-2016 10:23 (GMT+01:00)
> Aan: xml@gnome.org
> Onderwerp: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file
> descriptor
>
> Hello,
>
> porting my program on windows, I noticed that xmlOutputBufferCreateFile
> raised a message  I/O error : Bad file descriptor. Below is the sample
> program that crashes for me:
>
> FILE *f = fopen("C:\\myfolder\testdata.xml", "w");
>
> xmlOutputBufferPtr output = xmlOutputBufferCreateFile(f, NULL);
>
> xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
>
> xmlOutputBufferClose(output); <- at this moment it displays I/O error :
> Bad file descriptor
>
> fclose(f);
>
> I linked on libs pre-compiled for win32,
> I also tried with the lib I compiled myself, it even crashes in this case
> (it does not display IO error)
>
> Please note that the parsing (SAX) runs well.
>
> Do you have any idea? is it a bug or something I am not doing well?
>
> Best regards,
> Sylvain
>


Actually I made the mistake to replace the path at the last minute for the
email, but the path was correct in my test program. I really don't
understand where the issue could be...
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
On Sat, Apr 16, 2016 at 12:53 PM, Nikolay Sivov 
wrote:

> On 16.04.2016 11:23, Sylvain Pointeau wrote:
> >
> > FILE*f = fopen("C:\\myfolder\\testdata.xml", "w");
> >
> > xmlOutputBufferPtroutput = xmlOutputBufferCreateFile(f, NULL);
> >
> > xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
> >
> > xmlOutputBufferClose(output); <- at this moment it displays I/O error :
> > Bad file descriptor
> >
> > fclose(f);
> >
> >
>
> Not sure if it's important, but I see that internally libxml2 opens with
> "wb" mode in some cases.
>
>
no it does not solve the issue.
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Nikolay Sivov
On 16.04.2016 11:23, Sylvain Pointeau wrote:
> 
> FILE*f = fopen("C:\\myfolder\testdata.xml", "w");
> 
> xmlOutputBufferPtroutput = xmlOutputBufferCreateFile(f, NULL);
> 
> xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
> 
> xmlOutputBufferClose(output); <- at this moment it displays I/O error :
> Bad file descriptor
> 
> fclose(f);
> 
> 

Not sure if it's important, but I see that internally libxml2 opens with
"wb" mode in some cases.
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
hello again,

I investigated a bit more with my own compiled libxml2 in debug mode, the
stack trace is:

  libxml2.dll!_invalid_parameter(const wchar_t * const expression, const
wchar_t * const function_name, const wchar_t * const file_name, const
unsigned int line_number, const unsigned int reserved) Line 91 C++
  libxml2.dll!_invalid_parameter_noinfo() Line 97 C++
  libxml2.dll!_write(int fh, const void * buffer, unsigned int size) Line 48
C++
> libxml2.dll!__acrt_stdio_flush_nolock(_iobuf * public_stream) Line 152 C++
  libxml2.dll!_fflush_nolock(_iobuf * public_stream) Line 114 C++
  libxml2.dll!fflush(_iobuf * stream) Line 94 C++
  libxml2.dll!xmlFileFlush(void * context) Line 1104 C
  libxml2.dll!xmlOutputBufferClose(_xmlOutputBuffer * out) Line 2606 C

Best regards,
Sylvain



On Sat, Apr 16, 2016 at 11:25 AM, Sylvain Pointeau <
sylvain.point...@gmail.com> wrote:

> Hello,
>
> using
> xmlOutputBufferPtr output = xmlOutputBufferCreateFilename("C
> :\\myfolder\testdata.xml", 0, 0);
> works...
>
> what can be wrong with xmlOutputBufferCreateFile?
>
> Best regards,
> Sylvain
>
> On Sat, Apr 16, 2016 at 10:23 AM, Sylvain Pointeau <
> sylvain.point...@gmail.com> wrote:
>
>> Hello,
>>
>> porting my program on windows, I noticed that xmlOutputBufferCreateFile
>> raised a message  I/O error : Bad file descriptor. Below is the sample
>> program that crashes for me:
>>
>> FILE *f = fopen("C:\\myfolder\testdata.xml", "w");
>>
>> xmlOutputBufferPtr output = xmlOutputBufferCreateFile(f, NULL);
>>
>> xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
>>
>> xmlOutputBufferClose(output); <- at this moment it displays I/O error :
>> Bad file descriptor
>>
>> fclose(f);
>>
>> I linked on libs pre-compiled for win32,
>> I also tried with the lib I compiled myself, it even crashes in this case
>> (it does not display IO error)
>>
>> Please note that the parsing (SAX) runs well.
>>
>> Do you have any idea? is it a bug or something I am not doing well?
>>
>> Best regards,
>> Sylvain
>>
>
>
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlOutputBufferCreateFile VS2015 I/O error : Bad file descriptor

2016-04-16 Thread Sylvain Pointeau
Hello,

using
xmlOutputBufferPtr output = xmlOutputBufferCreateFilename("C
:\\myfolder\testdata.xml", 0, 0);
works...

what can be wrong with xmlOutputBufferCreateFile?

Best regards,
Sylvain

On Sat, Apr 16, 2016 at 10:23 AM, Sylvain Pointeau <
sylvain.point...@gmail.com> wrote:

> Hello,
>
> porting my program on windows, I noticed that xmlOutputBufferCreateFile
> raised a message  I/O error : Bad file descriptor. Below is the sample
> program that crashes for me:
>
> FILE *f = fopen("C:\\myfolder\testdata.xml", "w");
>
> xmlOutputBufferPtr output = xmlOutputBufferCreateFile(f, NULL);
>
> xmlOutputBufferWriteString(output, "WHY DO YOU CRASH?");
>
> xmlOutputBufferClose(output); <- at this moment it displays I/O error :
> Bad file descriptor
>
> fclose(f);
>
> I linked on libs pre-compiled for win32,
> I also tried with the lib I compiled myself, it even crashes in this case
> (it does not display IO error)
>
> Please note that the parsing (SAX) runs well.
>
> Do you have any idea? is it a bug or something I am not doing well?
>
> Best regards,
> Sylvain
>
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml