static void ps_putchar(struct termp *p, char c) { int pos; /* See ps_printf(). */ if ( ! (PS_MARGINS & p->ps->flags)) { putchar(c); p->ps->pdfbytes++; return; } ps_growbuf(p, 2); pos = (int)p->ps->psmargcur++; p->ps->psmarg[pos++] = c; p->ps->psmarg[pos] = '\0'; }
static void ps_printf(struct termp *p, const char *fmt, ...) { va_list ap; int pos, len; va_start(ap, fmt); /* * If we're running in regular mode, then pipe directly into * vprintf(). If we're processing margins, then push the data * into our growable margin buffer. */ if ( ! (PS_MARGINS & p->ps->flags)) { len = vprintf(fmt, ap); va_end(ap); p->ps->pdfbytes += /* LINTED */ len < 0 ? 0 : (size_t)len; return; } /* * XXX: I assume that the in-margin print won't exceed * PS_BUFSLOP (128 bytes), which is reasonable but still an * assumption that will cause pukeage if it's not the case. */ ps_growbuf(p, PS_BUFSLOP); pos = (int)p->ps->psmargcur; vsnprintf(&p->ps->psmarg[pos], PS_BUFSLOP, fmt, ap); va_end(ap); p->ps->psmargcur = strlen(p->ps->psmarg); }