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.
chprintf enhancement Topic is solved
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: chprintf enhancement
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
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
- FXCoder
- Posts: 384
- Joined: Sun Jun 12, 2016 4:10 am
- Location: Sydney, Australia
- Has thanked: 180 times
- Been thanked: 130 times
Re: chprintf enhancement
Hi,
The .n precision was broken by the malformed format string detection...
--
Bob
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;
- }
}
}
}
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Return to “Small Change Requests”
Who is online
Users browsing this forum: No registered users and 7 guests