1 | # Oracle VM VirtualBox
|
---|
2 | # VirtualBox to Linux kernel coding style conversion script.
|
---|
3 |
|
---|
4 | #
|
---|
5 | # Copyright (C) 2017 Oracle Corporation
|
---|
6 | #
|
---|
7 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | # available from http://www.virtualbox.org. This file is free software;
|
---|
9 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | # General Public License (GPL) as published by the Free Software
|
---|
11 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | #
|
---|
15 |
|
---|
16 | # This script is for converting code inside the vboxvideo module to Linux
|
---|
17 | # kernel coding style. It assumes correct VirtualBox coding style, will break
|
---|
18 | # break if the coding style is wrong (e.g. tab instead of spaces) and is not
|
---|
19 | # indended to be a generic solution: for example, identifiers will be
|
---|
20 | # translated case by case, not algorithmically. It also assumes that any
|
---|
21 | # flexibility in either coding style will be used where possible to make the
|
---|
22 | # code conform to both at once.
|
---|
23 |
|
---|
24 | # Replace up to six leading groups of four spaces with tabs.
|
---|
25 | s/^ /\t\t\t\t\t\t/g
|
---|
26 | s/^ /\t\t\t\t\t/g
|
---|
27 | s/^ /\t\t\t\t/g
|
---|
28 | s/^ /\t\t\t/g
|
---|
29 | s/^ /\t\t/g
|
---|
30 | s/^ /\t/g
|
---|
31 | # Remove any spaces left after the tabs. This also limits maximum indentation.
|
---|
32 | s/^\(\t\t*\) */\1/g
|
---|
33 | # And move braces. This must be the last expression as it jumps to the next
|
---|
34 | # line.
|
---|
35 | /..*$/ {
|
---|
36 | N
|
---|
37 | s/^\([\t ][\t ]*\)} *\n[\t ]*else/\1} else/g
|
---|
38 | t continue_else
|
---|
39 | b try_brace
|
---|
40 | :continue_else
|
---|
41 | N
|
---|
42 | :try_brace
|
---|
43 | s/^\([\t ].*\)\n[\t ][\t ]*{/\1 {/g
|
---|
44 | t done_brace
|
---|
45 | P
|
---|
46 | D
|
---|
47 | :done_brace
|
---|
48 | p
|
---|
49 | d
|
---|
50 | }
|
---|