aspeed: Make the ast2600-a3 SoC not user creatable
[qemu/kevin.git] / scripts / fix-multiline-comments.sh
blobc15a041272023ab6ac0e3668cdfca79b894059f6
1 #! /bin/sh
3 # Fix multiline comments to match docs/devel/style.rst
5 # Copyright (C) 2018 Red Hat, Inc.
7 # Author: Paolo Bonzini
9 # Usage: scripts/fix-multiline-comments.sh [-i] FILE...
11 # -i edits the file in place (requires gawk 4.1.0).
13 # Set the AWK environment variable to choose the awk interpreter to use
14 # (default 'awk')
16 if test "$1" = -i; then
17 # gawk extension
18 inplace="-i inplace"
19 shift
21 ${AWK-awk} $inplace 'BEGIN { indent = -1 }
23 line = $0
24 # apply a star to the indent on lines after the first
25 if (indent != -1) {
26 if (line == "") {
27 line = sp " *"
28 } else if (substr(line, 1, indent + 2) == sp " ") {
29 line = sp " *" substr(line, indent + 3)
33 is_lead = (line ~ /^[ \t]*\/\*/)
34 is_trail = (line ~ /\*\//)
35 if (is_lead && !is_trail) {
36 # grab the indent at the start of a comment, but not for
37 # single-line comments
38 match(line, /^[ \t]*\/\*/)
39 indent = RLENGTH - 2
40 sp = substr(line, 1, indent)
43 # the regular expression filters out lone /*, /**, or */
44 if (indent != -1 && !(line ~ /^[ \t]*(\/\*+|\*\/)[ \t]*$/)) {
45 if (is_lead) {
46 # split the leading /* or /** on a separate line
47 match(line, /^[ \t]*\/\*+/)
48 lead = substr(line, 1, RLENGTH)
49 match(line, /^[ \t]*\/\*+[ \t]*/)
50 line = lead "\n" sp " *" substr(line, RLENGTH)
52 if (is_trail) {
53 # split the trailing */ on a separate line
54 match(line, /[ \t]*\*\//)
55 line = substr(line, 1, RSTART - 1) "\n" sp " */"
58 if (is_trail) {
59 indent = -1
61 print line
62 }' "$@"