* document the %ps / %pS extensions to printf
* remove (from memcheck) emiN, as PRINTF_CHECK can be done properly
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13942 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h
index 70cd381..374d8e6 100644
--- a/include/pub_tool_libcprint.h
+++ b/include/pub_tool_libcprint.h
@@ -37,6 +37,18 @@
Formatting functions
------------------------------------------------------------------ */
+/* The formatting functions supports a subset (and 2 extensions) of
+ the 'printf' format.
+ The extensions are:
+ %pS : print a string (like %s) but escaping chars for XML safety.
+ %ps : with --xml=no, synonym for %s, with --xml=yes, synonym of %pS.
+
+ Note: these extensions do not cause the compiler to barf with PRINTF_CHECK
+ as for the classical printf, %p requires a pointer, which must also
+ be provided for the %ps and %pS extensions. The s/S following %p
+ are understood by PRINTF_CHECK as characters to output.
+*/
+
extern UInt VG_(sprintf) ( HChar* buf, const HChar* format, ... )
PRINTF_CHECK(2, 3);
diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c
index 424e512..6a03a50 100644
--- a/memcheck/mc_errors.c
+++ b/memcheck/mc_errors.c
@@ -286,13 +286,6 @@
emit_WRK(format, vargs);
va_end(vargs);
}
-static void emiN ( const HChar* format, ... ) /* NO FORMAT CHECK */
-{
- va_list vargs;
- va_start(vargs, format);
- emit_WRK(format, vargs);
- va_end(vargs);
-}
static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
@@ -371,7 +364,7 @@
}
case Addr_DataSym:
- emiN( "%sAddress 0x%llx is %llu bytes "
+ emit( "%sAddress 0x%llx is %llu bytes "
"inside data symbol \"%pS\"%s\n",
xpre,
(ULong)a,
@@ -395,7 +388,7 @@
break;
case Addr_SectKind:
- emiN( "%sAddress 0x%llx is in the %pS segment of %pS%s\n",
+ emit( "%sAddress 0x%llx is in the %pS segment of %pS%s\n",
xpre,
(ULong)a,
VG_(pp_SectKind)(ai->Addr.SectKind.kind),
@@ -589,7 +582,7 @@
// the following code is untested. Bad.
if (xml) {
emit( " <kind>CoreMemError</kind>\n" );
- emiN( " <what>%pS contains unaddressable byte(s)</what>\n",
+ emit( " <what>%pS contains unaddressable byte(s)</what>\n",
VG_(get_error_string)(err));
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
} else {
@@ -647,7 +640,7 @@
MC_(any_value_errors) = True;
if (xml) {
emit( " <kind>SyscallParam</kind>\n" );
- emiN( " <what>Syscall param %pS contains "
+ emit( " <what>Syscall param %pS contains "
"uninitialised byte(s)</what>\n",
VG_(get_error_string)(err) );
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
@@ -669,7 +662,7 @@
MC_(any_value_errors) = True;
if (xml) {
emit( " <kind>SyscallParam</kind>\n" );
- emiN( " <what>Syscall param %pS points to %s byte(s)</what>\n",
+ emit( " <what>Syscall param %pS points to %s byte(s)</what>\n",
VG_(get_error_string)(err),
extra->Err.MemParam.isAddrErr
? "unaddressable" : "uninitialised" );
@@ -797,7 +790,7 @@
if (xml) {
emit( " <kind>Overlap</kind>\n" );
if (extra->Err.Overlap.szB == 0) {
- emiN( " <what>Source and destination overlap "
+ emit( " <what>Source and destination overlap "
"in %pS(%#lx, %#lx)\n</what>\n",
VG_(get_error_string)(err),
extra->Err.Overlap.dst, extra->Err.Overlap.src );
@@ -811,7 +804,7 @@
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
} else {
if (extra->Err.Overlap.szB == 0) {
- emiN( "Source and destination overlap in %pS(%#lx, %#lx)\n",
+ emit( "Source and destination overlap in %pS(%#lx, %#lx)\n",
VG_(get_error_string)(err),
extra->Err.Overlap.dst, extra->Err.Overlap.src );
} else {