From patchwork Mon Feb 20 01:29:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Micah Galizia X-Patchwork-Id: 2609 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.22 with SMTP id n22csp648286vsb; Sun, 19 Feb 2017 17:36:04 -0800 (PST) X-Received: by 10.28.213.142 with SMTP id m136mr9543672wmg.90.1487554564834; Sun, 19 Feb 2017 17:36:04 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 1si21919749wri.286.2017.02.19.17.36.04; Sun, 19 Feb 2017 17:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 81BDA6899CE; Mon, 20 Feb 2017 03:35:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f43.google.com (mail-it0-f43.google.com [209.85.214.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F1BC680B16 for ; Mon, 20 Feb 2017 03:35:46 +0200 (EET) Received: by mail-it0-f43.google.com with SMTP id h10so59740721ith.1 for ; Sun, 19 Feb 2017 17:35:53 -0800 (PST) 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 :mime-version; bh=ZfN8FrdPAvEHbCVs0yWmYrKCag3Q3q4C4dW9JHF3/Cs=; b=SSAwvnhWGgyRC3OoNzb6pC2NreBRW383z0o0Jhx1T25Cpv24J4jrfsghrUH/871m87 0OWJr9dqy7HFgo7uJbDD5rTno2AqhTACeKpjpX+FvYXjQkRPWdFlhuf3IneHZ1+aHeat 8eghB0+z+cpV6oxb3Y1HwnVsyC5yNMyDo6LE+upIJ1bFgX6J0IsajfxV8ow0ROh7giLQ 8iAAmq6dmBVu14zwmdwo5ex5NJMijlx+g5GtKsOQMnB9yxhOlIzzIWohFEwicVTIWqSC qSEJW0u5NyefIHymJ8IQg2mFPqNzQJfLl3vpWre0mq0I6HKXLgiziB8GRhQmMzQAOtxX khyQ== 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:mime-version; bh=ZfN8FrdPAvEHbCVs0yWmYrKCag3Q3q4C4dW9JHF3/Cs=; b=mS7Zt68SMwurmpCcXJfIEPZiI4SGVjDZT3eJ9TtyjnnbTbQn8IerCh82bbnPq/BMpi uyCt1N6jmK/yO1BCenprN6DWjgXxaaXwRvklb2AfgIcs7UTZCUQezpaG+hj8g/Vp4v1l 5hdtC9MIhzisp/3uRp/Hv3IcKFYhRyfQkGQZto/a0vLH/4XeKCC2fVWNHmDqVvwXdjOK e2bPvxrY02MolEzR85xywbN4DPKhPXVDqed7h7HFKLf+lHKPBfJV56T56yKotI7Y6Ucg cNHp2+rqc3pyDjFXoQcWscgxWrAgNxQJwaYnLPnQKxE6KrxSNL2UElDJcceY8o24Z+a+ e8ww== X-Gm-Message-State: AMke39lE1fExEyJ3NicPWotl+yJspRHBPEN71IE/OlurxzQ5iqhQ6ndD2LLu+m1nloRB2w== X-Received: by 10.36.50.206 with SMTP id j197mr10972305ita.118.1487554197092; Sun, 19 Feb 2017 17:29:57 -0800 (PST) Received: from localhost.localdomain (30.40.44.96.scpe.hay.net. [96.44.40.30]) by smtp.gmail.com with ESMTPSA id 96sm8432840ioh.27.2017.02.19.17.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Feb 2017 17:29:56 -0800 (PST) From: Micah Galizia To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Feb 2017 20:29:41 -0500 Message-Id: <20170220012941.26070-2-micahgalizia@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170220012941.26070-1-micahgalizia@gmail.com> References: <20170220012941.26070-1-micahgalizia@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] add locale month names to av_small_strptime 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: Micah Galizia Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavutil/parseutils.c | 31 +++++++++++++++++++++++++++++++ libavutil/tests/parseutils.c | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 86d3dac..a273216 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -140,6 +140,12 @@ static const VideoRateAbbr video_rate_abbrs[]= { { "ntsc-film", { 24000, 1001 } }, }; +static const char *mo_abr[] = { "jan", "feb", "mar", "apr", "may", "jun", + "jul", "aug", "sep", "oct", "nov", "dec" }; + +static const char *mo_full[] = { "uary", "ruary", "ch", "il", NULL, "e", "y", + "ust", "tember", "ober", "ember", "ember" }; + int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) { int i; @@ -466,6 +472,23 @@ static int date_get_num(const char **pp, return val; } +static int date_get_month(const char **pp) { + for (int i = 0; i < 12; i++) { + if (!av_strncasecmp(*pp, mo_abr[i], 3)) { + *pp += 3; + if (mo_full[i] != NULL) { + int len = strlen(mo_full[i]); + if (!av_strncasecmp(*pp, mo_full[i], len)) { + *pp += len; + return i; + } + } + return i; + } + } + return -1; +} + char *av_small_strptime(const char *p, const char *fmt, struct tm *dt) { int c, val; @@ -525,6 +548,14 @@ char *av_small_strptime(const char *p, const char *fmt, struct tm *dt) if (!p) return NULL; break; + case 'b': + case 'B': + case 'h': + val = date_get_month(&p); + if (val == -1) + return NULL; + dt->tm_mon = val; + break; case '%': if (*p++ != '%') return NULL; diff --git a/libavutil/tests/parseutils.c b/libavutil/tests/parseutils.c index 682b390..e9b9599 100644 --- a/libavutil/tests/parseutils.c +++ b/libavutil/tests/parseutils.c @@ -138,6 +138,11 @@ static void test_av_small_strptime(void) { "%Y - %m - %d", "2012-12-21" }, { "%Y-%m-%d %H:%M:%S", "2012-12-21 20:12:21" }, { " %Y - %m - %d %H : %M : %S", " 2012 - 12 - 21 20 : 12 : 21" }, + { " %Y - %b - %d %H : %M : %S", " 2012 - nOV - 21 20 : 12 : 21" }, + { " %Y - %B - %d %H : %M : %S", " 2012 - nOVemBeR - 21 20 : 12 : 21" }, + { " %Y - %B - %d %H : %M : %S", " 2012 - may - 21 20 : 12 : 21" }, + { " %Y - %B - %d %H : %M : %S", " 2012 - JunE - 21 20 : 12 : 21" }, + { " %Y - %B - %d %H : %M : %S", " 2012 - January - 21 20 : 12 : 21" }, }; av_log_set_level(AV_LOG_DEBUG);