Bugzilla – Attachment 170671 Details for
Bug 124176
Use pragma once instead of include guards
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
define_to_pragma.py
define_to_pragma.py (text/x-python), 1.17 KB, created by
LE GARREC Vincent
on 2021-03-23 19:15:44 UTC
(
hide
)
Description:
define_to_pragma.py
Filename:
MIME Type:
Creator:
LE GARREC Vincent
Created:
2021-03-23 19:15:44 UTC
Size:
1.17 KB
patch
obsolete
>import re >from pathlib import Path > >def my_function(fname): > with open(fname, 'r') as infile: > lines = infile.readlines() > > pifn = re.compile('^#ifndef') > pdefinc = re.compile('^#define INCLUDED_.*_H??') > pendif = re.compile('^#endif') > i = len(lines)-2 > for i in range(len(lines)-1): > if lines[i] == '#pragma once\n': > return > if pifn.search(lines[i]) and pdefinc.search(lines[i+1]): > break > > if i != len(lines)-2: > print(i, lines[i]) > lines[i] = "#pragma once\n" > del lines[i+1] > > for i in range(len(lines)-1, -1, -1): > if pendif.search(lines[i]): > print(i, lines[i]) > del lines[i] > if lines[i-1]=="\n" and len(lines) != i and lines[i]=="\n": > del lines[i] > with open(fname, 'w', newline='\n') as outfile: > outfile.write(''.join(lines)) > break > > >for path in Path('G:\\Github\\libreoffice\\').rglob('*.h*'): > try: > my_function(path) > except UnicodeDecodeError: > pass > except PermissionError: > pass
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 124176
: 170671