From patchwork Wed Oct 9 09:10:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15598 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7978D448CAF for ; Wed, 9 Oct 2019 12:11:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64042688192; Wed, 9 Oct 2019 12:11:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7110668818B for ; Wed, 9 Oct 2019 12:11:05 +0300 (EEST) Received: by mail-pl1-f193.google.com with SMTP id q15so738614pll.11 for ; Wed, 09 Oct 2019 02:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cjow9jlSpHvrS19SGpTx4RS4+2UecsIabuxf/nm3nNU=; b=XerxUxh38YYp+I7Jff/pwwe4kGGQ0tGgG12rfdDma83kLGsc+MFS15y4pLOjUKfoLa E9BBaGpnlBULVGwIPIJ+QLvznlqzNyZHfJPsadh3/JW3W6of2fxjxLLpYmNSu/CLzzbM ifFBoXAuFL71RrCJaJnDFQsCmbDtZ2XFmJ9V2rlulWcjllrZXD6srxmdb7i2FtEzwHIT VYV34xlUius9cwIbALsEkzvBSLCSQB0YYDcHiVjAEvkmgqwjFN8Pd9eKEplpH8e5plqq 8/9QItwkAzVllSg1filejj1O0SnGfaOlY4W4yinswU3/SDlfO3F8mCWKvUJf7XY/IBrw rEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cjow9jlSpHvrS19SGpTx4RS4+2UecsIabuxf/nm3nNU=; b=g0zIhjZdlKTFimm5j/Bl59qnMQE16dDnWFJaisZyXycNhwAE1LIRE9nvY4zJyMJxVq gN6FPNNbdwdW6f3DDWbfFAEd9iD4wPEiNxMLlbDMJHqBSiprrSX6VeXm0AtyFauG/mhZ i6WDHc5XZo+XZf7ykOLmHrBuNMNwNCQ2HPuDyVD9DBH/aQ+AOUZ7vOO+giUZUpVU9ECz DZ2q2b9etkafN6ta24YeA0Reg4e238HL5fS3Jk6DHhDzbSWyHItoKpP1dHgKw69piuhV n3Ew2UbgcH83AEB1PQvXrXegKIzBN/MZ3PlpHU0xfmNgqpbT/ttMaH6RtPsGJqsraH9y bGxw== X-Gm-Message-State: APjAAAWPezA/kScwWuuLUiziugoSRl36JcVKDfFx6ZrQZY99DQZDCp7a 4Mhht/MVg1jGRd0z6psKoZoIs12K X-Google-Smtp-Source: APXvYqxuJLcAwRgiU3jQDOsRWEuA31aAhq77vgassgihoa3reDCpkqd6Xs2E3g+5Gs+36/EyaYY6PQ== X-Received: by 2002:a17:902:9a85:: with SMTP id w5mr2061942plp.316.1570612263521; Wed, 09 Oct 2019 02:11:03 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id u11sm2414037pgb.75.2019.10.09.02.11.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Oct 2019 02:11:02 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 17:10:55 +0800 Message-Id: <20191009091055.32508-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191009091055.32508-1-lance.lmwang@gmail.com> References: <20191009082826.31858-1-lance.lmwang@gmail.com> <20191009091055.32508-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 2/2] avutil/avstring: replace with system interface if dirname and basename functions are detected X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- configure | 4 ++++ libavutil/avstring.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 8413826..5296a4c 100755 --- a/configure +++ b/configure @@ -2188,6 +2188,8 @@ SYSTEM_FUNCS=" clock_gettime closesocket CommandLineToArgvW + dirname + basename fcntl getaddrinfo gethrtime @@ -5980,6 +5982,8 @@ check_func access check_func_headers stdlib.h arc4random check_lib clock_gettime time.h clock_gettime || check_lib clock_gettime time.h clock_gettime -lrt check_func fcntl +check_func_headers libgen.h dirname +check_func_headers libgen.h basename check_func fork check_func gethrtime check_func getopt diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 76a13ba..66654fb 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -19,12 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include #include #include #include +#if defined(HAVE_DIRNAME) || defined(HAVE_BASENAME) +#include +#endif -#include "config.h" #include "common.h" #include "mem.h" #include "avassert.h" @@ -257,6 +260,9 @@ char *av_strireplace(const char *str, const char *from, const char *to) const char *av_basename(const char *path) { +#if HAVE_BASENAME + return basename((char*)path); +#else char *p; if (!path || *path == '\0') @@ -274,10 +280,14 @@ const char *av_basename(const char *path) return path; return p + 1; +#endif } const char *av_dirname(char *path) { +#if HAVE_DIRNAME + return dirname(path); +#else char *p = path ? strrchr(path, '/') : NULL; #if HAVE_DOS_PATHS @@ -295,6 +305,7 @@ const char *av_dirname(char *path) *p = '\0'; return path; +#endif } char *av_append_path_component(const char *path, const char *component)