Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte Order Mark skipping #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sax/m_sax_xml_source.F90
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ subroutine parse_declaration(f, eof, es, standalone)
ch => null()
do
c = get_char_from_file(f, XML1_0, eof, es)
! If we don't have a sensible character it may be a Byte
! Order Mark. Skip it and carry on to see if we can still
! read.
if (parse_state == XD_0 .and. c /= '<') &
cycle
if (eof) then
call rewind_source(f)
exit
Expand Down
Binary file added sax/test/test_sax_fsm_1_utf16_bom.in
Binary file not shown.
2 changes: 2 additions & 0 deletions sax/test/test_sax_fsm_1_utf8_bom.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.1" standalone="yes"?>
<a/>
15 changes: 15 additions & 0 deletions sax/test/test_sax_parser_6.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
program test_sax_reader

use FoX_sax
type(xml_t) :: xp
integer :: iostat

call open_xml_file(xp, "test_sax_fsm_1_utf8_bom.in", iostat)

write(*,'(i1)') iostat

call parse(xp)

call close_xml_t(xp)

end program test_sax_reader
1 change: 1 addition & 0 deletions sax/test/test_sax_parser_6.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
15 changes: 15 additions & 0 deletions sax/test/test_sax_parser_7.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
program test_sax_reader

use FoX_sax
type(xml_t) :: xp
integer :: iostat

call open_xml_file(xp, "test_sax_fsm_1_utf16_bom.in", iostat)

write(*,'(i1)') iostat

call parse(xp)

call close_xml_t(xp)

end program test_sax_reader
3 changes: 3 additions & 0 deletions sax/test/test_sax_parser_7.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0
ERROR(FoX)
Illegal character found at test_sax_fsm_1_utf16_bom.in:0:3 Error parsing XML declaration (Possibly near line=0 col=3)