openldap/doc/devel/variadic_debug/03-libldap_Debug.cocci
2019-02-15 16:51:53 +00:00

71 lines
1.0 KiB
Plaintext

using "equivalence.iso"
@initialize:ocaml@
@@
// count the number of % characters in the format string
let fmtn(fmt,n) =
List.length (Str.split_delim (Str.regexp_string "%") fmt) = n + 1
# replace osip_debug/oslocal_debug with Debug() macros first
@@
expression E;
expression list args;
@@
(
-osip_debug
|
-oslocal_debug
)
+Debug
(
-E,
+LDAP_DEBUG_TRACE,
args );
// replace Debug( ..., arg1, arg2, 0 ) with Debug2( ..., arg1, arg2 )
@@
char[] fmt : script:ocaml() { fmtn(fmt,2) };
expression list[2] args;
expression E;
@@
-Debug
+Debug2
( E, _(fmt), args
-, 0
);
// replace Debug( ..., arg1, 0, 0 ) with Debug1()
@@
char[] fmt : script:ocaml() { fmtn(fmt,1) };
expression list[1] args;
expression E;
@@
-Debug
+Debug1
( E, _(fmt), args
-, 0, 0
);
// Zero-argument Debug() -> Debug0()
@@
expression E, S;
@@
-Debug
+Debug0
( E, S
-, 0, 0, 0
);
// everything else is a regular 3-argument debug macro, replace with Debug3()
@@
expression E, S;
expression list[3] args;
@@
-Debug
+Debug3
( E, S, args );