Fix most brutal breakages introduced by commit 974a567

The cleanup commit 974a567 added some stub namespace-addition code to
project-text-files.py, which was never completed, but which broke all
other functionality of project-text-files.py. This commit doesn't
complete the implementation, but restores its previous functionality.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-03-01 13:57:51 +01:00
commit 70117f9d34

View file

@ -83,14 +83,15 @@ class Cmd(jwutils.Cmd):
r = r + line r = r + line
return r return r
def self._add_namespace_to_header(self, data, ns_new): def _add_namespace_to_header(self, data, ns_new):
lines = data.splitlines() lines = data.splitlines()
old = None old = None
ns_cur = [] ns_cur = []
for line in iter(lines): for line in iter(lines):
match = re.sub('^ *namespace[ \t]*([^ ]+)[ \t]*{.*', '\\1', line) match = re.sub('^ *namespace[ \t]*([^ ]+)[ \t]*{.*', '\\1', line)
if match != line: if match != line:
ns_cur = match(blah, bl #ns_cur = match(blah, bl
raise Exception("Name space addition is not yet implemented")
classname = re.sub('^ *#[ \t]*ifndef[\t ]+([^ ]+)($|[ \t/;])', '\\1', line) classname = re.sub('^ *#[ \t]*ifndef[\t ]+([^ ]+)($|[ \t/;])', '\\1', line)
def _fix_multiple_inclusion_preventer(self, prefix, path): def _fix_multiple_inclusion_preventer(self, prefix, path):
@ -292,8 +293,8 @@ class CmdAddCppNamespace(Cmd):
data = self._add_namespace_to_header(data, namespace) data = self._add_namespace_to_header(data, namespace)
elif ext in _exts_cpp: elif ext in _exts_cpp:
data = self._add_using_namespace(data, namespace) data = self._add_using_namespace(data, namespace)
elif: #elif: Not sure what this was meant to do
continue # continue
if data == odata: if data == odata:
continue continue
tmp = path + '.' + ('rep' if args.backup is None else args.backup) tmp = path + '.' + ('rep' if args.backup is None else args.backup)