[asterisk-commits] rmudgett: trunk r403560 - in /trunk: ./ res/res_sorcery_astdb.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 9 13:25:00 CST 2013


Author: rmudgett
Date: Mon Dec  9 13:24:58 2013
New Revision: 403560

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403560
Log:
Reverting regex part of -r403545 at request of file.

res_sorcery_astdb.c: Fix get multiple records by regex.

* Fix sorcery_astdb_retrieve_regex() pattern matching.  Let the regexec()
function match the stored key values instead of having astdb prefilter
them.  Previoiusly you could only use a simple regex pattern when the
pattern began with '^'.
........

Merged revisions 403559 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_sorcery_astdb.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Dec  9 13:24:58 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403541-403542,403545
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403541-403542,403545,403559

Modified: trunk/res/res_sorcery_astdb.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_sorcery_astdb.c?view=diff&rev=403560&r1=403559&r2=403560
==============================================================================
--- trunk/res/res_sorcery_astdb.c (original)
+++ trunk/res/res_sorcery_astdb.c Mon Dec  9 13:24:58 2013
@@ -218,14 +218,20 @@
 static void sorcery_astdb_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
 {
 	const char *prefix = data;
-	char family[strlen(prefix) + strlen(type) + 2];
+	char family[strlen(prefix) + strlen(type) + 2], tree[strlen(regex) + 1];
 	RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree);
 	regex_t expression;
 	struct ast_db_entry *entry;
 
 	snprintf(family, sizeof(family), "%s/%s", prefix, type);
 
-	if (!(entries = ast_db_gettree(family, NULL)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
+	if (regex[0] == '^') {
+		snprintf(tree, sizeof(tree), "%s%%", regex + 1);
+	} else {
+		tree[0] = '\0';
+	}
+
+	if (!(entries = ast_db_gettree(family, tree)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
 		return;
 	}
 




More information about the asterisk-commits mailing list