Module Name:    othersrc
Committed By:   agc
Date:           Wed Feb 22 01:01:40 UTC 2023

Modified Files:
        othersrc/external/bsd/elex/dist: agcre.c agcre.h elex.c elex.h main.c
        othersrc/external/bsd/elex/dist/tests: 28.expected

Log Message:
Update to elex version 20230221

20230221
========
+ protect elex embedded name space in a more extensible way
+ properly protect elex_make_new_rule
+ don't filter on symbol visibility, use LIB_NAMESPACE definition
+ sync agcre with bug fixes and reverse searching and other functionality 
updates
+ when searching elex start state names, use a hash value
+ bump version to 20230221


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/external/bsd/elex/dist/agcre.c \
    othersrc/external/bsd/elex/dist/agcre.h \
    othersrc/external/bsd/elex/dist/elex.c \
    othersrc/external/bsd/elex/dist/elex.h \
    othersrc/external/bsd/elex/dist/main.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/bsd/elex/dist/tests/28.expected

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/elex/dist/agcre.c
diff -u othersrc/external/bsd/elex/dist/agcre.c:1.1 othersrc/external/bsd/elex/dist/agcre.c:1.2
--- othersrc/external/bsd/elex/dist/agcre.c:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/agcre.c	Wed Feb 22 01:01:39 2023
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#define LIB_NAMESPACE	elex_
 #include "agcre.h"
 
 /* callback struct */
@@ -223,6 +224,7 @@ static int unicode_isOther_Uppercase(uin
 static int unicode_isPattern_White_Space(uint32_t /*ch*/);
 static int unicode_isalnum(uint32_t /*ch*/);
 static int unicode_isalpha(uint32_t /*ch*/);
+static int unicode_ispunct2(uint32_t /*ch*/);
 static int unicode_isblank(uint32_t /*ch*/);
 static int unicode_iscntrl(uint32_t /*ch*/);
 static int unicode_isdigit(uint32_t /*ch*/);
@@ -233,7 +235,7 @@ static int unicode_ispunct(uint32_t /*ch
 static int unicode_isspace(uint32_t /*ch*/);
 static int unicode_isupper(uint32_t /*ch*/);
 static int unicode_isxdigit(uint32_t /*ch*/);
-static int unicode_isident(uint32_t /*ch*/);
+static int unicode_isword(uint32_t /*ch*/);
 static uint32_t unicode_tolower(uint32_t /*ch*/);
 static uint32_t unicode_toupper(uint32_t /*ch*/);
 
@@ -417,7 +419,7 @@ emit(re_t *re, retoken_t *tok)
 			(tok->ch == 'd' || tok->ch == 'D') ? unicode_isdigit :
 			(tok->ch == 'p' || tok->ch == 'P') ? unicode_isprint :
 			(tok->ch == 's' || tok->ch == 'S') ? unicode_isspace :
-								unicode_isident,
+								unicode_isword,
 			unicode_isupper(tok->ch));
 		re->pc++;
 		return 1;
@@ -1169,16 +1171,16 @@ isendline(re_t *re, input_t *in)
 static inline int
 isbegword(re_t *re, input_t *in)
 {
-	return (isbegline(re, in) || !unicode_isident(in->prevch)) &&
-		unicode_isident(in->ch);
+	return (isbegline(re, in) || !unicode_isword(in->prevch)) &&
+		unicode_isword(in->ch);
 }
 
 /* return 1 at end of words */
 static inline int
 isendword(re_t *re, input_t *in)
 {
-	return (isendline(re, in) || (in->c > in->so && unicode_isident(in->prevch))) &&
-		(!unicode_isident(in->ch));
+	return (isendline(re, in) || (in->c > in->so && unicode_isword(in->prevch))) &&
+		(!unicode_isword(in->ch));
 }
 
 /* do the chars match? */
@@ -1577,10 +1579,6 @@ rec_posix_class(input_t *in, set_t *set)
 		set_add_callback(set, unicode_isgraph, 0);
 		in->c += 8;
 		return 1;
-	case /* ":ident:]" */ 0x8a1572f1:
-		set_add_callback(set, unicode_isident, 0);
-		in->c += 8;
-		return 1;
 	case /* ":lower:]" */ 0x8bfc6af8:
 		set_add_callback(set, unicode_islower, 0);
 		in->c += 8;
@@ -1593,6 +1591,10 @@ rec_posix_class(input_t *in, set_t *set)
 		set_add_callback(set, unicode_ispunct, 0);
 		in->c += 8;
 		return 1;
+	case /* ":punct2:]" */ 0xf09af6aa:
+		set_add_callback(set, unicode_ispunct2, 0);
+		in->c += 9;
+		return 1;
 	case /* ":space:]" */ 0xa876bcf2:
 		set_add_callback(set, unicode_isspace, 0);
 		in->c += 8;
@@ -1605,6 +1607,10 @@ rec_posix_class(input_t *in, set_t *set)
 		set_add_callback(set, unicode_isxdigit, 0);
 		in->c += 9;
 		return 1;
+	case /* ":word:]" */ 0x96b11914:
+		set_add_callback(set, unicode_isword, 0);
+		in->c += 7;
+		return 1;
 	default:
 		return 0;
 	}
@@ -1661,7 +1667,7 @@ rec_set(input_t *in)
 					(token->ch == 'd' || token->ch == 'D') ? unicode_isdigit :
 					(token->ch == 'p' || token->ch == 'P') ? unicode_isprint :
 					(token->ch == 's' || token->ch == 'S') ? unicode_isspace :
-										unicode_isident,
+										unicode_isword,
 					unicode_isupper((uint8_t)token->ch));
 				break;
 			}
@@ -2612,11 +2618,20 @@ unicode_isxdigit(uint32_t ch)
 }
 
 static int
-unicode_isident(uint32_t ch)
+unicode_isword(uint32_t ch)
 {
 	return unicode_isalnum(ch) || ch == '_';
 }
 
+static int
+unicode_ispunct2(uint32_t ch)
+{
+	if (!unicode_isprint(ch) || unicode_isspace(ch) || unicode_isword(ch)) {
+		return 0;
+	}
+	return 1;
+}
+
 static uint32_t
 unicode_tolower(uint32_t ch)
 {
@@ -2658,14 +2673,14 @@ growspace(char **buf, size_t *size, size
 /***********************************************************/
 
 /* allocate a new structure and return it */
-AGCRE_EXPORT agcre_regex_t *
+agcre_regex_t *
 agcre_new(void)
 {
 	return calloc(1, sizeof(agcre_regex_t));
 }
 
 /* compile regular expression */
-AGCRE_EXPORT int
+int
 agcre_regcomp(agcre_regex_t *agcre, const void *vs, uint32_t flags)
 {
 	retoken_t	*tok;
@@ -2737,7 +2752,7 @@ agcre_regcomp(agcre_regex_t *agcre, cons
 #endif
 
 /* format the error nicely */
-AGCRE_EXPORT size_t
+size_t
 agcre_regerror(int errcode, const agcre_regex_t *agcre, char *errbuf, size_t size)
 {
 	re_t	*re;
@@ -2751,7 +2766,7 @@ agcre_regerror(int errcode, const agcre_
 }
 
 /* execute the regular expression */
-AGCRE_EXPORT int
+int
 agcre_regexec(agcre_regex_t *agcre, const void *vs, size_t matchc, agcre_regmatch_t *m, uint32_t flags)
 {
 	threadlist_t	*current;
@@ -2917,14 +2932,16 @@ break_for:
 }
 
 /* execute the regular expression backwards */
-AGCRE_EXPORT int
+int
 agcre_rev_regexec(agcre_regex_t *agcre, const void *vs, size_t matchc, agcre_regmatch_t *m, uint32_t flags)
 {
-	int64_t	from;
-	int64_t	to;
-	int64_t	i;
-	int	found;
-	int	this;
+	uint32_t	revflags;
+	uint32_t	bolflags;
+	int64_t		from;
+	int64_t		to;
+	int64_t		i;
+	int		found;
+	int		lastmatch;
 
 	if (flags & AGCRE_REG_STARTEND) {
 		from = m[0].rm_so;
@@ -2933,23 +2950,36 @@ agcre_rev_regexec(agcre_regex_t *agcre, 
 		from = 0;
 		to = strlen(vs);
 	}
-	flags |= (AGCRE_REG_STARTEND | AGCRE_REG_ANCHOR);
+	/* initialise here or final regexec doesn't work for "^$" */
+	lastmatch = 0;
+	m[0].rm_so = from;
+	m[0].rm_eo = to;
+	/* quick check to see if we have anything */
+	if (agcre_regexec(agcre, vs, matchc, m, flags | AGCRE_REG_STARTEND) != 0) {
+		lastmatch = m[0].rm_so;
+		return AGCRE_REG_FAILURE;
+	}
+	revflags = (AGCRE_REG_STARTEND | AGCRE_REG_ANCHOR);
 	for (found = 0, i = to - 1 ; i >= from ; --i) {
 		m[0].rm_so = i;
 		m[0].rm_eo = to;
-		if ((this = agcre_regexec(agcre, vs, matchc, m, flags)) == 0) {
+		bolflags = (i > 0) ? AGCRE_REG_NOTBOL : 0;
+		if (agcre_regexec(agcre, vs, matchc, m, flags | revflags | bolflags) == 0) {
 			found += 1;
+			lastmatch = i;
 		} else if (found > 0) {
-			m[0].rm_so = i + 1;
-			m[0].rm_eo = to;
-			return agcre_regexec(agcre, vs, matchc, m, flags);
+			break;
 		}
 	}
-	return AGCRE_REG_FAILURE;
+	/* just do 1 final forward search to load m array */
+	m[0].rm_so = lastmatch;
+	m[0].rm_eo = to;
+	bolflags = (lastmatch > 0) ? AGCRE_REG_NOTBOL : 0;
+	return agcre_regexec(agcre, vs, matchc, m, flags | revflags | bolflags);
 }
 
 /* free the regular expression */
-AGCRE_EXPORT void
+void
 agcre_regfree(agcre_regex_t *agcre)
 {
 	uint32_t	 i;
@@ -2969,7 +2999,7 @@ agcre_regfree(agcre_regex_t *agcre)
 }
 
 /* do regexp sed-style substitution */
-AGCRE_EXPORT ssize_t
+ssize_t
 agcre_regnsub(char *buf, size_t size, const char *repl, const agcre_regmatch_t *rm, const char *str)
 {
 	const char	*i;
@@ -3022,7 +3052,7 @@ agcre_regnsub(char *buf, size_t size, co
 }
 
 /* do regexp sed-style substitution */
-AGCRE_EXPORT ssize_t
+ssize_t
 agcre_regasub(char **buf, const char *repl, const agcre_regmatch_t *rm, const char *str)
 {
 	const char	*i;
Index: othersrc/external/bsd/elex/dist/agcre.h
diff -u othersrc/external/bsd/elex/dist/agcre.h:1.1 othersrc/external/bsd/elex/dist/agcre.h:1.2
--- othersrc/external/bsd/elex/dist/agcre.h:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/agcre.h	Wed Feb 22 01:01:39 2023
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013,2017,2020,2021 Alistair Crooks. All Rights reserved.
+ * Copyright (c) 2013,2017,2020,2021,2022,2023 Alistair Crooks. All Rights reserved.
  * Copyright (c) 2007-2009 Russ Cox, Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -95,6 +95,22 @@
 #define AGCRE_MAX_SUBEXPR	100
 #define AGCRE_MAX_EXPR_LENGTH	1024
 
+#ifdef LIB_NAMESPACE
+#define AGCRE_CONCAT(x, y)	x##y
+#define AGCRE_NAMESPACE(x, y)	AGCRE_CONCAT(x, y)
+#define agcre_regex_t		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regex_t)
+#define agcre_regoff_t		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regoff_t)
+#define agcre_regmatch_t	AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regmatch_t)
+#define agcre_regex_new		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regex_new)
+#define agcre_regcomp		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regcomp)
+#define agcre_regexec		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regexec)
+#define agcre_rev_regexec	AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_rev_regexec)
+#define agcre_regfree		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regfree)
+#define agcre_regerror		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regerror)
+#define agcre_regnsub		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regnsub)
+#define agcre_regasub		AGCRE_NAMESPACE(LIB_NAMESPACE, agcre_regasub)
+#endif
+
 typedef int64_t		 agcre_regoff_t;
 
 /* a match structure */
@@ -111,37 +127,6 @@ typedef struct agcre_regex_t {
 	void		*re_g;		/* internals */
 } agcre_regex_t;
 
-#ifndef USE_VISIBILITY
-#  if defined(__GNUC__)
-#    if __GNUC__ >= 4
-#    define USE_VISIBILITY	1
-#    else
-#    define USE_VISIBILITY	0
-#    endif
-#  else
-#    define USE_VISIBILITY	0
-#  endif
-#endif
-
-#if USE_VISIBILITY
-#  define DLL_PUBLIC __attribute__ ((visibility ("default")))
-#  define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
-#else
-#  define DLL_PUBLIC
-#  define DLL_LOCAL
-#endif
-
-/* by default, don't hide external symbols */
-#ifndef HIDE_AGCRE
-#define HIDE_AGCRE	0
-#endif
-
-#if HIDE_AGCRE
-#define AGCRE_EXPORT	DLL_LOCAL
-#else
-#define AGCRE_EXPORT	DLL_PUBLIC
-#endif
-
 #ifndef __BEGIN_DECLS
 #  if defined(__cplusplus)
 #  define __BEGIN_DECLS           extern "C" {
@@ -154,18 +139,18 @@ typedef struct agcre_regex_t {
 
 __BEGIN_DECLS
 
-AGCRE_EXPORT agcre_regex_t *agcre_new(void);
-AGCRE_EXPORT int agcre_regcomp(agcre_regex_t */*re*/, const void */*s*/, uint32_t /*flags*/);
-AGCRE_EXPORT int agcre_regexec(agcre_regex_t */*re*/, const void */*vs*/, size_t /*mc*/,
+agcre_regex_t *agcre_new(void);
+int agcre_regcomp(agcre_regex_t */*re*/, const void */*s*/, uint32_t /*flags*/);
+int agcre_regexec(agcre_regex_t */*re*/, const void */*vs*/, size_t /*mc*/,
 		agcre_regmatch_t */*m*/, uint32_t /*flags*/);
-AGCRE_EXPORT int agcre_rev_regexec(agcre_regex_t */*agcre*/, const void */*vs*/,
+int agcre_rev_regexec(agcre_regex_t */*agcre*/, const void */*vs*/,
 		size_t /*matchc*/, agcre_regmatch_t */*m*/, uint32_t /*flags*/);
-AGCRE_EXPORT void agcre_regfree(agcre_regex_t */*re*/);
-AGCRE_EXPORT size_t agcre_regerror(int /*errcode*/, const agcre_regex_t */*agcre*/,
+void agcre_regfree(agcre_regex_t */*re*/);
+size_t agcre_regerror(int /*errcode*/, const agcre_regex_t */*agcre*/,
 		char */*errbuf*/, size_t /*size*/);
-AGCRE_EXPORT ssize_t agcre_regnsub(char */*buf*/, size_t /*size*/, const char */*repl*/,
+ssize_t agcre_regnsub(char */*buf*/, size_t /*size*/, const char */*repl*/,
 		const agcre_regmatch_t */*rm*/, const char */*str*/);
-AGCRE_EXPORT ssize_t agcre_regasub(char **/*buf*/, const char */*repl*/,
+ssize_t agcre_regasub(char **/*buf*/, const char */*repl*/,
 		const agcre_regmatch_t */*rm*/, const char */*str*/);
 
 __END_DECLS
Index: othersrc/external/bsd/elex/dist/elex.c
diff -u othersrc/external/bsd/elex/dist/elex.c:1.1 othersrc/external/bsd/elex/dist/elex.c:1.2
--- othersrc/external/bsd/elex/dist/elex.c:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/elex.c	Wed Feb 22 01:01:39 2023
@@ -33,27 +33,35 @@
 #include <string.h>
 #include <unistd.h>
 
+#define LIB_NAMESPACE	elex_
 #include "agcre.h"
 #include "striter.h"
 #include "elex.h"
 
 /* a rule for matching */
 typedef struct rule_t {
-	int		 startstate;	/* start state of rule */
-	char		*pat;		/* pattern before expansion */
-	uint64_t	 patlen;	/* length of pattern */
-	agcre_regex_t	 re;		/* compiled regexp */
-	int		 newstate;	/* new state */
-	int		 ret;		/* return value (0 == no return) */
+	int			 startstate;	/* start state of rule */
+	char			*pat;		/* pattern before expansion */
+	uint64_t		 patlen;	/* length of pattern */
+	agcre_regex_t		 re;		/* compiled regexp */
+	int			 newstate;	/* new state */
+	int			 ret;		/* return value (0 == no return) */
+	uint32_t		 mbase;		/* match base in state regexp */
 } rule_t;
 
 /* used for recognising return types */
 typedef struct type_t {
-	char		*pat;		/* name of type */
-	uint64_t	 len;		/* length of type */
-	uint32_t	 val;		/* return value for type */
+	char			*pat;		/* name of type */
+	uint64_t		 len;		/* length of type */
+	uint32_t		 val;		/* return value for type */
 } type_t;
 
+/* all the information needed for a start state */
+typedef struct startstate_t {
+	char			*name;		/* start state name */
+	uint32_t		 hash;		/* hash value of state name */
+} startstate_t;
+
 /* embedded lex struct */
 struct elex_t {
 	uint32_t		  rulec;	/* # of rules */
@@ -61,7 +69,7 @@ struct elex_t {
 	rule_t			 *rules;	/* rules */
 	uint32_t		  statec;	/* # of states */
 	uint32_t		  statemax;	/* size of states array */
-	char			**states;	/* string names of states */
+	startstate_t		 *states;	/* string names of states */
 	uint32_t		  typec;	/* # of return types used */
 	uint32_t		  typemax;	/* # of return types allocated */
 	type_t			 *types;	/* return types */
@@ -103,12 +111,15 @@ djbhash(const char *s)
 
 /* map from string state to index */
 static inline int
-findstate(elex_t *elex, const char *state)
+findstate(elex_t *elex, const char *name)
 {
-	uint32_t	i;
+	startstate_t	*state;
+	uint32_t	 hash;
+	uint32_t	 i;
 
-	for (i = 0 ; i < elex->statec ; i++) {
-		if (strcmp(elex->states[i], state) == 0) {
+	hash = djbhash(name);
+	for (state = elex->states, i = 0 ; i < elex->statec ; i++, state++) {
+		if (state->hash == hash && strcmp(state->name, name) == 0) {
 			return i;
 		}
 	}
@@ -148,10 +159,10 @@ makerule(elex_t *elex)
 }
 
 /* create a new state entry */
-static char **
+static startstate_t *
 makestate(elex_t *elex)
 {
-	char	**state;
+	startstate_t	*state;
 
 	if (elex->statec == elex->statemax) {
 		state = realloc(elex->states, (elex->statemax + 16) * sizeof(*state));
@@ -196,7 +207,7 @@ matchbol(elex_t *elex, rule_t *rule)
 static int
 make_new_state(elex_t *elex, const char *state)
 {
-	char	**newstate;
+	startstate_t	*newstate;
 
 	if (elex == NULL || state == NULL) {
 		return 0;
@@ -209,7 +220,8 @@ make_new_state(elex_t *elex, const char 
 		warnx("already got state '%s'", state);
 		return 0;
 	}
-	*newstate = strdup(state);
+	newstate->name = strdup(state);
+	newstate->hash = djbhash(state);
 	return 1;
 }
 
@@ -477,7 +489,7 @@ makeclone(elex_t *old)
 	}
 	elex->states = calloc(old->statemax, sizeof(*elex->states));
 	for (i = 0 ; i < old->statec ; i++) {
-		elex->states[i] = strdup(old->states[i]);
+		elex->states[i].name = strdup(old->states[i].name);
 	}
 	elex->types = calloc(old->typemax, sizeof(*elex->types));
 	for (i = 0 ; i < old->typec ; i++) {
@@ -516,9 +528,9 @@ getrule(elex_t *elex, uint64_t n, uint64
 		ret[0] = 0x0;
 	}
 	*size = asprintf(&p, "<%s>%s</>\t{ BEGIN(%s); %s }",
-		elex->states[rule->startstate],
+		elex->states[rule->startstate].name,
 		rule->pat,
-		elex->states[rule->newstate],
+		elex->states[rule->newstate].name,
 		ret);
 	return p;
 }
@@ -526,7 +538,7 @@ getrule(elex_t *elex, uint64_t n, uint64
 /********************************************************/
 
 /* create a new elex struct */
-ELEX_EXPORT elex_t *
+elex_t *
 elex_new(void)
 {
 	elex_t	*elex;
@@ -538,7 +550,7 @@ elex_new(void)
 }
 
 /* dispose of elex struct */
-ELEX_EXPORT int
+int
 elex_dispose(elex_t **elex)
 {
 	uint32_t	i;
@@ -550,7 +562,7 @@ elex_dispose(elex_t **elex)
 		}
 		free((*elex)->rules);
 		for (i = 0 ; i < (*elex)->statec ; i++) {
-			free((*elex)->states[i]);
+			free((*elex)->states[i].name);
 		}
 		free((*elex)->states);
 		for (i = 0 ; i < (*elex)->typec ; i++) {
@@ -567,7 +579,7 @@ elex_dispose(elex_t **elex)
 }
 
 /* create a new rule */
-ELEX_EXPORT int
+int
 elex_make_new_rule(elex_t *elex, const char *startstate, const char *pat,
 	const char *newstate, int ret)
 {
@@ -605,7 +617,7 @@ elex_make_new_rule(elex_t *elex, const c
 /* accessor functions */
 
 /* one function to execute with integer return */
-ELEX_EXPORT int64_t
+int64_t
 elex_exec(elex_t *elex, const char *info, uint64_t num, const char *s, int64_t cc)
 {
 	if (elex == NULL || info == NULL) {
@@ -661,7 +673,7 @@ elex_exec(elex_t *elex, const char *info
 }
 
 /* one function to access string values */
-ELEX_EXPORT void *
+void *
 elex_exec_str(elex_t *elex, const char *info, uint64_t n, uint64_t *size)
 {
 	uint64_t	 len;
@@ -683,7 +695,7 @@ elex_exec_str(elex_t *elex, const char *
 	case /* "get-yyrule-pat" */ 0x3387cdfa:
 		return (elex->yyrule == NULL) ? NULL : allocate(elex->yyrule->pat, elex->yyrule->patlen, size);
 	case /* "get-yystate" */ 0xc6d2a7:
-		return allocate(elex->states[elex->yystate], strlen(elex->states[elex->yystate]), size);
+		return allocate(elex->states[elex->yystate].name, strlen(elex->states[elex->yystate].name), size);
 	case /* "get-yytext" */ 0x88065864:
 		return allocate(elex->yytext, elex->yyleng, size);
 	}
Index: othersrc/external/bsd/elex/dist/elex.h
diff -u othersrc/external/bsd/elex/dist/elex.h:1.1 othersrc/external/bsd/elex/dist/elex.h:1.2
--- othersrc/external/bsd/elex/dist/elex.h:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/elex.h	Wed Feb 22 01:01:39 2023
@@ -23,38 +23,23 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifndef ELEX_H_
-#define ELEX_H_	20211115
+#define ELEX_H_	20230221
 
 #include <inttypes.h>
 
-struct elex_t;
-typedef struct elex_t	elex_t;
-
-#ifndef USE_VISIBILITY
-#  if defined(__GNUC__)
-#    if __GNUC__ >= 4
-#    define USE_VISIBILITY	1
-#    else
-#    define USE_VISIBILITY	0
-#    endif
-#  else
-#    define USE_VISIBILITY	0
-#  endif
+#ifdef LIB_NAMESPACE
+#define ELEX_CONCAT(x, y)	x##y
+#define ELEX_NAMESPACE(x, y)	ELEX_CONCAT(x, y)
+#define elex_t			ELEX_NAMESPACE(LIB_NAMESPACE, elex_t)
+#define elex_new		ELEX_NAMESPACE(LIB_NAMESPACE, elex_new)
+#define elex_dispose		ELEX_NAMESPACE(LIB_NAMESPACE, elex_dispose)
+#define elex_exec		ELEX_NAMESPACE(LIB_NAMESPACE, elex_exec)
+#define elex_exec_str		ELEX_NAMESPACE(LIB_NAMESPACE, elex_exec_str)
+#define elex_make_new_rule	ELEX_NAMESPACE(LIB_NAMESPACE, elex_make_new_rule)
 #endif
 
-#if USE_VISIBILITY
-#  define DLL_PUBLIC __attribute__ ((visibility ("default")))
-#  define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
-#else
-#  define DLL_PUBLIC
-#  define DLL_LOCAL
-#endif
-
-#ifdef HIDE_ELEX
-#define ELEX_EXPORT	DLL_LOCAL
-#else
-#define ELEX_EXPORT	DLL_PUBLIC
-#endif
+struct elex_t;
+typedef struct elex_t	elex_t;
 
 #ifndef __BEGIN_DECLS
 #  if defined(__cplusplus)
@@ -69,15 +54,15 @@ typedef struct elex_t	elex_t;
 __BEGIN_DECLS
 
 /* create and destroy */
-ELEX_EXPORT elex_t *elex_new(void);
-ELEX_EXPORT int elex_dispose(elex_t **/*elex*/);
+elex_t *elex_new(void);
+int elex_dispose(elex_t **/*elex*/);
 
 /* these functions do ALL the work */
-ELEX_EXPORT int64_t elex_exec(elex_t */*elex*/, const char */*info*/, uint64_t /*num*/, const char */*s*/, int64_t /*cc*/);
-ELEX_EXPORT void *elex_exec_str(elex_t */*elex*/, const char */*info*/, uint64_t /*n*/, uint64_t */*size*/);
+int64_t elex_exec(elex_t */*elex*/, const char */*info*/, uint64_t /*num*/, const char */*s*/, int64_t /*cc*/);
+void *elex_exec_str(elex_t */*elex*/, const char */*info*/, uint64_t /*n*/, uint64_t */*size*/);
 
 /* with one exeception - deal with states */
-ELEX_EXPORT int elex_make_new_rule(elex_t */*elex*/, const char */*startstate*/,
+int elex_make_new_rule(elex_t */*elex*/, const char */*startstate*/,
 	const char */*pat*/, const char */*newstate*/, int /*ret*/);
 
 __END_DECLS
Index: othersrc/external/bsd/elex/dist/main.c
diff -u othersrc/external/bsd/elex/dist/main.c:1.1 othersrc/external/bsd/elex/dist/main.c:1.2
--- othersrc/external/bsd/elex/dist/main.c:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/main.c	Wed Feb 22 01:01:39 2023
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#define LIB_NAMESPACE	elex_
 #include "elex.h"
 
 #define STRINGIFY(x)	#x

Index: othersrc/external/bsd/elex/dist/tests/28.expected
diff -u othersrc/external/bsd/elex/dist/tests/28.expected:1.1 othersrc/external/bsd/elex/dist/tests/28.expected:1.2
--- othersrc/external/bsd/elex/dist/tests/28.expected:1.1	Thu Dec  9 04:15:26 2021
+++ othersrc/external/bsd/elex/dist/tests/28.expected	Wed Feb 22 01:01:40 2023
@@ -1 +1 @@
-elex version 20211115
+elex version 20230221

Reply via email to