From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=1.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,LIST_MIRROR_RECEIVED,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 88E041F852 for ; Wed, 2 Feb 2022 07:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239287AbiBBHe4 (ORCPT ); Wed, 2 Feb 2022 02:34:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238436AbiBBHeu (ORCPT ); Wed, 2 Feb 2022 02:34:50 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014A1C061744 for ; Tue, 1 Feb 2022 23:34:49 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id a13so36590852wrh.9 for ; Tue, 01 Feb 2022 23:34:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=/Hd+gHGQwZ5LygnSwiXiwkGrK0fyJvSF73snz4VsFvU=; b=BP+61sE4fQ7qF6hiaopb5hgbLJhuG3aeqO4RxBAyGGJW8YPWB1dBNeGOu1o5aAtGQB dlhpLuZ5HIw5qcTUgHtV0lkeLlzHp3aMti0vky0MqoYeoKLOwZu3U7go+TOj7oUDee21 pfIB8QMvXUGU5ywtsGkUYDToFr0IuCt4SW5dy48FplC3K8fmYDg9tNMFVSBU9ySDHFZF VsWLeHcAT/sBojbyCsXRmd2cc19nowaB24sOvWC0pAmYuBNd8DD+2IlM58/EhKLrUjCu 5L/wmIMsp2haOHVEFQ6/iiZGvHNVu8dMpXG6mXddq/gaXUeXewaVri2rnwislYsWRN7u /kbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=/Hd+gHGQwZ5LygnSwiXiwkGrK0fyJvSF73snz4VsFvU=; b=Iq00eAOLI51vSHUHVjoKwI6FrU8Ejw6tsR4sCgJ3Kxa4wWAGTJqKETtCnmr23anAIv baXTQzmnInsE/dmAZ5nbUOmnZon03WjK/YBMoWnl2DChtrv24OF26BUZ9KBweq4HcDpC t70X4sS/8z3ou+1YhDF+5jEIY7w9i0b072UmYZg+t4Za/pVAlyGl6+r5Hqy71e4S3ph2 MdE3z3WcO/zR7azaWMLAulfKcAoALLiINI6GrQOZUWBVdnrwajTNHr3vaVDs524w8mim 6eMshNeeRMMRrZwh0uGAew8OHi3qCyyZvXhbXgzxKhfNGMefO8pKBFwjCSVktKwMiJS1 J8hg== X-Gm-Message-State: AOAM532WhgJEOVBPBPREKYIkuzGxo6QXKdguGuUrR4GJqYFy9s5xY33u GGYU4a1DFqpCPOaVMy73SrBSxwMCV3A= X-Google-Smtp-Source: ABdhPJyUi8Msd5k9+zRQZfQpuD+f1+uQunkUgR6iSlNvsSHJLbhvbh3/EPKp/Dxh+l1zkEXl3zm7YQ== X-Received: by 2002:adf:ef47:: with SMTP id c7mr24244957wrp.330.1643787287434; Tue, 01 Feb 2022 23:34:47 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x13sm16525796wru.28.2022.02.01.23.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 23:34:47 -0800 (PST) Message-Id: <290b42846b5557055b84e4237ddc8c3532752d5d.1643787281.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 02 Feb 2022 07:34:31 +0000 Subject: [PATCH v3 05/15] Introduce a variant of the `warning()` function that takes a `FILE *` Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Christian Couder , Taylor Blau , Johannes Altmanninger , Ramsay Jones , Johannes Schindelin , Christian Couder , =?UTF-8?Q?Ren=C3=A9?= Scharfe , =?UTF-8?Q?=C3=86var_Arnfj=C3=B6r=C3=B0?= Bjarmason , Elijah Newren , Johannes Sixt , Elijah Newren , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin We are about to teach `diff_warn_rename_limit()` to write into a file instead of `stderr`. That function wants to call `warning()` when writing to `stderr`, though, allowing for the `warn_routine` to be overridden. Let's introduce a helper for that. Note: Since there is currently no need to provide similar functions for `error()` or `die()`, let alone for the `_errno` variants, we will leave that to a date when the need for those should arise, if ever. Signed-off-by: Johannes Schindelin Signed-off-by: Elijah Newren --- git-compat-util.h | 1 + usage.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index d70ce142861..64ba60e5c71 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -475,6 +475,7 @@ int error(const char *err, ...) __attribute__((format (printf, 1, 2))); int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); +void warning_fp(FILE *out, const char *warn, ...) __attribute__((format (printf, 2, 3))); #ifndef NO_OPENSSL #ifdef APPLE_COMMON_CRYPTO diff --git a/usage.c b/usage.c index c7d233b0de9..0bfd2c603c0 100644 --- a/usage.c +++ b/usage.c @@ -253,6 +253,20 @@ void warning(const char *warn, ...) va_end(params); } +void warning_fp(FILE *out, const char *warn, ...) +{ + va_list params; + + va_start(params, warn); + if (out == stderr) + warn_routine(warn, params); + else { + vfprintf(out, warn, params); + fputc('\n', out); + } + va_end(params); +} + /* Only set this, ever, from t/helper/, when verifying that bugs are caught. */ int BUG_exit_code; -- gitgitgadget