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?= <[email protected]> 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 -- [email protected] To unsubscribe send an email to [email protected]
