From patchwork Mon Sep 19 22:21:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 9340733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D015607D0 for ; Mon, 19 Sep 2016 22:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17362299E6 for ; Mon, 19 Sep 2016 22:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BFB8299EE; Mon, 19 Sep 2016 22:21:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA5E3299E6 for ; Mon, 19 Sep 2016 22:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbcISWV2 (ORCPT ); Mon, 19 Sep 2016 18:21:28 -0400 Received: from gofer.mess.org ([80.229.237.210]:57569 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753453AbcISWV1 (ORCPT ); Mon, 19 Sep 2016 18:21:27 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 85F0660766; Mon, 19 Sep 2016 23:21:25 +0100 (BST) From: Sean Young To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Subject: [PATCH] v4l-utils: ir-ctl: deal with consecutive pulses or spaces correctly Date: Mon, 19 Sep 2016 23:21:25 +0100 Message-Id: <1474323685-16439-4-git-send-email-sean@mess.org> X-Mailer: git-send-email 2.1.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When sending a pulse-space file with consecutive spaces or pulses, add them together correctly. For example: pulse 100 space 150 space 100 pulse 150 pulse 200 Would send pulse 100, space 250, and pulse 350. Signed-off-by: Sean Young --- utils/ir-ctl/ir-ctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c index 229330e..2f85e6d 100644 --- a/utils/ir-ctl/ir-ctl.c +++ b/utils/ir-ctl/ir-ctl.c @@ -211,7 +211,7 @@ static struct file *read_file(const char *fname) fprintf(stderr, _("warning: %s:%d: leading space ignored\n"), fname, lineno); } else { - f->buf[len] += arg; + f->buf[len-1] += arg; } } else { f->buf[len++] = arg; @@ -220,7 +220,7 @@ static struct file *read_file(const char *fname) expect_pulse = true; } else if (strcmp(keyword, "pulse") == 0) { if (!expect_pulse) - f->buf[len] += arg; + f->buf[len-1] += arg; else f->buf[len++] = arg; expect_pulse = false;