ref: ad010bdfe465964f5c901be74d3abeff4edd94ce
parent: 0b94c7c529bf0baf7685990596e2cd58f354e11a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Sep 26 09:09:51 EDT 2014
ren: end diversions with a newline instead of using sbuf_putnl()
--- a/ren.c
+++ b/ren.c
@@ -72,7 +72,6 @@
n_mk = 0;
n_ns = 0;
} else if (cdiv) {
- sbuf_putnl(&cdiv->sbuf);
sbuf_printf(&cdiv->sbuf, "%c%s\n", c_cc, TR_DIVEND);
str_set(cdiv->reg, sbuf_buf(&cdiv->sbuf));
sbuf_done(&cdiv->sbuf);
@@ -159,12 +158,10 @@
n_d += n ? n : n_v;
if (n_d > n_h)
n_h = n_d;
- if (cdiv && !nodiv) {
- sbuf_putnl(&cdiv->sbuf);
+ if (cdiv && !nodiv)
sbuf_printf(&cdiv->sbuf, "%csp %du\n", c_cc, n ? n : n_v);
- } else {
+ else
n_nl = n_d;
- }
}
static int render_rec(int level);
@@ -253,6 +250,7 @@
sbuf_append(&cdiv->sbuf, beg);
sbuf_append(&cdiv->sbuf, mid);
sbuf_append(&cdiv->sbuf, end);
+ sbuf_append(&cdiv->sbuf, "\n");
} else {
out("H%d\n", n_o);
out("V%d\n", n_d);
--- a/roff.h
+++ b/roff.h
@@ -220,7 +220,6 @@
void sbuf_add(struct sbuf *sbuf, int c);
void sbuf_append(struct sbuf *sbuf, char *s);
void sbuf_printf(struct sbuf *sbuf, char *s, ...);
-void sbuf_putnl(struct sbuf *sbuf);
void sbuf_cut(struct sbuf *sbuf, int n);
int sbuf_len(struct sbuf *sbuf);
int sbuf_empty(struct sbuf *sbuf);
--- a/sbuf.c
+++ b/sbuf.c
@@ -49,12 +49,6 @@
sbuf_append(sbuf, buf);
}
-void sbuf_putnl(struct sbuf *sbuf)
-{
- if (sbuf->n && sbuf->s[sbuf->n - 1] != '\n')
- sbuf_add(sbuf, '\n');
-}
-
int sbuf_empty(struct sbuf *sbuf)
{
return !sbuf->n;