boostorg / wave

Boost.org wave module
http://boost.org/libs/wave
21 stars 49 forks source link

Qualify "newline at EOF not required" with actually being there #141

Closed jefftrull closed 2 years ago

jefftrull commented 2 years ago

In C++11 and later modes Wave by default does not require newline prior to EOF. This works fine but there is one place where the test for this feature was used where Wave is not necessarily looking at the end of the file: pp_is_last_on_line. One observable (and surprising) result is that unknown directives are not getting flagged - but there may be others. The unit tests did not discover this problem because they generally do not set c++11 mode.

This PR adds the necessary qualifiers and adds a unit test (the same as an existing one but with C++11 enabled).

If merged this will resolve #137

jefftrull commented 2 years ago

btw @hkaiser Wave also has the language option single_line which is documented as:

If the support_option_single_line flag is set, the Wave library will now report an error if the last line of the processed input is not terminated by a new line...

no_newline_at_end_of_file is unfortunately not documented in the same place - what's the difference? should we add an explanation?

jefftrull commented 2 years ago

I'm thinking in particular of this old trac report which I believe is referencing this logic

hkaiser commented 2 years ago

btw @hkaiser Wave also has the language option single_line which is documented as:

If the support_option_single_line flag is set, the Wave library will now report an error if the last line of the processed input is not terminated by a new line...

no_newline_at_end_of_file is unfortunately not documented in the same place - what's the difference? should we add an explanation?

@jefftrull I don't have any recollection of the difference, sorry :/ My best guess would be that the former is applied in single-line mode, the latter in normal mode.

jefftrull commented 2 years ago

btw @hkaiser Wave also has the language option single_line which is documented as:

If the support_option_single_line flag is set, the Wave library will now report an error if the last line of the processed input is not terminated by a new line...

no_newline_at_end_of_file is unfortunately not documented in the same place - what's the difference? should we add an explanation?

@jefftrull I don't have any recollection of the difference, sorry :/ My best guess would be that the former is applied in single-line mode, the latter in normal mode.

I think I get it now, perhaps... maybe the documentation should say "... the Wave library will not report an error..."? That would explain that TRAC report. Actually I might rewrite it to explain that it does more than that. I'll send another PR.