From a2bc07cf7f8a95ebe06129e74a5dca6c1e600d19 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 8 May 2015 00:42:31 +0200 Subject: [PATCH] Introduce a helper for dry-run mode --- src/makefile.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/makefile.c b/src/makefile.c index 09772ac..4d269e0 100644 --- a/src/makefile.c +++ b/src/makefile.c @@ -25,8 +25,6 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 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 */ static int _makefile_is_phony(Configure * configure, char const * target); +/* useful */ static int _makefile_link(FILE * fp, int symlink, char const * link, char const * path); static int _makefile_output_variable(FILE * fp, char const * name, char const * value); +static int _makefile_print(FILE * fp, char const * format, ...); static int _makefile_remove(FILE * fp, int recursive, ...); static int _makefile_subdirs(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 */ static int _makefile_remove(FILE * fp, int recursive, ...) {