From 1d1cd21814aad2b5db7e176450f5fd540b0d74c8 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 10 Mar 2004 19:21:39 +0000 Subject: [PATCH] allow '$' as action prefix instead of '%'; backward compatibility is preserved --- libraries/librewrite/map.c | 2 +- libraries/librewrite/rewrite-int.h | 5 ++++- libraries/librewrite/subst.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/librewrite/map.c b/libraries/librewrite/map.c index c94c7bf530..d8ba01cdb2 100644 --- a/libraries/librewrite/map.c +++ b/libraries/librewrite/map.c @@ -51,7 +51,7 @@ rewrite_map_parse( * Go to the end of the map invocation (the right closing brace) */ for ( p = string, cnt = 1; p[ 0 ] != '\0' && cnt > 0; p++ ) { - if ( p[ 0 ] == REWRITE_SUBMATCH_ESCAPE ) { + if ( IS_REWRITE_SUBMATCH_ESCAPE( p[ 0 ] ) ) { /* * '%' marks the beginning of a new map */ diff --git a/libraries/librewrite/rewrite-int.h b/libraries/librewrite/rewrite-int.h index bf17fb3e20..798620ad41 100644 --- a/libraries/librewrite/rewrite-int.h +++ b/libraries/librewrite/rewrite-int.h @@ -55,7 +55,10 @@ */ /* the '\' conflicts with slapd.conf parsing */ /* #define REWRITE_SUBMATCH_ESCAPE '\\' */ -#define REWRITE_SUBMATCH_ESCAPE '%' +#define REWRITE_SUBMATCH_ESCAPE_ORIG '%' +#define REWRITE_SUBMATCH_ESCAPE '$' +#define IS_REWRITE_SUBMATCH_ESCAPE(c) \ + ((c) == REWRITE_SUBMATCH_ESCAPE || (c) == REWRITE_SUBMATCH_ESCAPE_ORIG) /* * REGEX flags diff --git a/libraries/librewrite/subst.c b/libraries/librewrite/subst.c index 1ec0af7dc9..3fb2ae2476 100644 --- a/libraries/librewrite/subst.c +++ b/libraries/librewrite/subst.c @@ -55,11 +55,11 @@ rewrite_subst_compile( /* * Keep only single escapes '%' */ - if ( p[ 0 ] != REWRITE_SUBMATCH_ESCAPE ) { + if ( !IS_REWRITE_SUBMATCH_ESCAPE( p[ 0 ] ) ) { continue; } - if ( p[ 1 ] == REWRITE_SUBMATCH_ESCAPE ) { + if ( IS_REWRITE_SUBMATCH_ESCAPE( p[ 1 ] ) ) { /* Pull &p[1] over p, including the trailing '\0' */ AC_MEMCPY((char *)p, &p[ 1 ], strlen( p ) ); continue; -- 2.39.5