Introduce a helper for dry-run mode

This commit is contained in:
Pierre Pronchery 2015-05-08 00:42:31 +02:00
parent 42020536b1
commit a2bc07cf7f

View File

@ -25,8 +25,6 @@
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* TODO:
* - only check the PREFS_n flags inside a wrapper around fputs()/fprintf() */
@ -49,10 +47,12 @@
/* accessors */ /* accessors */
static int _makefile_is_phony(Configure * configure, char const * target); static int _makefile_is_phony(Configure * configure, char const * target);
/* useful */
static int _makefile_link(FILE * fp, int symlink, char const * link, static int _makefile_link(FILE * fp, int symlink, char const * link,
char const * path); char const * path);
static int _makefile_output_variable(FILE * fp, char const * name, static int _makefile_output_variable(FILE * fp, char const * name,
char const * value); char const * value);
static int _makefile_print(FILE * fp, char const * format, ...);
static int _makefile_remove(FILE * fp, int recursive, ...); static int _makefile_remove(FILE * fp, int recursive, ...);
static int _makefile_subdirs(FILE * fp, char const * target); static int _makefile_subdirs(FILE * fp, char const * target);
static int _makefile_target(FILE * fp, char const * target, ...); static int _makefile_target(FILE * fp, char const * target, ...);
@ -2648,6 +2648,22 @@ static int _makefile_output_variable(FILE * fp, char const * name,
} }
/* makefile_print */
static int _makefile_print(FILE * fp, char const * format, ...)
{
int ret;
va_list ap;
va_start(ap, format);
if(fp == NULL)
ret = vsprintf(NULL, format, ap);
else
ret = vfprintf(fp, format, ap);
va_end(ap);
return ret;
}
/* makefile_remove */ /* makefile_remove */
static int _makefile_remove(FILE * fp, int recursive, ...) static int _makefile_remove(FILE * fp, int recursive, ...)
{ {