qt5base-lts/qmake
Orgad Shaneh 601ab660af Remove braces for single lines of conditions
#!/usr/bin/env ruby

Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}

Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-02-06 14:21:44 +01:00
..
generators qmake/MSVC: fix parsing of the /openmp option 2013-02-04 16:33:17 +01:00
library Remove braces for single lines of conditions 2013-02-06 14:21:44 +01:00
cachekeys.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
main.cpp Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
Makefile.unix port qmake to qt creator's qmake language evaluator 2012-09-11 00:13:01 +02:00
Makefile.win32 MSVC: don't use the variable name LINK in generated makefiles 2012-12-06 14:46:13 +01:00
Makefile.win32-g++ MinGW: Statically link runtime libraries into qmake 2013-01-12 07:16:37 +01:00
meta.cpp Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
meta.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
option.cpp don't flush qmake command line twice 2013-02-01 17:38:29 +01:00
option.h don't flush qmake command line twice 2013-02-01 17:38:29 +01:00
project.cpp Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
project.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
property.cpp remove versioned config backwards compatibility hack 2013-02-01 10:23:26 +01:00
property.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qmake_pch.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qmake.pri remove some unnecessary CONFIG additions 2012-12-17 14:08:17 +01:00
qmake.pro port qmake to qt creator's qmake language evaluator 2012-09-11 00:13:01 +02:00