Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] tools: Make indent_arm_assembly.pl able to reformat a file in place (PR #20980)
@ 2025-11-20 12:42 Martin Storsjö via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Martin Storsjö via ffmpeg-devel @ 2025-11-20 12:42 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Martin Storsjö

PR #20980 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20980
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20980.patch

This allows using the tool for one-off reindentations without needing
the check_arm_indent.sh script (e.g. for use outside of ffmpeg),
without having to pipe the file through stdin/stdout.


From 053aec1915fbe5ea506beb254b29cc9f4480560b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Tue, 18 Nov 2025 12:13:37 +0200
Subject: [PATCH] tools: Make indent_arm_assembly.pl able to reformat a file in
 place

This allows using the tool for one-off reindentations without needing
the check_arm_indent.sh script (e.g. for use outside of ffmpeg),
without having to pipe the file through stdin/stdout.
---
 tools/indent_arm_assembly.pl | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/tools/indent_arm_assembly.pl b/tools/indent_arm_assembly.pl
index 7d5d1ecef2..77d6d6fdf3 100755
--- a/tools/indent_arm_assembly.pl
+++ b/tools/indent_arm_assembly.pl
@@ -41,6 +41,7 @@ my $indent_operands = 0;
 my $instr_indent = 8;
 my $operand_indent = 24;
 my $match_indent = 0;
+my $file;
 
 while (@ARGV) {
     my $opt = shift;
@@ -54,7 +55,11 @@ while (@ARGV) {
     } elsif ($opt eq "-match-indent") {
         $match_indent = 1;
     } else {
-        die "Unrecognized parameter $opt\n";
+        if (!$file) {
+            $file = $opt;
+        } else {
+            die "Unrecognized parameter $opt\n";
+        }
     }
 }
 
@@ -130,7 +135,22 @@ sub columns {
     return indentcolumns($rest, 3);
 }
 
-while (<STDIN>) {
+my $in;
+my $out;
+my $tempfile;
+
+if ($file) {
+    open(INPUT, "$file") or die "Unable to open $file: $!";
+    $in = *INPUT;
+    $tempfile = "$file.tmp";
+    open(OUTPUT, ">$tempfile") or die "Unable to open $tempfile: $!";
+    $out = *OUTPUT;
+} else {
+    $in = *STDIN;
+    $out = *STDOUT;
+}
+
+while (<$in>) {
     # Trim off trailing whitespace.
     chomp;
     if (/^([\.\w\d]+:)?(\s+)([\w\\][\w\\\.]*)(?:(\s+)(.*)|$)/) {
@@ -201,5 +221,10 @@ while (<STDIN>) {
             $_ = $label . $indent . $instr . $operand_space . $rest;
         }
     }
-    print $_ . "\n";
+    print $out $_ . "\n";
+}
+
+if ($file) {
+    close(OUTPUT);
+    rename($tempfile, $file);
 }
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-20 12:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-20 12:42 [FFmpeg-devel] [PATCH] tools: Make indent_arm_assembly.pl able to reformat a file in place (PR #20980) Martin Storsjö via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git