add "%%" escape

This commit is contained in:
John Cupitt 2014-04-11 22:51:39 +01:00
parent 44b4830ceb
commit dd35d6ffc7
2 changed files with 10 additions and 2 deletions

2
TODO
View File

@ -1,5 +1,3 @@
- vips_system needs to use "%%" for a % character, for compatibility with
vips 7.38
- can we use postbuild elsewhere? look at use of "preclose" / "written", etc.

View File

@ -119,6 +119,7 @@ vips_system_build( VipsObject *object )
char line[VIPS_PATH_MAX];
char txt[VIPS_PATH_MAX];
VipsBuf buf = VIPS_BUF_STATIC( txt );
char *p;
int result;
if( VIPS_OBJECT_CLASS( vips_system_parent_class )->build( object ) )
@ -164,6 +165,15 @@ vips_system_build( VipsObject *object )
cmd, VIPS_PATH_MAX, system->out_name ) )
return( -1 );
/* Swap all "%%" in the string for a single "%". We need this for
* compatibility with older printf-based vips_system()s which
* needed a double %%.
*/
for( p = cmd; *p; p++ )
if( p[0] == '%' &&
p[1] == '%' )
memmove( p, p + 1, strlen( p ) );
if( !(fp = vips_popenf( "%s", "r", cmd )) )
return( -1 );