VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/indent.sed@ 69019

Last change on this file since 69019 was 69019, checked in by vboxsync, 7 years ago

Additions/linux/drm: fix a bad symbol replacement.
bugref:8524: Additions/linux: play nicely with distribution-installed Additions

A mixup in the sed symbol replacement script for the vboxvideo kernel module
created a syntax error. Fix.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
Line 
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.
25s/^ */\t\t\t\t\t\t/g
26s/^ /\t\t\t\t\t/g
27s/^ /\t\t\t\t/g
28s/^ /\t\t\t/g
29s/^ /\t\t/g
30s/^ /\t/g
31
32# Change various symbols and file names to fit kernel conventions.
33
34# Miscellaneous:
35# Remove @file headers.
36\|/\*\* @file| {
37:start
38 N
39 s|\*/|\*/|g
40 T start
41 N
42 d
43}
44/^\/\* \$Id:.*\*\/$/d
45/^typedef .* HGSMIOFFSET;$/d
46/^typedef .* HGSMISIZE;$/d
47s/^#\( *\)include <\([^/]*\)>$/#\1include "\2"/g
48
49# File names:
50s/\bHGSMIBase\.h\b/vbox_drv.h/g
51s/\bHGSMIChannels\.h\b/hgsmi_channels.h/g
52s/\bHGSMIChSetup\.h\b/hgsmi_ch_setup.h/g
53s/\bHGSMIContext\.h\b/hgsmi_context.h/g
54s/\bHGSMIDefs\.h\b/hgsmi_defs.h/g
55s/\bVBoxVideoGuest\.h\b/vboxvideo_guest.h/g
56s/\bVBoxVideo\.h\b/vboxvideo.h/g
57s/\bVBoxVideoIPRT\.h\b/vbox_err.h/g
58s/\bVBoxVideoVBE\.h\b/vboxvideo_vbe.h/g
59
60# Function names:
61s/\btestQueryConf\b/hgsmi_test_query_conf/g
62s/\bVBoxHGSMIBufferAlloc\b/hgsmi_buffer_alloc/g
63s/\bVBoxHGSMIBufferFree\b/hgsmi_buffer_free/g
64s/\bVBoxHGSMIBufferSubmit\b/hgsmi_buffer_submit/g
65s/\bVBoxHGSMICursorPosition\b/hgsmi_cursor_position/g
66s/\bVBoxHGSMIGetModeHints\b/hgsmi_get_mode_hints/g
67s/\bVBoxHGSMIProcessDisplayInfo\b/hgsmi_process_display_info/g
68s/\bVBoxHGSMIReportFlagsLocation\b/hgsmi_report_flags_location/g
69s/\bVBoxHGSMISendCapsInfo\b/hgsmi_send_caps_info/g
70s/\bVBoxHGSMIUpdateInputMapping\b/hgsmi_update_input_mapping/g
71s/\bVBoxHGSMIUpdatePointerShape\b/hgsmi_update_pointer_shape/g
72s/\bvboxHwBufferAvail\b/vbva_buffer_available/g
73s/\bvboxHwBufferEndUpdate\b/vbva_buffer_end_update/g
74s/\bvboxHwBufferFlush\b/vbva_buffer_flush/g
75s/\bvboxHwBufferPlaceDataAt\b/vbva_buffer_place_data_at/g
76s/\bvboxHwBufferWrite\b/vbva_write/g
77s/\bVBoxQueryConfHGSMI\b/hgsmi_query_conf/g
78s/\bVBoxVBVABufferBeginUpdate\b/vbva_buffer_begin_update/g
79s/\bVBoxVBVABufferEndUpdate\b/vbva_buffer_end_update/g
80s/\bVBoxVBVADisable\b/vbva_disable/g
81s/\bVBoxVBVAEnable\b/vbva_enable/g
82s/\bvboxVBVAInformHost\b/vbva_inform_host/g
83s/\bvboxVBVASetupBufferContext\b/vbva_setup_buffer_context/g
84s/\bVBVO_PORT_READ_U8\b/inb/g
85s/\bVBVO_PORT_READ_U16\b/inw/g
86s/\bVBVO_PORT_READ_U32\b/inl/g
87s/\bVBVO_PORT_WRITE_U8\b/outb/g
88s/\bVBVO_PORT_WRITE_U16\b/outw/g
89s/\bVBVO_PORT_WRITE_U32\b/outl/g
90
91# Macros:
92s/\b_1K\b/1024/g
93s/\b_4M\b/4*1024*1024/g
94s/\bAssert\b\([^;]*\);$/WARN_ON_ONCE(!(\1));/g
95s/\bAssertCompile\b/assert_compile/g
96s/\bAssertCompileSize\b/assert_compile_size/g
97s/\bAssertPtr\b\([^;]*\);$/WARN_ON_ONCE(!(\1));/g
98/AssertPtrNullReturnVoid/d
99s/\bAssertRC\b\([^;]*\);$/WARN_ON_ONCE(RT_FAILURE\1);/g
100s/\bDECLCALLBACK\b(\([^)]*\))/\1/g
101s/\bDECLCALLBACKMEMBER\b(\([^,)]*\), *\([^,)]*\))/\1 (*\2)/g
102s/^\bDECLHIDDEN\b(\([^)]*\))/\1/g
103s/\bDECLINLINE\b(\([^)]*\))/static inline \1/g
104s/\bRT_BIT\b/BIT/g
105s/\bRT_BOOL\b(\([^)]*\))/(!!(\1))/g
106/RT_C_DECLS/d
107s/\bUINT16_MAX\b/U16_MAX/g
108s/\bUINT32_MAX\b/U32_MAX/g
109s/\bUINT32_C\b(\(.*\))/\1u/g
110s/!VALID_PTR(/WARN_ON(!/g
111
112# Type names:
113s/\bint32_t\b/s32/g
114s/\buint8_t\b/u8/g
115s/\buint16_t\b/u16/g
116s/\buint32_t\b/u32/g
117s/(HGSMIBUFFERLOCATION \*)//g # Remove C++ casts from void.
118s/typedef struct HGSMIBUFFERLOCATION/struct hgsmi_buffer_location/g
119s/struct HGSMIBUFFERLOCATION/struct hgsmi_buffer_location/g
120s/} HGSMIBUFFERLOCATION/}/g
121s/\bHGSMIBUFFERLOCATION\b/struct hgsmi_buffer_location/g
122s/\([^*] *\)\bPHGSMIGUESTCOMMANDCONTEXT\b/\1struct gen_pool */g
123s/(HGSMIHOSTFLAGS \*)//g # Remove C++ casts from void.
124s/typedef struct HGSMIHOSTFLAGS/struct hgsmi_host_flags/g
125s/struct HGSMIHOSTFLAGS/struct hgsmi_host_flags/g
126s/} HGSMIHOSTFLAGS/}/g
127s/\bHGSMIHOSTFLAGS\b/struct hgsmi_host_flags/g
128s/\bHGSMIOFFSET\b/u32/g
129s/\bHGSMISIZE\b/u32/g
130s/\bRTRECT\b/void/g
131s/(VBVABUFFERCONTEXT \*)//g # Remove C++ casts from void.
132s/struct VBVABUFFERCONTEXT/struct vbva_buf_context/g
133s/} VBVABUFFERCONTEXT/} vbva_buf_context/g
134s/\bVBVABUFFERCONTEXT\b/struct vbva_buf_context/g
135s/\([^*] *\)\bPVBVABUFFERCONTEXT\b/\1struct vbva_buf_context */g
136s/(VBVACAPS \*)//g # Remove C++ casts from void.
137s/struct VBVACAPS/struct vbva_caps/g
138s/} VBVACAPS/} vbva_caps/g
139s/\bVBVACAPS\b/struct vbva_caps/g
140s/(VBVACONF32 \*)//g # Remove C++ casts from void.
141s/struct VBVACONF32/struct vbva_conf32/g
142s/} VBVACONF32/} vbva_conf32/g
143s/\bVBVACONF32\b/struct vbva_conf32/g
144s/(VBVACURSORPOSITION \*)//g # Remove C++ casts from void.
145s/struct VBVACURSORPOSITION/struct vbva_cursor_position/g
146s/} VBVACURSORPOSITION/} vbva_cursor_position/g
147s/\bVBVACURSORPOSITION\b/struct vbva_cursor_position/g
148s/(VBVAENABLE_EX \*)//g # Remove C++ casts from void.
149s/struct VBVAENABLE_EX/struct vbva_enable_ex/g
150s/} VBVAENABLE_EX/} vbva_enable_ex/g
151s/\bVBVAENABLE_EX\b/struct vbva_enable_ex/g
152s/(VBVAMOUSEPOINTERSHAPE \*)//g # Remove C++ casts from void.
153s/struct VBVAMOUSEPOINTERSHAPE/struct vbva_mouse_pointer_shape/g
154s/} VBVAMOUSEPOINTERSHAPE/} vbva_mouse_pointer_shape/g
155s/\bVBVAMOUSEPOINTERSHAPE\b/struct vbva_mouse_pointer_shape/g
156s/(VBVAMODEHINT \*)//g # Remove C++ casts from void.
157s/struct VBVAMODEHINT/struct vbva_modehint/g
158s/} VBVAMODEHINT/} vbva_modehint/g
159s/\bVBVAMODEHINT\b/struct vbva_modehint/g
160s/(VBVAQUERYMODEHINTS \*)//g # Remove C++ casts from void.
161s/struct VBVAQUERYMODEHINTS/struct vbva_query_mode_hints/g
162s/} VBVAQUERYMODEHINTS/} vbva_query_mode_hints/g
163s/\bVBVAQUERYMODEHINTS\b/struct vbva_query_mode_hints/g
164s/(VBVAREPORTINPUTMAPPING \*)//g # Remove C++ casts from void.
165s/struct VBVAREPORTINPUTMAPPING/struct vbva_report_input_mapping/g
166s/} VBVAREPORTINPUTMAPPING/} vbva_report_input_mapping/g
167s/\bVBVAREPORTINPUTMAPPING\b/struct vbva_report_input_mapping/g
168
169# Variable and parameter names:
170s/\baRecords\b/records/g
171s/\bau8Data\b/data/g
172s/\bau32Reserved\b/reserved/g
173s/\bBase\b/base/g
174s/\bbEnable\b/enable/g
175s/\bbRc\b/ret/g
176s/\bcb\b/len/g
177s/\bcbBuffer\b/buffer_length/g
178s/\bcbChunk\b/chunk/g
179s/\bcbData\b/data_len/g
180s/\bcbHintsStructureGuest\b/hints_structure_guest_size/g
181s/\bcbHwBufferAvail\b/available/g
182s/\bcbLength\b/len/g
183s/\bcbLocation\b/buf_len/g
184s/\bcbPartialWriteThreshold\b/partial_write_tresh/g ## @todo fix this?
185s/\bcbPitch\b/pitch/g
186s/\bcbPixels\b/pixel_len/g
187s/\bcBPP\b/bpp/g
188s/\bcbRecord\b/len_and_flags/g ## @todo fix this?
189s/\bcDisplay\b/display/g
190s/\bcHeight\b/height/g
191s/\bcHintsQueried\b/hints_queried_count/g
192s/\bcHotX\b/hot_x/g
193s/\bcHotY\b/hot_y/g
194s/\bcOriginX\b/origin_x/g
195s/\bcOriginY\b/origin_y/g
196s/\bcScreen\b/screen/g
197s/\bcScreens\b/screens/g
198s/\bcWidth\b/width/g
199s/\bfCaps\b/caps/g
200s/\bfFlags\b/flags/g
201s/\bfHwBufferOverflow\b/buffer_overflow/g
202s/\bfReportPosition\b/report_position/g
203s/\bfu32Flags\b/flags/g
204s/\bhostFlags\b/host_flags/g
205s/\bi32Diff\b/diff/g
206s/\bi32OriginX\b/origin_x/g
207s/\bi32OriginY\b/origin_y/g
208s/\bi32Result\b/result/g
209s/\bindexRecordFirst\b/first_record_index/g
210s/\bindexRecordFree\b/free_record_index/g
211s/\bindexRecordNext\b/next/g
212s/\boff32Data\b/data_offset/g
213s/\boff32Free\b/free_offset/g
214s/\boffLocation\b/location/g
215s/\boffStart\b/start_offset/g
216s/\boffVRAMBuffer\b/buffer_offset/g
217s/\bpaHints\b/hints/g
218s/\bpCtx\b/ctx/g
219s/\bpPixels\b/pixels/g
220s/\bpRecord\b/record/g
221s/\bpulValue\b/value_ret/g
222s/\bpVBVA\b/vbva/g
223s/\bpxHost\b/x_host/g
224s/\bpyHost\b/y_host/g
225s/\bu16BitsPerPixel\b/bits_per_pixel/g
226s/\bu16Flags\b/flags/g
227s/\bu32BytesTillBoundary\b/bytes_till_boundary/g
228s/\bu32Flags\b/flags/g
229s/\bu32Height\b/height/g
230s/\bu32HostEvents\b/host_events/g
231s/\bu32HostFlags\b/host_flags/g
232s/\bu32HotX\b/hot_x/g
233s/\bu32HotY\b/hot_y/g
234s/\bu32Index\b/index/g
235s/\bu32LineSize\b/line_size/g
236s/\bu32Offset\b/offset/g
237s/\bu32Reserved\b/reserved/g
238s/\bu32ScreenId\b/screen_id/g
239s/\bu32StartOffset\b/start_offset/g
240s/\bu32SupportedOrders\b/supported_orders/g
241s/\bu32Value\b/value/g
242s/\bu32ViewIndex\b/view_index/g
243s/\bu32Width\b/width/g
244s/\bulValue\b/value/g
245
246# Header file guard:
247s/__HGSMIChannels_h__/__HGSMI_CHANNELS_H__/g
248s/___VBox_Graphics_HGSMIChSetup_h/__HGSMI_CH_SETUP_H__/g
249
250# And move braces. This must be the last expression as it jumps to the next
251# line.
252/..*$/ {
253 N
254 s/^\([\t ][\t ]*\)} *\n[\t ]*else/\1} else/g
255 t continue_else
256 b try_brace
257:continue_else
258 N
259:try_brace
260 s/^\([\t ].*\)\n[\t ][\t ]*{/\1 {/g
261 s/^\([^#()]*\)\n[\t ]*{/\1 {/g
262 t done_brace
263 P
264 D
265:done_brace
266 p
267 d
268}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette