Skip to content

Commit 679931a

Browse files
committed
fix small example
1 parent cdea770 commit 679931a

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

cprintf.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
5353

5454
int cprintf_capi(int stream, const char * format)
5555
{
56+
if (_cprintf_::get_num_format_specifiers_in_string(_cprintf_::ascii_to_unicode_string_conversion(format)))
57+
{
58+
return 2;
59+
}
60+
5661
switch (stream) {
5762
case 1:
5863
return cprintf(stdout, format);

cprintf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _promote_va_arg(a):
4141
return casted
4242

4343
def invoke(lib_hndl, *args):
44-
API_name = "cprintf_c"
44+
API_name = "cprintf_capi"
4545
if not hasattr(lib_hndl, API_name):
4646
raise ValueError("cprintf error: Unsupported Type combination")
4747
lib_func = getattr(lib_hndl, API_name)

cprintf_examples.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <cprintf/cprintf.h>
22
#include <cinttypes> // PRIu32
3+
34
int main(void) {
45
cprintf(stdout, "Characters: $R%c %c \n", 'a', 65);
56
cprintf(stderr, "$GDecimals$?: %d %ld\n", 1977, 650000L);

cprintf_examples.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
from sys import stdout, stderr
2323

2424
def main():
25-
cprintf("$Yhello world!!\n")
26-
sys.exit(1)
27-
#cprintf(stdout, "Characters: $R%c %c \n", 'a', 65)
28-
#cprintf(stderr, "$GDecimals$?: %d %ld\n", 1977, 650000L)
29-
cprintf("$BPreceding with blanks: %10d \n", 1977)
25+
cprintf(stdout, "Characters: $R{} {:c} \n".format('a', 65))
26+
cprintf(stderr, "$GDecimals$?: {} {}\n".format(1977, 650000))
27+
cprintf("$BPreceding with blanks: {0:{width}{base}} \n".format(1977, width=4, base=10))
28+
sys.exit(0)
3029
cprintf("Preceding with zeros: $Y%010d \n", 1977)
3130
#cprintf("Some different radices: %d %x %o $M%#x$W %#o \n", 100, 100, 100, 100, 100)
3231
#cprintf("floats: %4.2f $C%+.0e$? %E \n", 3.1416, 3.1416, 3.1416)

0 commit comments

Comments
 (0)