aboutsummaryrefslogtreecommitdiffhomepage
path: root/io.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-14 17:27:37 +0100
committerlemon <lsof@mailbox.org>2026-03-14 17:46:54 +0100
commit42ce457bba06bd3607fc04700a919b6c395f22c3 (patch)
tree77a3f2230324248055a69a41d12b18471d56fe4f /io.c
parent1f3ebe69478f245f69cd6f77db946226557085d2 (diff)
c: static eval refactoring
Explicit node for static symbol (addresses). Should not break with edge cases like the previous ad-hoc approach. And some other bugfixes
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/io.c b/io.c
index f29e6d3..d33afb1 100644
--- a/io.c
+++ b/io.c
@@ -300,7 +300,7 @@ putdouble(struct wbuf *buf, double x)
int
vbfmt(struct wbuf *out, const char *fmt, va_list ap)
{
- bool quote, umod, lmod, zmod, lower;
+ bool quote, umod, lmod, zmod, lower, possign;
int base;
vlong i;
int pad, prec, q;
@@ -326,6 +326,7 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
continue;
}
fmt += quote = *fmt == '\'';
+ fmt += possign = *fmt == '+';
pad = 0;
if (aisdigit(*fmt)) { /* left pad */
for (; aisdigit(*fmt); ++fmt)
@@ -421,6 +422,12 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
: zmod && sizeof(&i-&i) > sizeof(int) ? va_arg(ap, vlong)
: (vlong)va_arg(ap, int);
tmp2.len = 0;
+ if (!umod && i < 0) {
+ n += bputc(buf, '-');
+ i = -(uvlong)i;
+ } else if (possign) {
+ n += bputc(buf, '+');
+ }
if (quote) {
switch (base) {
case 2: n += bwriteS(buf, "0b"); break;
@@ -428,10 +435,6 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
case 16: n += bwriteS(buf, "0x"); break;
}
}
- if (!umod && i < 0) {
- n += bputc(buf, '-');
- i = -(uvlong)i;
- }
n += putuint(prec > 0 ? &tmp2 : buf, i, base, lower);
if (prec > 0) {
int fil = prec - tmp2.len;