Page 1 of 1
chprintf enhancement Topic is solved
Posted: Thu Apr 19, 2018 1:20 pm
by steved
I made a small change to chprintf() to support '+' within the formatting definition.
Also wasn't clear on a quick look whether getting the width specification from a variable would work; I've highlighted this and suggested an alternative.
Re: chprintf enhancement
Posted: Sun Jan 06, 2019 4:59 pm
by Giovanni
bump
Re: chprintf enhancement
Posted: Fri May 31, 2019 11:13 am
by steved
Updated for 19.1
Re: chprintf enhancement
Posted: Fri May 31, 2019 1:22 pm
by Giovanni
Hi,
I merged it with some fixes and also made some other changes. It is possible I introduced problems but it was needed, final zero was not always detected in the format string if malformed. That TODO was correct IMO, fixed that as well.
Giovanni
Re: chprintf enhancement
Posted: Sun Jun 16, 2019 7:49 am
by FXCoder
Hi,
The .n precision was broken by the malformed format string detection...
--
Bob
Code: Select all
Index: chprintf.c
===================================================================
--- chprintf.c (revision 12837)
+++ chprintf.c (working copy)
@@ -203,18 +203,13 @@
precision = va_arg(ap, int);
}
else {
- while (true) {
+ while (c >= '0' && c <= '9') {
+ c -= '0';
+ precision = precision * 10 + c;
c = *fmt++;
if (c == 0) {
return n;
}
- if (c >= '0' && c <= '9') {
- c -= '0';
- precision = precision * 10 + c;
- }
- else {
- break;
- }
}
}
}
Re: chprintf enhancement
Posted: Sun Jun 16, 2019 1:02 pm
by Giovanni
Fix committed thanks.
Giovanni