Christian Weisgerber <[email protected]> writes:
> What actually uses textproc/sgmlformat?
>
> This package contains SGML formatting tools that were once a part
> of the base FreeBSD distribution. This port should be regarded
> as a temporary solution to formatting SGML files until the
> wrinkles in jade, a DSSSL processor, get ironed out.
>
> devel/c2hs depends on sgmlformat, but doesn't appear to use it.
>
> It seems the only other project that has sgmlformat is FreeBSD.
> Their port even features a regexp(3) to regex(3) conversion--which
> is badly botched, so that's rarely used functionality, I guess.
>
> sgmlformat is the last user of regexp(3) and converting it to
> regex(3) isn't straightforward, so if we could get rid of it
> altogether...
If no one chimes in, ok to delete it. This being said, here's a
compile-tested (and may^Wprobably incomplete) attempt to convert it to
regex(3).
Index: patches/patch-instant_Makefile
===================================================================
RCS file: /cvs/ports/textproc/sgmlformat/patches/patch-instant_Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 patch-instant_Makefile
--- patches/patch-instant_Makefile 26 Oct 2007 21:29:30 -0000 1.1
+++ patches/patch-instant_Makefile 30 Nov 2013 00:01:21 -0000
@@ -1,9 +1,11 @@
$OpenBSD: patch-instant_Makefile,v 1.1 2007/10/26 21:29:30 jasper Exp $
--- instant/Makefile.orig Wed Jul 16 18:42:34 1997
-+++ instant/Makefile Fri Oct 26 23:26:36 2007
-@@ -8,7 +8,6 @@ SRCS+= sgmls.c
++++ instant/Makefile Sat Nov 30 01:01:14 2013
+@@ -6,9 +6,7 @@ SRCS+= tranvar.c util.c
+ SRCS+= sgmls.c
+
CFLAGS+=-DTRANSPEC_DIR=\"${TRANSPEC_DIR}\"
- LDADD= -lcompat
+-LDADD= -lcompat
-MAN1= instant.1
-MAN5= transpec.5
Index: patches/patch-instant_tables_c
===================================================================
RCS file: patches/patch-instant_tables_c
diff -N patches/patch-instant_tables_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-instant_tables_c 30 Nov 2013 00:42:24 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+POSIX-compatible regexps.
+--- instant/tables.c.orig Sat Nov 30 01:41:40 2013
++++ instant/tables.c Sat Nov 30 01:41:45 2013
+@@ -84,7 +84,7 @@ static char *RCSid =
+ #include <sys/types.h>
+ #include <errno.h>
+
+-#include <regexp.h>
++#include <regex.h>
+ #include "general.h"
+ #include "translate.h"
+
Index: patches/patch-instant_traninit_c
===================================================================
RCS file: /cvs/ports/textproc/sgmlformat/patches/patch-instant_traninit_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-instant_traninit_c
--- patches/patch-instant_traninit_c 26 Oct 2007 21:29:30 -0000 1.1
+++ patches/patch-instant_traninit_c 30 Nov 2013 00:55:18 -0000
@@ -1,6 +1,16 @@
$OpenBSD: patch-instant_traninit_c,v 1.1 2007/10/26 21:29:30 jasper Exp $
+POSIX-compatible regexps.
--- instant/traninit.c.orig Wed Jul 16 18:44:12 1997
-+++ instant/traninit.c Fri Oct 26 23:26:37 2007
++++ instant/traninit.c Sat Nov 30 01:53:54 2013
+@@ -69,7 +69,7 @@ static char *RCSid =
+ #include <memory.h>
+ #include <sys/types.h>
+ #include <errno.h>
+-#include <regexp.h>
++#include <regex.h>
+
+ #include "general.h"
+ #include "translate.h"
@@ -129,7 +129,7 @@ ReadTransSpec(
char buf[LINESIZE];
char buf2[LINESIZE];
@@ -10,3 +20,42 @@ $OpenBSD: patch-instant_traninit_c,v 1.1
char maptype = '\0';
(void)sgmls_set_errhandler(input_error);
+@@ -392,7 +392,7 @@ static void build_ts(char *gi, char* cp)
+ tok = Split(cp, &i, S_STRDUP);
+ T.var_RE_name = tok[0];
+ ExpandVariables(tok[1], buf, 0);
+- if (!(T.var_RE_value=regcomp(buf))) {
++ if (regcomp(&T.var_RE_value, buf, REG_BASIC|REG_NOSUB)) {
+ fprintf(stderr, "Regex error in VarREValue Content: %s\n",
+ tok[1]);
+ }
+@@ -454,7 +454,7 @@ RememberTransSpec(
+
+ if (do_regex) {
+ t->depth = MAX_DEPTH;
+- if (!(t->context_re=regcomp(t->context))) {
++ if (regcomp(&t->context_re, t->context, REG_BASIC|REG_NOSUB)) {
+ fprintf(stderr, "Regex error in Context: %s\n", t->context);
+ }
+ }
+@@ -493,17 +493,17 @@ RememberTransSpec(
+ else { /* value not found */
+ t->attpair[i].val = ".";
+ }
+- if (!(t->attpair[i].rex=regcomp(t->attpair[i].val))) {
++ if (regcomp(&t->attpair[i].rex, t->attpair[i].val,
++ REG_BASIC|REG_NOSUB)) {
+ fprintf(stderr, "Regex error in AttValue: %s %s\n",
+ t->attpair[i].name, t->attpair[i].val);
+ }
+ }
+
+ /* Compile regular expression for content */
+- t->content_re = 0;
+ if (t->content) {
+ ExpandVariables(t->content, buf, 0);
+- if (!(t->content_re=regcomp(buf)))
++ if (regcomp(&t->content_re, buf, REG_BASIC|REG_NOSUB))
+ fprintf(stderr, "Regex error in Content: %s\n",
+ t->content);
+ }
Index: patches/patch-instant_translate_c
===================================================================
RCS file: patches/patch-instant_translate_c
diff -N patches/patch-instant_translate_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-instant_translate_c 30 Nov 2013 10:55:23 -0000
@@ -0,0 +1,69 @@
+$OpenBSD$
+POSIX-compatible regexps.
+--- instant/translate.c.orig Sun Sep 8 03:55:10 1996
++++ instant/translate.c Sat Nov 30 11:54:58 2013
+@@ -69,7 +69,7 @@ static char *RCSid =
+ #include <memory.h>
+ #include <sys/types.h>
+ #include <errno.h>
+-#include <regexp.h>
++#include <regex.h>
+
+ #include "general.h"
+ #define STORAGE
+@@ -415,11 +415,23 @@ FindTrans(
+ if (!QRelation(e, t->parent, REL_Parent)) continue;
+
+ if (t->context) { /* no context specified -> a match */
++ char *cp;
++ int do_regex = 0;
++
++ for (do_regex=0,cp=t->context; *cp; cp++) {
++ if (!isalnum(*cp) && *cp != '-' && *cp != '.' && *cp != ' ') {
++ do_regex = 1;
++ break;
++ }
++ }
++
+ FindContext(e, t->depth, context);
+
+ /* If reg expr set, do regex compare; else just string compare. */
+- if (t->context_re) {
+- if (! regexec(t->context_re, context)) continue;
++ if (do_regex) {
++ if (regexec(&t->context_re, context, 0, NULL,
++ REG_NOTBOL|REG_NOTEOL) != 0)
++ continue;
+ }
+ else {
+ /* Is depth of spec deeper than element's depth? */
+@@ -439,7 +451,9 @@ FindTrans(
+ match = 0;
+ break;
+ }
+- if (!regexec(t->attpair[a].rex, atval)) match = 0;
++ if (regexec(&t->attpair[a].rex, atval, 0, NULL,
++ REG_NOTBOL|REG_NOTEOL) != 0)
++ match = 0;
+ }
+ if (!match) continue;
+ }
+@@ -499,13 +513,16 @@ FindTrans(
+ /* check for variable regular expression match */
+ if ( t->var_RE_name ) {
+ cp = FindMappingVal(Variables, t->var_RE_name);
+- if (!cp || !regexec(t->var_RE_value, cp)) continue;
++ if (!cp || regexec(&t->var_RE_value, cp, 0, NULL,
++ REG_NOTBOL|REG_NOTEOL) != 0)
++ continue;
+ }
+
+ /* check content */
+ if (t->content) { /* no att specified -> a match */
+ for (match=0,i=0; i<e->ndcont; i++) {
+- if (regexec(t->content_re, e->dcont[i])) {
++ if (regexec(&t->content_re, e->dcont[i], 0, NULL,
++ REG_NOTBOL|REG_NOTEOL) == 0) {
+ match = 1;
+ break;
+ }
Index: patches/patch-instant_translate_h
===================================================================
RCS file: patches/patch-instant_translate_h
diff -N patches/patch-instant_translate_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-instant_translate_h 30 Nov 2013 00:55:18 -0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+POSIX-compatible regexps.
+--- instant/translate.h.orig Sat Nov 30 01:41:40 2013
++++ instant/translate.h Sat Nov 30 01:49:24 2013
+@@ -75,7 +75,7 @@ typedef enum { RA_Current, RA_Related } RelAction_t;
+ typedef struct {
+ char *name; /* attribute name string */
+ char *val; /* attribute value string */
+- regexp *rex; /* attribute value reg expr (compiled) */
++ regex_t rex; /* attribute value reg expr (compiled) */
+ } AttPair_t;
+
+ typedef struct _Trans {
+@@ -83,19 +83,19 @@ typedef struct _Trans {
+ char *gi; /* element name of tag under consideration */
+ char **gilist; /* list of element names (multiple gi's) */
+ char *context; /* context in tree - looking depth levels up */
+- regexp *context_re; /* tree heirarchy looking depth levels up */
++ regex_t context_re; /* tree heirarchy looking depth levels up */
+ int depth; /* number of levels to look up the tree
*/
+ AttPair_t *attpair; /* attr name-value pairs */
+ int nattpairs; /* number of name-value pairs */
+ char *parent; /* GI has this element as parent */
+ int nth_child; /* GI is Nth child of this of parent
element */
+ char *content; /* element has this string in content */
+- regexp *content_re; /* content reg expr (compiled) */
++ regex_t content_re; /* content reg expr (compiled) */
+ char *pattrset; /* is this attr set (any value) in parent? */
+ char *var_name; /* variable name */
+ char *var_value; /* variable value */
+ char *var_RE_name; /* variable name (for VarREValue) */
+- regexp *var_RE_value; /* variable value (compiled, for VarREValue) */
++ regex_t var_RE_value; /* variable value (compiled, for VarREValue) */
+ Map_t *relations; /* various relations to check */
+
+ /* actions */
Index: patches/patch-instant_tranvar_c
===================================================================
RCS file: patches/patch-instant_tranvar_c
diff -N patches/patch-instant_tranvar_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-instant_tranvar_c 30 Nov 2013 00:42:36 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+POSIX-compatible regexps.
+--- instant/tranvar.c.orig Sat Nov 30 01:41:40 2013
++++ instant/tranvar.c Sat Nov 30 01:41:45 2013
+@@ -66,7 +66,7 @@ static char *RCSid =
+ #include <sys/types.h>
+ #include <errno.h>
+
+-#include <regexp.h>
++#include <regex.h>
+ #include "general.h"
+ #include "translate.h"
+
Index: patches/patch-instant_util_c
===================================================================
RCS file: patches/patch-instant_util_c
diff -N patches/patch-instant_util_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-instant_util_c 30 Nov 2013 00:42:41 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+POSIX-compatible regexps.
+--- instant/util.c.orig Sat Nov 30 01:41:40 2013
++++ instant/util.c Sat Nov 30 01:41:45 2013
+@@ -85,7 +85,7 @@ static char *RCSid =
+ #include <sys/stat.h>
+ #include <sys/file.h>
+ #include <errno.h>
+-#include <regexp.h>
++#include <regex.h>
+ /* CSS don't have it and I don't see where it's used
+ #include <values.h>
+ */