Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp239068lqc; Thu, 7 Mar 2024 16:21:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVSS53sidOw2iRpLoNqkDwronlxEpNn7JyBG8lyy2ApiKpBjcFR67rse4usTnbPtIFmIvqMEcuAcAy4xanB1ZdBrEJ6ilXsdf9E/QUjfg== X-Google-Smtp-Source: AGHT+IHM2J8iZqmOKgjsiC9RaAvkJLJMHiVE58JBLosuq0d/nNvS9ltB4p+qnxLiQFB2afaoNQ+9 X-Received: by 2002:a17:903:2449:b0:1db:55cc:d226 with SMTP id l9-20020a170903244900b001db55ccd226mr10840120pls.66.1709857299636; Thu, 07 Mar 2024 16:21:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709857299; cv=pass; d=google.com; s=arc-20160816; b=pP2P2YWJMKnMXufFHkpVB3QxpUXhGbOOiE7/njfY7hDdP3mk1a9q6Bxyc4CeA3V31l 46Ao8y0hY1US+kxajl2dRKauthjf00CKkEcUOOWr8pKcgzVQFISnjjzvZdSDrF/kfH3i MgCMY2hLPCN2v6JhqlTS9f14SVNJa2MVZu+ZFUmPG5m3Cch+XF0AlVdoJ3s4O0GGeerL tWtdgtk6vYFIl/6ghz13MaUf9jch8P8T4P8dUjMJitpD27jgMfGe9pu+gxGAxC9mBa5x wTEfvHIwYgmUJLEC9/ZEJmn/HZ9TUjjPVeiHLfV9GlpphKhCmjj7/p50MvxO69MM5pej BLzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=GMafHwnxZN4CIEYFiJO7IENRNxeo2KK0p3Rv7PcNfpc=; fh=78ClevVHaBeV+DXvJ4i7emsSQWmQMixuCDAKVBZ6X0o=; b=xBv3Gxnt1rNNhik8l+DvSbyjd2REzCD4SrrNaGw+8Z53xCwPR2MgXLziA5UX3C194B QJIlK2QNpyjXHZHFvrVaCQGzmdxVFQFDhQRgfQnogEe9jxEkU2NHqcpYK5D0FSRD6n53 7S2kLUEbSW6ftp90yvuhnHx7L91RK6/hNJZqdoyKuedO4lTZ1laHsSs2vcatShWsF5ud FhAS1ga6nHxBdGz5j+0lpxVqdi1y97Rqh0fKeLEnfm6Y7l4NYtcalqCjjafnokCAlW0C VEB5MlD0YOymzEEdETsskW9TZMGYnzJ32oKGxn36rXiWecQ7Nmd3OxXXVDb/SNKdRL96 N47A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pIkvQnQI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-96384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96384-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y3-20020a17090322c300b001dcce526167si14944452plg.245.2024.03.07.16.21.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 16:21:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pIkvQnQI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-96384-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96384-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 34103B22821 for ; Fri, 8 Mar 2024 00:20:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CA61F9F7; Fri, 8 Mar 2024 00:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pIkvQnQI" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16F3A568A for ; Fri, 8 Mar 2024 00:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709857184; cv=none; b=Fkkr+Gpz21rsbwd+v9SpaX3zIxp8r9gtvC8zMjLcKy7XqQV5JhBjyCimViyhmMim+W18ZSLXcaO0QIVwE1u85J6XpjM+5FzXYZiyjwxiwHD0qnUQxisMp49mAen0h4qbl02M4vOHdL071G/f7Vc+YRPUOU49ixZ0SVl83cVODIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709857184; c=relaxed/simple; bh=FRTaxqQ9z0fdBOTvorH6lKFlBCFvX2RUJshMGjEelbw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=q509FakfstHy3SUA/kzT32VScCjqt2umUlcqvOekMXaoOnkTJWaaaxTFhtOHa0Ehq76XSiyJ4LMWpZMyqz6PBIQbfvuj0MDhKGj33eti02ds6ryQfKUl9OiDJR5FiwZtf0cFfFQ1QHEJWYkTIVSMt6yyyuHXytgpfr/K3LHjfdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pIkvQnQI; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso2539690276.1 for ; Thu, 07 Mar 2024 16:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709857182; x=1710461982; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GMafHwnxZN4CIEYFiJO7IENRNxeo2KK0p3Rv7PcNfpc=; b=pIkvQnQIWFxNjYJNyjvMsnfG4CsaRWlnjpM/gDrLqTO35Y3Xp+G51s7QoiwSl6XSUx CubaXRgY1mqdxO9cImQC1OFCqtVU46K77QWORxLr9j/RlswtREscTEoqIWYcdqLm/y9R x2r0r9neCJ2vkXigtbuYXindTKpRd7Byqo6DPKWmVJE4gcgVKiXI8uxfx1D+5OUnvtH7 JERjBdz+3+qz630bxjMiS8Ui1W27wj0+gZRzmls9eidTIU8P6VyCq3+nwEyJwNltuTma r49bl8T1ddDrasTYjfOZFu7wkqTYVEmDm9oo5BHB2+Tc7gvBeInJISOAXZFLd2IzuKxK WCbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709857182; x=1710461982; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GMafHwnxZN4CIEYFiJO7IENRNxeo2KK0p3Rv7PcNfpc=; b=GMoywfwsO92rd9yCyHoUAznwiAC9Lg3DOvEK7yOScEyIYnrYFDvXrQhpxseHBMPfzT QzQ+md0CrxwJPQFR0Z6fFXLe5G2+HuSRAkElhC0qIsUJ89U3GPTJesWqFypw/1ZfJxHF bo4Cayu90pKYWHwR6zr4eEvlMVlqQj3SzzKfvSdDALgjePfZHJo/bi4XH8+vT3zvx9lJ yImyNTe8Df8+ZFlyHlpL+x7NviYxZfoGRk8H2K2dbzodYg32MPBjKfJBcs3MHzHSvGKP 2ZzKYjVmQqLWKOlgUDOvhV7hmuBcwI31mktDAHpHzX/30TEyiBe7w38ygTATLNf2/LMh rRQA== X-Forwarded-Encrypted: i=1; AJvYcCU0Vmax+phVl0bqzEtCtb/bskxp9eoY/P5YGOFEhvKVM2Er8yIdJYRf/IB5Uty4Mht501IWgjp7ozdSt4feYA/AlWuE+9vfMWxvWiWa X-Gm-Message-State: AOJu0YxleiqnCkBhBBXZs78f0whLx73D5dVDtjeWUyAl42v42pBdPRgD dN1VuM247dJkS77wHd6tplUYHVFWMHojRqoD1oeorOH0EnyU6STLXGkZigyJuXcq39LWnt2X5k7 xNlgm7Q== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:218f:92ee:d543:c1a2]) (user=irogers job=sendgmr) by 2002:a05:6902:1004:b0:dc7:42:ecd with SMTP id w4-20020a056902100400b00dc700420ecdmr4897415ybt.6.1709857182253; Thu, 07 Mar 2024 16:19:42 -0800 (PST) Date: Thu, 7 Mar 2024 16:19:12 -0800 In-Reply-To: <20240308001915.4060155-1-irogers@google.com> Message-Id: <20240308001915.4060155-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240308001915.4060155-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v3 3/6] perf list: Allow wordwrap to wrap on commas From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Yang Jihong , Kan Liang , James Clark , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" A raw event encoding may be a block with terms separated by commas. If wrapping such a string it would be useful to break at the commas, so add this ability to wordwrap. Signed-off-by: Ian Rogers --- tools/perf/builtin-list.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 02bf608d585e..e0fe3d178d63 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -76,26 +77,38 @@ static void default_print_start(void *ps) static void default_print_end(void *print_state __maybe_unused) {} +static const char *skip_spaces_or_commas(const char *str) +{ + while (isspace(*str) || *str == ',') + ++str; + return str; +} + static void wordwrap(FILE *fp, const char *s, int start, int max, int corr) { int column = start; int n; bool saw_newline = false; + bool comma = false; while (*s) { - int wlen = strcspn(s, " \t\n"); + int wlen = strcspn(s, " ,\t\n"); + const char *sep = comma ? "," : " "; if ((column + wlen >= max && column > start) || saw_newline) { - fprintf(fp, "\n%*s", start, ""); + fprintf(fp, comma ? ",\n%*s" : "\n%*s", start, ""); column = start + corr; } - n = fprintf(fp, "%s%.*s", column > start ? " " : "", wlen, s); + if (column <= start) + sep = ""; + n = fprintf(fp, "%s%.*s", sep, wlen, s); if (n <= 0) break; saw_newline = s[wlen] == '\n'; s += wlen; + comma = s[0] == ','; column += n; - s = skip_spaces(s); + s = skip_spaces_or_commas(s); } } -- 2.44.0.278.ge034bb2e1d-goog