diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:20 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:20 +0200 |
commit | ea859f50d9438bc61ae96721a4d255b49de78653 (patch) | |
tree | bfb52a5f403ad1e86c562b2f4d608d1268fe8fcf /scripts | |
parent | 266ab52b3a741a58fb17c48b0f7939d7c5d266de (diff) | |
download | debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.gz debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.bz2 debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.zip |
Imported Upstream version 0.6.2upstream/0.6.2
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/MakeHeader.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/MakeHeader.py b/scripts/MakeHeader.py new file mode 100755 index 0000000..2268fcf --- /dev/null +++ b/scripts/MakeHeader.py @@ -0,0 +1,60 @@ +#!/usr/bin/python + +import os, sys, string + +ANY=1 +COPY=2 +SKIP=3 +SKIPONE=4 + +state = ANY + +file = open(sys.argv[1]) +name = sys.argv[1][:-2] + +out = open(name + ".h", "w") +class writer: + def __init__(self, file): + self.file = file + def write(self, text): + self.file.write(text + "\n") +out = writer(out) + +selfheader = '#include "' + name + '.h"' + +out.write( "/* Do not edit this file. It was automatically generated. */" ) +out.write( "" ) + +out.write( "#ifndef HEADER_" + name ) +out.write( "#define HEADER_" + name ) +for line in file.readlines(): + line = line[:-1] + if state == ANY: + if line == '/*{': + state = COPY + elif line == selfheader: + pass + elif string.find(line, "typedef") == 0 or line == "/* private */": + state = SKIP + elif string.find(line, "/* private property */") == 0: + state = SKIPONE + elif len(line) > 1 and line[-1] == "{": + out.write( line[:-2] + ";" ) + state = SKIP + elif line == "": + out.write( "" ) + else: + out.write( line ) + elif state == COPY: + if line == "}*/": + state = ANY + else: + out.write( line ) + elif state == SKIP: + if len(line) >= 1 and line[0] == "}": + state = ANY + elif state == SKIPONE: + state = ANY + +out.write( "" ) +out.write( "#endif" ) |