Skip to content

Commit

Permalink
New MSVC support, license update, tiny simplification (charlesnichols…
Browse files Browse the repository at this point in the history
…on#237)

* just write 1 to cbuf_len instead of incrementing, for percent and char

* shut up msvc about implicit fall-through, it's intentional

* shut up msvc about doctest

* more msvc fixing

* bump paland

* shut up msvc about doctest

* shut up msvc about doctest
  • Loading branch information
charlesnicholson authored Dec 3, 2022
1 parent c2d00b2 commit c707dc4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ structure is to make nanoprintf as consumable as possible in as many
environments / countries / companies as possible without encumbering
users.

This license applies to all of the nanoprintf source code, build code,
and tests, with the explicit exception of doctest.h, which exists under
its own license and is included in this repository.

The text of the two licenses follows below:

============================== UNLICENSE ==============================
Expand Down
11 changes: 6 additions & 5 deletions nanoprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ NPF_VISIBILITY int npf_vpprintf(
#pragma warning(push)
#pragma warning(disable:4514) // unreferenced inline function removed
#pragma warning(disable:4505) // unreferenced function removed
#pragma warning(disable:4820) // padding after data member
#pragma warning(disable:5039) // extern "C" throw
#pragma warning(disable:5045) // spectre mitigation
#pragma warning(disable:4701) // possibly uninitialized
#pragma warning(disable:4706) // assignment in conditional
#pragma warning(disable:4710) // not inlined
#pragma warning(disable:4711) // selected for inline
#pragma warning(disable:4820) // padding after data member
#pragma warning(disable:5039) // extern "C" throw
#pragma warning(disable:5045) // spectre mitigation
#pragma warning(disable:5262) // implicit switch fall-through
#endif

#if (NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS == 1) || \
Expand Down Expand Up @@ -751,12 +752,12 @@ int npf_vpprintf(npf_putc pc, void *pc_ctx, char const *format, va_list args) {
switch (fs.conv_spec) {
case NPF_FMT_SPEC_CONV_PERCENT:
*cbuf = '%';
++cbuf_len;
cbuf_len = 1;
break;

case NPF_FMT_SPEC_CONV_CHAR:
*cbuf = (char)va_arg(args, int);
++cbuf_len;
cbuf_len = 1;
break;

case NPF_FMT_SPEC_CONV_STRING: {
Expand Down
1 change: 1 addition & 0 deletions tests/conformance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma warning(disable:5039) // extern "c" throw
#pragma warning(disable:4710) // function not inlined
#pragma warning(disable:4711) // selected for inline
#pragma warning(disable:5264) // const variable not used (shut up doctest)
#endif

#define NANOPRINTF_IMPLEMENTATION
Expand Down
2 changes: 2 additions & 0 deletions tests/doctest_main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifdef _MSC_VER
#pragma warning(disable:5246) // initialization of subobject needs braces
#pragma warning(disable:5262) // implicit switch fall-through
#pragma warning(disable:5264) // unused const variable
#endif

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
Expand Down
2 changes: 1 addition & 1 deletion tests/mpaland-conformance
Submodule mpaland-conformance updated 1 files
+2 −0 paland.cc
1 change: 1 addition & 0 deletions tests/unit_nanoprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#pragma warning(disable:4711) // function was inlined
#pragma warning(disable:4514) // unreferenced inline function has been removed
#pragma warning(disable:5039) // could throw inside extern c function
#pragma warning(disable:5264) // const variable not used (shut up doctest)
#endif

#include "doctest.h"
Expand Down

0 comments on commit c707dc4

Please sign in to comment.