aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarstr\xf6m <john@ankarstrom.se>2021-05-31 19:40:00 +0200
committerJohn Ankarstr\xf6m <john@ankarstrom.se>2021-05-31 19:40:00 +0200
commit55032742d5b9817d8fdbe1e9822b74f12c3d08d6 (patch)
tree6e76aef69582fae56cc77b9e62a2afe1989d1266
parenta8c2415961ae8b952a4fc57f19435c1d5ef883dd (diff)
downloadxutil-55032742d5b9817d8fdbe1e9822b74f12c3d08d6.tar.gz
Add 'isort' utility
-rwxr-xr-xisort8
1 files changed, 8 insertions, 0 deletions
diff --git a/isort b/isort
new file mode 100755
index 0000000..27a589d
--- /dev/null
+++ b/isort
@@ -0,0 +1,8 @@
+#!/usr/bin/perl -p
+
+# isort -- sort C variable declarations separated by commas
+
+s/([^,]*?)(\S+[,;])/$2/; $prefix = $1;
+s/;$/,/; @words = sort split /\s+/;
+$_ = $prefix . (join ' ', @words) . "\n";
+s/,$/;/;