* mdocml: Implement the \: (optional line break) escape sequence,
@ 2014-01-22 20:58 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2014-01-22 20:58 UTC (permalink / raw)
To: source
Log Message:
-----------
Implement the \: (optional line break) escape sequence,
documented in the Ossanna-Kernighan-Ritter troff manual
and also supported by groff.
Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
Modified Files:
--------------
mdocml:
chars.c
chars.in
html.c
mandoc.h
mandocdb.c
mdoc_man.c
term.c
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -Lterm.c -Lterm.c -u -p -r1.215 -r1.216
--- term.c
+++ term.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -179,7 +179,8 @@ term_flushln(struct termp *p)
/* Regular word. */
/* Break at the hyphen point if we overrun. */
if (vend > vis && vend < bp &&
- ASCII_HYPH == p->buf[j])
+ (ASCII_HYPH == p->buf[j] ||
+ ASCII_BREAK == p->buf[j]))
jhy = j;
vend += (*p->width)(p, p->buf[j]);
@@ -233,6 +234,8 @@ term_flushln(struct termp *p)
vbl += (*p->width)(p, ' ');
continue;
}
+ if (ASCII_BREAK == p->buf[i])
+ continue;
/*
* Now we definitely know there will be
@@ -644,7 +647,8 @@ term_strlen(const struct termp *p, const
int ssz, skip, c;
const char *seq, *rhs;
enum mandoc_esc esc;
- static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' };
+ static const char rej[] = { '\\', ASCII_NBRSP, ASCII_HYPH,
+ ASCII_BREAK, '\0' };
/*
* Account for escaped sequences within string length
@@ -732,6 +736,8 @@ term_strlen(const struct termp *p, const
case (ASCII_HYPH):
sz += cond_width(p, '-', &skip);
cp++;
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
break;
default:
break;
Index: chars.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -Lchars.c -Lchars.c -u -p -r1.54 -r1.55
--- chars.c
+++ chars.c
@@ -37,7 +37,7 @@ struct ln {
int unicode;
};
-#define LINES_MAX 329
+#define LINES_MAX 330
#define CHAR(in, ch, code) \
{ NULL, (in), (ch), (code) },
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.57 -r1.58
--- mdoc_man.c
+++ mdoc_man.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -364,6 +364,9 @@ print_word(const char *s)
break;
case (ASCII_HYPH):
putchar('-');
+ break;
+ case (ASCII_BREAK):
+ printf("\\:");
break;
case (' '):
if (MMAN_nbrword & outflags) {
Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -Lhtml.c -Lhtml.c -u -p -r1.153 -r1.154
--- html.c
+++ html.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -331,7 +331,8 @@ print_encode(struct html *h, const char
int c, len, nospace;
const char *seq;
enum mandoc_esc esc;
- static const char rejs[6] = { '\\', '<', '>', '&', ASCII_HYPH, '\0' };
+ static const char rejs[8] = { '\\', '<', '>', '&',
+ ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' };
nospace = 0;
@@ -360,8 +361,13 @@ print_encode(struct html *h, const char
case ('&'):
printf("&");
continue;
+ case (ASCII_NBRSP):
+ putchar('-');
+ continue;
case (ASCII_HYPH):
putchar('-');
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
continue;
default:
break;
Index: chars.in
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.in,v
retrieving revision 1.43
retrieving revision 1.44
diff -Lchars.in -Lchars.in -u -p -r1.43 -r1.44
--- chars.in
+++ chars.in
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -27,22 +28,25 @@
* XXX - update LINES_MAX if adding more!
*/
-/* Non-breaking, non-collapsing space uses unit separator. */
+/* Special break control characters. */
static const char ascii_nbrsp[2] = { ASCII_NBRSP, '\0' };
+static const char ascii_break[2] = { ASCII_BREAK, '\0' };
CHAR_TBL_START
/* Spacing. */
-CHAR("c", "", 0)
-CHAR("0", " ", 8194)
CHAR(" ", ascii_nbrsp, 160)
CHAR("~", ascii_nbrsp, 160)
-CHAR("%", "", 0)
-CHAR("&", "", 0)
-CHAR("^", "", 0)
+CHAR("0", " ", 8194)
CHAR("|", "", 0)
-CHAR("}", "", 0)
+CHAR("^", "", 0)
+CHAR("&", "", 0)
+CHAR("%", "", 0)
+CHAR(":", ascii_break, 0)
+/* XXX The following three do not really belong into this file. */
CHAR("t", "", 0)
+CHAR("c", "", 0)
+CHAR("}", "", 0)
/* Accents. */
CHAR("a\"", "\"", 779)
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.113 -r1.114
--- mandocdb.c
+++ mandocdb.c
@@ -1664,7 +1664,7 @@ static void
render_key(struct mchars *mc, struct str *key)
{
size_t sz, bsz, pos;
- char utfbuf[7], res[5];
+ char utfbuf[7], res[6];
char *buf;
const char *seq, *cpp, *val;
int len, u;
@@ -1676,7 +1676,8 @@ render_key(struct mchars *mc, struct str
res[1] = '\t';
res[2] = ASCII_NBRSP;
res[3] = ASCII_HYPH;
- res[4] = '\0';
+ res[4] = ASCII_BREAK;
+ res[5] = '\0';
val = key->key;
bsz = strlen(val);
@@ -1707,15 +1708,23 @@ render_key(struct mchars *mc, struct str
val += sz;
}
- if (ASCII_HYPH == *val) {
+ switch (*val) {
+ case (ASCII_HYPH):
buf[pos++] = '-';
val++;
continue;
- } else if ('\t' == *val || ASCII_NBRSP == *val) {
+ case ('\t'):
+ /* FALLTHROUGH */
+ case (ASCII_NBRSP):
buf[pos++] = ' ';
val++;
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
continue;
- } else if ('\\' != *val)
+ default:
+ break;
+ }
+ if ('\\' != *val)
break;
/* Read past the slash. */
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.114
retrieving revision 1.115
diff -Lmandoc.h -Lmandoc.h -u -p -r1.114 -r1.115
--- mandoc.h
+++ mandoc.h
@@ -20,6 +20,7 @@
#define ASCII_NBRSP 31 /* non-breaking space */
#define ASCII_HYPH 30 /* breakable hyphen */
+#define ASCII_BREAK 29 /* breakable zero-width space */
/*
* Status level. This refers to both internal status (i.e., whilst
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* mdocml: Implement the \: (optional line break) escape sequence,
@ 2014-01-22 21:02 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2014-01-22 21:02 UTC (permalink / raw)
To: source
Log Message:
-----------
Implement the \: (optional line break) escape sequence,
documented in the Ossanna-Kernighan-Ritter troff manual
and also supported by groff.
Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
Tags:
----
VERSION_1_12
Modified Files:
--------------
mdocml:
apropos_db.c
Revision Data
-------------
Index: apropos_db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Attic/apropos_db.c,v
retrieving revision 1.32.2.3
retrieving revision 1.32.2.4
diff -Lapropos_db.c -Lapropos_db.c -u -p -r1.32.2.3 -r1.32.2.4
--- apropos_db.c
+++ apropos_db.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -259,8 +259,8 @@ norm_string(const char *val, const struc
const char *seq, *cpp;
int len, u, pos;
enum mandoc_esc esc;
- static const char res[] = { '\\', '\t',
- ASCII_NBRSP, ASCII_HYPH, '\0' };
+ static const char res[] = { '\\', '\t', ASCII_NBRSP,
+ ASCII_HYPH, ASCII_BREAK, '\0' };
/* Pre-allocate by the length of the input */
@@ -280,15 +280,23 @@ norm_string(const char *val, const struc
val += (int)sz;
}
- if (ASCII_HYPH == *val) {
+ switch (*val) {
+ case (ASCII_HYPH):
(*buf)[pos++] = '-';
val++;
continue;
- } else if ('\t' == *val || ASCII_NBRSP == *val) {
+ case ('\t'):
+ /* FALLTHROUGH */
+ case (ASCII_NBRSP):
(*buf)[pos++] = ' ';
val++;
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
continue;
- } else if ('\\' != *val)
+ default:
+ break;
+ }
+ if ('\\' != *val)
break;
/* Read past the slash. */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-22 21:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-22 20:58 mdocml: Implement the \: (optional line break) escape sequence, schwarze
2014-01-22 21:02 schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).