diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle A.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle A.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle A.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle A.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,81 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle All.workspace" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle All.workspace" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle All.workspace" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle All.workspace" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,97 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle Java.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle Java.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle Java.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle Java.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,97 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle So.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle So.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-clang/Clang AStyle So.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-clang/Clang AStyle So.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,89 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle A.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle A.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle A.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle A.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,89 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle All.workspace" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle All.workspace" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle All.workspace" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle All.workspace" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,186 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle Java.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle Java.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle Java.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle Java.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,101 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle So.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle So.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-gcc/Gcc AStyle So.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-gcc/Gcc AStyle So.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,97 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle A.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle A.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle A.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle A.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,64 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle All.workspace" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle All.workspace" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle All.workspace" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle All.workspace" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,62 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle Java.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle Java.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle Java.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle Java.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,80 @@ + + + + + + diff -Nru "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle So.cbp" "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle So.cbp" --- "/tmp/tmp8UBkTZ/00VpxD2kAz/astyle-2.06/build/cb-intel/Intel AStyle So.cbp" 1970-01-01 00:00:00.000000000 +0000 +++ "/tmp/tmp8UBkTZ/smmWriFE0D/astyle-3.0.1/build/cb-intel/Intel AStyle So.cbp" 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,76 @@ + + + + + + diff -Nru astyle-2.06/build/clang/Makefile astyle-3.0.1/build/clang/Makefile --- astyle-2.06/build/clang/Makefile 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/build/clang/Makefile 2017-05-31 00:26:37.000000000 +0000 @@ -35,11 +35,23 @@ bindir = bin objdir = obj ipath=$(prefix)/bin -CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions +CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions -std=c++11 JAVAINCS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux CXX = clang++ INSTALL=install -o $(USER) -g $(USER) +# Library's major version number -- Increment in case of incompatible API +# change. +MAJORVER = 3 +# Library's minor version number -- Increment when functionnality is added in a +# backward-compatible manner; reset to 0 when major number changes. +MINORVER = 0 +# Library's patch version number -- Increment in case of backward-compatible +# bug fixes or refactoring; reset to 0 when minor number changes. +PATCHVER = 1 +# Library's full version number. +SOLIBVER = $(MAJORVER).$(MINORVER).$(PATCHVER) + ################################################## # define compile options for each build @@ -50,12 +62,12 @@ CFLAGSr = -DNDEBUG -O3 $(CBASEFLAGS) CFLAGSd = -g $(CBASEFLAGS) endif -CFLAGSs = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSr) -CFLAGSsd = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSd) +CFLAGSs = -DASTYLE_LIB -fPIC $(CFLAGSr) +CFLAGSsd = -DASTYLE_LIB -fPIC $(CFLAGSd) CFLAGSa = -DASTYLE_LIB $(CFLAGSr) CFLAGSad = -DASTYLE_LIB $(CFLAGSd) -CFLAGSsj = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSr) $(JAVAINCS) -CFLAGSsjd = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSd) $(JAVAINCS) +CFLAGSsj = -DASTYLE_JNI -fPIC $(CFLAGSr) $(JAVAINCS) +CFLAGSsjd = -DASTYLE_JNI -fPIC $(CFLAGSd) $(JAVAINCS) # define link options ifdef LDFLAGS @@ -137,13 +149,13 @@ shared: libastyle.so libastyle.so: $(OBJs) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastyle.so.$(MAJORVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ @ echo shareddebug: libastyled.so libastyled.so: $(OBJsd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^ + $(CXX) -shared $(LDFLAGSd) -Wl,-soname,libastyled.so.$(MAJORVER) -o $(bindir)/libastyled.so.$(SOLIBVER) $^ @ echo static: libastyle.a @@ -161,13 +173,13 @@ java: libastylej.so libastylej.so: $(OBJsj) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylej.so.$(MAJORVER) -o $(bindir)/libastylej.so.$(SOLIBVER) $^ @ echo javadebug: libastylejd.so libastylejd.so: $(OBJsjd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylejd.so.$(MAJORVER) -o $(bindir)/libastylejd.so.$(SOLIBVER) $^ @ echo all: release debug shared shareddebug static staticdebug diff -Nru astyle-2.06/build/gcc/Makefile astyle-3.0.1/build/gcc/Makefile --- astyle-2.06/build/gcc/Makefile 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/build/gcc/Makefile 2017-05-31 00:26:37.000000000 +0000 @@ -35,11 +35,23 @@ bindir = bin objdir = obj ipath=$(prefix)/bin -CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions +CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions -std=c++11 JAVAINCS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux CXX = g++ INSTALL=install -o $(USER) -g $(USER) +# Library's major version number -- Increment in case of incompatible API +# change. +MAJORVER = 3 +# Library's minor version number -- Increment when functionnality is added in a +# backward-compatible manner; reset to 0 when major number changes. +MINORVER = 0 +# Library's patch version number -- Increment in case of backward-compatible +# bug fixes or refactoring; reset to 0 when minor number changes. +PATCHVER = 1 +# Library's full version number. +SOLIBVER = $(MAJORVER).$(MINORVER).$(PATCHVER) + ################################################## # define compile options for each build @@ -50,12 +62,12 @@ CFLAGSr = -DNDEBUG -O3 $(CBASEFLAGS) CFLAGSd = -g $(CBASEFLAGS) endif -CFLAGSs = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSr) -CFLAGSsd = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSd) +CFLAGSs = -DASTYLE_LIB -fPIC $(CFLAGSr) +CFLAGSsd = -DASTYLE_LIB -fPIC $(CFLAGSd) CFLAGSa = -DASTYLE_LIB $(CFLAGSr) CFLAGSad = -DASTYLE_LIB $(CFLAGSd) -CFLAGSsj = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSr) $(JAVAINCS) -CFLAGSsjd = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSd) $(JAVAINCS) +CFLAGSsj = -DASTYLE_JNI -fPIC $(CFLAGSr) $(JAVAINCS) +CFLAGSsjd = -DASTYLE_JNI -fPIC $(CFLAGSd) $(JAVAINCS) # define link options ifdef LDFLAGS @@ -137,13 +149,13 @@ shared: libastyle.so libastyle.so: $(OBJs) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastyle.so.$(MAJORVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ @ echo shareddebug: libastyled.so libastyled.so: $(OBJsd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^ + $(CXX) -shared $(LDFLAGSd) -Wl,-soname,libastyled.so.$(MAJORVER) -o $(bindir)/libastyled.so.$(SOLIBVER) $^ @ echo static: libastyle.a @@ -161,13 +173,13 @@ java: libastylej.so libastylej.so: $(OBJsj) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylej.so.$(MAJORVER) -o $(bindir)/libastylej.so.$(SOLIBVER) $^ @ echo javadebug: libastylejd.so libastylejd.so: $(OBJsjd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylejd.so.$(MAJORVER) -o $(bindir)/libastylejd.so.$(SOLIBVER) $^ @ echo all: release debug shared shareddebug static staticdebug diff -Nru astyle-2.06/build/intel/Makefile astyle-3.0.1/build/intel/Makefile --- astyle-2.06/build/intel/Makefile 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/build/intel/Makefile 2017-05-31 00:26:37.000000000 +0000 @@ -45,12 +45,23 @@ bindir = bin objdir = obj ipath=$(prefix)/bin - -CBASEFLAGS = -w3 -Wall -fno-rtti -fno-exceptions +CBASEFLAGS = -w3 -Wall -fno-rtti -fno-exceptions -std=c++11 JAVAINCS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux CXX = icpc INSTALL=install -o $(USER) -g $(USER) +# Library's major version number -- Increment in case of incompatible API +# change. +MAJORVER = 3 +# Library's minor version number -- Increment when functionnality is added in a +# backward-compatible manner; reset to 0 when major number changes. +MINORVER = 0 +# Library's patch version number -- Increment in case of backward-compatible +# bug fixes or refactoring; reset to 0 when minor number changes. +PATCHVER = 1 +# Library's full version number. +SOLIBVER = $(MAJORVER).$(MINORVER).$(PATCHVER) + ################################################## # define compile options for each build @@ -61,12 +72,12 @@ CFLAGSr = -DNDEBUG -O3 $(CBASEFLAGS) CFLAGSd = -g $(CBASEFLAGS) endif -CFLAGSs = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSr) -CFLAGSsd = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSd) +CFLAGSs = -DASTYLE_LIB -fPIC $(CFLAGSr) +CFLAGSsd = -DASTYLE_LIB -fPIC $(CFLAGSd) CFLAGSa = -DASTYLE_LIB $(CFLAGSr) CFLAGSad = -DASTYLE_LIB $(CFLAGSd) -CFLAGSsj = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSr) $(JAVAINCS) -CFLAGSsjd = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSd) $(JAVAINCS) +CFLAGSsj = -DASTYLE_JNI -fPIC $(CFLAGSr) $(JAVAINCS) +CFLAGSsjd = -DASTYLE_JNI -fPIC $(CFLAGSd) $(JAVAINCS) # define link options ifdef LDFLAGS @@ -148,13 +159,13 @@ shared: libastyle.so libastyle.so: $(OBJs) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastyle.so.$(MAJORVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ @ echo shareddebug: libastyled.so libastyled.so: $(OBJsd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^ + $(CXX) -shared $(LDFLAGSd) -Wl,-soname,libastyled.so.$(MAJORVER) -o $(bindir)/libastyled.so.$(SOLIBVER) $^ @ echo static: libastyle.a @@ -172,13 +183,13 @@ java: libastylej.so libastylej.so: $(OBJsj) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylej.so.$(MAJORVER) -o $(bindir)/libastylej.so.$(SOLIBVER) $^ @ echo javadebug: libastylejd.so libastylejd.so: $(OBJsjd) @ mkdir -p $(bindir) - $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^ + $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastylejd.so.$(MAJORVER) -o $(bindir)/libastylejd.so.$(SOLIBVER) $^ @ echo all: release debug shared shareddebug static staticdebug diff -Nru astyle-2.06/debian/astyle.NEWS astyle-3.0.1/debian/astyle.NEWS --- astyle-2.06/debian/astyle.NEWS 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/astyle.NEWS 2017-09-08 15:45:58.000000000 +0000 @@ -1,3 +1,16 @@ +astyle (3.0-1) unstable; urgency=medium + + A few options have been renamed: + - "break-closing-brackets" becomes "break-closing-braces" + - "add-brackets" becomes "add-braces" + - "add-one-line-brackets" becomes "add-one-line-braces" + - "remove-brackets" becomes "remove-braces" + - "max-instatement-indent" becomes "max-continuation-indent" + The old names have been deprecated (rather than disabled), but you + should switch to the new names in your scripts. + + -- Matteo Cypriani Fri, 25 Aug 2017 17:33:54 -0400 + astyle (2.03-1) unstable; urgency=low The usual warning applies again: diff -Nru astyle-2.06/debian/changelog astyle-3.0.1/debian/changelog --- astyle-2.06/debian/changelog 2017-02-26 16:50:20.000000000 +0000 +++ astyle-3.0.1/debian/changelog 2017-11-09 07:44:58.000000000 +0000 @@ -1,3 +1,40 @@ +astyle (3.0.1-1ubuntu1) bionic; urgency=medium + + * Merge with Debian unstable, remaining changes: + + Update symbols for building with -O3 on ppc64el + + -- Graham Inggs Thu, 09 Nov 2017 07:44:58 +0000 + +astyle (3.0.1-1) unstable; urgency=medium + + * New upstream version. + * libastyle3.symbols: + + Add new symbol appeared in 3.0.1. + + Delete optional symbol disappeared in 3.0.0. + + -- Matteo Cypriani Fri, 08 Sep 2017 11:45:58 -0400 + +astyle (3.0-2) unstable; urgency=medium + + * Fix libastyle3.symbols for 32-bit architectures, including specific fixes + for armel. + * Quit parsing output of dpkg-parsechangelog. + + -- Matteo Cypriani Mon, 28 Aug 2017 14:34:54 -0400 + +astyle (3.0-1) unstable; urgency=medium + + * New upstream version. + + New library soname (3.0.0), renamed package (libastyle3). + + Dropped set_soname.patch. + + Refreshed privacy.patch. + * Update libastyle3.symbols. Closes: #853321. + * Drop hardening.patch, handle PIE via DEB_BUILD_MAINT_OPTIONS. + * Update debian/copyright. + * Bump Standards-Version to 4.1.0 (no changes needed). + + -- Matteo Cypriani Fri, 25 Aug 2017 17:33:54 -0400 + astyle (2.06-2ubuntu1) zesty; urgency=medium * Update symbols for building with -O3 on ppc64el diff -Nru astyle-2.06/debian/control astyle-3.0.1/debian/control --- astyle-2.06/debian/control 2017-02-26 16:50:20.000000000 +0000 +++ astyle-3.0.1/debian/control 2017-11-09 07:44:58.000000000 +0000 @@ -5,7 +5,7 @@ Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Matteo Cypriani Uploaders: Margarita Manterola -Standards-Version: 3.9.8 +Standards-Version: 4.1.0 Homepage: http://astyle.sourceforge.net/ Vcs-Git: https://anonscm.debian.org/git/collab-maint/astyle.git Vcs-Browser: https://anonscm.debian.org/gitweb/?p=collab-maint/astyle.git @@ -20,7 +20,7 @@ . This package contains the command line tool. -Package: libastyle0debian2.06 +Package: libastyle3 Section: libs Architecture: any Multi-Arch: same @@ -37,7 +37,7 @@ Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libastyle0debian2.06 (=${binary:Version}) + libastyle3 (=${binary:Version}) Description: Library header files for Artistic Style Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C++/CLI, Objective-C, C# and Java programming languages. diff -Nru astyle-2.06/debian/copyright astyle-3.0.1/debian/copyright --- astyle-2.06/debian/copyright 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/copyright 2017-09-08 15:45:58.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Artistic Style Upstream-Contact: Jim Pattee Source: http://astyle.sourceforge.net/ @@ -8,7 +8,7 @@ Copyright: 1998-2004 Tal Davidson 2005, 2006 Martin Baute - 2006-2014, 2016 Jim Pattee + 2006-2014, 2016-2017 Jim Pattee License: MIT Files: debian/* @@ -18,7 +18,7 @@ 2001-2003 Luca Filipozzi 2014 Scott Howard 2004-2011, 2016 Margarita Manterola - 2010-2016 Matteo Cypriani + 2010-2017 Matteo Cypriani 2016 Matthias Klose License: LGPL-3+ diff -Nru astyle-2.06/debian/libastyle0debian2.06.install astyle-3.0.1/debian/libastyle0debian2.06.install --- astyle-2.06/debian/libastyle0debian2.06.install 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/libastyle0debian2.06.install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -#! /usr/bin/dh-exec -build/gcc/bin/libastyle.so.0debian2.06 => usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so.0debian2.06 diff -Nru astyle-2.06/debian/libastyle0debian2.06.lintian-overrides astyle-3.0.1/debian/libastyle0debian2.06.lintian-overrides --- astyle-2.06/debian/libastyle0debian2.06.lintian-overrides 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/libastyle0debian2.06.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# We do import CPPFLAGS from dpkg-buildflags. -hardening-no-fortify-functions diff -Nru astyle-2.06/debian/libastyle0debian2.06.symbols astyle-3.0.1/debian/libastyle0debian2.06.symbols --- astyle-2.06/debian/libastyle0debian2.06.symbols 2017-02-26 16:50:20.000000000 +0000 +++ astyle-3.0.1/debian/libastyle0debian2.06.symbols 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -libastyle.so.0debian2.06 libastyle0debian2.06 #MINVER# - AStyleGetVersion@Base 0debian2.06 - AStyleMain@Base 0debian2.06 - AStyleMainUtf16@Base 0debian2.06 - _ZNKSt5ctypeIcE8do_widenEc@Base 0debian2.06 - _ZNSt6vectorIN6astyle11BracketTypeESaIS1_EE19_M_emplace_back_auxIJS1_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE19_M_emplace_back_auxIJRKS5_EEEvDpOT_@Base 0debian2.06 - (optional)_ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE12emplace_backIJS7_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE19_M_emplace_back_auxIJRKS7_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE19_M_emplace_back_auxIJS7_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE9push_backERKS7_@Base 0debian2.06 - _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEaSERKS9_@Base 0debian2.06 - _ZNSt6vectorIPKSt4pairIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ESaISA_EE19_M_emplace_back_auxIJSA_EEEvDpOT_@Base 0debian2.06 - (optional)_ZNSt6vectorIPS_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EESaISA_EE12emplace_backIJSA_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorIPS_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EESaISA_EE19_M_emplace_back_auxIJSA_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorISt4pairIiiESaIS1_EE19_M_emplace_back_auxIJRKS1_EEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorISt4pairIiiESaIS1_EEaSERKS3_@Base 0debian2.06 - _ZNSt6vectorIbSaIbEE13_M_insert_auxESt13_Bit_iteratorb@Base 0debian2.06 - (optional)_ZNSt6vectorIiSaIiEE12emplace_backIJiEEEvDpOT_@Base 0debian2.06 - (optional)_ZNSt6vectorIbSaIbEE9push_backEb@Base 2.06-2 0debian2.06 - _ZNSt6vectorIiSaIiEE19_M_emplace_back_auxIJiEEEvDpOT_@Base 0debian2.06 - _ZNSt6vectorIiSaIiEE9push_backERKi@Base 0debian2.06 - _ZNSt6vectorIiSaIiEEaSERKS1_@Base 0debian2.06 - (optional)_ZSt4findIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEES9_ET_SF_SF_RKT0_@Base 0debian2.06 - _ZSteqIcEN9__gnu_cxx11__enable_ifIXsrSt9__is_charIT_E7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS3_St11char_traitsIS3_ESaIS3_EEESE_@Base 0debian2.06 - (optional)_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEOS8_RKS8_@Base 0debian2.06 - _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_@Base 0debian2.06 diff -Nru astyle-2.06/debian/libastyle3.install astyle-3.0.1/debian/libastyle3.install --- astyle-2.06/debian/libastyle3.install 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/debian/libastyle3.install 2017-09-08 15:45:58.000000000 +0000 @@ -0,0 +1,2 @@ +#!/usr/bin/dh-exec +build/gcc/bin/libastyle.so.*.*.* usr/lib/${DEB_HOST_MULTIARCH} diff -Nru astyle-2.06/debian/libastyle3.links astyle-3.0.1/debian/libastyle3.links --- astyle-2.06/debian/libastyle3.links 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/debian/libastyle3.links 2017-09-08 15:45:58.000000000 +0000 @@ -0,0 +1,2 @@ +#!/usr/bin/dh-exec +usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so.3.0.1 usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so.3 diff -Nru astyle-2.06/debian/libastyle3.lintian-overrides astyle-3.0.1/debian/libastyle3.lintian-overrides --- astyle-2.06/debian/libastyle3.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/debian/libastyle3.lintian-overrides 2017-09-08 15:45:58.000000000 +0000 @@ -0,0 +1,2 @@ +# We do import CPPFLAGS from dpkg-buildflags. +hardening-no-fortify-functions diff -Nru astyle-2.06/debian/libastyle3.symbols astyle-3.0.1/debian/libastyle3.symbols --- astyle-2.06/debian/libastyle3.symbols 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/debian/libastyle3.symbols 2017-11-09 07:44:58.000000000 +0000 @@ -0,0 +1,541 @@ +libastyle.so.3 libastyle3 #MINVER# + AStyleGetVersion@Base 0debian2.06 + AStyleMain@Base 0debian2.06 + AStyleMainUtf16@Base 0debian2.06 + _ZN6astyle10ASEnhancer16parseCurrentLineERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbb@Base 3.0 + (arch-bits=32)_ZN6astyle10ASEnhancer18processSwitchBlockERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZN6astyle10ASEnhancer18processSwitchBlockERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZN6astyle10ASEnhancer4initEiiibbbbbbbPSt6vectorIPKSt4pairIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ESaISC_EE@Base 3.0 + _ZN6astyle10ASEnhancer7enhanceERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbbb@Base 3.0 + _ZN6astyle10ASEnhancerC1Ev@Base 3.0 + _ZN6astyle10ASEnhancerC2Ev@Base 3.0 + _ZN6astyle10ASEnhancerD0Ev@Base 3.0 + _ZN6astyle10ASEnhancerD1Ev@Base 3.0 + _ZN6astyle10ASEnhancerD2Ev@Base 3.0 + _ZN6astyle10ASResource10AS_BIT_ANDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_BIT_NOTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_BIT_XORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_DEFAULTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_FINALLYB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_FOREACHB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_FOREVERB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_MS__ASMB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10AS_PRIVATEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource10_AS_EXCEPTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_DELEGATEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_GR_EQUALB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_GR_GR_GRB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_LS_EQUALB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_LS_LS_LSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_NOEXCEPTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_OPERATORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_OVERRIDEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_QFOREACHB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_QFOREVERB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_QUESTIONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_SELECTORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_TEMPLATEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11AS_VOLATILEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource11_AS_FINALLYB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_BAR_ENDIFB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_INTERFACEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_INTERRUPTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_NAMESPACEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_NOT_EQUALB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_NS_DURINGB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_OR_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_PLUS_PLUSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_PROTECTEDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_SEMICOLONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12AS_UNCHECKEDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource12buildHeadersEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEib@Base 3.0 + _ZN6astyle10ASResource13AS_AND_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_BAR_DEFINEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_CONST_CASTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_DIV_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_MOD_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_NS_HANDLERB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_OPEN_BRACEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource13AS_XOR_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_BAR_INCLUDEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_CLOSE_BRACEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_MINUS_MINUSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_MULT_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_PLUS_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14AS_STATIC_CASTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource14buildOperatorsEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEi@Base 3.0 + _ZN6astyle10ASResource15AS_DYNAMIC_CASTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource15AS_GR_GR_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource15AS_LS_LS_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource15AS_MINUS_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource15AS_OPEN_COMMENTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource15AS_SYNCHRONIZEDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource16AS_CLOSE_COMMENTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource17AS_GCC_MAX_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource17AS_GCC_MIN_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource18AS_AUTORELEASEPOOLB5cxx11E@Base 3.0 + _ZN6astyle10ASResource18AS_GR_GR_GR_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource18AS_LS_LS_LS_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource18buildCastOperatorsEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE@Base 3.0 + _ZN6astyle10ASResource19AS_REINTERPRET_CASTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource19AS_SCOPE_RESOLUTIONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource20AS_OPEN_LINE_COMMENTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource20AS_QUESTION_QUESTIONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource20buildNonParenHeadersEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEib@Base 3.0 + _ZN6astyle10ASResource21buildIndentableMacrosEPSt6vectorIPKSt4pairIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ESaISC_EE@Base 3.0 + _ZN6astyle10ASResource22buildIndentableHeadersEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE@Base 3.0 + _ZN6astyle10ASResource22buildPreCommandHeadersEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEi@Base 3.0 + _ZN6astyle10ASResource23buildPreBlockStatementsEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEi@Base 3.0 + _ZN6astyle10ASResource24buildAssignmentOperatorsEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE@Base 3.0 + _ZN6astyle10ASResource25buildPreDefinitionHeadersEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEi@Base 3.0 + _ZN6astyle10ASResource27buildNonAssignmentOperatorsEPSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE@Base 3.0 + _ZN6astyle10ASResource5AS_DOB5cxx11E@Base 3.0 + _ZN6astyle10ASResource5AS_GRB5cxx11E@Base 3.0 + _ZN6astyle10ASResource5AS_IFB5cxx11E@Base 3.0 + _ZN6astyle10ASResource5AS_LSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource5AS_ORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_ADDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_ANDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_ASMB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_CINB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_DIVB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_ENDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_FORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_GETB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_LETB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_MODB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_NEWB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_NOTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_SETB5cxx11E@Base 3.0 + _ZN6astyle10ASResource6AS_TRYB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_AUTOB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_CASEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_CERRB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_COUTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_ELSEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_ENUMB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_LOCKB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_MULTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7AS_PLUSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource7_AS_TRYB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_ARROWB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_CATCHB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_CLASSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_COLONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_COMMAB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_CONSTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_EQUALB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_FINALB5cxx11E@Base 3.0.1 + _ZN6astyle10ASResource8AS_FIXEDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_GR_GRB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_LS_LSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_MINUSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_THROWB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_UNIONB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_USINGB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_WHEREB5cxx11E@Base 3.0 + _ZN6astyle10ASResource8AS_WHILEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_ASSIGNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_BAR_ELB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_BAR_IFB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_BIT_ORB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_DELETEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_EXTERNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_LAMBDAB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_MODULEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_MS_ASMB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_PUBLICB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_REMOVEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_RETURNB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_SEALEDB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_STATICB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_STRUCTB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_SWITCHB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_THROWSB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS_UNSAFEB5cxx11E@Base 3.0 + _ZN6astyle10ASResource9AS__ASM__B5cxx11E@Base 3.0 + _ZN6astyle10sortOnNameEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_@Base 3.0 + _ZN6astyle11ASFormatter10appendCharEcb@Base 3.0 + _ZN6astyle11ASFormatter11formatRunInEv@Base 3.0 + _ZN6astyle11ASFormatter11getNextCharEv@Base 3.0 + _ZN6astyle11ASFormatter11getNextLineEb@Base 3.0 + _ZN6astyle11ASFormatter11initNewLineEv@Base 3.0 + _ZN6astyle11ASFormatter12getBraceTypeEv@Base 3.0 + _ZN6astyle11ASFormatter12padOperatorsEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle11ASFormatter13initContainerERPSt6vectorINS_9BraceTypeESaIS2_EES5_@Base 3.0 + _ZN6astyle11ASFormatter14adjustCommentsEv@Base 3.0 + _ZN6astyle11ASFormatter14appendOperatorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb@Base 3.0 + _ZN6astyle11ASFormatter14appendSequenceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb@Base 3.0 + _ZN6astyle11ASFormatter14appendSpacePadEv@Base 3.0 + _ZN6astyle11ASFormatter14setAttachClassEb@Base 3.0 + _ZN6astyle11ASFormatter15deleteContainerERPSt6vectorINS_9BraceTypeESaIS2_EE@Base 3.0 + _ZN6astyle11ASFormatter15formatQuoteBodyEv@Base 3.0 + _ZN6astyle11ASFormatter15setAttachInlineEb@Base 3.0 + _ZN6astyle11ASFormatter16adjustChecksumInEi@Base 3.0 + _ZN6astyle11ASFormatter16appendSpaceAfterEv@Base 3.0 + _ZN6astyle11ASFormatter16formatArrayRunInEv@Base 3.0 + _ZN6astyle11ASFormatter16padObjCParamTypeEv@Base 3.0 + _ZN6astyle11ASFormatter16setAddBracesModeEb@Base 3.0 + _ZN6astyle11ASFormatter16setAttachExternCEb@Base 3.0 + _ZN6astyle11ASFormatter16setLineEndFormatENS_13LineEndFormatE@Base 3.0 + _ZN6astyle11ASFormatter16setMaxCodeLengthEi@Base 3.0 + _ZN6astyle11ASFormatter17computeChecksumInERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle11ASFormatter17formatArrayBracesENS_9BraceTypeEb@Base 3.0 + _ZN6astyle11ASFormatter17formatCommentBodyEv@Base 3.0 + _ZN6astyle11ASFormatter17formatQuoteOpenerEv@Base 3.0 + _ZN6astyle11ASFormatter17padObjCReturnTypeEv@Base 3.0 + _ZN6astyle11ASFormatter17setBreakAfterModeEb@Base 3.0 + _ZN6astyle11ASFormatter18computeChecksumOutERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle11ASFormatter18convertTabToSpacesEv@Base 3.0 + _ZN6astyle11ASFormatter18formatClosingBraceENS_9BraceTypeE@Base 3.0 + _ZN6astyle11ASFormatter18formatOpeningBraceENS_9BraceTypeE@Base 3.0 + _ZN6astyle11ASFormatter18padObjCMethodColonEv@Base 3.0 + _ZN6astyle11ASFormatter18setAddBracketsModeEb@Base 3.0 + _ZN6astyle11ASFormatter18setAttachNamespaceEb@Base 3.0 + _ZN6astyle11ASFormatter18setBraceFormatModeENS_9BraceModeE@Base 3.0 + _ZN6astyle11ASFormatter18setBreakBlocksModeEb@Base 3.0 + _ZN6astyle11ASFormatter18setFormattingStyleENS_11FormatStyleE@Base 3.0 + _ZN6astyle11ASFormatter18stripCommentPrefixEv@Base 3.0 + _ZN6astyle11ASFormatter19appendClosingHeaderEv@Base 3.0 + _ZN6astyle11ASFormatter19formatCommentCloserEv@Base 3.0 + _ZN6astyle11ASFormatter19formatCommentOpenerEv@Base 3.0 + _ZN6astyle11ASFormatter19padObjCMethodPrefixEv@Base 3.0 + _ZN6astyle11ASFormatter19processPreprocessorEv@Base 3.0 + _ZN6astyle11ASFormatter19resetEndOfStatementEv@Base 3.0 + _ZN6astyle11ASFormatter19setBreakElseIfsModeEb@Base 3.0 + _ZN6astyle11ASFormatter19setCommaPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter19setPointerAlignmentENS_12PointerAlignE@Base 3.0 + _ZN6astyle11ASFormatter19setRemoveBracesModeEb@Base 3.0 + _ZN6astyle11ASFormatter20addBracesToStatementEv@Base 3.0 + _ZN6astyle11ASFormatter20buildLanguageVectorsEv@Base 3.0 + _ZN6astyle11ASFormatter20trimContinuationLineEv@Base 3.0 + _ZN6astyle11ASFormatter21checkIfTemplateOpenerEv@Base 3.0 + _ZN6astyle11ASFormatter21formatLineCommentBodyEv@Base 3.0 + _ZN6astyle11ASFormatter21setAttachClosingWhileEb@Base 3.0 + _ZN6astyle11ASFormatter21setCloseTemplatesModeEb@Base 3.0 + _ZN6astyle11ASFormatter21setPreprocBlockIndentEb@Base 3.0 + _ZN6astyle11ASFormatter21setReferenceAlignmentENS_14ReferenceAlignE@Base 3.0 + _ZN6astyle11ASFormatter21setRemoveBracketsModeEb@Base 3.0 + _ZN6astyle11ASFormatter21setStripCommentPrefixEb@Base 3.0 + _ZN6astyle11ASFormatter22setOperatorPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter22setParensUnPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter23commentAndHeaderFollowsEv@Base 3.0 + _ZN6astyle11ASFormatter23formatLineCommentOpenerEv@Base 3.0 + _ZN6astyle11ASFormatter23setAddOneLineBracesModeEb@Base 3.0 + _ZN6astyle11ASFormatter23setDeleteEmptyLinesModeEb@Base 3.0 + _ZN6astyle11ASFormatter23setObjCColonPaddingModeENS_12ObjCColonPadE@Base 3.0 + _ZN6astyle11ASFormatter23setParamTypePaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter24appendCharInsideCommentsEv@Base 3.0 + _ZN6astyle11ASFormatter24formatPointerOrReferenceEv@Base 3.0 + _ZN6astyle11ASFormatter24isOkToSplitFormattedLineEv@Base 3.0 + _ZN6astyle11ASFormatter24setReturnTypePaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter25removeBracesFromStatementEv@Base 3.0 + _ZN6astyle11ASFormatter25setAddOneLineBracketsModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setAttachClosingBraceModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setBreakOneLineBlocksModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setIndentCol1CommentsModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setParamTypeUnPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setParensFirstPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter25setTabSpaceConversionModeEb@Base 3.0 + _ZN6astyle11ASFormatter26fixOptionVariableConflictsEv@Base 3.0 + _ZN6astyle11ASFormatter26setBreakOneLineHeadersModeEb@Base 3.0 + _ZN6astyle11ASFormatter26setMethodPrefixPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter26setParensHeaderPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter26setParensInsidePaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter26setReturnTypeUnPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter27setParensOutsidePaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter28formatPointerOrReferenceCastEv@Base 3.0 + _ZN6astyle11ASFormatter28getNextLineCommentAdjustmentEv@Base 3.0 + _ZN6astyle11ASFormatter28setMethodPrefixUnPaddingModeEb@Base 3.0 + _ZN6astyle11ASFormatter29clearFormattedLineSplitPointsEv@Base 3.0 + (arch-bits=32)_ZN6astyle11ASFormatter29isIndentablePreprocessorBlockERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZN6astyle11ASFormatter29isIndentablePreprocessorBlockERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZN6astyle11ASFormatter29setBreakOneLineStatementsModeEb@Base 3.0 + _ZN6astyle11ASFormatter30formatPointerOrReferenceToNameEv@Base 3.0 + _ZN6astyle11ASFormatter30formatPointerOrReferenceToTypeEv@Base 3.0 + _ZN6astyle11ASFormatter30isLineBreakBeforeClosingHeaderEv@Base 3.0 + _ZN6astyle11ASFormatter30updateFormattedLineSplitPointsEc@Base 3.0 + _ZN6astyle11ASFormatter31getCurrentLineCommentAdjustmentEv@Base 3.0 + _ZN6astyle11ASFormatter31setBreakClosingHeaderBlocksModeEb@Base 3.0 + _ZN6astyle11ASFormatter31setBreakClosingHeaderBracesModeEb@Base 3.0 + _ZN6astyle11ASFormatter31testForTimeToSplitFormattedLineEv@Base 3.0 + _ZN6astyle11ASFormatter32formatPointerOrReferenceToMiddleEv@Base 3.0 + _ZN6astyle11ASFormatter33setBreakClosingHeaderBracketsModeEb@Base 3.0 + _ZN6astyle11ASFormatter38updateFormattedLineSplitPointsOperatorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + (arch-bits=32)_ZN6astyle11ASFormatter48updateFormattedLineSplitPointsPointerOrReferenceEj@Base 3.0 + (arch-bits=64)_ZN6astyle11ASFormatter48updateFormattedLineSplitPointsPointerOrReferenceEm@Base 3.0 + _ZN6astyle11ASFormatter4initEPNS_16ASSourceIteratorE@Base 3.0 + _ZN6astyle11ASFormatter8nextLineB5cxx11Ev@Base 3.0 + _ZN6astyle11ASFormatter9breakLineEb@Base 3.0 + _ZN6astyle11ASFormatter9goForwardEi@Base 3.0 + _ZN6astyle11ASFormatter9padParensEv@Base 3.0 + _ZN6astyle11ASFormatterC1Ev@Base 3.0 + _ZN6astyle11ASFormatterC2Ev@Base 3.0 + _ZN6astyle11ASFormatterD0Ev@Base 3.0 + _ZN6astyle11ASFormatterD1Ev@Base 3.0 + _ZN6astyle11ASFormatterD2Ev@Base 3.0 + _ZN6astyle12ASBeautifier11initVectorsEv@Base 3.0 + _ZN6astyle12ASBeautifier12setJavaStyleEv@Base 3.0 + _ZN6astyle12ASBeautifier13setCaseIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier13setSharpStyleEv@Base 3.0 + _ZN6astyle12ASBeautifier14setBlockIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier14setBraceIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier14setClassIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier14setLabelIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier15setSwitchIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier16parseCurrentLineERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle12ASBeautifier16setEmptyLineFillEb@Base 3.0 + _ZN6astyle12ASBeautifier17setBraceIndentVtkEb@Base 3.0 + _ZN6astyle12ASBeautifier17setModifierIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier17setTabIndentationEib@Base 3.0 + _ZN6astyle12ASBeautifier18setModeManuallySetEb@Base 3.0 + _ZN6astyle12ASBeautifier18setNamespaceIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier19processPreprocessorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 3.0 + _ZN6astyle12ASBeautifier19setAfterParenIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier19setAlignMethodColonEb@Base 3.0 + _ZN6astyle12ASBeautifier19setDefaultTabLengthEv@Base 3.0 + _ZN6astyle12ASBeautifier19setSpaceIndentationEi@Base 3.0 + _ZN6astyle12ASBeautifier22setPreprocDefineIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier23deleteBeautifierVectorsEv@Base 3.0 + _ZN6astyle12ASBeautifier23initTempStacksContainerERPSt6vectorIPS1_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EESaISC_EESF_@Base 3.0 + _ZN6astyle12ASBeautifier23setForceTabXIndentationEi@Base 3.0 + _ZN6astyle12ASBeautifier25computePreprocessorIndentEv@Base 3.0 + _ZN6astyle12ASBeautifier25deleteBeautifierContainerERPSt6vectorIPS0_SaIS2_EE@Base 3.0 + _ZN6astyle12ASBeautifier25deleteTempStacksContainerERPSt6vectorIPS1_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EESaISC_EE@Base 3.0 + _ZN6astyle12ASBeautifier25popLastContinuationIndentEv@Base 3.0 + _ZN6astyle12ASBeautifier26registerContinuationIndentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiiiib@Base 3.0 + _ZN6astyle12ASBeautifier26setContinuationIndentationEi@Base 3.0 + (arch-bits=32)_ZN6astyle12ASBeautifier27adjustParsedLineIndentationEjb@Base 3.0 + (arch-bits=64)_ZN6astyle12ASBeautifier27adjustParsedLineIndentationEmb@Base 3.0 + _ZN6astyle12ASBeautifier27setPreprocConditionalIndentEb@Base 3.0 + _ZN6astyle12ASBeautifier29computePreliminaryIndentationEv@Base 3.0 + _ZN6astyle12ASBeautifier29setMaxInStatementIndentLengthEi@Base 3.0 + _ZN6astyle12ASBeautifier29setMinConditionalIndentLengthEv@Base 3.0 + _ZN6astyle12ASBeautifier29setMinConditionalIndentOptionEi@Base 3.0 + _ZN6astyle12ASBeautifier30setMaxContinuationIndentLengthEi@Base 3.0 + _ZN6astyle12ASBeautifier31adjustObjCMethodCallIndentationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle12ASBeautifier31registerContinuationIndentColonERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii@Base 3.0 + _ZN6astyle12ASBeautifier34clearObjCMethodDefinitionAlignmentEv@Base 3.0 + _ZN6astyle12ASBeautifier35isInPreprocessorUnterminatedCommentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle12ASBeautifier37adjustObjCMethodDefinitionIndentationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle12ASBeautifier4initEPNS_16ASSourceIteratorE@Base 3.0 + _ZN6astyle12ASBeautifier8beautifyERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZN6astyle12ASBeautifier9setCStyleEv@Base 3.0 + _ZN6astyle12ASBeautifierC1ERKS0_@Base 3.0 + _ZN6astyle12ASBeautifierC1Ev@Base 3.0 + _ZN6astyle12ASBeautifierC2ERKS0_@Base 3.0 + _ZN6astyle12ASBeautifierC2Ev@Base 3.0 + _ZN6astyle12ASBeautifierD0Ev@Base 3.0 + _ZN6astyle12ASBeautifierD1Ev@Base 3.0 + _ZN6astyle12ASBeautifierD2Ev@Base 3.0 + _ZN6astyle12sortOnLengthEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE12peekNextLineB5cxx11Ev@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE12peekNextLineEv@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE5tellgEv@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE8nextLineB5cxx11Eb@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE8nextLineEb@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE9peekResetEv@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEED0Ev@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEED1Ev@Base 3.0 + _ZN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEED2Ev@Base 3.0 + _ZN6astyle9ASLibrary20tempMemoryAllocationEm@Base 3.0 + _ZN6astyle9ASLibraryD0Ev@Base 3.0 + _ZN6astyle9ASLibraryD1Ev@Base 3.0 + _ZN6astyle9ASLibraryD2Ev@Base 3.0 + _ZN6astyle9ASOptions11parseOptionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 3.0 + _ZN6astyle9ASOptions12parseOptionsERSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EERKS7_@Base 3.0 + _ZN6astyle9ASOptions13importOptionsERSiRSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EE@Base 3.0 + _ZN6astyle9ASOptions13isOptionErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 3.0 + _ZN6astyle9ASOptions13isParamOptionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKc@Base 3.0 + _ZN6astyle9ASOptions13isParamOptionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcSA_@Base 3.0 + _ZN6astyle9ASOptions8getParamERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKc@Base 3.0 + _ZN6astyle9ASOptions8getParamERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcSA_@Base 3.0 + _ZN6astyle9ASOptions8isOptionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKc@Base 3.0 + _ZN6astyle9ASOptions8isOptionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcSA_@Base 3.0 + _ZN6astyle9ASOptionsC1ERNS_11ASFormatterE@Base 3.0 + _ZN6astyle9ASOptionsC2ERNS_11ASFormatterE@Base 3.0 + _ZN6astyle9g_versionE@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEncoding11utf16ToUtf8EPcjbbS1_@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEncoding11utf16ToUtf8EPcmbbS1_@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEncoding11utf8ToUtf16EPcjbS1_@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEncoding11utf8ToUtf16EPcmbS1_@Base 3.0 + _ZNK6astyle10ASEncoding12getBigEndianEv@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEncoding19utf16LengthFromUtf8EPKcj@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEncoding19utf16LengthFromUtf8EPKcm@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEncoding19utf8LengthFromUtf16EPKcjb@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEncoding19utf8LengthFromUtf16EPKcmb@Base 3.0 + _ZNK6astyle10ASEncoding8utf16lenEPKt@Base 3.0 + _ZNK6astyle10ASEncoding9swap16bitEi@Base 3.0 + _ZNK6astyle10ASEnhancer10indentLineERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle10ASEnhancer12unindentLineERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEnhancer13findCaseColonERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEnhancer13findCaseColonERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle10ASEnhancer21isOneLineBlockReachedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEnhancer22isEndDeclareSectionSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEnhancer22isEndDeclareSectionSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + (arch-bits=32)_ZNK6astyle10ASEnhancer24isBeginDeclareSectionSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle10ASEnhancer24isBeginDeclareSectionSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle10ASEnhancer28convertSpaceIndentToForceTabERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle10ASEnhancer29convertForceTabIndentToSpacesERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter11isBraceTypeENS_9BraceTypeES1_@Base 3.0 + _ZNK6astyle11ASFormatter11isEmptyLineERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter12findNextCharERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEci@Base 3.0 + _ZNK6astyle11ASFormatter12hasMoreLinesEv@Base 3.0 + _ZNK6astyle11ASFormatter12isInExponentEv@Base 3.0 + _ZNK6astyle11ASFormatter12peekNextCharEv@Base 3.0 + _ZNK6astyle11ASFormatter12peekNextTextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbSt10shared_ptrINS_12ASPeekStreamEE@Base 3.0 + _ZNK6astyle11ASFormatter13getChecksumInEv@Base 3.0 + _ZNK6astyle11ASFormatter14getChecksumOutEv@Base 3.0 + _ZNK6astyle11ASFormatter14getIsLineReadyEv@Base 3.0 + _ZNK6astyle11ASFormatter15getChecksumDiffEv@Base 3.0 + _ZNK6astyle11ASFormatter15getPreviousWordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle11ASFormatter15isArrayOperatorEv@Base 3.0 + _ZNK6astyle11ASFormatter15isBeforeCommentEv@Base 3.0 + _ZNK6astyle11ASFormatter15isClosingHeaderEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter15isUnaryOperatorEv@Base 3.0 + _ZNK6astyle11ASFormatter16getLineEndFormatEv@Base 3.0 + _ZNK6astyle11ASFormatter16isOkToBreakBlockENS_9BraceTypeE@Base 3.0 + _ZNK6astyle11ASFormatter18isBeforeAnyCommentEv@Base 3.0 + _ZNK6astyle11ASFormatter18isClassInitializerEv@Base 3.0 + _ZNK6astyle11ASFormatter19isInSwitchStatementEv@Base 3.0 + _ZNK6astyle11ASFormatter20getFollowingOperatorB5cxx11Ev@Base 3.0 + _ZNK6astyle11ASFormatter20getFormatterFileTypeEv@Base 3.0 + _ZNK6astyle11ASFormatter20isCurrentBraceBrokenEv@Base 3.0 + _ZNK6astyle11ASFormatter20isMultiStatementLineEv@Base 3.0 + _ZNK6astyle11ASFormatter20isPointerOrReferenceEv@Base 3.0 + _ZNK6astyle11ASFormatter20pointerSymbolFollowsEv@Base 3.0 + _ZNK6astyle11ASFormatter21isImmediatelyPostCastEv@Base 3.0 + _ZNK6astyle11ASFormatter21isOneLineBlockReachedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle11ASFormatter21isSharpStyleWithParenEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter22findObjCColonAlignmentEv@Base 3.0 + _ZNK6astyle11ASFormatter22isNDefPreprocStatementERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 3.0 + _ZNK6astyle11ASFormatter22isNextCharOpeningBraceEi@Base 3.0 + (arch-bits=32)_ZNK6astyle11ASFormatter22isStructAccessModifiedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle11ASFormatter22isStructAccessModifiedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle11ASFormatter24isDereferenceOrAddressOfEv@Base 3.0 + _ZNK6astyle11ASFormatter25isBeforeAnyLineEndCommentEi@Base 3.0 + _ZNK6astyle11ASFormatter25isOperatorPaddingDisabledEv@Base 3.0 + _ZNK6astyle11ASFormatter25isUniformInitializerBraceEv@Base 3.0 + _ZNK6astyle11ASFormatter26isNonInStatementArrayBraceEv@Base 3.0 + _ZNK6astyle11ASFormatter27findFormattedLineSplitPointEv@Base 3.0 + _ZNK6astyle11ASFormatter28isPointerOrReferenceCenteredEv@Base 3.0 + _ZNK6astyle11ASFormatter28isPointerOrReferenceVariableERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter29isNextWordSharpNonParenHeaderEi@Base 3.0 + _ZNK6astyle11ASFormatter30checkForHeaderFollowingCommentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle11ASFormatter31isBeforeMultipleLineEndCommentsEi@Base 3.0 + (arch-bits=32)_ZNK6astyle11ASFormatter9isExecSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle11ASFormatter9isExecSQLERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle11ASFormatter9isExternCEv@Base 3.0 + _ZNK6astyle12ASBeautifier11getFileTypeEv@Base 3.0 + (arch-bits=32)_ZNK6astyle12ASBeautifier11getNextWordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle12ASBeautifier11getNextWordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle12ASBeautifier12getTabLengthEv@Base 3.0 + _ZNK6astyle12ASBeautifier13getCaseIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier14copyTempStacksB5cxx11ERKS0_@Base 3.0 + _ZNK6astyle12ASBeautifier14getBlockIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier14getBraceIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier14getClassIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier15getIndentLengthEv@Base 3.0 + _ZNK6astyle12ASBeautifier15getIndentStringB5cxx11Ev@Base 3.0 + _ZNK6astyle12ASBeautifier15getSwitchIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier16getEmptyLineFillEv@Base 3.0 + _ZNK6astyle12ASBeautifier16isLineEndCommentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle12ASBeautifier17getModifierIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier18convertTabToSpacesEii@Base 3.0 + _ZNK6astyle12ASBeautifier18getModeManuallySetEv@Base 3.0 + _ZNK6astyle12ASBeautifier18getNamespaceIndentEv@Base 3.0 + _ZNK6astyle12ASBeautifier19getAlignMethodColonEv@Base 3.0 + _ZNK6astyle12ASBeautifier21getBeautifierFileTypeEv@Base 3.0 + _ZNK6astyle12ASBeautifier21getIndentedLineReturnERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 3.0 + _ZNK6astyle12ASBeautifier22getForceTabIndentationEv@Base 3.0 + _ZNK6astyle12ASBeautifier22getPreprocDefineIndentEv@Base 3.0 + (arch-bits=32)_ZNK6astyle12ASBeautifier22isIndentedPreprocessorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle12ASBeautifier22isIndentedPreprocessorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle12ASBeautifier22statementEndsWithCommaERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle12ASBeautifier23getObjCFollowingKeywordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + _ZNK6astyle12ASBeautifier25computeObjCColonAlignmentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle12ASBeautifier26getContinuationIndentCommaERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle12ASBeautifier26getContinuationIndentCommaERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle12ASBeautifier26getIndentedSpaceEquivalentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle12ASBeautifier26getNextProgramCharDistanceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle12ASBeautifier27getContinuationIndentAssignERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle12ASBeautifier27getContinuationIndentAssignERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle12ASBeautifier28extractPreprocessorStatementERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle12ASBeautifier34isPreprocessorConditionalCplusplusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle12ASBeautifier39adjustIndentCountForBreakElseIfCommentsEv@Base 3.0 + _ZNK6astyle12ASBeautifier4trimERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle12ASBeautifier5rtrimERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 3.0 + _ZNK6astyle12ASBeautifier7indexOfERKSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EES9_@Base 3.0 + _ZNK6astyle12ASBeautifier9preLineWSB5cxx11Eii@Base 3.0 + _ZNK6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE12hasMoreLinesEv@Base 3.0 + _ZNK6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEE15getStreamLengthEv@Base 3.0 + _ZNK6astyle6ASBase10findHeaderERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPKSt6vectorIPS7_SaISA_EE@Base 3.0 + _ZNK6astyle6ASBase11findKeywordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_@Base 3.0 + _ZNK6astyle6ASBase12findOperatorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPKSt6vectorIPS7_SaISA_EE@Base 3.0 + _ZNK6astyle6ASBase12peekNextCharERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle6ASBase14getCurrentWordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle6ASBase14getCurrentWordERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle6ASBase15isLegalNameCharEc@Base 3.0 + _ZNK6astyle6ASBase16isDigitSeparatorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi@Base 3.0 + (arch-bits=32)_ZNK6astyle6ASBase21isCharPotentialHeaderERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj@Base 3.0 + (arch-bits=64)_ZNK6astyle6ASBase21isCharPotentialHeaderERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm@Base 3.0 + _ZNK6astyle6ASBase23isCharPotentialOperatorEc@Base 3.0 + _ZNK6astyle6ASBase7isDigitEc@Base 3.0 + _ZNK6astyle9ASLibrary11formatUtf16EPKtS2_PFviPKcEPFPcmE@Base 3.0 + _ZNK6astyle9ASLibrary18convertUtf16ToUtf8EPKt@Base 3.0 + _ZNK6astyle9ASLibrary18convertUtf8ToUtf16EPKcPFPcmE@Base 3.0 + _ZNK6astyle9ASOptions15getOptionErrorsB5cxx11Ev@Base 3.0 + _ZNKSt5ctypeIcE8do_widenEc@Base 0debian2.06 + (arch=!armel)_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EE10_M_destroyEv@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EE10_M_disposeEv@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EE14_M_get_deleterERKSt9type_info@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EED0Ev@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EED1Ev@Base 3.0 + (arch=!armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EED2Ev@Base 3.0 + (arch=armel)_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE1EE10_M_releaseEv@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EE10_M_destroyEv@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EE10_M_disposeEv@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EE14_M_get_deleterERKSt9type_info@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EED0Ev@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EED1Ev@Base 3.0 + (arch=armel)_ZNSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EED2Ev@Base 3.0 + (optional)_ZNSt6vectorIN6astyle10ASEnhancer15SwitchVariablesESaIS2_EE17_M_realloc_insertIJRS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Base 3.0 + _ZNSt6vectorIN6astyle9BraceTypeESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Base 3.0 + _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Base 3.0 + _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE12emplace_backIJRS7_EEEvDpOT_@Base 3.0 + _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE12emplace_backIJS7_EEEvDpOT_@Base 0debian2.06 + _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE17_M_realloc_insertIJRS7_EEEvN9__gnu_cxx17__normal_iteratorIPS7_S9_EEDpOT_@Base 3.0 + (optional)_ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE17_M_realloc_insertIJS7_EEEvN9__gnu_cxx17__normal_iteratorIPS7_S9_EEDpOT_@Base 3.0 + (arch-bits=32)_ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE7reserveEj@Base 3.0 + (arch-bits=64|optional)_ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE7reserveEm@Base 3.0 + _ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEaSERKS9_@Base 0debian2.06 + (optional)_ZNSt6vectorIPKSt4pairIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Base 3.0 + (optional)_ZNSt6vectorIPN6astyle12ASBeautifierESaIS2_EE12emplace_backIJRS2_EEEvDpOT_@Base 3.0 + (optional)_ZNSt6vectorIPN6astyle12ASBeautifierESaIS2_EE12emplace_backIJS2_EEEvDpOT_@Base 3.0 + _ZNSt6vectorIPN6astyle12ASBeautifierESaIS2_EE17_M_realloc_insertIJRS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Base 3.0 + (optional)_ZNSt6vectorIPS_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EESaISA_EE12emplace_backIJSA_EEEvDpOT_@Base 0debian2.06 + _ZNSt6vectorIPS_IPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Base 3.0 + (optional)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJRS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Base 3.0 + _ZNSt6vectorISt4pairIiiESaIS1_EEaSERKS3_@Base 0debian2.06 + _ZNSt6vectorIbSaIbEE13_M_insert_auxESt13_Bit_iteratorb@Base 0debian2.06 + _ZNSt6vectorIiSaIiEE12emplace_backIJRiEEEvDpOT_@Base 3.0 + _ZNSt6vectorIiSaIiEE12emplace_backIJiEEEvDpOT_@Base 0debian2.06 + _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Base 3.0 + _ZNSt6vectorIiSaIiEEaSERKS1_@Base 0debian2.06 + (arch-bits=32)_ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEEiS9_NS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_T0_SL_T1_T2_@Base 3.0 + (arch-bits=64)_ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEElS9_NS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_T0_SL_T1_T2_@Base 3.0 + (optional)_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEENS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_SK_T0_@Base 3.0 + (arch-bits=32)_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEEiNS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_SK_T0_T1_@Base 3.0 + (arch-bits=64)_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEElNS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_SK_T0_T1_@Base 3.0 + (optional)_ZSt22__final_insertion_sortIN9__gnu_cxx17__normal_iteratorIPPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS9_SaIS9_EEEENS0_5__ops15_Iter_comp_iterIPFbS9_S9_EEEEvT_SK_T0_@Base 3.0 + _ZSteqIcEN9__gnu_cxx11__enable_ifIXsrSt9__is_charIT_E7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS3_St11char_traitsIS3_ESaIS3_EEESE_@Base 0debian2.06 + (optional)_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEOS8_RKS8_@Base 0debian2.06 + _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_@Base 0debian2.06 + _ZTVN6astyle10ASEnhancerE@Base 3.0 + _ZTVN6astyle11ASFormatterE@Base 3.0 + _ZTVN6astyle12ASBeautifierE@Base 3.0 + _ZTVN6astyle16ASStreamIteratorINSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEEE@Base 3.0 + _ZTVN6astyle9ASLibraryE@Base 3.0 + (arch=!armel)_ZTVSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE2EE8_DeleterISaIS1_EEES8_LS5_2EE@Base 3.0 + (arch=armel)_ZTVSt19_Sp_counted_deleterIPN6astyle12ASPeekStreamENSt12__shared_ptrIS1_LN9__gnu_cxx12_Lock_policyE1EE8_DeleterISaIS1_EEES8_LS5_1EE@Base 3.0 diff -Nru astyle-2.06/debian/libastyle-dev.links astyle-3.0.1/debian/libastyle-dev.links --- astyle-2.06/debian/libastyle-dev.links 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/libastyle-dev.links 2017-09-08 15:45:58.000000000 +0000 @@ -1,2 +1,2 @@ -#! /usr/bin/dh-exec --with-scripts=subst-multiarch -usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so.0debian2.06 usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so +#!/usr/bin/dh-exec +usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so.3 usr/lib/${DEB_HOST_MULTIARCH}/libastyle.so diff -Nru astyle-2.06/debian/libastylej-jni.install astyle-3.0.1/debian/libastylej-jni.install --- astyle-2.06/debian/libastylej-jni.install 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/libastylej-jni.install 2017-09-08 15:45:58.000000000 +0000 @@ -1,2 +1,2 @@ -#! /usr/bin/dh-exec -build/gcc/bin/libastyle-2.06j.so usr/lib/jni/${DEB_HOST_MULTIARCH} +#!/usr/bin/dh-exec +build/gcc/bin/libastylej.so.*.*.* usr/lib/jni/${DEB_HOST_MULTIARCH} diff -Nru astyle-2.06/debian/libastylej-jni.links astyle-3.0.1/debian/libastylej-jni.links --- astyle-2.06/debian/libastylej-jni.links 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/libastylej-jni.links 2017-09-08 15:45:58.000000000 +0000 @@ -1,2 +1,2 @@ -#! /usr/bin/dh-exec --with-scripts=subst-multiarch -usr/lib/jni/${DEB_HOST_MULTIARCH}/libastyle-2.06j.so usr/lib/jni/${DEB_HOST_MULTIARCH}/libastylej.so +#!/usr/bin/dh-exec +usr/lib/jni/${DEB_HOST_MULTIARCH}/libastylej.so.3.0.1 usr/lib/jni/${DEB_HOST_MULTIARCH}/libastylej.so diff -Nru astyle-2.06/debian/patches/hardening.patch astyle-3.0.1/debian/patches/hardening.patch --- astyle-2.06/debian/patches/hardening.patch 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/patches/hardening.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -Description: Hardening: build ELF executable with PIE -Author: Matteo Cypriani -Forwarded: https://sourceforge.net/p/astyle/bugs/412/ -Last-Update: 2017-01-13 ---- a/build/gcc/Makefile -+++ b/build/gcc/Makefile -@@ -50,20 +50,25 @@ - CFLAGSr = -DNDEBUG -O3 $(CBASEFLAGS) - CFLAGSd = -g $(CBASEFLAGS) - endif --CFLAGSs = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSr) -+CFLAGSs := -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSr) - CFLAGSsd = -DASTYLE_LIB -fPIC -fvisibility=hidden $(CFLAGSd) - CFLAGSa = -DASTYLE_LIB $(CFLAGSr) - CFLAGSad = -DASTYLE_LIB $(CFLAGSd) --CFLAGSsj = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSr) $(JAVAINCS) -+CFLAGSsj := -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSr) $(JAVAINCS) - CFLAGSsjd = -DASTYLE_JNI -fPIC -fvisibility=hidden $(CFLAGSd) $(JAVAINCS) -+CFLAGSr += -fPIE - - # define link options - ifdef LDFLAGS -- LDFLAGSr = $(LDFLAGS) -+ LDFLAGSr = $(LDFLAGS) -pie - LDFLAGSd = $(LDFLAGS) -+ LDFLAGSsr = $(LDFLAGS) -+ LDFLAGSsd = $(LDFLAGS) - else - LDFLAGSr = -s - LDFLAGSd = -+ LDFLAGSsr = -+ LDFLAGSsd = - endif - - # object files are built from the source list $(SRC) -@@ -138,7 +143,7 @@ - shared: libastyle.so - libastyle.so: $(OBJs) - @ mkdir -p $(bindir) -- $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastyle.so.$(SOLIBVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ -+ $(CXX) -shared $(LDFLAGSsr) -Wl,-soname,libastyle.so.$(SOLIBVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ - @ echo - - shareddebug: libastyled.so -@@ -162,7 +167,7 @@ - java: libastylej.so - libastylej.so: $(OBJsj) - @ mkdir -p $(bindir) -- $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^ -+ $(CXX) -shared $(LDFLAGSsr) -o $(bindir)/libastyle-2.06j.so $^ - @ echo - - javadebug: libastylejd.so diff -Nru astyle-2.06/debian/patches/privacy.patch astyle-3.0.1/debian/patches/privacy.patch --- astyle-2.06/debian/patches/privacy.patch 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/patches/privacy.patch 2017-09-08 15:45:58.000000000 +0000 @@ -1,10 +1,10 @@ Description: Remove SourceForge logo privacy breach Author: Matteo Cypriani Forwarded: not-needed -Last-Update: 2017-01-13 +Last-Update: 2017-04-13 --- a/doc/astyle.html +++ b/doc/astyle.html -@@ -2271,7 +2271,7 @@ +@@ -2346,7 +2346,7 @@

@@ -15,7 +15,7 @@

--- a/doc/install.html +++ b/doc/install.html -@@ -369,7 +369,7 @@ +@@ -431,7 +431,7 @@

@@ -26,7 +26,7 @@

--- a/doc/news.html +++ b/doc/news.html -@@ -474,7 +474,7 @@ +@@ -649,7 +649,7 @@

@@ -37,7 +37,7 @@  

--- a/doc/notes.html +++ b/doc/notes.html -@@ -298,7 +298,7 @@ +@@ -334,7 +334,7 @@

diff -Nru astyle-2.06/debian/patches/series astyle-3.0.1/debian/patches/series --- astyle-2.06/debian/patches/series 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/patches/series 2017-09-08 15:45:58.000000000 +0000 @@ -1,3 +1 @@ -set_soname.patch privacy.patch -hardening.patch diff -Nru astyle-2.06/debian/patches/set_soname.patch astyle-3.0.1/debian/patches/set_soname.patch --- astyle-2.06/debian/patches/set_soname.patch 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/patches/set_soname.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Description: set the library soname -Author: Scott Howard -Forwarded: https://sourceforge.net/p/astyle/bugs/416/ -Last-Update: 2017-01-13 ---- a/build/gcc/Makefile -+++ b/build/gcc/Makefile -@@ -134,10 +134,11 @@ - $(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^ - @ echo - -+SOLIBVER = 0debian2.06 - shared: libastyle.so - libastyle.so: $(OBJs) - @ mkdir -p $(bindir) -- $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^ -+ $(CXX) -shared $(LDFLAGSr) -Wl,-soname,libastyle.so.$(SOLIBVER) -o $(bindir)/libastyle.so.$(SOLIBVER) $^ - @ echo - - shareddebug: libastyled.so diff -Nru astyle-2.06/debian/rules astyle-3.0.1/debian/rules --- astyle-2.06/debian/rules 2017-01-20 15:27:16.000000000 +0000 +++ astyle-3.0.1/debian/rules 2017-09-08 15:45:58.000000000 +0000 @@ -4,20 +4,17 @@ #export DH_VERBOSE=1 #export DH_OPTIONS=-v -# Enable BINDNOW. PIE is handled through hardening.patch for now. -export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow - +export DEB_BUILD_MAINT_OPTIONS = hardening=+all DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/buildflags.mk -# Upstream build system uses CFLAGS only +# Upstream build system uses CFLAGS instead of CPPFLAGS and CXXFLAGS CFLAGS = $(CPPFLAGS) $(CXXFLAGS) # Avoid unneeded library dependencies LDFLAGS += -Wl,--as-needed JAVA_HOME = /usr/lib/jvm/default-java/ -DEB_UPSTREAM_VERSION = $(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^+]+).*-.*,\1,p') # Target for stripping / not stripping BUILD_TARGET = astyle diff -Nru astyle-2.06/doc/astyle.html astyle-3.0.1/doc/astyle.html --- astyle-2.06/doc/astyle.html 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/doc/astyle.html 2017-05-31 00:26:37.000000000 +0000 @@ -32,7 +32,7 @@ -

Artistic Style 2.06

+

Artistic Style 3.0

A Free, Fast, and Small Automatic Formatter
@@ -54,11 +54,11 @@

Disable Formatting

- Basic Bracket Styles

+ Basic Brace Styles

- Bracket Style Options

+ Brace Style Options

- default bracket style    + default brace style    style=allman    style=java    style=kr    @@ -73,7 +73,8 @@ style=google    style=mozilla    style=pico    - style=lisp   

+ style=lisp    +

Tab Options

@@ -81,14 +82,17 @@ indent=spaces    indent=tab    indent=force‑tab    - --indent=force‑tab‑x   

+ --indent=force‑tab‑x    +

- Bracket Modify Options

+ Brace Modify Options

attach‑namespaces    attach‑classes    attach‑inlines    - attach‑extern‑c   

+ attach‑extern‑c    + attach‑closing‑while    +

Indentation Options

@@ -97,6 +101,7 @@ indent‑switches    indent‑cases    indent‑namespaces    + indent‑after‑parens    indent‑continuation    indent‑labels    indent‑preproc‑block    @@ -104,7 +109,7 @@ indent‑preproc‑cond    indent‑col1‑comments    min‑conditional‑indent    - max‑instatement‑indent    + max‑continuation‑indent   

Padding Options

@@ -122,16 +127,17 @@ delete‑empty‑lines    fill‑empty‑lines    align‑pointer    - align‑reference   

+ align‑reference    +

Formatting Options

- break‑closing‑brackets    + break‑closing‑braces    break‑elseifs    break‑one‑line‑headers    - add‑brackets    - add‑one‑line‑brackets    - remove‑brackets    + add‑braces    + add‑one‑line‑braces    + remove‑braces    keep‑one‑line‑blocks    keep‑one‑line‑statements    convert‑tabs    @@ -139,7 +145,8 @@ remove‑comment‑prefix    max‑code‑length    break‑after‑logical    - mode   

+ mode    +

Objective‑C Options

@@ -150,7 +157,8 @@ pad‑param‑type    unpad‑param‑type    align‑method‑colon    - pad‑method‑colon   

+ pad‑method‑colon    +

Other Options   

@@ -165,7 +173,8 @@ verbose    formatted    quiet    - lineend   

+ lineend    +

Command Line Only

@@ -175,7 +184,10 @@ version    help    html    - html=   

+ html=    + stdin=    + stdout=    +

 


@@ -202,9 +214,8 @@

Artistic Style can process directories recursively. Wildcards (such as "*.cpp" or "*.c??") are processed internally. If a shell is used, it should pass the wildcards to Artistic Style instead of resolving them first. For Linux - use - double quotes around paths whose file name contains wildcards. For Windows use double quotes around paths whose - file name contains spaces. The recursive option in the + use double quotes around paths whose file name contains wildcards. For Windows use double quotes around paths + whose file name contains spaces. The recursive option in the Other Options section contains information on recursive processing.

File Names

@@ -214,7 +225,7 @@ is created with an .orig appended to the original file name. (This can be set to a different string by the option --suffix=, or suppressed altogether by the options -n or --suffix=none). Thus, after indenting SourceFile.cpp the indented file will - be named SourceFile.cpp, while the original pre-indented file will be renamed to + be named SourceFile.cpp, while the original pre-indented file will be renamed to SourceFile.cpp.orig.

Internationalization

@@ -242,17 +253,17 @@ The names of special characters used in programming vary by region. The terminology used by Artistic Style, followed by other common names, is:

- brackets { } ‑ also called braces, curly brackets, or curly braces.
- parens ( ) ‑ also called parentheses, brackets, round brackets, circle brackets, or soft brackets.
- block parens [ ] ‑ also called brackets, square brackets, closed brackets, or hard brackets.
+ braces or curly braces { } ‑ also called brackets, or curly brackets.
+ parens or round brackets ( ) ‑ also called parentheses, brackets, circle brackets, or soft brackets.
+ square brackets [ ] ‑ also called block parens, brackets, closed brackets, or hard brackets.
angle brackets < > ‑ also called brackets, pointy brackets, triangular brackets, diamond brackets, tuples, or chevrons.

- Visual Studio, and possibly other development environments, has an Edit option "Align Assignments" that will align - assignment operators across multiple lines. There is also an extension named "Code alignment" that will align - the code on other items as well. Formatting with these options and extensions can be used with Artistic Style. - The space padding will be maintained and the alignment will be preserved.

+ Visual Studio, and possibly other development environments, has extensions that will align assignment operators + across multiple lines. There is an extension named "Code alignment" that will align the code on other items as + well. Formatting with these options and extensions can be used with Artistic Style. The space padding will be + maintained and the alignment will be preserved.

Artistic Style can format standard class library statements such as Open GL, wxWidgets, Qt, and MFC.

@@ -266,15 +277,13 @@ Unicode files encoded as UTF‑16, both big and little endian, will be formatted. The files must begin with a byte order mark (BOM) to be recognized. Files encoded as UTF‑32 will be rejected. Some compilers do not support these encodings. These files can be converted to UTF‑8 encoding with the program "iconv". There - are Linux and Windows versions available (the Windows version does not seem to work for all encodings). A sample - command line is "iconv ‑f  UTF‑16 ‑t UTF‑8 < filein.cpp > fileout.cpp. Visual - Studio can convert the files from the "File > Advanced Save Options" menu. Then select encoding "Unicode (UTF‑8 - with signature) - Codepage 65001". There are other development environments and text editors, such as SciTE, that - can convert files to UTF‑8.

+ are Linux and Windows versions available (the Windows version does not seem to work for all encodings). Visual + Studio can convert the files from the "File > Advanced Save Options" menu. There are other development environments + and text editors, such as SciTE, that can convert files to UTF‑8.

Embedded statements that are multiple-line and are NOT in a C-type format, such as Python, are usually mal-formatted - (a C-type format has blocks enclosed by brackets and statements terminated by a semi-colon). Macros that define - functions may cause the following code to be mal-formatted because the macro is missing the brackets and semi-colons + (a C-type format has blocks enclosed by braces and statements terminated by a semi-colon). Macros that define + functions may cause the following code to be mal-formatted because the macro is missing the braces and semi-colons from the definition. If you have source code with these types of statements, exclude them with the exclude=#### option described in the Other Options section.

@@ -287,22 +296,21 @@

Quick Start

- If you have never used Artistic Style there are a - several of ways to start.

+ If you have never used Artistic Style, there are several of ways to get started.

- One is to run it with no options at all. This will use the default bracket - style, 4 spaces per indent, and no formatting changes. This will break the brackets for one + One is to run it with no options at all. This will use the default brace + style, 4 spaces per indent, and no formatting changes. This will break the braces for one line blocks and will break one line statements. To change this, use the option keep-one-line-blocks and/or keep-one-line-statements described in the Formatting Options section.

- Another way is to use one of the bracket styles described in the Bracket Style - Options section. Select one with a bracket formatting style you like. If no indentation option is set, + Another way is to use one of the brace styles described in the Brace Style + Options section. Select one with a brace formatting style you like. If no indentation option is set, the default option of 4 spaces will be used. These options also break one line blocks and one line statements as described above.

A third option is to use an options file from the "file" folder. If there is a coding style you want - to duplicate, input the appropriate options file. Use the option + to duplicate, input the appropriate options file. Use the option options=#### to specify the file to use. It must contain a path for the file, including the file name.

@@ -323,8 +331,8 @@

astyle  [OPTIONS]  SourceFile1  SourceFile2  SourceFile3  [ . . . ]

- The block parens [ ] indicate that more than one option or more than one file name can be entered. They are NOT - actually included in the command. For the options format refer to the following Options section.

+ The square brackets [ ] indicate that more than one option or more than one file name can be entered. They are + NOT actually included in the command. For the options format refer to the following Options section.

Example to format a single file:

@@ -337,9 +345,9 @@

The < and > characters may be used to redirect the files into standard input (stdin) and out of standard output - (stdout) - don't forget them! With this option only one file at a time can be formatted. Wildcards are not + (stdout) - don't forget them! With this option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages, and a backup is not created. On Windows the output will always have - Windows line ends.

+ Windows line ends. The options "stdin=" and "stdout=" can be used instead of redirection.

Example of redirection option to format a single file and change the name:

@@ -361,7 +369,7 @@

Options

- Not specifying any options will result in the default bracket style, + Not specifying any options will result in the default brace style, 4 spaces per indent, and no formatting changes.

Options may be written in two different ways.

@@ -465,9 +473,9 @@ padded incorrectly, then disabling the formatting may be necessary. To avoid having to use the "disable block" tags above, a single line disable is available.

- A line-end comment tag "*NOPAD* will disable the "pad-oper", "align-pointer", and "align-reference" - options. Parsing does NOT stop and all other formatting will be applied to the line. The tag applies to the - one line only.

+ A line-end comment tag "*NOPAD*" will disable the "pad-oper", "align-pointer", and + "align-reference" options. Parsing does NOT stop and all other formatting will be applied to the line. + The tag applies to the one line only.

The following prevents the operator padding from changing:

@@ -477,29 +485,29 @@  


- + -

Basic Bracket Styles

+

Basic Brace Styles

- There are three basic bracket styles.
- Attached – The brackets are attached to the end of + There are three basic brace styles.
+ Attached – The braces are attached to the end of the last line of the previous block. (Java).
- Broken – The brackets are broken from the previous + Broken – The braces are broken from the previous block. (Allman).
- Linux – The brackets are attached except for the opening bracket of a function, class, or namespace (K&R, + Linux – The braces are attached except for the opening brace of a function, class, or namespace (K&R, Linux).

- Other bracket styles are variations of these. Some will use variations on the placement of class, namespace, - or other brackets. (Stroustrup, Google, One True Brace, Lisp). Others will indent the brackets (Whitesmith, VTK, - Banner, GNU). Still others will use run-in brackets where the following statement is on the same line as the bracket - (Horstmann, Pico).

-

- There are technical arguments for selecting one style over another. But the usual reason comes down to - personal preference. Some like broken brackets with vertical whitespace that makes the code easy to read. - Others like attached brackets with code that is more compact. Sometimes programmers just want a change. It is - easier to select a preference if you can see an entire file formatted in a certain bracket style. With Artistic + Other brace styles are variations of these. Some will use variations on the placement of class, namespace, + or other braces. (Stroustrup, Google, One True Brace, Lisp). Others will indent the braces (Whitesmith, VTK, + Banner, and GNU). Still others will use run-in braces where the following statement is on the same line as the + brace (Horstmann and Pico).

+

+ There are technical arguments for selecting one style over another. But the usual reason comes down to + personal preference. Some like broken braces with vertical whitespace that makes the code easy to read. + Others like attached braces with code that is more compact. Sometimes programmers just want a change. It is + easier to select a preference if you can see an entire file formatted in a certain brace style. With Artistic Style you can easily modify source code to suit your preference.

@@ -508,28 +516,28 @@
- + -

Bracket Style Options

+

Brace Style Options

- Bracket Style options define the bracket style to use. All options default to 4 spaces per indent, indented with + Brace Style options define the brace style to use. All options default to 4 spaces per indent, indented with spaces. By default, none of the styles indent namespaces. Other indentations are indicated in the individual style - description. All options will break the brackets for one line blocks and will break one line statements. To change + description. All options will break the braces for one line blocks and will break one line statements. To change this, use the option keep-one-line-blocks and/or keep-one-line-statements described in the Formatting Options section.

 

-

- default bracket style
- If no bracket style is requested, the default bracket style will be used. The opening brackets are not changed - and the closing brackets will be broken from the preceding line. There are a few exceptions to this.

+

+ default brace style
+ If no brace style is requested, the default brace style will be used. The opening braces are not changed + and the closing braces will be broken from the preceding line. There are a few exceptions to this.

 

--style=allman / --style=bsd / --style=break / -A1
- Allman style uses broken brackets.

+ Allman style uses broken braces.

int Foo(bool isBar)
 {
@@ -547,7 +555,7 @@
          

--style=java / --style=attach / -A2
- Java style uses attached brackets.

+ Java style uses attached braces.

int Foo(bool isBar) {
     if (isBar) {
@@ -562,8 +570,8 @@
          

--style=kr / --style=k&r / --style=k/r / -A3
- Kernighan & Ritchie style uses linux brackets. Opening brackets are broken from namespaces, classes, and function - definitions. The brackets are attached to everything else, including arrays, structs, enums, and statements within + Kernighan & Ritchie style uses linux braces. Opening braces are broken from namespaces, classes, and function + definitions. The braces are attached to everything else, including arrays, structs, enums, and statements within a function.

Using the k&r option may cause problems because of the &. This can be resolved by enclosing the k&r @@ -584,10 +592,11 @@  

--style=stroustrup / -A4
- Stroustrup style uses linux brackets. Opening brackets are broken from function definitions only. - The brackets are attached to everything else, including namespaces, classes, arrays, structs, enums, - and statements within a function. This style frequently is used with headers broken from closing brackets - (break-closing-brackets) and an indent of 5 spaces.

+ Stroustrup style uses linux braces with closing headers broken from closing braces + (e.g. ‑‑break‑closing‑headers). Opening braces are broken from function definitions only. + The opening braces are attached to everything else, including namespaces, classes, arrays, structs, enums, and + statements within a function. This style frequently is used with "attach‑closing‑while", + tabbed indents, and an indent of 5 spaces per tab.

int Foo(bool isBar)
 {
@@ -604,7 +613,7 @@
          

--style=whitesmith / -A5
- Whitesmith style uses broken, indented brackets. Switch blocks and class blocks are indented to prevent a 'hanging + Whitesmith style uses broken, indented braces. Switch blocks and class blocks are indented to prevent a 'hanging indent' with the following case statements and C++ class modifiers (public, private, protected). 

int Foo(bool isBar)
@@ -623,8 +632,8 @@
          

--style=vtk / -A15
- VTK (Visualization Toolkit) style uses broken, indented brackets, except for the opening bracket. Switch blocks - are indented to prevent a 'hanging indent' with following case statements. 

+ VTK (Visualization Toolkit) style uses broken, indented braces, except for the opening brace. Switch blocks + are indented to prevent a 'hanging indent' with following case statements.

int Foo(bool isBar)
 {
@@ -642,7 +651,7 @@
          

--style=banner / -A6
- Banner style uses attached, indented brackets. Switch blocks and class blocks are indented to prevent a 'hanging + Banner style uses attached, indented braces. Switch blocks and class blocks are indented to prevent a 'hanging indent' with following case statements and C++ class modifiers (public, private, protected). 

int Foo(bool isBar) {
@@ -659,8 +668,8 @@
          

--style=gnu / -A7
- GNU style uses broken brackets and indented blocks. Extra indentation is added to blocks within a - function only. Other brackets and blocks are broken, but NOT indented. This style frequently is + GNU style uses broken braces and indented blocks. Extra indentation is added to blocks within a + function only. Other braces and blocks are broken, but NOT indented. This style frequently is used with an indent of 2 spaces.

int Foo(bool isBar)
@@ -679,13 +688,13 @@
          

--style=linux / --style=knf / -A8
- Linux style uses linux brackets. Opening brackets are broken from namespace, class, and function definitions. - The brackets are attached to everything else, including arrays, structs, enums, and statements within a function. + Linux style uses linux braces. Opening braces are broken from namespace, class, and function definitions. + The braces are attached to everything else, including arrays, structs, enums, and statements within a function. The minimum conditional indent is one-half indent. If you want a different minimum conditional - indent, use the K&R style instead. This style works best with a large indent. It frequently is used with + indent, use the K&R style instead. This style works best with a large indent. It frequently is used with an indent of 8 spaces.

- Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux + Also known as Kernel Normal Form (KNF) style, this is the style used in the Linux BSD kernel.

int Foo(bool isBar)
@@ -701,8 +710,8 @@
     

 

- --style=horstmann / -A9
- Horstmann style uses broken brackets and run-in statements. Switches are indented to allow a run-in to the opening + --style=horstmann / --style=run-in / -A9
+ Horstmann style uses broken braces and run-in statements. Switches are indented to allow a run-in to the opening switch block. This style frequently is used with an indent of 3 spaces.

int Foo(bool isBar)
@@ -719,12 +728,12 @@
          

--style=1tbs / --style=otbs / -A10
- "One True Brace Style" uses linux brackets and adds brackets to unbracketed one line conditional statements. Opening - brackets are broken from namespaces, classes, and function definitions. The brackets are attached to everything + "One True Brace Style" uses linux braces and adds braces to unbraced one line conditional statements. Opening + braces are broken from namespaces, classes, and function definitions. The braces are attached to everything else, including arrays, structs, enums, and statements within a function.

- In the following example, brackets have been added to the "return 0;" statement. The option - ‑‑add‑one‑line‑brackets can also be used with this style.

+ In the following example, braces have been added to the "return 0;" statement. The option + ‑‑add‑one‑line‑braces can also be used with this style.

int Foo(bool isBar)
 {
@@ -741,9 +750,9 @@
          

--style=google / -A14
- Google style uses attached brackets and indented class access modifiers. See the indent-modifiers - option for an example of the indented modifiers format. This is not actually a unique bracket style, but - is Java style with a non-bracket variation. This style frequently is used with an indent of 2 spaces.

+ Google style uses attached braces and indented class access modifiers. See the indent-modifiers + option for an example of the indented modifiers format. This is not actually a unique brace style, but + is Java style with a non-brace variation. This style frequently is used with an indent of 2 spaces.

int Foo(bool isBar) {
     if (isBar) {
@@ -758,8 +767,8 @@
          

--style=mozilla / -A16
- Mozilla style uses linux brackets. Opening brackets are broken from classes, structs, enums, and function - definitions. The brackets are attached to everything else, including namespaces, arrays, and statements + Mozilla style uses linux braces. Opening braces are broken from classes, structs, enums, and function + definitions. The braces are attached to everything else, including namespaces, arrays, and statements within a function. This style frequently is used with an indent of 2 spaces.

int Foo(bool isBar)
@@ -776,10 +785,10 @@
          

--style=pico / -A11
- Pico style uses broken brackets and run-in statements with attached closing brackets. The closing bracket is attached + Pico style uses broken braces and run-in statements with attached closing braces. The closing brace is attached to the last line in the block. Switches are indented to allow a run-in to the opening switch block. The style - implies keep-one-line-blocks and keep-one-line-statements. If add-brackets is used they will be added as one-line - brackets. This style frequently is used with an indent of 2 spaces.

+ implies keep-one-line-blocks and keep-one-line-statements. If add-braces is used they will be added as one-line + braces. This style frequently is used with an indent of 2 spaces.

int Foo(bool isBar)
 {   if (isBar)
@@ -793,9 +802,9 @@
          

--style=lisp / --style=python / -A12
- Lisp style uses attached opening and closing brackets. The closing bracket is attached to the last line in the + Lisp style uses attached opening and closing braces. The closing brace is attached to the last line in the block. The style implies keep-one-line-statements, but NOT keep-one-line-blocks. This style does not support one-line - brackets. If add-one-line-brackets is used they will be added as multiple-line brackets.

+ braces. If add-one-line-braces is used they will be added as multiple-line braces.

int Foo(bool isBar) {
     if (isBar) {
@@ -920,17 +929,17 @@
          


- + -

Bracket Modify Options

+

Brace Modify Options

--attach-namespaces / -xn
- Attach brackets to a namespace statement. This is done regardless of the bracket style being used. - It will also attach brackets to CORBA IDL module statements.

+ Attach braces to a namespace statement. This is done regardless of the brace style being used. + It will also attach braces to CORBA IDL module statements.

- the bracket is always attached to a namespace statement:

+ the brace is always attached to a namespace statement:

namespace FooName {
 ...
 }
@@ -940,10 +949,10 @@
          

--attach-classes / -xc
- Attach brackets to a class statement. This is done regardless of the bracket style being used.

+ Attach braces to a class statement. This is done regardless of the brace style being used.

- the bracket is always attached to a class statement:

+ the brace is always attached to a class statement:

class FooClass {
 ...
 };
@@ -953,11 +962,11 @@
          

--attach-inlines / -xl
- Attach brackets to class and struct inline function definitions. This is not done for run-in type brackets - (Horstmann and Pico styles). This option is effective for C++ files only.

+ Attach braces to class and struct inline function definitions. This option has precedence for all + styles except Horstmann and Pico (run-in styles). It is effective for C++ files only.

- all brackets are always attached to class and struct inline function definitions:

+ all braces are attached to class and struct inline method definitions:

class FooClass
 {
     void Foo() {
@@ -970,27 +979,50 @@
          

--attach-extern-c / -xk
- Attach brackets to a bracketed extern "C" statement. This is done regardless of the bracket style being used. + Attach braces to a braced extern "C" statement. This is done regardless of the brace style being used. This option is effective for C++ files only.

- An extern "C" statement that is part of a function definition is formatted according to the requested bracket - style. Bracketed extern "C" statements are unaffected by the bracket style and this option is the only way to + An extern "C" statement that is part of a function definition is formatted according to the requested brace + style. Braced extern "C" statements are unaffected by the brace style and this option is the only way to change them.

- this option attaches brackets to a bracketed extern "C" statement:

+ this option attaches braces to a braced extern "C" statement:

#ifdef __cplusplus
 extern "C" {
 #endif
 

- but function definitions are formatted according to the requested bracket style:

+ but function definitions are formatted according to the requested brace style:

extern "C" EXPORT void STDCALL Foo()
 {}
 

 

+

+ --attach-closing-while / -xV
+ Attach the closing 'while' of a 'do-while' statement to the closing brace. This has precedence over both + the brace style and the break closing braces option.

+
+
do
+{
+    bar();
+    ++x;
+}
+while x == 1;
+
+

+ becomes:

+
do
+{
+    bar();
+    ++x;
+} while x == 1;
+
+
+

+  


@@ -1049,7 +1081,7 @@  

--indent-switches / -S
- Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. The entire + Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. The entire case block is indented.

switch (foo)
@@ -1121,7 +1153,7 @@
          

--indent-namespaces / -N
- Add extra indentation to namespace blocks. This option has no effect on Java files. It + Add extra indentation to namespace blocks. This option has no effect on Java files. It will also indent CORBA IDL module statements.

namespace foospace
@@ -1149,12 +1181,45 @@
     

 

+

+ --indent-after-parens / -xU
+ Indent, instead of align, continuation lines following lines that contain an opening paren '(' or an assignment + '='. This includes function definitions and declarations and return statements. The indentation can be modified + by using the following indent-continuation option. This option may be preferred for editors displaying proportional + fonts.

+
+
void Foo(bool bar1,
+         bool bar2)
+{
+    isLongFunction(bar1,
+                   bar2);
+
+    isLongVariable = foo1
+                     || foo2;
+}
+
+

+ becomes:

+
void Foo(bool bar1,
+    bool bar2)
+{
+    isLongFunction(bar1,
+        bar2);
+
+    isLongVariable = foo1
+        || foo2;
+}
+
+
+

+  

--indent-continuation=# / -xt#
- Set the continuation indent for a line that ends with an opening paren '(' or an assignment - '='. This includes function definitions and declarations. The value for # - indicates a number of indents. The valid values are the integer - values from 0 thru 4: The default value is 1, one indent.

+ Set the continuation indent for a line that ends with an opening paren '(' or an assignment '='. This includes + function definitions and declarations. It will also modify the previous indent-after-paren option. The value for + # indicates a number of indents. The valid values are the integer + values from 0 thru 4. If this option is not used, the default value of 1 is + used.

isLongVariable =
     foo1 ||
@@ -1198,7 +1263,7 @@
     while (isFoo) {
         if (isFoo)
             goto error;
-        ... 
+        ...
     error:
         ...
         }
@@ -1210,9 +1275,9 @@
 
     

--indent-preproc-block / -xW
- Indent preprocessor blocks at bracket level zero and immediately within a namespace. There are restrictions on - what will be indented. Blocks within methods, classes, arrays, etc., will not be indented. Blocks containing brackets - or multi-line define statements will not be indented. Without this option the preprocessor block is not + Indent preprocessor blocks at brace level zero and immediately within a namespace. There are restrictions on + what will be indented. Blocks within methods, classes, arrays, etc., will not be indented. Blocks containing braces + or multi-line define statements will not be indented. Without this option the preprocessor block is not indented.

#ifdef _WIN32
@@ -1313,12 +1378,12 @@
         3 - indent at least one-half an additional indent. This is intended for large indents (e.g. 8).
The default value is 2, two additional indents.

-
// default setting makes this non-bracketed code clear
+        
// default setting makes this non-braced code clear
 if (a < b
         || c > d)
     foo++;
 
-// but creates an exaggerated indent in this bracketed code
+// but creates an exaggerated indent in this braced code
 if (a < b
         || c > d)
 {
@@ -1326,14 +1391,14 @@
 }
 

- becomes (when setting + becomes (when setting --min-conditional-indent=0):

-
// setting makes this non-bracketed code less clear
+        
// setting makes this non-braced code less clear
 if (a < b
     || c > d)
     foo++;
 
-// but makes this bracketed code clearer
+// but makes this braced code clearer
 if (a < b
     || c > d)
 {
@@ -1343,10 +1408,11 @@
     

 

-

- --max-instatement-indent=# / -M#
- Set the  maximum of # spaces to indent a continuation line. The - # indicates a number of columns and must not be less than 40 nor +

+ --max-continuation-indent=# / -M#
+ --max-instatement-indent=# is depreciated
+ Set the  maximum of # spaces to indent a continuation line. The + # indicates a number of columns and must not be less than 40 or greater than 120. If no value is set, the default value of 40 will be used. This option will prevent continuation lines from extending too far to the right. Setting a larger value will allow the code to be extended further to the right.

@@ -1452,8 +1518,8 @@  

--pad-comma / -xg
- Insert space padding after commas. This is not needed if pad-oper is used. Any end of line comments will - remain in the original column, if possible. Note that there is no option to unpad. Once padded, they + Insert space padding after commas. This is not needed if pad-oper is used. Any end of line comments will + remain in the original column, if possible. Note that there is no option to unpad. Once padded, they stay padded.

if (isFoo(a,b)
@@ -1560,14 +1626,14 @@
         --unpad-paren / -U 
         
Remove extra space padding around parens on the inside and outside. Any end of line comments will remain - in the original column, if possible. This option can be used in combination with the paren padding options - pad‑paren, pad‑paren‑out, pad‑paren‑in, - and pad‑header above. Only padding that has not been requested by other options will be + in the original column, if possible. This option can be used in combination with the paren padding options + pad‑paren, pad‑paren‑out, pad‑paren‑in, + and pad‑header above. Only padding that has not been requested by other options will be removed.

For example, if a source has parens padded on both the inside and outside, and you want inside only. You need - to use unpad-paren to remove the outside padding, and pad‑paren‑in to - retain the inside padding. Using only pad‑paren‑in> would not remove the outside + to use unpad-paren to remove the outside padding, and pad‑paren‑in to + retain the inside padding. Using only pad‑paren‑in> would not remove the outside padding.

if ( isFoo( ( a+2 ), b ) )
@@ -1689,11 +1755,12 @@
 
     

Formatting Options

-

- --break-closing-brackets / -y +

+ --break-closing-braces / -y
+ --break-closing-brackets is depreciated

When used with --style=java, --style=kr, --style=stroustrup, --style=linux, or --style=1tbs, this breaks closing - headers (e.g. 'else', 'catch', ...) from their immediately preceding closing brackets. Closing header brackets + headers (e.g. 'else', 'catch', ...) from their immediately preceding closing braces. Closing header braces are always broken with the other styles.

void Foo(bool isFoo) {
@@ -1758,8 +1825,8 @@
     

Break one line headers (e.g. 'if', 'while', 'else', ...) from a statement residing - on the same line. If the statement is enclosed in brackets, the brackets will be formatted according to the requested - bracket style.

+ on the same line. If the statement is enclosed in braces, the braces will be formatted according to the requested + brace style.

A multi-statement line will NOT be broken if keep-one-line-statements is requested. One line blocks will NOT be broken if keep-one-line-blocks is requested and the header is enclosed in the block.

@@ -1786,16 +1853,17 @@

 

-

- --add-brackets / -j +

+ --add-braces / -j
+ --add-brackets is depreciated

- Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...). The statement must - be on a single line. The brackets will be added according to the requested bracket style. If no style is requested - the brackets will be attached.

-

- Brackets will NOT be added to a multi-statement line if keep-one-line-statements is requested. Brackets will - NOT be added to a one line block if keep-one-line-blocks is requested. If --add-one-line-brackets is also - used, the result will be one line brackets.

+ Add braces to unbraced one line conditional statements (e.g. 'if', 'for', 'while'...). The statement must + be on a single line. The braces will be added according to the requested brace style. If no style is requested + the braces will be attached.

+

+ Braces will NOT be added to a multi-statement line if keep-one-line-statements is requested. Braces will + NOT be added to a one line block if keep-one-line-blocks is requested. If --add-one-line-braces is also + used, the result will be one line braces.

if (isFoo)
     isFoo = false;
@@ -1809,10 +1877,11 @@
     

 

-

- --add-one-line-brackets / -J +

+ --add-one-line-braces / -J
+ --add-one-line-brackets is depreciated

- Add one line brackets to unbracketed one line conditional statements (e.g. 'if', 'for', + Add one line braces to unbraced one line conditional statements (e.g. 'if', 'for', 'while'...). The statement must be on a single line. The option implies --keep-one-line-blocks and will not break the one line blocks.

@@ -1827,11 +1896,13 @@

 

-

- --remove-brackets / -xj
- Remove brackets from conditional statements (e.g. 'if', 'for', 'while'...). - The statement must be a single statement on a single line. If --add-brackets or --add-one-line-brackets is also - used the result will be to add brackets. Brackets will not be removed from "One True Brace Style", +

+ --remove-braces / -xj
+ --remove-brackets is depreciated
+
+ Remove braces from conditional statements (e.g. 'if', 'for', 'while'...). + The statement must be a single statement on a single line. If --add-braces or --add-one-line-braces is also + used the result will be to add braces. Braces will not be removed from "One True Brace Style", --style=1tbs.

if (isFoo)
@@ -1871,10 +1942,6 @@
 

remains unchanged.

-
if (isFoo) DoBar();
-
-

- remains unchanged.

 

@@ -1928,7 +1995,7 @@ (||, &&, ...), comma, paren, semicolon, or space.

Some code will not be broken, such as comments, quotes, and arrays. If used with keep‑one‑line‑blocks - or add-one-line-brackets the blocks will NOT be broken. If used with keep‑one‑line‑statements + or add-one-line-braces the blocks will NOT be broken. If used with keep‑one‑line‑statements the statements will be broken at a semicolon if the line goes over the maximum length. If there is no available break point within the max code length, the line will be broken at the first available break point after the max code length.

@@ -1974,12 +2041,12 @@ These options are effective for Objective‑C files only. The paren padding options will still apply to the Objective-C method prefix and return type unless overridden by the following options.

- Because of the longer indents sometimes needed for Objective‑C, the option "max-instatement-indent" may - need to be increased. If you are not getting the paren and block paren alignment you want try increasing this - value. The option is described in the "Indentation Options" section.

+ Because of the longer indents sometimes needed for Objective‑C, the option "max-continuation-indent" may + need to be increased. If you are not getting the paren and square bracket alignment you want try increasing + this value. The option is described in the "Indentation Options" section.

--pad-method-prefix / -xQ
- Insert space padding after the '-' or '+' Objective‑C method prefix. This will add + Insert space padding after the '-' or '+' Objective‑C method prefix. This will add exactly one space. Any additional spaces will be deleted.

-(void)foo1;
@@ -2023,7 +2090,7 @@
     

--unpad-return-type / -xr
Remove all space padding after the Objective‑C return type. This option - will be ignored if used with pad‑return‑type. This option takes precedence over the pad paren + will be ignored if used with pad‑return‑type. This option takes precedence over the pad paren outside option.

-(void) foo1;
@@ -2063,7 +2130,7 @@
         
-(void)foo1:(bool)barArg1;
 -(void)foo2:(bool)barArg2;

- becomes (with a padded method colon + becomes (with a padded method colon after):

-(void)foo1: (bool)barArg1;
 -(void)foo2: (bool)barArg2;
@@ -2072,7 +2139,7 @@  

--align-method-colon / -xM
- Align the colons in Objective‑C method declarations + Align the colons in Objective‑C method declarations and method calls. If this option is not declared, method definitions will be indented uniformly, and method calls will align with the first keyword.

@@ -2095,7 +2162,7 @@ error: arg3]; }

- becomes (with + becomes (with align-method-colon):

-(void)longKeyword: (ID)theArg1
            keyword: (int)theArg2
@@ -2168,9 +2235,9 @@
         named "templates". An exclude option of "cpp/templates" will exclude ALL "cpp/templates" directories. You may
         proceed backwards in the directory tree to exclude only the required directories.

- Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL files - named "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named "default.cpp" - contained in a "python" subdirectory. You may proceed backwards in the directory tree to exclude only the + Specific files may be excluded in the same manner. An exclude option of "default.cpp" will exclude ALL files + named "default.cpp". An exclude option of "python/default.cpp" will exclude ALL files named "default.cpp" + contained in a "python" subdirectory. You may proceed backwards in the directory tree to exclude only the required files.

Wildcards are NOT allowed. There may be more than one exclude statement. The file path and name may be placed @@ -2195,7 +2262,7 @@

--preserve-date / -Z
Preserve the original file's date and time modified. The time modified will be changed a few microseconds to - force the changed files to compile. This option is not effective if redirection is used to rename the input + force the changed files to compile. This option is not effective if redirection is used to rename the input file.

--verbose / -v
@@ -2240,11 +2307,11 @@ be formatted. The short option must be by itself, it cannot be concatenated with other options.

--version / -V
- Print version number and quit. The short option must be by itself, it cannot be concatenated with other + Print version number and quit. The short option must be by itself, it cannot be concatenated with other options.

--help / -h / -?
- Print a help message and quit. The short option must be by itself, it cannot be concatenated with other + Print a help message and quit. The short option must be by itself, it cannot be concatenated with other options.

--html / -!
@@ -2265,6 +2332,14 @@

Any HTML file can be opened by this option. The files you are likely to need are astyle.html (the default), install.html, and index.html.

+

+ --stdin=####
+ Open a file using the file path #### as input to single file formatting. This is a replacement for redirection. + Do not use this with "<" redirection.

+

+ --stdout=####
+ Open a file using the file path #### as output to single file formatting. This is a replacement for redirection. + Do not use this with ">" redirection.

 


diff -Nru astyle-2.06/doc/install.html astyle-3.0.1/doc/install.html --- astyle-2.06/doc/install.html 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/doc/install.html 2017-05-31 00:26:37.000000000 +0000 @@ -24,27 +24,31 @@

Linux Version

- GCC Compiler

+ CodeBlocks Linux

- Clang Compiler

+ GCC Makefile

- Intel Compiler

+ Clang Makefile

+

+ Intel Makefile

Other Makefile Targets

- Mac OS Version

+ MacOS Version

Xcode

- Makefile

+ MacOS Makefile

Windows Version

Precompiled Executable

- Visual C++ Compiler

+ CodeBlocks Windows

- Other Compilers

+ Visual Studio

+

+ Other Development Environments

Compiler Options

@@ -70,7 +74,38 @@

Linux Version

-

GCC Compiler

+

CodeBlocks Linux

+ +

+ There are build folders for the following compilers. All compiler folders are in the "build" directory. +

+
    +
  • cb-clang contains the workspace and project files for the Linux Clang Compiler.
  • +
  • cb-gcc contains the workspace and project files for the Linux GCC Compiler.
  • +
  • cb-intel contains the workspace and project files for the Linux Intel Compiler.
  • +
+

+ There are workspace and project files for each folder. All projects have at least Debug and Release + configurations. All output will be in the "bin" directory.

+

+ The workspace contains the following projects.

+
    +
  • AStyle builds the Artistic Style command line program (astyle).
  • +
  • AStyle So builds the Artistic Style program as a shared object (libastyle.so).
  • +
  • AStyle Java builds the Artistic Style program as a shared object (libastylej.so) that can + be called from a Java program. The Java Development Kit (JDK) is required for the project to compile. The + Project Properties must have an include path to the JDK include directories.
  • +
  • AStyle A builds the Artistic Style program as a Static Library (libastyle.a). This can be + statically linked to a user program.
  • +
+ +

+ For other Linux development environments, follow the instructions in Other + Development + Environments. +

+ +

GCC Makefile

To compile using the GCC compiler you must have GCC (3.1 or better) installed.

@@ -85,19 +120,19 @@ or "make release" will build the command line configuration. Following are the symbolic names and file names (in parens) of the various configurations:

    -
  • release builds the Artistic Style command line program (astyle). This is the default option. -
  • -
  • shared builds the Artistic Style program as a shared library (libastyle.so).
  • -
  • static builds the Artistic Style program as a static library (libastyle.a).
  • -
  • debug builds the Artistic Style command line program with debugging information (astyled). -
  • -
  • shareddebug builds the Artistic Style program as a shared library with debugging information - (libastyled.so). -
  • -
  • staticdebug builds the Artistic Style program as a static library with debugging information - (libastyled.a). -
  • -
  • all builds all the above configurations. +
  • release or astyle builds the Artistic Style command line program. This is the + default option.
  • +
  • shared or libastyle.so builds the Artistic Style program as a shared + library.
  • +
  • static or libastyle.a builds the Artistic Style program as a static + library.
  • +
  • debug or astyled builds the Artistic Style command line program with debugging + information
  • +
  • shareddebug or libastyled.so builds the Artistic Style program as a shared library + with debugging information.
  • +
  • staticdebug or libastyled.a builds the Artistic Style program as a static library + with debugging information.
  • +
  • all builds all the above configurations.

    The following Java shared library builds are separate from the above. They include a Java Native Interface (JNI) and require that the Java Development Kit (JDK) be installed. The environment variable JAVA_HOME should be defined. @@ -110,7 +145,7 @@

  • javadebug builds the Artistic Style program as a shared library which includes the JNI and debugging information (libastylejd.so).
  • -
  • javaall builds all the above java configurations.
  • +
  • javaall builds all the above java configurations.

More than one configuration can be built at the same time. For example, to build all the release configurations @@ -120,7 +155,7 @@ The Other Makefile Targets section contains additional target options.

-

Clang Compiler

+

Clang Makefile

Clang has a static analyzer that finds potential bugs in C/C++ and Objective-C programs. It can be run as a standalone @@ -134,7 +169,7 @@

To build the other astyle configurations, you can enter the file name or a symbolic name. The configurations for - Clang are the same as for the GCC compiler. More than one configuration can be + Clang are the same as for the GCC Makefile. More than one configuration can be built at the same time. For example, to build all the release configurations enter:

cd astyle/build/clang
make release shared static
@@ -142,20 +177,16 @@ The Other Makefile Targets section contains additional target options.

-

Intel Compiler

+

Intel Makefile

These procedures and the makefile are for recent versions of the compiler. They may not work for earlier versions. Instructions for your compiler are in the compiler documentation file "get_started_lc.htm".

- To compile the source there are environment variables that must be set by running the compiler environment script - compilervars.sh (or compilervars.csh) with an argument that specifies the target architecture. If this has not - been done already enter: "source  <install-dir>/bin/compilervars.sh <arg>", - where <install-dir> is the directory where the compiler is installed and <arg> is ia32 - or intel64. If this is not done "make" will display an error message "*** The compiler environment - variables are not set." On an Intel x64 platform installed in the default directory the instruction would - be

-
source /opt/intel/bin/compilervars.sh intel64
+ To compile with Intel there are environment variables that must be set by running the compiler environment + script compilervars.sh (or compilervars.csh) with an argument that specifies the target architecture. This + should be done before running the make. If it is not done, "make" will display an error message + stating that the compiler environment variables are not set.

The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the astyle/build/intel directory. The output executables will be in the astyle/build/intel/bin directory. To build @@ -163,7 +194,7 @@

cd astyle/build/intel
make

To build the other astyle configurations, you can enter the file name or a symbolic name. The configuration names - for Intel are the same as for the GCC compiler. More than one configuration can be + for Intel are the same as for the GCC Makefile. More than one configuration can be built at the same time. For example, to build the entire debug configurations enter:

cd astyle/build/intel
make debug shareddebug staticdebug

@@ -226,7 +257,7 @@ NOTE: The uninstall option will NOT remove the .astylerc files from the users' home directories. The files must be removed individually for each user.

-

Mac OS Version

+

MacOS Version

Xcode

@@ -277,7 +308,7 @@ NOTE: The uninstall option will NOT remove the .astylerc files from the users' home directories. The files must be removed individually for each user.

-

Makefile

+

MacOS Makefile

The Artistic Style makefile compile uses the Mac OS "Command Line Tools". If you have Xcode 4.3 or newer @@ -292,7 +323,7 @@

To build the other astyle configurations, you can enter the file name or a symbolic name. The configurations for - Mac are the same as for the Linux GCC compiler. More than one configuration can be + Mac are the same as for the GCC Makefile. More than one configuration can be built at the same time. For example, to build all the release configurations enter:

cd astyle/build/mac
make release shared static
@@ -308,41 +339,69 @@ In addition to the source files, the Windows distribution package contains an Artistic Style Win32 executable (AStyle.exe). If you prefer to compile the executable yourself, pursue the following instructions.

-

Visual C++ Compiler

+

CodeBlocks Windows

+ +

+ There are build folders for the following compilers. All compiler folders are in the "build" directory. +

+
    +
  • cb-bcc32c contains the workspace and project files for the Embarcadero BCC32C Compiler.
  • +
  • cb-mingw contains the workspace and project files for the MinGw or TDM_GCC Compilers.
  • +

- There are - solution and project files for - several versions of the Visual C compiler. Open an Artistic Style solution + There are workspace and project files for each folder. All projects have at least Debug and Release configurations. + All output + will be in the "bin" directory.

+

+ The workspace contains the following projects.

+
    +
  • AStyle builds the Artistic Style command line program (AStyle.exe).
  • +
  • AStyle Dll builds the Artistic Style program as a shared object (AStyle.dll).
  • +
  • AStyle Java builds the Artistic Style program as a shared object AStylej.dll) that can + be called from a Java program. The Java Development Kit (JDK) is required for the project to compile. The + Project Properties must have an include path to the JDK include directories.
  • +
  • AStyle Lib builds the Artistic Style program as a Static Library (astyle.lib). This can be + statically linked to a calling program.
  • +
+

+ For other development environments, follow the instructions in Other Development + Environments. +

+ +

Visual Studio

+ +

+ There are solution and project files for several versions of Microsoft Visual Studio. Open an Artistic Style solution file in the appropriate "build" directory. All projects have Debug, Release and Static configurations. Debug file output will be in the "debug" directory. Release file output will be in the "bin" directory. Static file output will be in the "binstatic" directory. The following solution files are available.

    -
  • All AStyle ll AStyle builds the release and the debug configurations for all the following. +
  • All AStyle builds the release and the debug configurations for all the following.
  • AStyle builds the Artistic Style command line program (AStyle.exe). This project has an extra "Static" option. It is the same as the "Release" build except that it is linked with a static runtime library. This is needed if the executable is to be run on a system without Visual Studio installed. The builds for this configuration are placed in a separate "binstatic" directory.
  • -
  • AStyleDll builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will +
  • AStyle Dll builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will also build an export library and a static library for linking the dll.
  • -
  • AStyleJava builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can +
  • AStyle Java builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can be called from a Java program. The Java Development (JDK) is required for the project to compile. The Project Properties must have an include path to the JDK include and include/win32 directories. This is set in "Project > Properties > C/C++ > General > Additional Include Directories". The default setting is for the JDK to be installed in the default directory, but it may not be the most current release. The output DLL can also be called from a C++ or C# program.
  • -
  • AStyleLib builds the Artistic Style program as a Static Library (libAStyle.lib). This can be +
  • AStyle Lib builds the Artistic Style program as a Static Library (libAStyle.lib). This can be statically linked to a calling program.
-

Other Compilers

+

Other Development Environments

- To use other compilers a project file must be built using a development environment.

+ To use other development environments a project file must be built.

    -
  • Create a project using the compiler development environment.
  • +
  • Create a project using the development environment.
  • Add to the project all the .cpp and .h files in the "src" directory.
  • The Compiler Options section discusses the compiler options to use.
  • Compile.
  • @@ -359,11 +418,10 @@

    Artistic Style is a small program and it is best to optimize for speed. The debug configurations are not usually optimized. To optimize for speed in the release configurations, use the macro NDEBUG to remove asserts. If - necessary, use an option to activate the C++11 standards (--std=c++0x on GCC and MinGW). Use an - option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed. Exceptions are - NOT - used. Use whole program optimization if your compiler supports it. There may be other options you can use depending - on the compiler.

    + necessary, use an option to activate the C++11 standards (-std=c++11 or -std=c++0x on most compilers). Use an + option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed and exceptions are + NOT used. Use whole program optimization if your compiler supports it. There may be other options you can use + depending on the compiler.

     

    @@ -374,6 +432,8 @@

     

    +

    +  

    diff -Nru astyle-2.06/doc/news.html astyle-3.0.1/doc/news.html --- astyle-2.06/doc/news.html 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/doc/news.html 2017-05-31 00:26:37.000000000 +0000 @@ -17,6 +17,184 @@

     

    +

    Artistic Style 3.0  (April 2017)

    + +

    + Release 3.0.1 (May 2017) is a maintenance release and no new features were added. A list of changes is in + the Release Notes. The following information is for the original 3.0 release. Thanks to Juan Alday for his + contribution.

    + +

    + In the Artistic Style documentation, in General Information, Other Considerations, there is a list of + terminology used for special characters used in programming. The terms used by Artistic Style have been + different than is used by Visual Studio, Clang, and others. In this release the terms used by Artistic Style + have been changed to the ones most commonly used in programming documentation. The following chart indicates + the changes.

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NEWOLD
    braces or curly braces    { }    brackets
    parens or round brackets    ( )    parens
    square brackets    [ ]    block parens
    angle brackets   < >    angle brackets
    +
    + +

    + Parens and angle brackets do not change. Brackets has been changed to braces. Block parens has been changed to + square brackets. Brackets can now collectively refer to the group containing round brackets (parens), square brackets, + and angle brackets. The documentation has been updated and the variable names in the source code have been + changed.

    +

    + There are four options affected by the change, "break-closing-brackets", "add-brackets", "add-one-line-brackets", + and "remove-brackets". These have been changed to the corresponding "break-closing-braces", + "add-braces", "add-one-line-braces", and "remove-braces". Also, the option "max-instatement-indent" + has been changed to "max-continuation-indent". The old options and method names have been depreciated, + but will continue to be accepted for the next several releases.

    +

    + The source code now uses the C++11 standard. Compilers that need a standard declared should use C++11. Visual + Studio 2010 is currently still currently supported. The classes were made independent of the containing + source code files (the source files contain multiple classes). The dependency on global variables in the console + build was removed.

    +

    + A new option, "indent-after-parens", will indent continuation lines following lines that contain an + opening paren '(' or an assignment '='. This includes function definitions and declarations + and return statements. This option may be preferred for editors displaying proportional fonts.

    +

    + A new option, "attach-closing-while", will attach the closing "while" of a + "do-while" statement to the closing brace. It has precedence over both the brace style and the break + closing braces option.

    +

    + The option "break-closing-braces" has been included in "style=stroustrup". This is the + correct style according to Wikipedia. The new option "attach-closing-while" is not included in + the style but can be used if you want. If there is a problem with the new format, change to the K&R style + using the same options as for Stroustrup.

    +

    + If you are using Windows XP, there is a download file available that has an XP compatible executable. Artistic + Style will still compile with Visual Studio 2010.

    +

    + Thanks to Jochen Tucht and Matthew Woehlke for their contributions.

    +

    + The following are additional topics.

    + +

    Version 3

    + +

    + Artistic Style was written in the 1990's when personal computers were much slower and compilers were not as + sophisticated as today. It used a lot of global variables instead of class members. In previous releases, classes + were created for the astyle_main.h source code. With this release, the classes have been made independent + of the source file containing them and the shared and global data has been eliminated. The classes could now be + separated into separate source files. They have not been actually separated because it seems more convenient + to leave them combined.

    +

    + As explained previously, the terminology for special characters has been changed to agree with various + development environments and compilers. The variable and method names in the source code were changed as well + as the documentation. This was a major renaming. If not for the "rename" refactoring feature in Visual + Studio, and the AStyleTest programs, it would probably not have been attempted.

    +

    + Artistic Style has also started using C++11. Older compiler versions and compilers without C++11support cannot + be used. If your compiler requires a compiler directive for C++, such as -std=c++11 or -std=c++0x, it will + need to be used.

    + +

    Library File Names

    + +

    + The shared library object (DLL) compile was originally intended to be a local library used by a single program. + Users could update the library at their convenience. Recently, it has started being distributed as a system library + for some distributions. In the past was not maintained for doing this. Since it is already being offered as + a distribution, the library soname on Linux has been standardized.

    +

    + It can still be used as a local or a static library if you want to control the changes. Or the system library + can be used. The system library version, of course, may change at any time. With this release the system + library will be available on Debian based systems, as well as possibly others.

    +

    + The Windows library name has been changed also. This Windows version is AStyle30.dll. The "30" refers + to the Artistic Style release number "3.0". The Linux library name is a soname version number, not the + Artistic Style release number.

    + +

    Artistic Style Wx

    + +

    + There is a new GUI test program AStyleWx that uses wxWidgets. This replaces the old AStyleWin program. AStyleWx + is multi-platform and has more features simply because they are easier to implement with wxWidgets.

    +

    + It has download files and a website in a new sub-project directory of Artistic Style. The downloads contain + source code, documentation, and scripts. The Windows download contains an executable. The needed Artistic Style + source files are included.

    +

    + It is licensed under the MIT license. The source code may be used and modified for any purpose you + choose. Developers using Artistic Style in another project may use any part of AStyleWx in their project. The + modified source code does NOT need to be made available to others.

    + +

    Code::Blocks Support

    + +

    + Code::Blocks is a free, open-source cross-platform IDE that supports multiple compilers. It currently gets over + 100,000 downloads per week. It is used by Artistic Style to test compilers on various systems. Code::Blocks build + files for several free compilers are now provided with the Artistic Style release. The "Install Information" + contains additional information.

    + +

    Embarcadero Compiler

    + +

    + Embarcadero is offering a new, free, BCC32C C++ compiler. It includes C++11 language support, the Dinkumware + Standard Template Library, and the Embarcadero Runtime Library. Included are a linker, a + resource compiler, and a number of command line tools. It is currently for Win32 only. There is more + information at their Free Tools web page. They are also currently offering a free debugger and two + different + development environments.

    + +

    Naming Conventions

    + +

    + If you use cppcheck, it has an add-on to check naming standards for functions and variables by using regular + expressions. Cppcheck must be run first to generate ".dump" files. The Python program, naming.py, + can then be run to check the names. It is basically a shell that you will probably want to modify for regular + use. The add-ons must be installed with cppcheck for naming.py to be available.

    + +

    WinMerge 2011

    + +

    + WinMerge 2011 is a fork of the original WinMerge application published on SourceForge by Thingamahoochie + Software. It is has removed the ATL/MFC dependencies and added some useful features. It uses Artistic Style + to format the source code.

    + +

    Whatstyle

    + +

    + Whatstyle finds a code format style that fits given source files. This program looks at your source code and + generates a style definition that fits its original formatting style as closely as possible. + Several formatters and programming languages are supported. It is written in Python and has an interesting + method for finding the style options. +

    +

    Artistic Style 2.06  (December 2016)

    @@ -33,7 +211,7 @@ has not been changed and will also add a space following a comma.

    A new option, "indent-continuation", will add extra indents to continuation lines following a line that - ends with an opening paren '(' or an assignment '='. This includes function definitions and declarations. + ends with an opening paren '(' or an assignment '='. This includes function definitions and declarations. There is more information in the "Indentation Options" section of the documentation.

    All spaces before a comma are now removed. Use the "disable formatting" comment tags if there are arrays @@ -44,7 +222,7 @@ lot of changes made to the code.

    New Objective-C options "pad-return-type" and "unpad-return-type" will add or remove space padding after - the Objective-C return type in a method definition. They are described in the "Objective-C" section of the + the Objective-C return type in a method definition. They are described in the "Objective-C" section of the documentation.

    New Objective-C options "pad-param-type" and "unpad-param-type" will add or remove space padding after @@ -92,15 +270,15 @@ The Artistic Style software license has changed. It is now under the MIT license. This is a permissive license which can be used in proprietary software and does NOT require modified Artistic Style source code be made available. It is compatible with the GNU General Public License (GPL) and most other software licenses. The change was made - to remove restrictions on using the software and to make it available for any project that wants to + to remove restrictions on using the software and to make it available for any project that wants to use it.

    Visual Studio 2015 and 2017 UTF-8 Files

    - In order to be used on both Linux and Windows, the ASLocalizer.cpp UTF-8 file in Artistic Style does not - contain a Byte Order Mark (BOM).  With Visual Studio 2015 there has been a change in how UTF-8 files - without a BOM are processed. The new procedure is described + In order to be used on both Linux and Windows, the ASLocalizer.cpp UTF-8 file in Artistic Style does not + contain a Byte Order Mark (BOM).  With Visual Studio 2015 there has been a change in how UTF-8 files + without a BOM are processed. The new procedure is described here. It affects only the language translations in the ".exe" file. The shared libraries and static libraries are not affected. It is necessary only if you are using a translation @@ -136,12 +314,14 @@

    Coding Styles

    -

    Coding style, or programming style, is a set of rules or guidelines used when writing the source code. It is - often claimed that following a particular programming style will help in reading and understanding source code +

    + Coding style, or programming style, is a set of rules or guidelines used when writing the source code. It is + often claimed that following a particular programming style will help in reading and understanding source code conforming to the style, and help to avoid introducing errors.

    -

    This Artistic Style distribution has a new "file" folder containing AStyle options files for various coding - styles. Using the option files will give approximately the indicated coding style. The files can be used as - they are, or modified as desired.

    +

    + This Artistic Style distribution has a new "file" folder containing AStyle options files for various + coding styles. Using the option files will give approximately the indicated coding style. The files can be used + as they are, or modified as desired.

    Artistic Style Wx

    @@ -149,7 +329,7 @@ There is a new GUI test program AStyleWx that uses wxWidgets. This replaces the old AStyleWin program. AStyleWx is multi-platform and has more features simply because they are easier to implement with wxWidgets.

    - It has download files and a website in a new sub-project directory of Artistic Style. The downloads contain + It has download files and a website in a new sub-project directory of Artistic Style. The downloads contain source code, documentation, and scripts. The Windows download contains an executable. The needed Artistic Style source files are included.

    @@ -160,14 +340,14 @@

    Windows XP

    - The executable in the Windows distribution package is now compiled with a Visual Studio version that will no + The executable in the Windows distribution package is now compiled with a Visual Studio version that will no longer work on Windows XP. Beginning with Visual Studio 2012, auto-vectorization tries to make loops run faster by automatically vectorizing the code. Auto-vectorization is on by default, and there are no compiler switches, #pragmas, or hints to disable it. It uses SSE instructions not available in Windows XP. Microsoft ended support and updates for XP on April 8, 2014, and the usage share percentage continues to decrease.

    To compile on a non-XP machine for use on XP, using a compiler other than Visual Studio should always - produce an XP executable. Using Visual Studio 2010 or earlier should always produce an XP executable. If + produce an XP executable. Using Visual Studio 2010 or earlier should always produce an XP executable. If you are using Visual Studio 2012, 2013, or 2015 on a non-XP machine, do the following for the Artistic Style configuration you want to use:

      @@ -175,14 +355,14 @@ and can be installed as a modification to the current install.
    • In the Artistic Style Properties, change General > Platform Toolset, to "Windows XP" for your Visual Studio version.
    • -
    • In the Artistic Style Properties, change C/C++ > Preprocessor > Preprocessor Definitions to include +
    • In the Artistic Style Properties, change C/C++ > Preprocessor > Preprocessor Definitions to include _USING_V110_SDK71_.
    • Change other Properties if you want, such as Output Directory or Target Name.
    • Compile. The output should be executable on Windows XP. It will also execute on the later versions of Windows.

    - In newer releases of Visual Studio 2015, the "Universal CRT" files have been moved. There is a + In newer releases of Visual Studio 2015, the "Universal CRT" files have been moved. There is a notification here. To compile using XP there may need to be additional include and library directories added. If the compile gets errors add the appropriate directories to the project properties.

    @@ -203,7 +383,7 @@ indented. The option is described in the "Indentation Options" section of the documentation.

    - A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as + A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as usual.

    Formatting of source code may now be disabled for portions of a program by embedding special comment tags in the @@ -256,7 +436,7 @@

    The "Indent Style" topic on Wikipedia states that the "ANSI" style refers to K&R style brackets and not Allman style as used by Artistic Style. The option "style=ansi" is therefore being deprecated and will - be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or + be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or style=break).

    Some of the documentation has been removed from the distribution package. It still contains all files needed to @@ -294,7 +474,7 @@ A new programming language, Objective‑C, has been added to Artistic Style. Four new options, "align‑method‑colon", "pad‑method‑colon=", "pad‑method‑prefix", and "unpad‑method‑prefix" have been added to format the methods. The options are described in a new "Objective‑C" section in the documentation. - These new options affect only Objective‑C source code. They have no effect on the other programming + These new options affect only Objective‑C source code. They have no effect on the other programming languages.

    Because of the longer continuation indents sometimes needed for Objective‑C, the option "max-instatement-indent" @@ -307,7 +487,7 @@ along with a python program to verify the style and an emacs script for using the style.

    A new indent option "indent-modifiers" will indent class access modifiers (public, protected, or 'private) one-half - indent. The rest of the class is not indented. It is described in the "Indentation Options" section of the + indent. The rest of the class is not indented. It is described in the "Indentation Options" section of the documentation.

    Four new bracket modify options, "attach-namespaces", "attach-classes", "attach-inlines", and "attach-extern-c", @@ -422,7 +602,7 @@ There is a new Linux makefile for the Clang Compiler. Clang is a free compiler can be installed as a package on many Linux distributions. Some of its features are fast compiles, low memory use, expressive diagnostic messages, and GCC compatibility. It includes a static analyzer tool that finds potential bugs in your source code. An experimental - version can be installed on a Windows platform. There is more information in the Install Information + version can be installed on a Windows platform. There is more information in the Install Information documentation.

    Visual Studio automatically creates an import library and an export file when you link a program that contains @@ -446,7 +626,7 @@

    If you use a compiler other than Visual Studio, you can probably get better execution by compiling using the C++11 standards. Artistic Style uses a lot of string vectors and the new move semantics will probably result in faster - execution. (To use C++11 on GCC and MinGW use the option --std=c++0x). This may change on future compiler + execution. (To use C++11 on GCC and MinGW use the option --std=c++0x). This may change on future compiler releases.

    The "Developer Information" page has a new example and download for calling Artistic Style from a Python script. @@ -467,7 +647,7 @@

     

    - Previous releases are available in the + Previous releases are available in the News Archives.

     

    diff -Nru astyle-2.06/doc/notes.html astyle-3.0.1/doc/notes.html --- astyle-2.06/doc/notes.html 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/doc/notes.html 2017-05-31 00:26:37.000000000 +0000 @@ -17,6 +17,50 @@

     

    +

    Artistic Style 3.0.1  (May 2017)

    + +
      +
    • Fix crash caused by certain class initializer formats (#435).
    • +
    • Fix "final" identifier not being recognized as a pre-command header (#433).
    • +
    • Fix recognition of certain rvalue reference variables.
    • +
    + +

    Artistic Style 3.0  (April 2017)

    + +
      +
    • Add new option "indent-after-parens" (#396, 152, 108, 79).
    • +
    • Add new option "attach-closing-while" (#177).
    • +
    • Add "style=run-in" as an alternative for "style=horstmann".
    • +
    • Add "break-closing-braces" to "style=stroustrup" (#267).
    • +
    • Add formatting for C++11 trailing return type methods.
    • +
    • Add new class ASPeekStream using RAII to allow early method returns.
    • +
    • Change affected variable names to new AStyle terminology.
    • +
    • Change some vector push_back() statements to emplace_back().
    • +
    • Fix memory leak when using "indent-preproc-define".
    • +
    • Fix sometimes splitting an r-value reference when "pad-oper" is used.
    • +
    • Fix in-statement-indent brace check not always checking a brace (#421).
    • +
    • Fix formatting of C# get/set and add/remove when braces are attached (#430).
    • +
    • Fix formatting of C# generic constraints (#430).
    • +
    • Fix padding of C# null conditional operator.
    • +
    • Fix attach-inlines to not attach a brace followed by a run-in comment.
    • +
    • Fix not always breaking lines after "add-braces" (#341).
    • +
    • Fix unpadding the "in" in a foreach statement (#386).
    • +
    • Fix boundary conditions discovered by american fuzzy lop fuzzer (#370).
    • +
    • Refactoring: +
        +
      • Replace NULL with C++11 nullptr.
      • +
      • Rename Utf8_16 class to ASEncoding.
      • +
      • Move ASConsole constructor and destructor from inline to non-inline.
      • +
      • Move console error stream (cerr) from global to ASConsole class.
      • +
      • Move ASConsole pointer in ASOptions from global to a class member.
      • +
      • Move findHeader and findOperator methods from ASBeautifier to ASBase.
      • +
      • Minor changes from PVS-Studio analyzer.
      • +
      • Minor changes from clang-tidy.
      • +
      +
    • +
    +

    Artistic Style 2.06  (December 2016)

      diff -Nru astyle-2.06/doc/styles.css astyle-3.0.1/doc/styles.css --- astyle-2.06/doc/styles.css 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/doc/styles.css 2017-05-31 00:26:37.000000000 +0000 @@ -11,22 +11,23 @@ * pre is a predefined format for formatting code */ +/* margin: [top] [right] [bottom] [left] */ -body { background-color: white; margin-top: 0.5in; margin-right: 0.8in; margin-bottom: 0.5in; margin-left: 1.3in; } +body { background-color: white; margin: 0.5in 0.8in 0.5in 1.3in; } -h1 { color: #0000A0; text-align: center; font-style: italic; margin-top: 18pt; margin-left: -0.5in; } -h2.large { color: #0000A0; text-align: center; font-size: x-large; margin-top: 0.4in; margin-left: -0.5in; } +h1 { color: #0000A0; text-align: center; font-style: italic; margin-top: 0.4in; margin-left: -0.5in; } +/* h2.large { color: #0000A0; text-align: center; font-size: x-large; margin-top: 0.4in; margin-left: -0.5in; } */ h2 { color: #0000A0; text-align: center; font-size: larger; margin-top: 0.4in; margin-left: -0.5in; } h3 { color: #0000A0; margin-top: 0.4in; margin-left: -0.4in; } h4 { color: #0000A0; margin-top: 0.3in; } -p.noindent { margin-left: -0.4in; } -p.contents1 { font-size: 105%; margin-top: 0in; margin-left: 0in; margin-bottom: 0in; margin-right: 0in; } -p.contents2 { margin-top: 0in; margin-left: .4in; margin-bottom: 0in; margin-right: .4in; } -/* p.contents3 { margin-top:0in; margin-left:.8in; margin-bottom:0in; margin-right:.8in; } */ +/* paragraph classes */ +.noindent { margin-left: -0.4in; } +.contents1 { font-size: 105%; margin: 0; } +.contents2 { margin: 0 0.4in 0 0.4in; } + a.contents:link, a.contents:visited { color: #0000A0; text-decoration: none; } a.contents:hover { color: #F00000; text-decoration: none; } - a:link, a:visited { color: #0000A0; text-decoration: underline; } a:hover { color: #F00000; text-decoration: underline; } diff -Nru astyle-2.06/file/allman.ini astyle-3.0.1/file/allman.ini --- astyle-2.06/file/allman.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/allman.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,22 @@ +# Allman Coding Style Options +# Based on an old AStyle release. + +# braces and indent +style=allman +# indent=spaces # this is the default + +# indentation +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs diff -Nru astyle-2.06/file/astyle.ini astyle-3.0.1/file/astyle.ini --- astyle-2.06/file/astyle.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/astyle.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,32 @@ +# astyle formatting options +# for all projects except AStyleDev example projects +# example projects use style=horstmann and indent=spaces (-A9s) +# for compatibility with Visual Studio: indent=force-tab, min-conditional-indent=0 (-Tm0) +# short options: -A1txn -SxWwM60 -pHk1 -xbO -xQxrxsxMxP2 + +# braces and indent +style=allman +indent=tab +attach-namespaces +# indentation +indent-switches +indent-preproc-block +indent-preproc-define +max-continuation-indent=60 +# padding +pad-oper +pad-header +align-pointer=type +# formatting +break-one-line-headers +keep-one-line-blocks +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=after +# other options +lineend=windows +# don't use "other options" (e.g. formatted) in this file +# send them as additional command line options diff -Nru astyle-2.06/file/chromium.ini astyle-3.0.1/file/chromium.ini --- astyle-2.06/file/chromium.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/chromium.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,33 @@ +# Chromium Coding Style Options +# https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md + +# braces and indent +style=google +indent=spaces=2 + +# indentation +indent-switches +indent-continuation=2 +indent-preproc-define +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs +#close-templates + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/file/gnu.ini astyle-3.0.1/file/gnu.ini --- astyle-2.06/file/gnu.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/gnu.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,23 @@ +# Gnu Coding Style Options +# https://www.gnu.org/prep/standards/html_node/Writing-C.html#Writing-C +# Based on an old AStyle release. + +# braces and indent +style=gnu +indent=spaces=2 + +# indentation +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs diff -Nru astyle-2.06/file/google.ini astyle-3.0.1/file/google.ini --- astyle-2.06/file/google.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/google.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,35 @@ +# Google Coding Style Options +# C++ - https://google.github.io/styleguide/cppguide.html +# Java - https://google.github.io/styleguide/javaguide.html +# ObjC - https://google.github.io/styleguide/objcguide.xml + +# braces and indent +style=google +indent=spaces=2 + +# indentation +indent-switches +indent-continuation=2 +indent-preproc-define +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs +#close-templates + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/file/horstmann.ini astyle-3.0.1/file/horstmann.ini --- astyle-2.06/file/horstmann.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/horstmann.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,24 @@ +# Horstmann Coding Style Options +# Obtained from Horstmann source code. + +# braces and indent +style=horstmann +indent=spaces=3 + +# indentation +indent-modifiers +indent-switches +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tab diff -Nru astyle-2.06/file/java.ini astyle-3.0.1/file/java.ini --- astyle-2.06/file/java.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/java.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,22 @@ +# Java Coding Style Options +# Obtained from Java source code. + +# braces and indent +style=java +# indent=spaces # this is the default + +# indentation +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tab diff -Nru astyle-2.06/file/linux.ini astyle-3.0.1/file/linux.ini --- astyle-2.06/file/linux.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/linux.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,22 @@ +# Linux Coding Style Options +# Obtained from the Linux Kernel BSD. + +# braces and indent +style=linux +indent=tab=8 + +# indentation +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs diff -Nru astyle-2.06/file/llvm.ini astyle-3.0.1/file/llvm.ini --- astyle-2.06/file/llvm.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/llvm.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,32 @@ +# LLVM Coding Style Options +# http://llvm.org/docs/CodingStandards.html + +# braces and indent +style=attach +indent=spaces=2 + +# indentation +indent-continuation=2 +indent-preproc-define +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=name + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs +close-templates + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/file/mozilla.ini astyle-3.0.1/file/mozilla.ini --- astyle-2.06/file/mozilla.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/mozilla.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,36 @@ +# Mozilla Coding Style Options +# https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style +# NOTE: Function return values should be on a separate line. +# The clang-mozilla.yaml options are: +# "AlwaysBreakAfterDefinitionReturnType: TopLevel" +# "AlwaysBreakAfterReturnType: TopLevelDefinitions" + +# braces and indent +style=mozilla +indent=spaces=2 + +# indentation +indent-switches +indent-preproc-define +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs +close-templates + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/file/stroustrup.ini astyle-3.0.1/file/stroustrup.ini --- astyle-2.06/file/stroustrup.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/stroustrup.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,27 @@ +# Stroustrup Coding Style Options +# Obtained from http://www.stroustrup.com/Programming/PPP-style.pdf. + +# braces and indent +style=stroustrup +attach-closing-while +indent=spaces=5 + +# indentation +indent-modifiers +indent-switches +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +#break-closing-braces # now included in the style +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs + diff -Nru astyle-2.06/file/visualstudio.ini astyle-3.0.1/file/visualstudio.ini --- astyle-2.06/file/visualstudio.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/visualstudio.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,29 @@ +# Visual Studio Coding Style Options +# http://code.visualstudio.com/docs/languages/cpp#_code-formatting + +# braces and indent +style=allman +indent=force-tab-x + +# indentation +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=name + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/file/webkit.ini astyle-3.0.1/file/webkit.ini --- astyle-2.06/file/webkit.ini 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/file/webkit.ini 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,32 @@ +# WebKit Coding Style Options +# https://webkit.org/code-style-guidelines/ + +# braces and indent +style=stroustrup +# indent=spaces # this is the default + +# indentation +indent-after-parens +indent-preproc-define +min-conditional-indent=0 +max-continuation-indent=80 + +# padding +pad-oper +pad-header +unpad-paren +align-pointer=type + +# formatting +break-one-line-headers +keep-one-line-blocks +keep-one-line-statements +convert-tabs +#close-templates + +# objective-c +pad-method-prefix +unpad-return-type +unpad-param-type +align-method-colon +pad-method-colon=none diff -Nru astyle-2.06/LICENSE.md astyle-3.0.1/LICENSE.md --- astyle-2.06/LICENSE.md 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/LICENSE.md 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,21 @@ +### MIT License + +Copyright (c) 2017 by Jim Pattee . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff -Nru astyle-2.06/LICENSE.txt astyle-3.0.1/LICENSE.txt --- astyle-2.06/LICENSE.txt 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/LICENSE.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 by Jim Pattee . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff -Nru astyle-2.06/README.md astyle-3.0.1/README.md --- astyle-2.06/README.md 1970-01-01 00:00:00.000000000 +0000 +++ astyle-3.0.1/README.md 2017-05-31 00:26:37.000000000 +0000 @@ -0,0 +1,9 @@ +Instructions for using Artistic Style are included in the *doc* directory. + +The file **install.html** contains instructions for compiling and +installing Artistic Style. + +The file **astyle.html**' contains information on using Artistic Style. + +The files **news.html** and **notes.html** contain information on changes +made to the various releases. diff -Nru astyle-2.06/README.txt astyle-3.0.1/README.txt --- astyle-2.06/README.txt 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/README.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -Instructions for using Artistic Style are included in the 'doc' directory. - -The file 'install.html' contains instructions for compiling and -installing Artistic Style. - -The file 'astyle.html' contains information on using Artistic Style. - -The files 'news.html' and 'notes.html' contain information on changes -made to the various releases. diff -Nru astyle-2.06/src/ASBeautifier.cpp astyle-3.0.1/src/ASBeautifier.cpp --- astyle-2.06/src/ASBeautifier.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASBeautifier.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASBeautifier.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. //----------------------------------------------------------------------------- // headers @@ -18,7 +18,7 @@ namespace astyle { // // this must be global -static int g_preprocessorCppExternCBracket; +static int g_preprocessorCppExternCBrace; //----------------------------------------------------------------------------- // ASBeautifier class @@ -31,28 +31,28 @@ */ ASBeautifier::ASBeautifier() { - waitingBeautifierStack = NULL; - activeBeautifierStack = NULL; - waitingBeautifierStackLengthStack = NULL; - activeBeautifierStackLengthStack = NULL; - - headerStack = NULL; - tempStacks = NULL; - blockParenDepthStack = NULL; - blockStatementStack = NULL; - parenStatementStack = NULL; - bracketBlockStateStack = NULL; - inStatementIndentStack = NULL; - inStatementIndentStackSizeStack = NULL; - parenIndentStack = NULL; - preprocIndentStack = NULL; - sourceIterator = NULL; + waitingBeautifierStack = nullptr; + activeBeautifierStack = nullptr; + waitingBeautifierStackLengthStack = nullptr; + activeBeautifierStackLengthStack = nullptr; + + headerStack = nullptr; + tempStacks = nullptr; + squareBracketDepthStack = nullptr; + blockStatementStack = nullptr; + parenStatementStack = nullptr; + braceBlockStateStack = nullptr; + continuationIndentStack = nullptr; + continuationIndentStackSizeStack = nullptr; + parenIndentStack = nullptr; + preprocIndentStack = nullptr; + sourceIterator = nullptr; isModeManuallySet = false; shouldForceTabIndentation = false; setSpaceIndentation(4); setContinuationIndentation(1); setMinConditionalIndentOption(MINCOND_TWO); - setMaxInStatementIndentLength(40); + setMaxContinuationIndentLength(40); classInitializerIndents = 1; tabLength = 0; setClassIndent(false); @@ -60,9 +60,10 @@ setSwitchIndent(false); setCaseIndent(false); setBlockIndent(false); - setBracketIndent(false); - setBracketIndentVtk(false); + setBraceIndent(false); + setBraceIndentVtk(false); setNamespaceIndent(false); + setAfterParenIndent(false); setLabelIndent(false); setEmptyLineFill(false); setCStyle(); @@ -93,10 +94,10 @@ ASBeautifier::ASBeautifier(const ASBeautifier& other) : ASBase(other) { // these don't need to copy the stack - waitingBeautifierStack = NULL; - activeBeautifierStack = NULL; - waitingBeautifierStackLengthStack = NULL; - activeBeautifierStackLengthStack = NULL; + waitingBeautifierStack = nullptr; + activeBeautifierStack = nullptr; + waitingBeautifierStackLengthStack = nullptr; + activeBeautifierStackLengthStack = nullptr; // vector '=' operator performs a DEEP copy of all elements in the vector @@ -105,8 +106,8 @@ tempStacks = copyTempStacks(other); - blockParenDepthStack = new vector; - *blockParenDepthStack = *other.blockParenDepthStack; + squareBracketDepthStack = new vector; + *squareBracketDepthStack = *other.squareBracketDepthStack; blockStatementStack = new vector; *blockStatementStack = *other.blockStatementStack; @@ -114,14 +115,14 @@ parenStatementStack = new vector; *parenStatementStack = *other.parenStatementStack; - bracketBlockStateStack = new vector; - *bracketBlockStateStack = *other.bracketBlockStateStack; + braceBlockStateStack = new vector; + *braceBlockStateStack = *other.braceBlockStateStack; - inStatementIndentStack = new vector; - *inStatementIndentStack = *other.inStatementIndentStack; + continuationIndentStack = new vector; + *continuationIndentStack = *other.continuationIndentStack; - inStatementIndentStackSizeStack = new vector; - *inStatementIndentStackSizeStack = *other.inStatementIndentStackSizeStack; + continuationIndentStackSizeStack = new vector; + *continuationIndentStackSizeStack = *other.continuationIndentStackSizeStack; parenIndentStack = new vector; *parenIndentStack = *other.parenIndentStack; @@ -145,8 +146,8 @@ // variables set by ASFormatter // must also be updated in activeBeautifierStack inLineNumber = other.inLineNumber; - horstmannIndentInStatement = other.horstmannIndentInStatement; - nonInStatementBracket = other.nonInStatementBracket; + runInIndentContinuation = other.runInIndentContinuation; + nonInStatementBrace = other.nonInStatementBrace; objCColonAlignSubsequent = other.objCColonAlignSubsequent; lineCommentNoBeautify = other.lineCommentNoBeautify; isElseHeaderIndent = other.isElseHeaderIndent; @@ -175,10 +176,10 @@ isInAsmBlock = other.isInAsmBlock; isInComment = other.isInComment; isInPreprocessorComment = other.isInPreprocessorComment; - isInHorstmannComment = other.isInHorstmannComment; + isInRunInComment = other.isInRunInComment; isInCase = other.isInCase; isInQuestion = other.isInQuestion; - isInStatement = other.isInStatement; + isContinuation = other.isContinuation; isInHeader = other.isInHeader; isInTemplate = other.isInTemplate; isInDefine = other.isInDefine; @@ -203,9 +204,10 @@ switchIndent = other.switchIndent; caseIndent = other.caseIndent; namespaceIndent = other.namespaceIndent; - bracketIndent = other.bracketIndent; - bracketIndentVtk = other.bracketIndentVtk; + braceIndent = other.braceIndent; + braceIndentVtk = other.braceIndentVtk; blockIndent = other.blockIndent; + shouldIndentAfterParen = other.shouldIndentAfterParen; labelIndent = other.labelIndent; isInConditional = other.isInConditional; isModeManuallySet = other.isModeManuallySet; @@ -218,12 +220,12 @@ blockCommentNoIndent = other.blockCommentNoIndent; blockCommentNoBeautify = other.blockCommentNoBeautify; previousLineProbationTab = other.previousLineProbationTab; - lineBeginsWithOpenBracket = other.lineBeginsWithOpenBracket; - lineBeginsWithCloseBracket = other.lineBeginsWithCloseBracket; + lineBeginsWithOpenBrace = other.lineBeginsWithOpenBrace; + lineBeginsWithCloseBrace = other.lineBeginsWithCloseBrace; lineBeginsWithComma = other.lineBeginsWithComma; lineIsCommentOnly = other.lineIsCommentOnly; lineIsLineCommentOnly = other.lineIsLineCommentOnly; - shouldIndentBrackettedLine = other.shouldIndentBrackettedLine; + shouldIndentBracedLine = other.shouldIndentBracedLine; isInSwitch = other.isInSwitch; foundPreCommandHeader = other.foundPreCommandHeader; foundPreCommandMacro = other.foundPreCommandMacro; @@ -233,7 +235,7 @@ indentCount = other.indentCount; spaceIndentCount = other.spaceIndentCount; spaceIndentObjCMethodAlignment = other.spaceIndentObjCMethodAlignment; - bracketPosObjCMethodAlignment = other.bracketPosObjCMethodAlignment; + bracePosObjCMethodAlignment = other.bracePosObjCMethodAlignment; colonIndentObjCMethodAlignment = other.colonIndentObjCMethodAlignment; lineOpeningBlocksNum = other.lineOpeningBlocksNum; lineClosingBlocksNum = other.lineClosingBlocksNum; @@ -245,10 +247,10 @@ tabLength = other.tabLength; continuationIndent = other.continuationIndent; blockTabCount = other.blockTabCount; - maxInStatementIndent = other.maxInStatementIndent; + maxContinuationIndent = other.maxContinuationIndent; classInitializerIndents = other.classInitializerIndents; templateDepth = other.templateDepth; - blockParenCount = other.blockParenCount; + squareBracketCount = other.squareBracketCount; prevFinalLineSpaceIndentCount = other.prevFinalLineSpaceIndentCount; prevFinalLineIndentCount = other.prevFinalLineIndentCount; defineIndentCount = other.defineIndentCount; @@ -271,12 +273,12 @@ deleteContainer(activeBeautifierStackLengthStack); deleteContainer(headerStack); deleteTempStacksContainer(tempStacks); - deleteContainer(blockParenDepthStack); + deleteContainer(squareBracketDepthStack); deleteContainer(blockStatementStack); deleteContainer(parenStatementStack); - deleteContainer(bracketBlockStateStack); - deleteContainer(inStatementIndentStack); - deleteContainer(inStatementIndentStackSizeStack); + deleteContainer(braceBlockStateStack); + deleteContainer(continuationIndentStack); + deleteContainer(continuationIndentStackSizeStack); deleteContainer(parenIndentStack); deleteContainer(preprocIndentStack); } @@ -297,7 +299,7 @@ sourceIterator = iter; initVectors(); ASBase::init(getFileType()); - g_preprocessorCppExternCBracket = 0; + g_preprocessorCppExternCBrace = 0; initContainer(waitingBeautifierStack, new vector); initContainer(activeBeautifierStack, new vector); @@ -308,21 +310,21 @@ initContainer(headerStack, new vector); initTempStacksContainer(tempStacks, new vector*>); - tempStacks->push_back(new vector); + tempStacks->emplace_back(new vector); - initContainer(blockParenDepthStack, new vector); + initContainer(squareBracketDepthStack, new vector); initContainer(blockStatementStack, new vector); initContainer(parenStatementStack, new vector); - initContainer(bracketBlockStateStack, new vector); - bracketBlockStateStack->push_back(true); - initContainer(inStatementIndentStack, new vector); - initContainer(inStatementIndentStackSizeStack, new vector); - inStatementIndentStackSizeStack->push_back(0); + initContainer(braceBlockStateStack, new vector); + braceBlockStateStack->push_back(true); + initContainer(continuationIndentStack, new vector); + initContainer(continuationIndentStackSizeStack, new vector); + continuationIndentStackSizeStack->emplace_back(0); initContainer(parenIndentStack, new vector); initContainer(preprocIndentStack, new vector >); - previousLastLineHeader = NULL; - currentHeader = NULL; + previousLastLineHeader = nullptr; + currentHeader = nullptr; isInQuote = false; isInVerbatimQuote = false; @@ -332,8 +334,8 @@ isInAsmBlock = false; isInComment = false; isInPreprocessorComment = false; - isInHorstmannComment = false; - isInStatement = false; + isInRunInComment = false; + isContinuation = false; isInCase = false; isInQuestion = false; isIndentModeOff = false; @@ -358,12 +360,12 @@ indentCount = 0; spaceIndentCount = 0; spaceIndentObjCMethodAlignment = 0; - bracketPosObjCMethodAlignment = 0; + bracePosObjCMethodAlignment = 0; colonIndentObjCMethodAlignment = 0; lineOpeningBlocksNum = 0; lineClosingBlocksNum = 0; templateDepth = 0; - blockParenCount = 0; + squareBracketCount = 0; parenDepth = 0; blockTabCount = 0; prevFinalLineSpaceIndentCount = 0; @@ -375,8 +377,8 @@ prevNonLegalCh = '{'; currentNonLegalCh = '{'; quoteChar = ' '; - probationHeader = NULL; - lastLineHeader = NULL; + probationHeader = nullptr; + lastLineHeader = nullptr; backslashEndsPrevLine = false; lineOpensWithLineComment = false; lineOpensWithComment = false; @@ -389,12 +391,12 @@ blockCommentNoIndent = false; blockCommentNoBeautify = false; previousLineProbationTab = false; - lineBeginsWithOpenBracket = false; - lineBeginsWithCloseBracket = false; + lineBeginsWithOpenBrace = false; + lineBeginsWithCloseBrace = false; lineBeginsWithComma = false; lineIsCommentOnly = false; lineIsLineCommentOnly = false; - shouldIndentBrackettedLine = true; + shouldIndentBracedLine = true; isInSwitch = false; foundPreCommandHeader = false; foundPreCommandMacro = false; @@ -407,8 +409,8 @@ isInIndentableStruct = false; isInIndentablePreproc = false; inLineNumber = 0; - horstmannIndentInStatement = 0; - nonInStatementBracket = 0; + runInIndentContinuation = 0; + nonInStatementBrace = 0; objCColonAlignSubsequent = 0; } @@ -531,9 +533,17 @@ * * @param max maximum indentation length. */ +void ASBeautifier::setMaxContinuationIndentLength(int max) +{ + maxContinuationIndent = max; +} + +// retained for compatability with release 2.06 +// "MaxInStatementIndent" has been changed to "MaxContinuationIndent" in 3.0 +// it is referenced only by the old "MaxInStatementIndent" options void ASBeautifier::setMaxInStatementIndentLength(int max) { - maxInStatementIndent = max; + setMaxContinuationIndentLength(max); } /** @@ -563,27 +573,27 @@ } /** - * set the state of the bracket indent option. If true, brackets will + * set the state of the brace indent option. If true, braces will * be indented one additional indent. * * @param state state of option. */ -void ASBeautifier::setBracketIndent(bool state) +void ASBeautifier::setBraceIndent(bool state) { - bracketIndent = state; + braceIndent = state; } /** -* set the state of the bracket indent VTK option. If true, brackets will -* be indented one additional indent, except for the opening bracket. +* set the state of the brace indent VTK option. If true, braces will +* be indented one additional indent, except for the opening brace. * * @param state state of option. */ -void ASBeautifier::setBracketIndentVtk(bool state) +void ASBeautifier::setBraceIndentVtk(bool state) { // need to set both of these - setBracketIndent(state); - bracketIndentVtk = state; + setBraceIndent(state); + braceIndentVtk = state; } /** @@ -654,6 +664,16 @@ } /** +* set the state of the indent after parens option. +* +* @param state state of option. +*/ +void ASBeautifier::setAfterParenIndent(bool state) +{ + shouldIndentAfterParen = state; +} + +/** * set the state of the label indentation option. * If true, labels will be indented one indent LESS than the * current indentation level. @@ -768,13 +788,13 @@ } /** - * get the state of the bracket indentation option. + * get the state of the brace indentation option. * - * @return state of bracketIndent option. + * @return state of braceIndent option. */ -bool ASBeautifier::getBracketIndent() const +bool ASBeautifier::getBraceIndent() const { - return bracketIndent; + return braceIndent; } /** @@ -880,17 +900,17 @@ string line; bool isInQuoteContinuation = isInVerbatimQuote || haveLineContinuationChar; - currentHeader = NULL; - lastLineHeader = NULL; + currentHeader = nullptr; + lastLineHeader = nullptr; blockCommentNoBeautify = blockCommentNoIndent; isInClass = false; isInSwitch = false; - lineBeginsWithOpenBracket = false; - lineBeginsWithCloseBracket = false; + lineBeginsWithOpenBrace = false; + lineBeginsWithCloseBrace = false; lineBeginsWithComma = false; lineIsCommentOnly = false; lineIsLineCommentOnly = false; - shouldIndentBrackettedLine = true; + shouldIndentBracedLine = true; isInAsmOneLine = false; lineOpensWithLineComment = false; lineOpensWithComment = false; @@ -928,14 +948,14 @@ trimEnd++; if (trimEnd < line.length()) line.erase(trimEnd); - // does a bracket open the line + // does a brace open the line size_t firstChar = line.find_first_not_of(" \t"); if (firstChar != string::npos) { if (line[firstChar] == '{') - lineBeginsWithOpenBracket = true; + lineBeginsWithOpenBrace = true; else if (line[firstChar] == '}') - lineBeginsWithCloseBracket = true; + lineBeginsWithCloseBrace = true; else if (line[firstChar] == ',') lineBeginsWithComma = true; } @@ -946,9 +966,9 @@ if (line.length() > 0) { if (line[0] == '{') - lineBeginsWithOpenBracket = true; + lineBeginsWithOpenBrace = true; else if (line[0] == '}') - lineBeginsWithCloseBracket = true; + lineBeginsWithCloseBrace = true; else if (line[0] == ',') lineBeginsWithComma = true; else if (line.compare(0, 2, "//") == 0) @@ -960,7 +980,7 @@ } } - isInHorstmannComment = false; + isInRunInComment = false; size_t j = line.find_first_not_of(" \t{"); if (j != string::npos && line.compare(j, 2, "//") == 0) lineOpensWithLineComment = true; @@ -969,7 +989,7 @@ lineOpensWithComment = true; size_t k = line.find_first_not_of(" \t"); if (k != string::npos && line.compare(k, 1, "{") == 0) - isInHorstmannComment = true; + isInRunInComment = true; } } @@ -984,8 +1004,16 @@ if (backslashEndsPrevLine) { backslashEndsPrevLine = false; - isInDefine = false; - isInDefineDefinition = false; + // check if this line ends a multi-line #define + // if so, remove the #define's cloned beautifier from the active + // beautifier stack and delete it. + if (isInDefineDefinition && !isInDefine) + { + isInDefineDefinition = false; + ASBeautifier* defineBeautifier = activeBeautifierStack->back(); + activeBeautifierStack->pop_back(); + delete defineBeautifier; + } } if (emptyLineFill && !isInQuoteContinuation) { @@ -1056,11 +1084,11 @@ if (preproc.length() >= 2 && preproc.substr(0, 2) == "if") // #if, #ifdef, #ifndef { pair entry; // indentCount, spaceIndentCount - if (!isInDefine && activeBeautifierStack != NULL && !activeBeautifierStack->empty()) + if (!isInDefine && activeBeautifierStack != nullptr && !activeBeautifierStack->empty()) entry = activeBeautifierStack->back()->computePreprocessorIndent(); else entry = computePreprocessorIndent(); - preprocIndentStack->push_back(entry); + preprocIndentStack->emplace_back(entry); indentedLine = preLineWS(preprocIndentStack->back().first, preprocIndentStack->back().second) + line; return getIndentedLineReturn(indentedLine, originalLine); @@ -1116,11 +1144,11 @@ // if there exists any worker beautifier in the activeBeautifierStack, // then use it instead of me to indent the current line. // variables set by ASFormatter must be updated. - if (!isInDefine && activeBeautifierStack != NULL && !activeBeautifierStack->empty()) + if (!isInDefine && activeBeautifierStack != nullptr && !activeBeautifierStack->empty()) { activeBeautifierStack->back()->inLineNumber = inLineNumber; - activeBeautifierStack->back()->horstmannIndentInStatement = horstmannIndentInStatement; - activeBeautifierStack->back()->nonInStatementBracket = nonInStatementBracket; + activeBeautifierStack->back()->runInIndentContinuation = runInIndentContinuation; + activeBeautifierStack->back()->nonInStatementBrace = nonInStatementBrace; activeBeautifierStack->back()->objCColonAlignSubsequent = objCColonAlignSubsequent; activeBeautifierStack->back()->lineCommentNoBeautify = lineCommentNoBeautify; activeBeautifierStack->back()->isElseHeaderIndent = isElseHeaderIndent; @@ -1140,9 +1168,9 @@ // The header in the header stack will be deleted by a one-line block. bool isInExtraHeaderIndent = false; if (!headerStack->empty() - && lineBeginsWithOpenBracket - && (headerStack->back() != &AS_OPEN_BRACKET - || probationHeader != NULL)) + && lineBeginsWithOpenBrace + && (headerStack->back() != &AS_OPEN_BRACE + || probationHeader != nullptr)) isInExtraHeaderIndent = true; size_t iPrelim = headerStack->size(); @@ -1170,8 +1198,8 @@ string preproc = trim(line.substr(1)); if (preproc.compare(0, 6, "define") == 0) { - if (!inStatementIndentStack->empty() - && inStatementIndentStack->back() > 0) + if (!continuationIndentStack->empty() + && continuationIndentStack->back() > 0) { defineIndentCount = indentCount; } @@ -1200,7 +1228,7 @@ prevFinalLineSpaceIndentCount = spaceIndentCount; prevFinalLineIndentCount = indentCount; - if (lastLineHeader != NULL) + if (lastLineHeader != nullptr) previousLastLineHeader = lastLineHeader; if ((lineIsLineCommentOnly || lineIsCommentOnly) @@ -1210,10 +1238,10 @@ return indentedLine; } -string& ASBeautifier::getIndentedLineReturn(string& newLine, const string& originalLine) const +const string& ASBeautifier::getIndentedLineReturn(const string& newLine, const string& originalLine) const { if (isIndentModeOff) - return const_cast(originalLine); + return originalLine; return newLine; } @@ -1245,32 +1273,32 @@ } /** - * register an in-statement indent. + * register a continuation indent. */ -void ASBeautifier::registerInStatementIndent(const string& line, int i, int spaceIndentCount_, - int tabIncrementIn, int minIndent, bool updateParenStack) +void ASBeautifier::registerContinuationIndent(const string& line, int i, int spaceIndentCount_, + int tabIncrementIn, int minIndent, bool updateParenStack) { int remainingCharNum = line.length() - i; int nextNonWSChar = getNextProgramCharDistance(line, i); - // if indent is around the last char in the line, indent with the continuation indent - if (nextNonWSChar == remainingCharNum) + // if indent is around the last char in the line OR indent-after-paren is requested, + // indent with the continuation indent + if (nextNonWSChar == remainingCharNum || shouldIndentAfterParen) { int previousIndent = spaceIndentCount_; - if (!inStatementIndentStack->empty()) - previousIndent = inStatementIndentStack->back(); + if (!continuationIndentStack->empty()) + previousIndent = continuationIndentStack->back(); int currIndent = continuationIndent * indentLength + previousIndent; - if (currIndent > maxInStatementIndent - && line[i] != '{') + if (currIndent > maxContinuationIndent && line[i] != '{') currIndent = indentLength * 2 + spaceIndentCount_; - inStatementIndentStack->push_back(currIndent); + continuationIndentStack->emplace_back(currIndent); if (updateParenStack) - parenIndentStack->push_back(previousIndent); + parenIndentStack->emplace_back(previousIndent); return; } if (updateParenStack) - parenIndentStack->push_back(i + spaceIndentCount_ - horstmannIndentInStatement); + parenIndentStack->emplace_back(i + spaceIndentCount_ - runInIndentContinuation); int tabIncrement = tabIncrementIn; @@ -1281,35 +1309,36 @@ tabIncrement += convertTabToSpaces(j, tabIncrement); } - int inStatementIndent = i + nextNonWSChar + spaceIndentCount_ + tabIncrement; + int continuationIndentCount = i + nextNonWSChar + spaceIndentCount_ + tabIncrement; // check for run-in statement if (i > 0 && line[0] == '{') - inStatementIndent -= indentLength; + continuationIndentCount -= indentLength; - if (inStatementIndent < minIndent) - inStatementIndent = minIndent + spaceIndentCount_; + if (continuationIndentCount < minIndent) + continuationIndentCount = minIndent + spaceIndentCount_; // this is not done for an in-statement array - if (inStatementIndent > maxInStatementIndent + if (continuationIndentCount > maxContinuationIndent && !(prevNonLegalCh == '=' && currentNonLegalCh == '{')) - inStatementIndent = indentLength * 2 + spaceIndentCount_; + continuationIndentCount = indentLength * 2 + spaceIndentCount_; - if (!inStatementIndentStack->empty() - && inStatementIndent < inStatementIndentStack->back()) - inStatementIndent = inStatementIndentStack->back(); + if (!continuationIndentStack->empty() + && continuationIndentCount < continuationIndentStack->back()) + continuationIndentCount = continuationIndentStack->back(); // the block opener is not indented for a NonInStatementArray - if (isNonInStatementArray && !isInEnum && !bracketBlockStateStack->empty() && bracketBlockStateStack->back()) - inStatementIndent = 0; + if ((isNonInStatementArray && line[i] == '{') + && !isInEnum && !braceBlockStateStack->empty() && braceBlockStateStack->back()) + continuationIndentCount = 0; - inStatementIndentStack->push_back(inStatementIndent); + continuationIndentStack->emplace_back(continuationIndentCount); } /** -* Register an in-statement indent for a class header or a class initializer colon. +* Register a continuation indent for a class header or a class initializer colon. */ -void ASBeautifier::registerInStatementIndentColon(const string& line, int i, int tabIncrementIn) +void ASBeautifier::registerContinuationIndentColon(const string& line, int i, int tabIncrementIn) { assert(line[i] == ':'); assert(isInClassInitializer || isInClassHeaderTab); @@ -1319,11 +1348,11 @@ if (firstChar == (size_t) i) // firstChar is ':' { size_t firstWord = line.find_first_not_of(" \t", firstChar + 1); - if (firstChar != string::npos) + if (firstWord != string::npos) { - int inStatementIndent = firstWord + spaceIndentCount + tabIncrementIn; - inStatementIndentStack->push_back(inStatementIndent); - isInStatement = true; + int continuationIndentCount = firstWord + spaceIndentCount + tabIncrementIn; + continuationIndentStack->emplace_back(continuationIndentCount); + isContinuation = true; } } } @@ -1389,64 +1418,6 @@ return charDistance; } -// check if a specific line position contains a header. -const string* ASBeautifier::findHeader(const string& line, int i, - const vector* possibleHeaders) const -{ - assert(isCharPotentialHeader(line, i)); - // check the word - size_t maxHeaders = possibleHeaders->size(); - for (size_t p = 0; p < maxHeaders; p++) - { - const string* header = (*possibleHeaders)[p]; - const size_t wordEnd = i + header->length(); - if (wordEnd > line.length()) - continue; - int result = (line.compare(i, header->length(), *header)); - if (result > 0) - continue; - if (result < 0) - break; - // check that this is not part of a longer word - if (wordEnd == line.length()) - return header; - if (isLegalNameChar(line[wordEnd])) - continue; - const char peekChar = peekNextChar(line, wordEnd - 1); - // is not a header if part of a definition - if (peekChar == ',' || peekChar == ')') - break; - // the following accessor definitions are NOT headers - // goto default; is NOT a header - // default(int) keyword in C# is NOT a header - else if ((header == &AS_GET || header == &AS_SET || header == &AS_DEFAULT) - && (peekChar == ';' || peekChar == '(' || peekChar == '=')) - break; - return header; - } - return NULL; -} - -// check if a specific line position contains an operator. -const string* ASBeautifier::findOperator(const string& line, int i, - const vector* possibleOperators) const -{ - assert(isCharPotentialOperator(line[i])); - // find the operator in the vector - // the vector contains the LONGEST operators first - // must loop thru the entire vector - size_t maxOperators = possibleOperators->size(); - for (size_t p = 0; p < maxOperators; p++) - { - const size_t wordEnd = i + (*(*possibleOperators)[p]).length(); - if (wordEnd > line.length()) - continue; - if (line.compare(i, (*(*possibleOperators)[p]).length(), *(*possibleOperators)[p]) == 0) - return (*possibleOperators)[p]; - } - return NULL; -} - /** * find the index number of a string element in a container of strings * @@ -1454,7 +1425,7 @@ * @param container a vector of strings. * @param element the element to find . */ -int ASBeautifier::indexOf(vector& container, const string* element) const +int ASBeautifier::indexOf(const vector& container, const string* element) const { vector::const_iterator where; @@ -1532,7 +1503,7 @@ { vector* newVec = new vector; *newVec = **iter; - tempStacksNew->push_back(newVec); + tempStacksNew->emplace_back(newVec); } return tempStacksNew; } @@ -1560,11 +1531,11 @@ template void ASBeautifier::deleteContainer(T& container) { - if (container != NULL) + if (container != nullptr) { container->clear(); delete (container); - container = NULL; + container = nullptr; } } @@ -1576,7 +1547,7 @@ */ void ASBeautifier::deleteBeautifierContainer(vector*& container) { - if (container != NULL) + if (container != nullptr) { vector::iterator iter = container->begin(); while (iter < container->end()) @@ -1586,7 +1557,7 @@ } container->clear(); delete (container); - container = NULL; + container = nullptr; } } @@ -1597,7 +1568,7 @@ */ void ASBeautifier::deleteTempStacksContainer(vector*>*& container) { - if (container != NULL) + if (container != nullptr) { vector*>::iterator iter = container->begin(); while (iter < container->end()) @@ -1607,7 +1578,7 @@ } container->clear(); delete (container); - container = NULL; + container = nullptr; } } @@ -1620,7 +1591,7 @@ { // since the ASFormatter object is never deleted, // the existing vectors must be deleted before creating new ones - if (container != NULL) + if (container != nullptr) deleteContainer(container); container = value; } @@ -1633,7 +1604,7 @@ void ASBeautifier::initTempStacksContainer(vector*>*& container, vector*>* value) { - if (container != NULL) + if (container != nullptr) deleteTempStacksContainer(container); container = value; } @@ -1749,7 +1720,7 @@ * * @return is the index to the previous word (the in statement indent). */ -int ASBeautifier::getInStatementIndentAssign(const string& line, size_t currPos) const +int ASBeautifier::getContinuationIndentAssign(const string& line, size_t currPos) const { assert(line[currPos] == '='); @@ -1777,7 +1748,7 @@ * * @return is the indent to the second word on the line (the in statement indent). */ -int ASBeautifier::getInStatementIndentComma(const string& line, size_t currPos) const +int ASBeautifier::getContinuationIndentComma(const string& line, size_t currPos) const { assert(line[currPos] == ','); @@ -1894,7 +1865,7 @@ // check for " #if defined(__cplusplus)" size_t charNum = 2; charNum = preproc.find_first_not_of(" \t", charNum); - if (preproc.compare(charNum, 7, "defined") == 0) + if (charNum != string::npos && preproc.compare(charNum, 7, "defined") == 0) { charNum += 7; charNum = preproc.find_first_not_of(" \t", charNum); @@ -1934,14 +1905,14 @@ return true; } -void ASBeautifier::popLastInStatementIndent() +void ASBeautifier::popLastContinuationIndent() { - assert(!inStatementIndentStackSizeStack->empty()); - int previousIndentStackSize = inStatementIndentStackSizeStack->back(); - if (inStatementIndentStackSizeStack->size() > 1) - inStatementIndentStackSizeStack->pop_back(); - while (previousIndentStackSize < (int) inStatementIndentStack->size()) - inStatementIndentStack->pop_back(); + assert(!continuationIndentStackSizeStack->empty()); + int previousIndentStackSize = continuationIndentStackSizeStack->back(); + if (continuationIndentStackSizeStack->size() > 1) + continuationIndentStackSizeStack->pop_back(); + while (previousIndentStackSize < (int) continuationIndentStack->size()) + continuationIndentStack->pop_back(); } // for unit testing @@ -1970,7 +1941,7 @@ // push a new beautifier into the active stack // this beautifier will be used for the indentation of this define ASBeautifier* defineBeautifier = new ASBeautifier(*this); - activeBeautifierStack->push_back(defineBeautifier); + activeBeautifierStack->emplace_back(defineBeautifier); } else { @@ -1980,39 +1951,39 @@ } else if (preproc.length() >= 2 && preproc.substr(0, 2) == "if") { - if (isPreprocessorConditionalCplusplus(line) && !g_preprocessorCppExternCBracket) - g_preprocessorCppExternCBracket = 1; + if (isPreprocessorConditionalCplusplus(line) && !g_preprocessorCppExternCBrace) + g_preprocessorCppExternCBrace = 1; // push a new beautifier into the stack waitingBeautifierStackLengthStack->push_back(waitingBeautifierStack->size()); activeBeautifierStackLengthStack->push_back(activeBeautifierStack->size()); if (activeBeautifierStackLengthStack->back() == 0) - waitingBeautifierStack->push_back(new ASBeautifier(*this)); + waitingBeautifierStack->emplace_back(new ASBeautifier(*this)); else - waitingBeautifierStack->push_back(new ASBeautifier(*activeBeautifierStack->back())); + waitingBeautifierStack->emplace_back(new ASBeautifier(*activeBeautifierStack->back())); } else if (preproc == "else") { - if (waitingBeautifierStack && !waitingBeautifierStack->empty()) + if ((waitingBeautifierStack != nullptr) && !waitingBeautifierStack->empty()) { // MOVE current waiting beautifier to active stack. - activeBeautifierStack->push_back(waitingBeautifierStack->back()); + activeBeautifierStack->emplace_back(waitingBeautifierStack->back()); waitingBeautifierStack->pop_back(); } } else if (preproc == "elif") { - if (waitingBeautifierStack && !waitingBeautifierStack->empty()) + if ((waitingBeautifierStack != nullptr) && !waitingBeautifierStack->empty()) { // append a COPY current waiting beautifier to active stack, WITHOUT deleting the original. - activeBeautifierStack->push_back(new ASBeautifier(*(waitingBeautifierStack->back()))); + activeBeautifierStack->emplace_back(new ASBeautifier(*(waitingBeautifierStack->back()))); } } else if (preproc == "endif") { int stackLength = 0; - ASBeautifier* beautifier = NULL; + ASBeautifier* beautifier = nullptr; - if (waitingBeautifierStackLengthStack != NULL && !waitingBeautifierStackLengthStack->empty()) + if (waitingBeautifierStackLengthStack != nullptr && !waitingBeautifierStackLengthStack->empty()) { stackLength = waitingBeautifierStackLengthStack->back(); waitingBeautifierStackLengthStack->pop_back(); @@ -2047,11 +2018,11 @@ spaceIndentCount = 0; isInClassHeaderTab = false; - if (isInObjCMethodDefinition && !inStatementIndentStack->empty()) - spaceIndentObjCMethodAlignment = inStatementIndentStack->back(); + if (isInObjCMethodDefinition && !continuationIndentStack->empty()) + spaceIndentObjCMethodAlignment = continuationIndentStack->back(); - if (!inStatementIndentStack->empty()) - spaceIndentCount = inStatementIndentStack->back(); + if (!continuationIndentStack->empty()) + spaceIndentCount = continuationIndentStack->back(); for (size_t i = 0; i < headerStack->size(); i++) { @@ -2070,19 +2041,19 @@ || (*headerStack)[i] == &AS_STATIC)) ++indentCount; } - else if (!(i > 0 && (*headerStack)[i - 1] != &AS_OPEN_BRACKET - && (*headerStack)[i] == &AS_OPEN_BRACKET)) + else if (!(i > 0 && (*headerStack)[i - 1] != &AS_OPEN_BRACE + && (*headerStack)[i] == &AS_OPEN_BRACE)) ++indentCount; if (!isJavaStyle() && !namespaceIndent && i > 0 && ((*headerStack)[i - 1] == &AS_NAMESPACE || (*headerStack)[i - 1] == &AS_MODULE) - && (*headerStack)[i] == &AS_OPEN_BRACKET) + && (*headerStack)[i] == &AS_OPEN_BRACE) --indentCount; if (isCStyle() && i >= 1 && (*headerStack)[i - 1] == &AS_CLASS - && (*headerStack)[i] == &AS_OPEN_BRACKET) + && (*headerStack)[i] == &AS_OPEN_BRACE) { if (classIndent) ++indentCount; @@ -2092,7 +2063,7 @@ // is the switchIndent option is on, indent switch statements an additional indent. else if (switchIndent && i > 1 && (*headerStack)[i - 1] == &AS_SWITCH - && (*headerStack)[i] == &AS_OPEN_BRACKET) + && (*headerStack)[i] == &AS_OPEN_BRACE) { ++indentCount; isInSwitch = true; @@ -2106,14 +2077,14 @@ isInClassHeaderTab = true; if (lineOpensWithLineComment || lineStartsInComment || lineOpensWithComment) { - if (!lineBeginsWithOpenBracket) + if (!lineBeginsWithOpenBrace) --indentCount; - if (!inStatementIndentStack->empty()) - spaceIndentCount -= inStatementIndentStack->back(); + if (!continuationIndentStack->empty()) + spaceIndentCount -= continuationIndentStack->back(); } else if (blockIndent) { - if (!lineBeginsWithOpenBracket) + if (!lineBeginsWithOpenBrace) ++indentCount; } } @@ -2123,11 +2094,11 @@ indentCount += classInitializerIndents; } - if (isInEnum && lineBeginsWithComma && !inStatementIndentStack->empty()) + if (isInEnum && lineBeginsWithComma && !continuationIndentStack->empty()) { // unregister '=' indent from the previous line - inStatementIndentStack->pop_back(); - isInStatement = false; + continuationIndentStack->pop_back(); + isContinuation = false; spaceIndentCount = 0; } @@ -2135,32 +2106,32 @@ if (isInObjCInterface) ++indentCount; - // unindent a class closing bracket... + // unindent a class closing brace... if (!lineStartsInComment && isCStyle() && isInClass && classIndent && headerStack->size() >= 2 && (*headerStack)[headerStack->size() - 2] == &AS_CLASS - && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET - && lineBeginsWithCloseBracket - && bracketBlockStateStack->back()) + && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE + && lineBeginsWithCloseBrace + && braceBlockStateStack->back()) --indentCount; - // unindent an indented switch closing bracket... + // unindent an indented switch closing brace... else if (!lineStartsInComment && isInSwitch && switchIndent && headerStack->size() >= 2 && (*headerStack)[headerStack->size() - 2] == &AS_SWITCH - && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET - && lineBeginsWithCloseBracket) + && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE + && lineBeginsWithCloseBrace) --indentCount; - // handle special case of horstmann comment in an indented class statement + // handle special case of run-in comment in an indented class statement if (isInClass && classIndent - && isInHorstmannComment + && isInRunInComment && !lineOpensWithComment && headerStack->size() > 1 && (*headerStack)[headerStack->size() - 2] == &AS_CLASS) @@ -2168,7 +2139,7 @@ if (isInConditional) --indentCount; - if (g_preprocessorCppExternCBracket >= 4) + if (g_preprocessorCppExternCBrace >= 4) --indentCount; } @@ -2179,11 +2150,11 @@ // unindent a one-line statement in a header indent if (!blockIndent - && lineBeginsWithOpenBracket + && lineBeginsWithOpenBrace && headerStack->size() < iPrelim && isInExtraHeaderIndent && (lineOpeningBlocksNum > 0 && lineOpeningBlocksNum <= lineClosingBlocksNum) - && shouldIndentBrackettedLine) + && shouldIndentBracedLine) --indentCount; /* @@ -2192,24 +2163,24 @@ * by one indentation relative to its block. */ else if (!blockIndent - && lineBeginsWithOpenBracket + && lineBeginsWithOpenBrace && !(lineOpeningBlocksNum > 0 && lineOpeningBlocksNum <= lineClosingBlocksNum) - && (headerStack->size() > 1 && (*headerStack)[headerStack->size() - 2] != &AS_OPEN_BRACKET) - && shouldIndentBrackettedLine) + && (headerStack->size() > 1 && (*headerStack)[headerStack->size() - 2] != &AS_OPEN_BRACE) + && shouldIndentBracedLine) --indentCount; // must check one less in headerStack if more than one header on a line (allow-addins)... else if (headerStack->size() > iPrelim + 1 && !blockIndent - && lineBeginsWithOpenBracket + && lineBeginsWithOpenBrace && !(lineOpeningBlocksNum > 0 && lineOpeningBlocksNum <= lineClosingBlocksNum) - && (headerStack->size() > 2 && (*headerStack)[headerStack->size() - 3] != &AS_OPEN_BRACKET) - && shouldIndentBrackettedLine) + && (headerStack->size() > 2 && (*headerStack)[headerStack->size() - 3] != &AS_OPEN_BRACE) + && shouldIndentBracedLine) --indentCount; - // unindent a closing bracket... - else if (lineBeginsWithCloseBracket - && shouldIndentBrackettedLine) + // unindent a closing brace... + else if (lineBeginsWithCloseBrace + && shouldIndentBracedLine) --indentCount; // correctly indent one-line-blocks... @@ -2221,18 +2192,18 @@ if (indentCount < 0) indentCount = 0; - // take care of extra bracket indentation option... + // take care of extra brace indentation option... if (!lineStartsInComment - && bracketIndent - && shouldIndentBrackettedLine - && (lineBeginsWithOpenBracket || lineBeginsWithCloseBracket)) + && braceIndent + && shouldIndentBracedLine + && (lineBeginsWithOpenBrace || lineBeginsWithCloseBrace)) { - if (!bracketIndentVtk) + if (!braceIndentVtk) ++indentCount; else { - // determine if a style VTK bracket is indented - bool haveUnindentedBracket = false; + // determine if a style VTK brace is indented + bool haveUnindentedBrace = false; for (size_t i = 0; i < headerStack->size(); i++) { if (((*headerStack)[i] == &AS_NAMESPACE @@ -2240,19 +2211,19 @@ || (*headerStack)[i] == &AS_CLASS || (*headerStack)[i] == &AS_STRUCT) && i + 1 < headerStack->size() - && (*headerStack)[i + 1] == &AS_OPEN_BRACKET) + && (*headerStack)[i + 1] == &AS_OPEN_BRACE) i++; - else if (lineBeginsWithOpenBracket) + else if (lineBeginsWithOpenBrace) { - // don't double count the current bracket + // don't double count the current brace if (i + 1 < headerStack->size() - && (*headerStack)[i] == &AS_OPEN_BRACKET) - haveUnindentedBracket = true; + && (*headerStack)[i] == &AS_OPEN_BRACE) + haveUnindentedBrace = true; } - else if ((*headerStack)[i] == &AS_OPEN_BRACKET) - haveUnindentedBracket = true; + else if ((*headerStack)[i] == &AS_OPEN_BRACE) + haveUnindentedBrace = true; } // end of for loop - if (haveUnindentedBracket) + if (haveUnindentedBrace) ++indentCount; } } @@ -2268,7 +2239,7 @@ assert(isElseHeaderIndent && !tempStacks->empty()); int indentCountIncrement = 0; vector* lastTempStack = tempStacks->back(); - if (lastTempStack != NULL) + if (lastTempStack != nullptr) { for (size_t i = 0; i < lastTempStack->size(); i++) { @@ -2310,19 +2281,19 @@ if (objCColonAlignSubsequentIndent > colonIndentObjCMethodAlignment) colonIndentObjCMethodAlignment = objCColonAlignSubsequentIndent; } - else if (inStatementIndentStack->empty() - || inStatementIndentStack->back() == 0) + else if (continuationIndentStack->empty() + || continuationIndentStack->back() == 0) { - inStatementIndentStack->push_back(indentLength); - isInStatement = true; + continuationIndentStack->emplace_back(indentLength); + isContinuation = true; } } // set indent for last definition line - else if (!lineBeginsWithOpenBracket) + else if (!lineBeginsWithOpenBrace) { if (shouldAlignMethodColon) spaceIndentCount = computeObjCColonAlignment(line_, colonIndentObjCMethodAlignment); - else if (inStatementIndentStack->empty()) + else if (continuationIndentStack->empty()) spaceIndentCount = spaceIndentObjCMethodAlignment; } } @@ -2336,16 +2307,16 @@ { isInObjCMethodCallFirst = false; string convertedLine = getIndentedSpaceEquivalent(line_); - bracketPosObjCMethodAlignment = convertedLine.find('['); + bracePosObjCMethodAlignment = convertedLine.find('['); keywordIndentObjCMethodAlignment = - getObjCFollowingKeyword(convertedLine, bracketPosObjCMethodAlignment); + getObjCFollowingKeyword(convertedLine, bracePosObjCMethodAlignment); colonIndentObjCMethodAlignment = convertedLine.find(':'); if (colonIndentObjCMethodAlignment >= 0) { int objCColonAlignSubsequentIndent = objCColonAlignSubsequent + indentLength; if (objCColonAlignSubsequentIndent > colonIndentObjCMethodAlignment) colonIndentObjCMethodAlignment = objCColonAlignSubsequentIndent; - if (lineBeginsWithOpenBracket) + if (lineBeginsWithOpenBrace) colonIndentObjCMethodAlignment -= indentLength; } } @@ -2373,13 +2344,13 @@ { isInObjCMethodCallFirst = false; string convertedLine = getIndentedSpaceEquivalent(line_); - bracketPosObjCMethodAlignment = convertedLine.find('['); + bracePosObjCMethodAlignment = convertedLine.find('['); keywordIndentObjCMethodAlignment = - getObjCFollowingKeyword(convertedLine, bracketPosObjCMethodAlignment); + getObjCFollowingKeyword(convertedLine, bracePosObjCMethodAlignment); } else { - if (spaceIndentCount < keywordIndentObjCMethodAlignment + bracketPosObjCMethodAlignment) + if (spaceIndentCount < keywordIndentObjCMethodAlignment + bracePosObjCMethodAlignment) spaceIndentCount += keywordIndentObjCMethodAlignment; } } @@ -2396,8 +2367,8 @@ colonIndentObjCMethodAlignment = 0; isInObjCMethodDefinition = false; isImmediatelyPostObjCMethodDefinition = false; - if (!inStatementIndentStack->empty()) - inStatementIndentStack->pop_back(); + if (!continuationIndentStack->empty()) + continuationIndentStack->pop_back(); } /** @@ -2417,10 +2388,10 @@ /* * Compute postition of the keyword following the method call object. */ -int ASBeautifier::getObjCFollowingKeyword(const string& line, int bracketPos) const +int ASBeautifier::getObjCFollowingKeyword(const string& line, int bracePos) const { - assert(line[bracketPos] == '['); - size_t firstText = line.find_first_not_of(" \t", bracketPos + 1); + assert(line[bracePos] == '['); + size_t firstText = line.find_first_not_of(" \t", bracePos + 1); if (firstText == string::npos) return -(indentCount * indentLength - 1); size_t searchBeg = firstText; @@ -2483,8 +2454,8 @@ bool isSpecialChar = false; bool haveCaseIndent = false; bool haveAssignmentThisLine = false; - bool closingBracketReached = false; - bool previousLineProbation = (probationHeader != NULL); + bool closingBraceReached = false; + bool previousLineProbation = (probationHeader != nullptr); char ch = ' '; int tabIncrementIn = 0; if (isInQuote @@ -2556,8 +2527,8 @@ else if (isSharpStyle() && prevCh == '@') isInVerbatimQuote = true; // check for "C" following "extern" - else if (g_preprocessorCppExternCBracket == 2 && line.compare(i, 3, "\"C\"") == 0) - ++g_preprocessorCppExternCBracket; + else if (g_preprocessorCppExternCBrace == 2 && line.compare(i, 3, "\"C\"") == 0) + ++g_preprocessorCppExternCBrace; } else if (isInVerbatimQuote && ch == '"') { @@ -2586,7 +2557,7 @@ else if (quoteChar == ch) { isInQuote = false; - isInStatement = true; + isContinuation = true; continue; } } @@ -2676,19 +2647,19 @@ // if we have reached this far then we are NOT in a comment or string of special character... - if (probationHeader != NULL) + if (probationHeader != nullptr) { if ((probationHeader == &AS_STATIC && ch == '{') || (probationHeader == &AS_SYNCHRONIZED && ch == '(')) { // insert the probation header as a new header isInHeader = true; - headerStack->push_back(probationHeader); + headerStack->emplace_back(probationHeader); // handle the specific probation header isInConditional = (probationHeader == &AS_SYNCHRONIZED); - isInStatement = false; + isContinuation = false; // if the probation comes from the previous line, then indent by 1 tab count. if (previousLineProbation && ch == '{' @@ -2701,7 +2672,7 @@ } // dismiss the probation header - probationHeader = NULL; + probationHeader = nullptr; } prevNonSpaceCh = currentNonSpaceCh; @@ -2718,7 +2689,7 @@ currentHeader = headerStack->back(); } else - currentHeader = NULL; + currentHeader = nullptr; if (isCStyle() && isInTemplate && (ch == '<' || ch == '>') @@ -2727,12 +2698,12 @@ if (ch == '<') { ++templateDepth; - inStatementIndentStackSizeStack->push_back(inStatementIndentStack->size()); - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); + continuationIndentStackSizeStack->push_back(continuationIndentStack->size()); + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); } else if (ch == '>') { - popLastInStatementIndent(); + popLastContinuationIndent(); if (--templateDepth <= 0) { ch = ';'; @@ -2763,34 +2734,34 @@ if (parenDepth == 0) { - parenStatementStack->push_back(isInStatement); - isInStatement = true; + parenStatementStack->push_back(isContinuation); + isContinuation = true; } parenDepth++; if (ch == '[') { - ++blockParenCount; - if (blockParenCount == 1 && isCStyle()) + ++squareBracketCount; + if (squareBracketCount == 1 && isCStyle()) { isInObjCMethodCall = true; isInObjCMethodCallFirst = true; } } - inStatementIndentStackSizeStack->push_back(inStatementIndentStack->size()); + continuationIndentStackSizeStack->push_back(continuationIndentStack->size()); - if (currentHeader != NULL) - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, minConditionalIndent/*indentLength*2*/, true); + if (currentHeader != nullptr) + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, minConditionalIndent, true); else - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); } else if (ch == ')' || ch == ']') { if (ch == ']') - --blockParenCount; - if (blockParenCount <= 0) + --squareBracketCount; + if (squareBracketCount <= 0) { - blockParenCount = 0; + squareBracketCount = 0; if (isInObjCMethodCall) isImmediatelyPostObjCMethodCall = true; } @@ -2800,16 +2771,16 @@ { if (!parenStatementStack->empty()) // in case of unmatched closing parens { - isInStatement = parenStatementStack->back(); + isContinuation = parenStatementStack->back(); parenStatementStack->pop_back(); } isInAsm = false; isInConditional = false; } - if (!inStatementIndentStackSizeStack->empty()) + if (!continuationIndentStackSizeStack->empty()) { - popLastInStatementIndent(); + popLastContinuationIndent(); if (!parenIndentStack->empty()) { @@ -2827,7 +2798,7 @@ if (ch == '{') { // first, check if '{' is a block-opener or a static-array opener - bool isBlockOpener = ((prevNonSpaceCh == '{' && bracketBlockStateStack->back()) + bool isBlockOpener = ((prevNonSpaceCh == '{' && braceBlockStateStack->back()) || prevNonSpaceCh == '}' || prevNonSpaceCh == ')' || prevNonSpaceCh == ';' @@ -2852,14 +2823,25 @@ { objCColonAlignSubsequent = 0; isImmediatelyPostObjCMethodDefinition = true; - if (lineBeginsWithOpenBracket) // for horstmann brackets + if (lineBeginsWithOpenBrace) // for run-in braces clearObjCMethodDefinitionAlignment(); } - if (!isBlockOpener && !isInStatement && !isInClassInitializer && !isInEnum) + if (!isBlockOpener && !isContinuation && !isInClassInitializer && !isInEnum) { if (headerStack->empty()) isBlockOpener = true; + else if (headerStack->back() == &AS_OPEN_BRACE + && headerStack->size() >= 2) + { + if ((*headerStack)[headerStack->size() - 2] == &AS_NAMESPACE + || (*headerStack)[headerStack->size() - 2] == &AS_MODULE + || (*headerStack)[headerStack->size() - 2] == &AS_CLASS + || (*headerStack)[headerStack->size() - 2] == &AS_INTERFACE + || (*headerStack)[headerStack->size() - 2] == &AS_STRUCT + || (*headerStack)[headerStack->size() - 2] == &AS_UNION) + isBlockOpener = true; + } else if (headerStack->back() == &AS_NAMESPACE || headerStack->back() == &AS_MODULE || headerStack->back() == &AS_CLASS @@ -2869,7 +2851,7 @@ isBlockOpener = true; } - if (!isBlockOpener && currentHeader != NULL) + if (!isBlockOpener && currentHeader != nullptr) { for (size_t n = 0; n < nonParenHeaders->size(); n++) if (currentHeader == (*nonParenHeaders)[n]) @@ -2879,28 +2861,28 @@ } } - bracketBlockStateStack->push_back(isBlockOpener); + braceBlockStateStack->push_back(isBlockOpener); if (!isBlockOpener) { - inStatementIndentStackSizeStack->push_back(inStatementIndentStack->size()); - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); + continuationIndentStackSizeStack->push_back(continuationIndentStack->size()); + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, 0, true); parenDepth++; if (i == 0) - shouldIndentBrackettedLine = false; + shouldIndentBracedLine = false; isInEnumTypeID = false; continue; } - // this bracket is a block opener... + // this brace is a block opener... ++lineOpeningBlocksNum; if (isInClassInitializer || isInEnumTypeID) { - // decrease tab count if bracket is broken - if (lineBeginsWithOpenBracket) + // decrease tab count if brace is broken + if (lineBeginsWithOpenBrace) { indentCount -= classInitializerIndents; // decrease one more if an empty class @@ -2917,15 +2899,15 @@ if (isInObjCInterface) { isInObjCInterface = false; - if (lineBeginsWithOpenBracket) + if (lineBeginsWithOpenBrace) --indentCount; } - if (bracketIndent && !namespaceIndent && !headerStack->empty() + if (braceIndent && !namespaceIndent && !headerStack->empty() && ((*headerStack).back() == &AS_NAMESPACE || (*headerStack).back() == &AS_MODULE)) { - shouldIndentBrackettedLine = false; + shouldIndentBracedLine = false; --indentCount; } @@ -2935,41 +2917,41 @@ && isInIndentableStruct) (*headerStack).back() = &AS_CLASS; - blockParenDepthStack->push_back(parenDepth); - blockStatementStack->push_back(isInStatement); + squareBracketDepthStack->emplace_back(parenDepth); + blockStatementStack->push_back(isContinuation); - if (!inStatementIndentStack->empty()) + if (!continuationIndentStack->empty()) { // completely purge the inStatementIndentStack - while (!inStatementIndentStack->empty()) - popLastInStatementIndent(); + while (!continuationIndentStack->empty()) + popLastContinuationIndent(); if (isInClassInitializer || isInClassHeaderTab) { - if (lineBeginsWithOpenBracket || lineBeginsWithComma) + if (lineBeginsWithOpenBrace || lineBeginsWithComma) spaceIndentCount = 0; } else spaceIndentCount = 0; } - blockTabCount += (isInStatement ? 1 : 0); - if (g_preprocessorCppExternCBracket == 3) - ++g_preprocessorCppExternCBracket; + blockTabCount += (isContinuation ? 1 : 0); + if (g_preprocessorCppExternCBrace == 3) + ++g_preprocessorCppExternCBrace; parenDepth = 0; isInClassHeader = false; isInClassHeaderTab = false; isInClassInitializer = false; isInEnumTypeID = false; - isInStatement = false; + isContinuation = false; isInQuestion = false; isInLet = false; foundPreCommandHeader = false; foundPreCommandMacro = false; isInExternC = false; - tempStacks->push_back(new vector); - headerStack->push_back(&AS_OPEN_BRACKET); - lastLineHeader = &AS_OPEN_BRACKET; + tempStacks->emplace_back(new vector); + headerStack->emplace_back(&AS_OPEN_BRACE); + lastLineHeader = &AS_OPEN_BRACE; continue; } // end '{' @@ -2977,7 +2959,7 @@ //check if a header has been reached bool isPotentialHeader = isCharPotentialHeader(line, i); - if (isPotentialHeader && !blockParenCount) + if (isPotentialHeader && squareBracketCount == 0) { const string* newHeader = findHeader(line, i, headers); @@ -2986,20 +2968,20 @@ && (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH)) { if (line.find_first_of("=;", i) != string::npos) - newHeader = NULL; + newHeader = nullptr; } else if (newHeader == &AS_USING && ASBeautifier::peekNextChar(line, i + (*newHeader).length() - 1) != '(') - newHeader = NULL; + newHeader = nullptr; - if (newHeader != NULL) + if (newHeader != nullptr) { // if we reached here, then this is a header... bool isIndentableHeader = true; isInHeader = true; - vector* lastTempStack = NULL;; + vector* lastTempStack = nullptr;; if (!tempStacks->empty()) lastTempStack = tempStacks->back(); @@ -3015,7 +2997,7 @@ // take care of 'else' else if (newHeader == &AS_ELSE) { - if (lastTempStack != NULL) + if (lastTempStack != nullptr) { int indexOfIf = indexOf(*lastTempStack, &AS_IF); if (indexOfIf != -1) @@ -3025,10 +3007,10 @@ int restackSize = lastTempStack->size() - indexOfIf - 1; for (int r = 0; r < restackSize; r++) { - headerStack->push_back(lastTempStack->back()); + headerStack->emplace_back(lastTempStack->back()); lastTempStack->pop_back(); } - if (!closingBracketReached) + if (!closingBraceReached) indentCount += restackSize; } /* @@ -3042,7 +3024,7 @@ // check if 'while' closes a previous 'do' else if (newHeader == &AS_WHILE) { - if (lastTempStack != NULL) + if (lastTempStack != nullptr) { int indexOfDo = indexOf(*lastTempStack, &AS_DO); if (indexOfDo != -1) @@ -3052,10 +3034,10 @@ int restackSize = lastTempStack->size() - indexOfDo - 1; for (int r = 0; r < restackSize; r++) { - headerStack->push_back(lastTempStack->back()); + headerStack->emplace_back(lastTempStack->back()); lastTempStack->pop_back(); } - if (!closingBracketReached) + if (!closingBraceReached) indentCount += restackSize; } } @@ -3063,7 +3045,7 @@ // check if 'catch' closes a previous 'try' or 'catch' else if (newHeader == &AS_CATCH || newHeader == &AS_FINALLY) { - if (lastTempStack != NULL) + if (lastTempStack != nullptr) { int indexOfTry = indexOf(*lastTempStack, &AS_TRY); if (indexOfTry == -1) @@ -3075,11 +3057,11 @@ int restackSize = lastTempStack->size() - indexOfTry - 1; for (int r = 0; r < restackSize; r++) { - headerStack->push_back(lastTempStack->back()); + headerStack->emplace_back(lastTempStack->back()); lastTempStack->pop_back(); } - if (!closingBracketReached) + if (!closingBraceReached) indentCount += restackSize; } } @@ -3090,7 +3072,7 @@ if (!haveCaseIndent) { haveCaseIndent = true; - if (!lineBeginsWithOpenBracket) + if (!lineBeginsWithOpenBrace) --indentCount; } } @@ -3122,8 +3104,8 @@ if (isIndentableHeader) { - headerStack->push_back(newHeader); - isInStatement = false; + headerStack->emplace_back(newHeader); + isContinuation = false; if (indexOf(*nonParenHeaders, newHeader) == -1) { isInConditional = true; @@ -3136,9 +3118,9 @@ i += newHeader->length() - 1; continue; - } // newHeader != NULL + } // newHeader != nullptr - if (findHeader(line, i, preCommandHeaders)) + if (findHeader(line, i, preCommandHeaders) != nullptr) foundPreCommandHeader = true; // Objective-C NSException macros are preCommandHeaders @@ -3188,7 +3170,7 @@ { // found a 'class' c'tor initializer isInClassInitializer = true; - registerInStatementIndentColon(line, i, tabIncrementIn); + registerContinuationIndentColon(line, i, tabIncrementIn); if (i == 0) indentCount += classInitializerIndents; } @@ -3196,7 +3178,7 @@ { // is in a 'class A : public B' definition isInClassHeaderTab = true; - registerInStatementIndentColon(line, i, tabIncrementIn); + registerContinuationIndentColon(line, i, tabIncrementIn); } else if (isInAsm || isInAsmOneLine || isInAsmBlock) { @@ -3216,10 +3198,10 @@ else if (isCStyle() && !isInClass && headerStack->size() >= 2 && (*headerStack)[headerStack->size() - 2] == &AS_CLASS - && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET) + && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE) { // found a 'private:' or 'public:' inside a class definition - // and on the same line as the class opening bracket + // and on the same line as the class opening brace // do nothing } else if (isJavaStyle() && lastLineHeader == &AS_FOR) @@ -3229,7 +3211,7 @@ } else { - currentNonSpaceCh = ';'; // so that brackets after the ':' will appear as block-openers + currentNonSpaceCh = ';'; // so that braces after the ':' will appear as block-openers char peekedChar = peekNextChar(line, i); if (isInCase) { @@ -3241,23 +3223,23 @@ // is in a label (e.g. 'label1:') if (labelIndent) --indentCount; // unindent label by one indent - else if (!lineBeginsWithOpenBracket) + else if (!lineBeginsWithOpenBrace) indentCount = 0; // completely flush indent to left } } } - if ((ch == ';' || (parenDepth > 0 && ch == ',')) && !inStatementIndentStackSizeStack->empty()) - while ((int) inStatementIndentStackSizeStack->back() + (parenDepth > 0 ? 1 : 0) - < (int) inStatementIndentStack->size()) - inStatementIndentStack->pop_back(); + if ((ch == ';' || (parenDepth > 0 && ch == ',')) && !continuationIndentStackSizeStack->empty()) + while ((int) continuationIndentStackSizeStack->back() + (parenDepth > 0 ? 1 : 0) + < (int) continuationIndentStack->size()) + continuationIndentStack->pop_back(); - else if (ch == ',' && isInEnum && isNonInStatementArray && !inStatementIndentStack->empty()) - inStatementIndentStack->pop_back(); + else if (ch == ',' && isInEnum && isNonInStatementArray && !continuationIndentStack->empty()) + continuationIndentStack->pop_back(); // handle commas // previous "isInStatement" will be from an assignment operator or class initializer - if (ch == ',' && parenDepth == 0 && !isInStatement && !isNonInStatementArray) + if (ch == ',' && parenDepth == 0 && !isContinuation && !isNonInStatementArray) { // is comma at end of line size_t nextChar = line.find_first_not_of(" \t", i + 1); @@ -3278,10 +3260,10 @@ // register indent at second word on the line else if (!isInTemplate && !isInClassHeaderTab && !isInClassInitializer) { - int prevWord = getInStatementIndentComma(line, i); - int inStatementIndent = prevWord + spaceIndentCount + tabIncrementIn; - inStatementIndentStack->push_back(inStatementIndent); - isInStatement = true; + int prevWord = getContinuationIndentComma(line, i); + int continuationIndentCount = prevWord + spaceIndentCount + tabIncrementIn; + continuationIndentStack->emplace_back(continuationIndentCount); + isContinuation = true; } } } @@ -3296,19 +3278,19 @@ if (ch == '}') { // first check if this '}' closes a previous block, or a static array... - if (bracketBlockStateStack->size() > 1) + if (braceBlockStateStack->size() > 1) { - bool bracketBlockState = bracketBlockStateStack->back(); - bracketBlockStateStack->pop_back(); - if (!bracketBlockState) + bool braceBlockState = braceBlockStateStack->back(); + braceBlockStateStack->pop_back(); + if (!braceBlockState) { - if (!inStatementIndentStackSizeStack->empty()) + if (!continuationIndentStackSizeStack->empty()) { - // this bracket is a static array - popLastInStatementIndent(); + // this brace is a static array + popLastContinuationIndent(); parenDepth--; if (i == 0) - shouldIndentBrackettedLine = false; + shouldIndentBracedLine = false; if (!parenIndentStack->empty()) { @@ -3322,35 +3304,35 @@ } } - // this bracket is block closer... + // this brace is block closer... ++lineClosingBlocksNum; - if (!inStatementIndentStackSizeStack->empty()) - popLastInStatementIndent(); + if (!continuationIndentStackSizeStack->empty()) + popLastContinuationIndent(); - if (!blockParenDepthStack->empty()) + if (!squareBracketDepthStack->empty()) { - parenDepth = blockParenDepthStack->back(); - blockParenDepthStack->pop_back(); - isInStatement = blockStatementStack->back(); + parenDepth = squareBracketDepthStack->back(); + squareBracketDepthStack->pop_back(); + isContinuation = blockStatementStack->back(); blockStatementStack->pop_back(); - if (isInStatement) + if (isContinuation) blockTabCount--; } - closingBracketReached = true; + closingBraceReached = true; if (i == 0) spaceIndentCount = 0; isInAsmBlock = false; isInAsm = isInAsmOneLine = isInQuote = false; // close these just in case - int headerPlace = indexOf(*headerStack, &AS_OPEN_BRACKET); + int headerPlace = indexOf(*headerStack, &AS_OPEN_BRACE); if (headerPlace != -1) { const string* popped = headerStack->back(); - while (popped != &AS_OPEN_BRACKET) + while (popped != &AS_OPEN_BRACE) { headerStack->pop_back(); popped = headerStack->back(); @@ -3358,14 +3340,14 @@ headerStack->pop_back(); if (headerStack->empty()) - g_preprocessorCppExternCBracket = 0; + g_preprocessorCppExternCBrace = 0; - // do not indent namespace bracket unless namespaces are indented + // do not indent namespace brace unless namespaces are indented if (!namespaceIndent && !headerStack->empty() && ((*headerStack).back() == &AS_NAMESPACE || (*headerStack).back() == &AS_MODULE) - && i == 0) // must be the first bracket on the line - shouldIndentBrackettedLine = false; + && i == 0) // must be the first brace on the line + shouldIndentBracedLine = false; if (!tempStacks->empty()) { @@ -3390,14 +3372,14 @@ if (!tempStacks->back()->empty()) while (!tempStacks->back()->empty()) tempStacks->back()->pop_back(); - while (!headerStack->empty() && headerStack->back() != &AS_OPEN_BRACKET) + while (!headerStack->empty() && headerStack->back() != &AS_OPEN_BRACE) { - tempStacks->back()->push_back(headerStack->back()); + tempStacks->back()->emplace_back(headerStack->back()); headerStack->pop_back(); } if (parenDepth == 0 && ch == ';') - isInStatement = false; + isContinuation = false; if (isInObjCMethodDefinition) { @@ -3405,7 +3387,7 @@ isImmediatelyPostObjCMethodDefinition = true; } - previousLastLineHeader = NULL; + previousLastLineHeader = nullptr; isInClassHeader = false; // for 'friend' class isInEnum = false; isInEnumTypeID = false; @@ -3414,7 +3396,7 @@ isInObjCInterface = false; foundPreCommandHeader = false; foundPreCommandMacro = false; - blockParenCount = 0; + squareBracketCount = 0; continue; } @@ -3431,20 +3413,21 @@ { char nextChar = peekNextChar(line, i + newHeader->length() - 1); if (prevNonSpaceCh == ')' || !isalpha(nextChar)) - newHeader = NULL; + newHeader = nullptr; } - if (newHeader != NULL + if (newHeader != nullptr && !(isCStyle() && newHeader == &AS_CLASS && isInEnum)) // is not 'enum class' { if (!isSharpStyle()) - headerStack->push_back(newHeader); + headerStack->emplace_back(newHeader); // do not need 'where' in the headerStack // do not need second 'class' statement in a row else if (!(newHeader == &AS_WHERE - || (newHeader == &AS_CLASS + || ((newHeader == &AS_CLASS || newHeader == &AS_STRUCT) && !headerStack->empty() - && headerStack->back() == &AS_CLASS))) - headerStack->push_back(newHeader); + && (headerStack->back() == &AS_CLASS + || headerStack->back() == &AS_STRUCT)))) + headerStack->emplace_back(newHeader); if (!headerStack->empty()) { @@ -3457,10 +3440,10 @@ else if ((*headerStack).back() == &AS_NAMESPACE || (*headerStack).back() == &AS_MODULE) { - // remove inStatementIndent from namespace - if (!inStatementIndentStack->empty()) - inStatementIndentStack->pop_back(); - isInStatement = false; + // remove continuationIndent from namespace + if (!continuationIndentStack->empty()) + continuationIndentStack->pop_back(); + isContinuation = false; } } @@ -3470,14 +3453,14 @@ } const string* foundIndentableHeader = findHeader(line, i, indentableHeaders); - if (foundIndentableHeader != NULL) + if (foundIndentableHeader != nullptr) { // must bypass the header before registering the in statement i += foundIndentableHeader->length() - 1; if (!isInOperator && !isInTemplate && !isNonInStatementArray) { - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, false); - isInStatement = true; + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, 0, false); + isContinuation = true; } continue; } @@ -3485,17 +3468,17 @@ if (isCStyle() && findKeyword(line, i, AS_OPERATOR)) isInOperator = true; - if (g_preprocessorCppExternCBracket == 1 && findKeyword(line, i, AS_EXTERN)) - ++g_preprocessorCppExternCBracket; + if (g_preprocessorCppExternCBrace == 1 && findKeyword(line, i, AS_EXTERN)) + ++g_preprocessorCppExternCBrace; - if (g_preprocessorCppExternCBracket == 3) // extern "C" is not followed by a '{' - g_preprocessorCppExternCBracket = 0; + if (g_preprocessorCppExternCBrace == 3) // extern "C" is not followed by a '{' + g_preprocessorCppExternCBrace = 0; // "new" operator is a pointer, not a calculation if (findKeyword(line, i, AS_NEW)) { - if (isInStatement && !inStatementIndentStack->empty() && prevNonSpaceCh == '=') - inStatementIndentStack->back() = 0; + if (isContinuation && !continuationIndentStack->empty() && prevNonSpaceCh == '=') + continuationIndentStack->back() = 0; } if (isCStyle()) @@ -3558,7 +3541,7 @@ } else if (curWord == AS_END) { - popLastInStatementIndent(); + popLastContinuationIndent(); spaceIndentCount = 0; isInObjCMethodDefinition = false; string name = '@' + curWord; @@ -3588,25 +3571,27 @@ const string* foundAssignmentOp = findOperator(line, i, assignmentOperators); const string* foundNonAssignmentOp = findOperator(line, i, nonAssignmentOperators); - if (foundNonAssignmentOp == &AS_LAMBDA) - foundPreCommandHeader = true; - - if (isInTemplate && foundNonAssignmentOp == &AS_GR_GR) - foundNonAssignmentOp = NULL; + if (foundNonAssignmentOp != nullptr) + { + if (foundNonAssignmentOp == &AS_LAMBDA) + foundPreCommandHeader = true; + if (isInTemplate && foundNonAssignmentOp == &AS_GR_GR) + foundNonAssignmentOp = nullptr; + } // Since findHeader's boundary checking was not used above, it is possible // that both an assignment op and a non-assignment op where found, // e.g. '>>' and '>>='. If this is the case, treat the LONGER one as the // found operator. - if (foundAssignmentOp != NULL && foundNonAssignmentOp != NULL) + if (foundAssignmentOp != nullptr && foundNonAssignmentOp != nullptr) { if (foundAssignmentOp->length() < foundNonAssignmentOp->length()) - foundAssignmentOp = NULL; + foundAssignmentOp = nullptr; else - foundNonAssignmentOp = NULL; + foundNonAssignmentOp = nullptr; } - if (foundNonAssignmentOp != NULL) + if (foundNonAssignmentOp != nullptr) { if (foundNonAssignmentOp->length() > 1) i += foundNonAssignmentOp->length() - 1; @@ -3615,7 +3600,7 @@ // aligned, if we are not in a statement already and // also not in the "operator<<(...)" header line if (!isInOperator - && inStatementIndentStack->empty() + && continuationIndentStack->empty() && isCStyle() && (foundNonAssignmentOp == &AS_GR_GR || foundNonAssignmentOp == &AS_LS_LS)) @@ -3624,11 +3609,11 @@ if (i < 2 && spaceIndentCount == 0) spaceIndentCount += 2 * indentLength; // align to the beginning column of the operator - registerInStatementIndent(line, i - foundNonAssignmentOp->length(), spaceIndentCount, tabIncrementIn, 0, false); + registerContinuationIndent(line, i - foundNonAssignmentOp->length(), spaceIndentCount, tabIncrementIn, 0, false); } } - else if (foundAssignmentOp != NULL) + else if (foundAssignmentOp != nullptr) { foundPreCommandHeader = false; // clears this for array assignments foundPreCommandMacro = false; @@ -3647,10 +3632,10 @@ { // register indent at previous word haveAssignmentThisLine = true; - int prevWordIndex = getInStatementIndentAssign(line, i); - int inStatementIndent = prevWordIndex + spaceIndentCount + tabIncrementIn; - inStatementIndentStack->push_back(inStatementIndent); - isInStatement = true; + int prevWordIndex = getContinuationIndentAssign(line, i); + int continuationIndentCount = prevWordIndex + spaceIndentCount + tabIncrementIn; + continuationIndentStack->emplace_back(continuationIndentCount); + isContinuation = true; } } // don't indent an assignment if 'let' @@ -3662,8 +3647,8 @@ { if (i == 0 && spaceIndentCount == 0) spaceIndentCount += indentLength; - registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, false); - isInStatement = true; + registerContinuationIndent(line, i, spaceIndentCount, tabIncrementIn, 0, false); + isContinuation = true; } } } diff -Nru astyle-2.06/src/ASEnhancer.cpp astyle-3.0.1/src/ASEnhancer.cpp --- astyle-2.06/src/ASEnhancer.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASEnhancer.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASEnhancer.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. //----------------------------------------------------------------------------- // headers @@ -66,18 +66,18 @@ // unindent variables lineNumber = 0; - bracketCount = 0; + braceCount = 0; isInComment = false; isInQuote = false; switchDepth = 0; eventPreprocDepth = 0; - lookingForCaseBracket = false; + lookingForCaseBrace = false; unindentNextLine = false; shouldUnindentLine = false; shouldUnindentComment = false; // switch struct and vector - sw.switchBracketCount = 0; + sw.switchBraceCount = 0; sw.unindentDepth = 0; sw.unindentCase = false; switchStack.clear(); @@ -124,7 +124,7 @@ && !emptyLineFill) return; - // test for unindent on attached brackets + // test for unindent on attached braces if (unindentNextLine) { sw.unindentDepth++; @@ -202,7 +202,7 @@ * @param caseIndex the line index of the case statement. * @return the line index of the colon. */ -size_t ASEnhancer::findCaseColon(string& line, size_t caseIndex) const +size_t ASEnhancer::findCaseColon(const string& line, size_t caseIndex) const { size_t i = caseIndex; bool isInQuote_ = false; @@ -293,7 +293,7 @@ * @param index the current line index. * @return true if a hit. */ -bool ASEnhancer::isBeginDeclareSectionSQL(string& line, size_t index) const +bool ASEnhancer::isBeginDeclareSectionSQL(const string& line, size_t index) const { string word; size_t hits = 0; @@ -342,7 +342,7 @@ * @param index the current line index. * @return true if a hit. */ -bool ASEnhancer::isEndDeclareSectionSQL(string& line, size_t index) const +bool ASEnhancer::isEndDeclareSectionSQL(const string& line, size_t index) const { string word; size_t hits = 0; @@ -384,12 +384,12 @@ } /** - * check if a one-line bracket has been reached, + * check if a one-line brace has been reached, * i.e. if the currently reached '{' character is closed * with a complimentary '}' elsewhere on the current line, *. - * @return false = one-line bracket has not been reached. - * true = one-line bracket has been reached. + * @return false = one-line brace has not been reached. + * true = one-line brace has been reached. */ bool ASEnhancer::isOneLineBlockReached(const string& line, int startChar) const { @@ -397,7 +397,7 @@ bool isInComment_ = false; bool isInQuote_ = false; - int _bracketCount = 1; + int _braceCount = 1; int lineLength = line.length(); char quoteChar_ = ' '; char ch = ' '; @@ -448,11 +448,11 @@ } if (ch == '{') - ++_bracketCount; + ++_braceCount; else if (ch == '}') - --_bracketCount; + --_braceCount; - if (_bracketCount == 0) + if (_braceCount == 0) return true; } @@ -519,17 +519,17 @@ // check for windows line markers if (line.compare(i + 2, 1, "\xf0") > 0) lineNumber--; - // unindent if not in case brackets + // unindent if not in case braces if (line.find_first_not_of(" \t") == i - && sw.switchBracketCount == 1 + && sw.switchBraceCount == 1 && sw.unindentCase) shouldUnindentComment = true; break; // finished with the line } else if (!(isInComment) && line.compare(i, 2, "/*") == 0) { - // unindent if not in case brackets - if (sw.switchBracketCount == 1 && sw.unindentCase) + // unindent if not in case braces + if (sw.switchBraceCount == 1 && sw.unindentCase) shouldUnindentComment = true; isInComment = true; size_t commentEnd = line.find("*/", i); @@ -541,8 +541,8 @@ } else if ((isInComment) && line.compare(i, 2, "*/") == 0) { - // unindent if not in case brackets - if (sw.switchBracketCount == 1 && sw.unindentCase) + // unindent if not in case braces + if (sw.switchBraceCount == 1 && sw.unindentCase) shouldUnindentComment = true; isInComment = false; i++; @@ -551,8 +551,8 @@ if (isInComment) { - // unindent if not in case brackets - if (sw.switchBracketCount == 1 && sw.unindentCase) + // unindent if not in case braces + if (sw.switchBraceCount == 1 && sw.unindentCase) shouldUnindentComment = true; size_t commentEnd = line.find("*/", i); if (commentEnd == string::npos) @@ -565,10 +565,10 @@ // if we have reached this far then we are NOT in a comment or string of special characters if (line[i] == '{') - bracketCount++; + braceCount++; if (line[i] == '}') - bracketCount--; + braceCount--; // check for preprocessor within an event table if (isInEventTable && line[i] == '#' && preprocBlockIndent) @@ -621,11 +621,11 @@ // ---------------- process switch statements --------------------------------- - if (isPotentialKeyword && findKeyword(line, i, "switch")) + if (isPotentialKeyword && findKeyword(line, i, ASResource::AS_SWITCH)) { switchDepth++; - switchStack.push_back(sw); // save current variables - sw.switchBracketCount = 0; + switchStack.emplace_back(sw); // save current variables + sw.switchBraceCount = 0; sw.unindentCase = false; // don't clear case until end of switch i += 5; // bypass switch statement continue; @@ -665,22 +665,22 @@ if (line[i] == '{') { - sw.switchBracketCount++; - if (lookingForCaseBracket) // if 1st after case statement + sw.switchBraceCount++; + if (lookingForCaseBrace) // if 1st after case statement { sw.unindentCase = true; // unindenting this case sw.unindentDepth++; - lookingForCaseBracket = false; // not looking now + lookingForCaseBrace = false; // not looking now } return i; } - lookingForCaseBracket = false; // no opening bracket, don't indent + lookingForCaseBrace = false; // no opening brace, don't indent if (line[i] == '}') { - sw.switchBracketCount--; - assert(sw.switchBracketCount <= bracketCount); - if (sw.switchBracketCount == 0) // if end of switch statement + sw.switchBraceCount--; + assert(sw.switchBraceCount <= braceCount); + if (sw.switchBraceCount == 0) // if end of switch statement { int lineUnindent = sw.unindentDepth; if (line.find_first_not_of(" \t") == i @@ -700,7 +700,8 @@ } if (isPotentialKeyword - && (findKeyword(line, i, "case") || findKeyword(line, i, "default"))) + && (findKeyword(line, i, ASResource::AS_CASE) + || findKeyword(line, i, ASResource::AS_DEFAULT))) { if (sw.unindentCase) // if unindented last case { @@ -720,14 +721,14 @@ { if (line[i] == '{') { - bracketCount++; - sw.switchBracketCount++; + braceCount++; + sw.switchBraceCount++; if (!isOneLineBlockReached(line, i)) unindentNextLine = true; return i; } } - lookingForCaseBracket = true; + lookingForCaseBrace = true; i--; // need to process this char return i; } diff -Nru astyle-2.06/src/ASFormatter.cpp astyle-3.0.1/src/ASFormatter.cpp --- astyle-2.06/src/ASFormatter.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASFormatter.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASFormatter.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. //----------------------------------------------------------------------------- // headers @@ -27,16 +27,16 @@ */ ASFormatter::ASFormatter() { - sourceIterator = NULL; + sourceIterator = nullptr; enhancer = new ASEnhancer; - preBracketHeaderStack = NULL; - bracketTypeStack = NULL; - parenStack = NULL; - structStack = NULL; - questionMarkStack = NULL; + preBraceHeaderStack = nullptr; + braceTypeStack = nullptr; + parenStack = nullptr; + structStack = nullptr; + questionMarkStack = nullptr; lineCommentNoIndent = false; formattingStyle = STYLE_NONE; - bracketFormatMode = NONE_MODE; + braceFormatMode = NONE_MODE; pointerAlignment = PTR_ALIGN_NONE; referenceAlignment = REF_SAME_AS_PTR; objCColonPadMode = COLON_PAD_NO_CHANGE; @@ -50,7 +50,7 @@ shouldPadHeader = false; shouldStripCommentPrefix = false; shouldUnPadParens = false; - attachClosingBracketMode = false; + attachClosingBraceMode = false; shouldBreakOneLineBlocks = true; shouldBreakOneLineHeaders = false; shouldBreakOneLineStatements = true; @@ -61,16 +61,17 @@ shouldAttachExternC = false; shouldAttachNamespace = false; shouldAttachClass = false; + shouldAttachClosingWhile = false; shouldAttachInline = false; shouldBreakBlocks = false; shouldBreakClosingHeaderBlocks = false; - shouldBreakClosingHeaderBrackets = false; + shouldBreakClosingHeaderBraces = false; shouldDeleteEmptyLines = false; shouldBreakElseIfs = false; shouldBreakLineAfterLogical = false; - shouldAddBrackets = false; - shouldAddOneLineBrackets = false; - shouldRemoveBrackets = false; + shouldAddBraces = false; + shouldAddOneLineBraces = false; + shouldRemoveBraces = false; shouldPadMethodColon = false; shouldPadMethodPrefix = false; shouldUnPadMethodPrefix = false; @@ -99,8 +100,8 @@ ASFormatter::~ASFormatter() { // delete ASFormatter stack vectors - deleteContainer(preBracketHeaderStack); - deleteContainer(bracketTypeStack); + deleteContainer(preBraceHeaderStack); + deleteContainer(braceTypeStack); deleteContainer(parenStack); deleteContainer(structStack); deleteContainer(questionMarkStack); @@ -118,8 +119,8 @@ // delete ASEnhancer member vectors delete indentableMacros; - // delete ASBeautifier member vectors // must be done when the ASFormatter object is deleted (not ASBeautifier) + // delete ASBeautifier member vectors ASBeautifier::deleteBeautifierVectors(); delete enhancer; @@ -154,16 +155,16 @@ getEmptyLineFill(), indentableMacros); - initContainer(preBracketHeaderStack, new vector); + initContainer(preBraceHeaderStack, new vector); initContainer(parenStack, new vector); initContainer(structStack, new vector); initContainer(questionMarkStack, new vector); - parenStack->push_back(0); // parenStack must contain this default entry - initContainer(bracketTypeStack, new vector); - bracketTypeStack->push_back(NULL_TYPE); // bracketTypeStack must contain this default entry + parenStack->emplace_back(0); // parenStack must contain this default entry + initContainer(braceTypeStack, new vector); + braceTypeStack->emplace_back(NULL_TYPE); // braceTypeStack must contain this default entry clearFormattedLineSplitPoints(); - currentHeader = NULL; + currentHeader = nullptr; currentLine = ""; readyFormattedLine = ""; formattedLine = ""; @@ -177,20 +178,19 @@ charNum = 0; checksumIn = 0; checksumOut = 0; - currentLineFirstBracketNum = string::npos; + currentLineFirstBraceNum = string::npos; formattedLineCommentNum = 0; leadingSpaces = 0; previousReadyFormattedLineLength = string::npos; - preprocBracketTypeStackSize = 0; + preprocBraceTypeStackSize = 0; spacePadNum = 0; nextLineSpacePadNum = 0; objCColonAlign = 0; templateDepth = 0; - blockParenCount = 0; - horstmannIndentChars = 0; + squareBracketCount = 0; + runInIndentChars = 0; tabIncrementIn = 0; - previousBracketType = NULL_TYPE; - previousOperator = NULL; + previousBraceType = NULL_TYPE; isVirgin = true; isInVirginLine = true; @@ -222,6 +222,7 @@ foundPreDefinitionHeader = false; foundPreCommandHeader = false; foundPreCommandMacro = false; + foundTrailingReturnType = false; foundCastOperator = false; foundQuestionMark = false; isInLineBreak = false; @@ -236,9 +237,9 @@ isLineReady = false; elseHeaderFollowsComments = false; caseHeaderFollowsComments = false; - isPreviousBracketBlockRelated = false; + isPreviousBraceBlockRelated = false; isInPotentialCalculation = false; - needHeaderOpeningBracket = false; + needHeaderOpeningBrace = false; shouldBreakLineAtNextChar = false; shouldKeepLineUnbroken = false; shouldReparseCurrentChar = false; @@ -274,15 +275,15 @@ isInObjCReturnType = false; isInObjCSelector = false; breakCurrentOneLineBlock = false; - shouldRemoveNextClosingBracket = false; - isInBracketRunIn = false; - currentLineBeginsWithBracket = false; + shouldRemoveNextClosingBrace = false; + isInBraceRunIn = false; + currentLineBeginsWithBrace = false; isPrependPostBlockEmptyLineRequested = false; isAppendPostBlockEmptyLineRequested = false; isIndentableProprocessor = false; isIndentableProprocessorBlock = false; prependEmptyLine = false; - appendOpeningBracket = false; + appendOpeningBrace = false; foundClosingHeader = false; isImmediatelyPostHeader = false; isInHeader = false; @@ -330,109 +331,110 @@ { if (formattingStyle == STYLE_ALLMAN) { - setBracketFormatMode(BREAK_MODE); + setBraceFormatMode(BREAK_MODE); } else if (formattingStyle == STYLE_JAVA) { - setBracketFormatMode(ATTACH_MODE); + setBraceFormatMode(ATTACH_MODE); } else if (formattingStyle == STYLE_KR) { - setBracketFormatMode(LINUX_MODE); + setBraceFormatMode(LINUX_MODE); } else if (formattingStyle == STYLE_STROUSTRUP) { - setBracketFormatMode(LINUX_MODE); + setBraceFormatMode(LINUX_MODE); + setBreakClosingHeaderBracesMode(true); } else if (formattingStyle == STYLE_WHITESMITH) { - setBracketFormatMode(BREAK_MODE); - setBracketIndent(true); + setBraceFormatMode(BREAK_MODE); + setBraceIndent(true); setClassIndent(true); // avoid hanging indent with access modifiers setSwitchIndent(true); // avoid hanging indent with case statements } else if (formattingStyle == STYLE_VTK) { - // the unindented class bracket does NOT cause a hanging indent like Whitesmith - setBracketFormatMode(BREAK_MODE); - setBracketIndentVtk(true); // sets both bracketIndent and bracketIndentVtk + // the unindented class brace does NOT cause a hanging indent like Whitesmith + setBraceFormatMode(BREAK_MODE); + setBraceIndentVtk(true); // sets both braceIndent and braceIndentVtk setSwitchIndent(true); // avoid hanging indent with case statements } else if (formattingStyle == STYLE_BANNER) { - // attached brackets can have hanging indents with the closing bracket - setBracketFormatMode(ATTACH_MODE); - setBracketIndent(true); + // attached braces can have hanging indents with the closing brace + setBraceFormatMode(ATTACH_MODE); + setBraceIndent(true); setClassIndent(true); // avoid hanging indent with access modifiers setSwitchIndent(true); // avoid hanging indent with case statements } else if (formattingStyle == STYLE_GNU) { - setBracketFormatMode(BREAK_MODE); + setBraceFormatMode(BREAK_MODE); setBlockIndent(true); } else if (formattingStyle == STYLE_LINUX) { - setBracketFormatMode(LINUX_MODE); + setBraceFormatMode(LINUX_MODE); // always for Linux style setMinConditionalIndentOption(MINCOND_ONEHALF); } else if (formattingStyle == STYLE_HORSTMANN) { - setBracketFormatMode(RUN_IN_MODE); + setBraceFormatMode(RUN_IN_MODE); setSwitchIndent(true); } else if (formattingStyle == STYLE_1TBS) { - setBracketFormatMode(LINUX_MODE); - setAddBracketsMode(true); - setRemoveBracketsMode(false); + setBraceFormatMode(LINUX_MODE); + setAddBracesMode(true); + setRemoveBracesMode(false); } else if (formattingStyle == STYLE_GOOGLE) { - setBracketFormatMode(ATTACH_MODE); + setBraceFormatMode(ATTACH_MODE); setModifierIndent(true); setClassIndent(false); } else if (formattingStyle == STYLE_MOZILLA) { - setBracketFormatMode(LINUX_MODE); + setBraceFormatMode(LINUX_MODE); } else if (formattingStyle == STYLE_PICO) { - setBracketFormatMode(RUN_IN_MODE); - setAttachClosingBracketMode(true); + setBraceFormatMode(RUN_IN_MODE); + setAttachClosingBraceMode(true); setSwitchIndent(true); setBreakOneLineBlocksMode(false); setBreakOneLineStatementsMode(false); - // add-brackets won't work for pico, but it could be fixed if necessary + // add-braces won't work for pico, but it could be fixed if necessary // both options should be set to true - if (shouldAddBrackets) - shouldAddOneLineBrackets = true; + if (shouldAddBraces) + shouldAddOneLineBraces = true; } else if (formattingStyle == STYLE_LISP) { - setBracketFormatMode(ATTACH_MODE); - setAttachClosingBracketMode(true); + setBraceFormatMode(ATTACH_MODE); + setAttachClosingBraceMode(true); setBreakOneLineStatementsMode(false); - // add-one-line-brackets won't work for lisp - // only shouldAddBrackets should be set to true - if (shouldAddOneLineBrackets) + // add-one-line-braces won't work for lisp + // only shouldAddBraces should be set to true + if (shouldAddOneLineBraces) { - shouldAddBrackets = true; - shouldAddOneLineBrackets = false; + shouldAddBraces = true; + shouldAddOneLineBraces = false; } } setMinConditionalIndentLength(); // if not set by indent=force-tab-x set equal to indentLength - if (!getTabLength()) + if (getTabLength() == 0) setDefaultTabLength(); - // add-one-line-brackets implies keep-one-line-blocks - if (shouldAddOneLineBrackets) + // add-one-line-braces implies keep-one-line-blocks + if (shouldAddOneLineBraces) setBreakOneLineBlocksMode(false); - // don't allow add-brackets and remove-brackets - if (shouldAddBrackets || shouldAddOneLineBrackets) - setRemoveBracketsMode(false); + // don't allow add-braces and remove-braces + if (shouldAddBraces || shouldAddOneLineBraces) + setRemoveBracesMode(false); // don't allow indent-classes and indent-modifiers if (getClassIndent()) setModifierIndent(false); @@ -445,7 +447,7 @@ */ string ASFormatter::nextLine() { - const string* newHeader = NULL; + const string* newHeader = nullptr; isInVirginLine = isVirgin; isCharImmediatelyPostComment = false; isPreviousCharPostComment = false; @@ -467,16 +469,16 @@ { // make sure that a virgin '{' at the beginning of the file will be treated as a block... if (isInVirginLine && currentChar == '{' - && currentLineBeginsWithBracket + && currentLineBeginsWithBrace && previousCommandChar == ' ') previousCommandChar = '{'; if (isInClassInitializer - && isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) + && isBraceType(braceTypeStack->back(), COMMAND_TYPE)) isInClassInitializer = false; - if (isInBracketRunIn) + if (isInBraceRunIn) isInLineBreak = false; if (!isWhiteSpace(currentChar)) - isInBracketRunIn = false; + isInBraceRunIn = false; isPreviousCharPostComment = isCharImmediatelyPostComment; isCharImmediatelyPostComment = false; isCharImmediatelyPostTemplate = false; @@ -585,14 +587,14 @@ || findKeyword(preproc, 0, "line"))) { currentLine = rtrim(currentLine); // trim the end only - // check for horstmann run-in + // check for run-in if (formattedLine.length() > 0 && formattedLine[0] == '{') { isInLineBreak = true; - isInBracketRunIn = false; + isInBraceRunIn = false; } if (previousCommandChar == '}') - currentHeader = NULL; + currentHeader = nullptr; isInLineComment = true; appendCurrentChar(); continue; @@ -611,10 +613,10 @@ continue; } - if (shouldRemoveNextClosingBracket && currentChar == '}') + if (shouldRemoveNextClosingBrace && currentChar == '}') { currentLine[charNum] = currentChar = ' '; - shouldRemoveNextClosingBracket = false; + shouldRemoveNextClosingBrace = false; assert(adjustChecksumIn(-'}')); if (isEmptyLine(currentLine)) continue; @@ -635,17 +637,17 @@ if (currentChar == '#') { isInPreprocessor = true; - // check for horstmann run-in + // check for run-in if (formattedLine.length() > 0 && formattedLine[0] == '{') { isInLineBreak = true; - isInBracketRunIn = false; + isInBraceRunIn = false; } processPreprocessor(); // if top level it is potentially indentable if (shouldIndentPreprocBlock - && (isBracketType(bracketTypeStack->back(), NULL_TYPE) - || isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE)) + && (isBraceType(braceTypeStack->back(), NULL_TYPE) + || isBraceType(braceTypeStack->back(), NAMESPACE_TYPE)) && !foundClassHeader && !isInClassInitializer && sourceIterator->tellg() > preprocBlockEnd) @@ -727,14 +729,14 @@ // reset isImmediatelyPostHeader information if (isImmediatelyPostHeader) { - // should brackets be added + // should braces be added if (currentChar != '{' - && shouldAddBrackets + && shouldAddBraces && (shouldBreakOneLineStatements || !isHeaderInMultiStatementLine) - && isOkToBreakBlock(bracketTypeStack->back())) + && isOkToBreakBlock(braceTypeStack->back())) { - bool bracketsAdded = addBracketsToStatement(); - if (bracketsAdded && !shouldAddOneLineBrackets) + bool bracesAdded = addBracesToStatement(); + if (bracesAdded && !shouldAddOneLineBraces) { size_t firstText = currentLine.find_first_not_of(" \t"); assert(firstText != string::npos); @@ -742,17 +744,17 @@ breakCurrentOneLineBlock = true; } } - // should brackets be removed - else if (currentChar == '{' && shouldRemoveBrackets) + // should braces be removed + else if (currentChar == '{' && shouldRemoveBraces) { - bool bracketsRemoved = removeBracketsFromStatement(); - if (bracketsRemoved) + bool bracesRemoved = removeBracesFromStatement(); + if (bracesRemoved) { - shouldRemoveNextClosingBracket = true; + shouldRemoveNextClosingBrace = true; if (isBeforeAnyLineEndComment(charNum)) spacePadNum--; else if (shouldBreakOneLineBlocks - || (currentLineBeginsWithBracket + || (currentLineBeginsWithBrace && currentLine.find_first_not_of(" \t") != string::npos)) shouldBreakLineAtNextChar = true; continue; @@ -762,14 +764,14 @@ // break 'else-if' if shouldBreakElseIfs is requested if (shouldBreakElseIfs && currentHeader == &AS_ELSE - && isOkToBreakBlock(bracketTypeStack->back()) + && isOkToBreakBlock(braceTypeStack->back()) && !isBeforeAnyComment() && (shouldBreakOneLineStatements || !isHeaderInMultiStatementLine)) { string nextText = peekNextText(currentLine.substr(charNum)); if (nextText.length() > 0 && isCharPotentialHeader(nextText, 0) - && ASBeautifier::findHeader(nextText, 0, headers) == &AS_IF) + && ASBase::findHeader(nextText, 0, headers) == &AS_IF) { isInLineBreak = true; } @@ -781,12 +783,12 @@ && (shouldBreakOneLineStatements || (!isHeaderInMultiStatementLine && !isMultiStatementLine())) - && isOkToBreakBlock(bracketTypeStack->back()) + && isOkToBreakBlock(braceTypeStack->back()) && !isBeforeAnyComment()) { if (currentChar == '{') { - if (!currentLineBeginsWithBracket) + if (!currentLineBeginsWithBrace) { if (isOneLineBlockReached(currentLine, charNum) == 3) isInLineBreak = false; @@ -799,7 +801,7 @@ string nextText = peekNextText(currentLine.substr(charNum), true); if (nextText.length() > 0 && ((isCharPotentialHeader(nextText, 0) - && ASBeautifier::findHeader(nextText, 0, headers) != &AS_IF) + && ASBase::findHeader(nextText, 0, headers) != &AS_IF) || nextText[0] == '{')) isInLineBreak = true; } @@ -818,9 +820,9 @@ if (parenStack->back() == 0 && !isCharImmediatelyPostComment && currentChar != ';') // allow ;; { // does a one-line block have ending comments? - if (isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE)) + if (isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE)) { - size_t blockEnd = currentLine.rfind(AS_CLOSE_BRACKET); + size_t blockEnd = currentLine.rfind(AS_CLOSE_BRACE); assert(blockEnd != string::npos); // move ending comments to this formattedLine if (isBeforeAnyLineEndComment(blockEnd)) @@ -852,10 +854,10 @@ shouldReparseCurrentChar = true; if (formattedLine.find_first_not_of(" \t") != string::npos) isInLineBreak = true; - if (needHeaderOpeningBracket) + if (needHeaderOpeningBrace) { isCharImmediatelyPostCloseBlock = true; - needHeaderOpeningBracket = false; + needHeaderOpeningBrace = false; } continue; } @@ -888,8 +890,8 @@ parenStack->back()++; if (currentChar == '[') { - ++blockParenCount; - if (getAlignMethodColon() && blockParenCount == 1 && isCStyle()) + ++squareBracketCount; + if (getAlignMethodColon() && squareBracketCount == 1 && isCStyle()) objCColonAlign = findObjCColonAlignment(); } } @@ -924,10 +926,10 @@ } if (currentChar == ']') { - --blockParenCount; - if (blockParenCount <= 0) + --squareBracketCount; + if (squareBracketCount <= 0) { - blockParenCount = 0; + squareBracketCount = 0; objCColonAlign = 0; } } @@ -939,13 +941,13 @@ } } - // handle brackets + // handle braces if (currentChar == '{' || currentChar == '}') { - // if appendOpeningBracket this was already done for the original bracket - if (currentChar == '{' && !appendOpeningBracket) + // if appendOpeningBrace this was already done for the original brace + if (currentChar == '{' && !appendOpeningBrace) { - BracketType newBracketType = getBracketType(); + BraceType newBraceType = getBraceType(); breakCurrentOneLineBlock = false; foundNamespaceHeader = false; foundClassHeader = false; @@ -954,65 +956,66 @@ foundPreDefinitionHeader = false; foundPreCommandHeader = false; foundPreCommandMacro = false; + foundTrailingReturnType = false; isInPotentialCalculation = false; isInObjCMethodDefinition = false; isInObjCInterface = false; isInEnum = false; isJavaStaticConstructor = false; isCharImmediatelyPostNonInStmt = false; - needHeaderOpeningBracket = false; + needHeaderOpeningBrace = false; shouldKeepLineUnbroken = false; objCColonAlign = 0; - isPreviousBracketBlockRelated = !isBracketType(newBracketType, ARRAY_TYPE); - bracketTypeStack->push_back(newBracketType); - preBracketHeaderStack->push_back(currentHeader); - currentHeader = NULL; + isPreviousBraceBlockRelated = !isBraceType(newBraceType, ARRAY_TYPE); + braceTypeStack->emplace_back(newBraceType); + preBraceHeaderStack->emplace_back(currentHeader); + currentHeader = nullptr; structStack->push_back(isInIndentableStruct); - if (isBracketType(newBracketType, STRUCT_TYPE) && isCStyle()) + if (isBraceType(newBraceType, STRUCT_TYPE) && isCStyle()) isInIndentableStruct = isStructAccessModified(currentLine, charNum); else isInIndentableStruct = false; } - // this must be done before the bracketTypeStack is popped - BracketType bracketType = bracketTypeStack->back(); - bool isOpeningArrayBracket = (isBracketType(bracketType, ARRAY_TYPE) - && bracketTypeStack->size() >= 2 - && !isBracketType((*bracketTypeStack)[bracketTypeStack->size() - 2], ARRAY_TYPE) - ); + // this must be done before the braceTypeStack is popped + BraceType braceType = braceTypeStack->back(); + bool isOpeningArrayBrace = (isBraceType(braceType, ARRAY_TYPE) + && braceTypeStack->size() >= 2 + && !isBraceType((*braceTypeStack)[braceTypeStack->size() - 2], ARRAY_TYPE) + ); if (currentChar == '}') { // if a request has been made to append a post block empty line, - // but the block exists immediately before a closing bracket, + // but the block exists immediately before a closing brace, // then there is no need for the post block empty line. isAppendPostBlockEmptyLineRequested = false; if (isInAsm) endOfAsmReached = true; isInAsmOneLine = isInQuote = false; shouldKeepLineUnbroken = false; - blockParenCount = 0; + squareBracketCount = 0; - if (bracketTypeStack->size() > 1) + if (braceTypeStack->size() > 1) { - previousBracketType = bracketTypeStack->back(); - bracketTypeStack->pop_back(); - isPreviousBracketBlockRelated = !isBracketType(bracketType, ARRAY_TYPE); + previousBraceType = braceTypeStack->back(); + braceTypeStack->pop_back(); + isPreviousBraceBlockRelated = !isBraceType(braceType, ARRAY_TYPE); } else { - previousBracketType = NULL_TYPE; - isPreviousBracketBlockRelated = false; + previousBraceType = NULL_TYPE; + isPreviousBraceBlockRelated = false; } - if (!preBracketHeaderStack->empty()) + if (!preBraceHeaderStack->empty()) { - currentHeader = preBracketHeaderStack->back(); - preBracketHeaderStack->pop_back(); + currentHeader = preBraceHeaderStack->back(); + preBraceHeaderStack->pop_back(); } else - currentHeader = NULL; + currentHeader = nullptr; if (!structStack->empty()) { @@ -1023,8 +1026,8 @@ isInIndentableStruct = false; if (isNonInStatementArray - && (!isBracketType(bracketTypeStack->back(), ARRAY_TYPE) // check previous bracket - || peekNextChar() == ';')) // check for "};" added V2.01 + && (!isBraceType(braceTypeStack->back(), ARRAY_TYPE) // check previous brace + || peekNextChar() == ';')) // check for "};" added V2.01 isImmediatelyPostNonInStmt = true; if (!shouldBreakOneLineStatements @@ -1037,42 +1040,42 @@ } } - // format brackets - appendOpeningBracket = false; - if (isBracketType(bracketType, ARRAY_TYPE)) + // format braces + appendOpeningBrace = false; + if (isBraceType(braceType, ARRAY_TYPE)) { - formatArrayBrackets(bracketType, isOpeningArrayBracket); + formatArrayBraces(braceType, isOpeningArrayBrace); } else { if (currentChar == '{') - formatOpeningBracket(bracketType); + formatOpeningBrace(braceType); else - formatClosingBracket(bracketType); + formatClosingBrace(braceType); } continue; } - if ((((previousCommandChar == '{' && isPreviousBracketBlockRelated) + if ((((previousCommandChar == '{' && isPreviousBraceBlockRelated) || ((previousCommandChar == '}' && !isImmediatelyPostEmptyBlock - && isPreviousBracketBlockRelated + && isPreviousBraceBlockRelated && !isPreviousCharPostComment // Fixes wrongly appended newlines after '}' immediately after comments && peekNextChar() != ' ' - && !isBracketType(previousBracketType, DEFINITION_TYPE)) - && !isBracketType(bracketTypeStack->back(), DEFINITION_TYPE))) - && isOkToBreakBlock(bracketTypeStack->back())) + && !isBraceType(previousBraceType, DEFINITION_TYPE)) + && !isBraceType(braceTypeStack->back(), DEFINITION_TYPE))) + && isOkToBreakBlock(braceTypeStack->back())) // check for array || (previousCommandChar == '{' // added 9/30/2010 - && isBracketType(bracketTypeStack->back(), ARRAY_TYPE) - && !isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE) + && isBraceType(braceTypeStack->back(), ARRAY_TYPE) + && !isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE) && isNonInStatementArray) - // check for pico one line brackets + // check for pico one line braces || (formattingStyle == STYLE_PICO - && (previousCommandChar == '{' && isPreviousBracketBlockRelated) - && isBracketType(bracketTypeStack->back(), COMMAND_TYPE) - && isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE) - && bracketFormatMode == RUN_IN_MODE) + && (previousCommandChar == '{' && isPreviousBraceBlockRelated) + && isBraceType(braceTypeStack->back(), COMMAND_TYPE) + && isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE) + && braceFormatMode == RUN_IN_MODE) ) { isCharImmediatelyPostOpenBlock = (previousCommandChar == '{'); @@ -1084,18 +1087,18 @@ { previousCommandChar = ' '; - if (bracketFormatMode == NONE_MODE) + if (braceFormatMode == NONE_MODE) { - if (isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE) - && (isBracketType(bracketTypeStack->back(), BREAK_BLOCK_TYPE) + if (isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE) + && (isBraceType(braceTypeStack->back(), BREAK_BLOCK_TYPE) || shouldBreakOneLineBlocks)) isInLineBreak = true; - else if (currentLineBeginsWithBracket) + else if (currentLineBeginsWithBrace) formatRunIn(); else breakLine(); } - else if (bracketFormatMode == RUN_IN_MODE + else if (braceFormatMode == RUN_IN_MODE && currentChar != '#') formatRunIn(); else @@ -1103,8 +1106,13 @@ } else if (isCharImmediatelyPostCloseBlock && shouldBreakOneLineStatements - && (isLegalNameChar(currentChar) && currentChar != '.') - && !isCharImmediatelyPostComment) + && !isCharImmediatelyPostComment + && ((isLegalNameChar(currentChar) && currentChar != '.') + || currentChar == '+' + || currentChar == '-' + || currentChar == '*' + || currentChar == '&' + || currentChar == '(')) { previousCommandChar = ' '; isInLineBreak = true; @@ -1117,7 +1125,7 @@ // look for headers bool isPotentialHeader = isCharPotentialHeader(currentLine, charNum); - if (isPotentialHeader && !isInTemplate && !blockParenCount) + if (isPotentialHeader && !isInTemplate && squareBracketCount == 0) { isNonParenHeader = false; foundClosingHeader = false; @@ -1129,40 +1137,58 @@ && (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH)) { if (currentLine.find_first_of("=;", charNum) != string::npos) - newHeader = NULL; + newHeader = nullptr; } if (isJavaStyle() && (newHeader == &AS_SYNCHRONIZED)) { // want synchronized statements not synchronized methods - if (!isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) - newHeader = NULL; + if (!isBraceType(braceTypeStack->back(), COMMAND_TYPE)) + newHeader = nullptr; } else if (newHeader == &AS_USING && ASBeautifier::peekNextChar( currentLine, charNum + (*newHeader).length() - 1) != '(') - newHeader = NULL; + newHeader = nullptr; - if (newHeader != NULL) + if (newHeader != nullptr) { foundClosingHeader = isClosingHeader(newHeader); - if (!foundClosingHeader - && ((newHeader == &AS_WHILE && currentHeader == &AS_DO) - || (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY) - || (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY) - || (newHeader == &AS_SET && currentHeader == &AS_GET) - || (newHeader == &AS_REMOVE && currentHeader == &AS_ADD))) - foundClosingHeader = true; + if (!foundClosingHeader) + { + // these are closing headers + if ((newHeader == &AS_WHILE && currentHeader == &AS_DO) + || (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY) + || (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY)) + foundClosingHeader = true; + // don't append empty block for these related headers + else if (isSharpStyle() + && previousNonWSChar == '}' + && ((newHeader == &AS_SET && currentHeader == &AS_GET) + || (newHeader == &AS_REMOVE && currentHeader == &AS_ADD)) + && isOkToBreakBlock(braceTypeStack->back())) + isAppendPostBlockEmptyLineRequested = false; + } + + // TODO: this can be removed in a future release + // version 3.0 - break erroneous attached header from previous versions + if (isSharpStyle() + && ((newHeader == &AS_SET && currentHeader == &AS_GET) + || (newHeader == &AS_REMOVE && currentHeader == &AS_ADD)) + && !isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE) + && currentLine[currentLine.find_first_not_of(" \t")] == '}') + isInLineBreak = true; + // END TODO const string* previousHeader = currentHeader; currentHeader = newHeader; - needHeaderOpeningBracket = true; + needHeaderOpeningBrace = true; // is the previous statement on the same line? if ((previousNonWSChar == ';' || previousNonWSChar == ':') && !isInLineBreak - && isOkToBreakBlock(bracketTypeStack->back())) + && isOkToBreakBlock(braceTypeStack->back())) { // if breaking lines, break the line at the header // except for multiple 'case' statements on a line @@ -1175,7 +1201,7 @@ if (foundClosingHeader && previousNonWSChar == '}') { - if (isOkToBreakBlock(bracketTypeStack->back())) + if (isOkToBreakBlock(braceTypeStack->back())) isLineBreakBeforeClosingHeader(); // get the adjustment for a comment following the closing header @@ -1186,7 +1212,7 @@ } // check if the found header is non-paren header - isNonParenHeader = findHeader(nonParenHeaders) != NULL; + isNonParenHeader = findHeader(nonParenHeaders) != nullptr; if (isNonParenHeader && (currentHeader == &AS_CATCH @@ -1242,10 +1268,10 @@ } if (shouldBreakBlocks - && isOkToBreakBlock(bracketTypeStack->back()) + && isOkToBreakBlock(braceTypeStack->back()) && !isHeaderInMultiStatementLine) { - if (previousHeader == NULL + if (previousHeader == nullptr && !foundClosingHeader && !isCharImmediatelyPostOpenBlock && !isImmediatelyPostCommentOnly) @@ -1275,7 +1301,7 @@ continue; } - else if ((newHeader = findHeader(preDefinitionHeaders)) != NULL + else if ((newHeader = findHeader(preDefinitionHeaders)) != nullptr && parenStack->back() == 0 && !isInEnum) // not C++11 enum class { @@ -1293,13 +1319,13 @@ continue; } - else if ((newHeader = findHeader(preCommandHeaders)) != NULL) + else if ((newHeader = findHeader(preCommandHeaders)) != nullptr) { // a 'const' variable is not a preCommandHeader if (previousNonWSChar == ')') foundPreCommandHeader = true; } - else if ((newHeader = findHeader(castOperators)) != NULL) + else if ((newHeader = findHeader(castOperators)) != nullptr) { foundCastOperator = true; appendSequence(*newHeader); @@ -1327,12 +1353,12 @@ { if (currentChar == ';') { - blockParenCount = 0; + squareBracketCount = 0; if (((shouldBreakOneLineStatements - || isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE)) - && isOkToBreakBlock(bracketTypeStack->back())) - && !(attachClosingBracketMode && peekNextChar() == '}')) + || isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE)) + && isOkToBreakBlock(braceTypeStack->back())) + && !(attachClosingBraceMode && peekNextChar() == '}')) { passedSemicolon = true; } @@ -1346,7 +1372,7 @@ } if (shouldBreakBlocks - && currentHeader != NULL + && currentHeader != nullptr && currentHeader != &AS_CASE && currentHeader != &AS_DEFAULT && !isHeaderInMultiStatementLine @@ -1356,8 +1382,8 @@ } } if (currentChar != ';' - || (needHeaderOpeningBracket && parenStack->back() == 0)) - currentHeader = NULL; + || (needHeaderOpeningBrace && parenStack->back() == 0)) + currentHeader = nullptr; resetEndOfStatement(); } @@ -1372,13 +1398,13 @@ passedColon = true; } else if (isCStyle() // for C/C++ only - && isOkToBreakBlock(bracketTypeStack->back()) + && isOkToBreakBlock(braceTypeStack->back()) && shouldBreakOneLineStatements && !foundQuestionMark // not in a ?: sequence && !foundPreDefinitionHeader // not in a definition block && previousCommandChar != ')' // not after closing paren of a method header && !foundPreCommandHeader // not after a 'noexcept' - && !blockParenCount // not in objC method call + && squareBracketCount == 0 // not in objC method call && !isInObjCMethodDefinition // not objC '-' or '+' method && !isInObjCInterface // not objC @interface && !isInObjCSelector // not objC @selector @@ -1393,7 +1419,7 @@ if (isCStyle() && shouldPadMethodColon - && (blockParenCount > 0 || isInObjCMethodDefinition || isInObjCSelector) + && (squareBracketCount > 0 || isInObjCMethodDefinition || isInObjCSelector) && !foundQuestionMark) // not in a ?: sequence padObjCMethodColon(); @@ -1448,6 +1474,12 @@ if (isCStyle() && findKeyword(currentLine, charNum, AS_EXTERN) && isExternC()) isInExternC = true; + if (isCStyle() && findKeyword(currentLine, charNum, AS_AUTO) + && (isBraceType(braceTypeStack->back(), NULL_TYPE) + || isBraceType(braceTypeStack->back(), NAMESPACE_TYPE) + || isBraceType(braceTypeStack->back(), CLASS_TYPE))) + foundTrailingReturnType = true; + // Objective-C NSException macros are preCommandHeaders if (isCStyle() && findKeyword(currentLine, charNum, AS_NS_DURING)) foundPreCommandMacro = true; @@ -1481,7 +1513,7 @@ if (isJavaStyle() && (findKeyword(currentLine, charNum, AS_STATIC) - && isNextCharOpeningBracket(charNum + 6))) + && isNextCharOpeningBrace(charNum + 6))) isJavaStaticConstructor = true; if (isSharpStyle() @@ -1525,7 +1557,7 @@ if (currentChar == '@' && isCharPotentialHeader(currentLine, charNum + 1) && findKeyword(currentLine, charNum + 1, AS_INTERFACE) - && isBracketType(bracketTypeStack->back(), NULL_TYPE)) + && isBraceType(braceTypeStack->back(), NULL_TYPE)) { isInObjCInterface = true; string name = '@' + AS_INTERFACE; @@ -1546,7 +1578,7 @@ else if ((currentChar == '-' || currentChar == '+') && (int) currentLine.find_first_not_of(" \t") == charNum && peekNextChar() == '(' - && isBracketType(bracketTypeStack->back(), NULL_TYPE) + && isBraceType(braceTypeStack->back(), NULL_TYPE) && !isInPotentialCalculation) { isInObjCMethodDefinition = true; @@ -1561,17 +1593,20 @@ // determine if this is a potential calculation bool isPotentialOperator = isCharPotentialOperator(currentChar); - newHeader = NULL; + newHeader = nullptr; if (isPotentialOperator) { newHeader = findOperator(operators); // check for Java ? wildcard - if (newHeader == &AS_GCC_MIN_ASSIGN && isJavaStyle() && isInTemplate) - newHeader = NULL; + if (newHeader != nullptr + && newHeader == &AS_GCC_MIN_ASSIGN + && isJavaStyle() + && isInTemplate) + newHeader = nullptr; - if (newHeader != NULL) + if (newHeader != nullptr) { if (newHeader == &AS_LAMBDA) foundPreCommandHeader = true; @@ -1583,9 +1618,9 @@ if (!isInPotentialCalculation) { // must determine if newHeader is an assignment operator - // do NOT use findOperator!!! - if (find(assignmentOperators->begin(), assignmentOperators->end(), newHeader) - != assignmentOperators->end()) + // do NOT use findOperator - the length must be exact!!! + if (find(begin(*assignmentOperators), end(*assignmentOperators), newHeader) + != end(*assignmentOperators)) { foundPreCommandHeader = false; char peekedChar = peekNextChar(); @@ -1599,7 +1634,7 @@ // process pointers and references // check newHeader to eliminate things like '&&' sequence - if (!isJavaStyle() + if (newHeader != nullptr && !isJavaStyle() && (newHeader == &AS_MULT || newHeader == &AS_BIT_AND || newHeader == &AS_BIT_XOR @@ -1617,7 +1652,7 @@ continue; } - if (shouldPadOperators && newHeader != NULL && !isOperatorPaddingDisabled()) + if (shouldPadOperators && newHeader != nullptr && !isOperatorPaddingDisabled()) { padOperators(newHeader); continue; @@ -1650,7 +1685,7 @@ && nextChar != '>' && nextChar != ';' && !isBeforeAnyComment() - /* && !(isBracketType(bracketTypeStack->back(), ARRAY_TYPE)) */ + /* && !(isBraceType(braceTypeStack->back(), ARRAY_TYPE)) */ ) { appendCurrentChar(); @@ -1698,7 +1733,7 @@ } // bypass the entire operator - if (newHeader != NULL) + if (newHeader != nullptr) { appendOperator(*newHeader); goForward(newHeader->length() - 1); @@ -1713,7 +1748,7 @@ string beautifiedLine; size_t readyFormattedLineLength = trim(readyFormattedLine).length(); - bool isInNamespace = isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE); + bool isInNamespace = isBraceType(braceTypeStack->back(), NAMESPACE_TYPE); if (prependEmptyLine // prepend a blank line before this formatted line && readyFormattedLineLength > 0 @@ -1728,13 +1763,13 @@ else // format the current formatted line { isLineReady = false; - horstmannIndentInStatement = horstmannIndentChars; + runInIndentContinuation = runInIndentChars; beautifiedLine = beautify(readyFormattedLine); previousReadyFormattedLineLength = readyFormattedLineLength; // the enhancer is not called for no-indent line comments if (!lineCommentNoBeautify && !isFormattingModeOff) enhancer->enhance(beautifiedLine, isInNamespace, isInPreprocessorBeautify, isInBeautifySQL); - horstmannIndentChars = 0; + runInIndentChars = 0; lineCommentNoBeautify = lineCommentNoIndent; lineCommentNoIndent = false; isInIndentablePreproc = isIndentableProprocessor; @@ -1767,9 +1802,9 @@ } /** - * comparison function for BracketType enum + * comparison function for BraceType enum */ -bool ASFormatter::isBracketType(BracketType a, BracketType b) const +bool ASFormatter::isBraceType(BraceType a, BraceType b) const { if (a == NULL_TYPE || b == NULL_TYPE) return (a == b); @@ -1787,54 +1822,87 @@ } /** - * set the add brackets mode. + * set the add braces mode. * options: - * true brackets added to headers for single line statements. - * false brackets NOT added to headers for single line statements. + * true braces added to headers for single line statements. + * false braces NOT added to headers for single line statements. * - * @param state the add brackets state. + * @param state the add braces state. */ -void ASFormatter::setAddBracketsMode(bool state) +void ASFormatter::setAddBracesMode(bool state) { - shouldAddBrackets = state; + shouldAddBraces = state; } /** - * set the add one line brackets mode. + * set the add one line braces mode. * options: - * true one line brackets added to headers for single line statements. - * false one line brackets NOT added to headers for single line statements. + * true one line braces added to headers for single line statements. + * false one line braces NOT added to headers for single line statements. * - * @param state the add one line brackets state. + * @param state the add one line braces state. */ -void ASFormatter::setAddOneLineBracketsMode(bool state) +void ASFormatter::setAddOneLineBracesMode(bool state) { - shouldAddBrackets = state; - shouldAddOneLineBrackets = state; + shouldAddBraces = state; + shouldAddOneLineBraces = state; } /** - * set the remove brackets mode. + * set the remove braces mode. * options: - * true brackets removed from headers for single line statements. - * false brackets NOT removed from headers for single line statements. + * true braces removed from headers for single line statements. + * false braces NOT removed from headers for single line statements. * - * @param state the remove brackets state. + * @param state the remove braces state. */ +void ASFormatter::setRemoveBracesMode(bool state) +{ + shouldRemoveBraces = state; +} + +// retained for compatability with release 2.06 +// "Brackets" have been changed to "Braces" in 3.0 +// it is referenced only by the old "bracket" options +void ASFormatter::setAddBracketsMode(bool state) +{ + setAddBracesMode(state); +} + +// retained for compatability with release 2.06 +// "Brackets" have been changed to "Braces" in 3.0 +// it is referenced only by the old "bracket" options +void ASFormatter::setAddOneLineBracketsMode(bool state) +{ + setAddOneLineBracesMode(state); +} + +// retained for compatability with release 2.06 +// "Brackets" have been changed to "Braces" in 3.0 +// it is referenced only by the old "bracket" options void ASFormatter::setRemoveBracketsMode(bool state) { - shouldRemoveBrackets = state; + setRemoveBracesMode(state); +} + +// retained for compatability with release 2.06 +// "Brackets" have been changed to "Braces" in 3.0 +// it is referenced only by the old "bracket" options +void ASFormatter::setBreakClosingHeaderBracketsMode(bool state) +{ + setBreakClosingHeaderBracesMode(state); } + /** - * set the bracket formatting mode. + * set the brace formatting mode. * options: * - * @param mode the bracket formatting mode. + * @param mode the brace formatting mode. */ -void ASFormatter::setBracketFormatMode(BracketMode mode) +void ASFormatter::setBraceFormatMode(BraceMode mode) { - bracketFormatMode = mode; + braceFormatMode = mode; } /** @@ -1848,17 +1916,17 @@ } /** - * set closing header bracket breaking mode + * set closing header brace breaking mode * options: - * true brackets just before closing headers (e.g. 'else', 'catch') - * will be broken, even if standard brackets are attached. - * false closing header brackets will be treated as standard brackets. + * true braces just before closing headers (e.g. 'else', 'catch') + * will be broken, even if standard braces are attached. + * false closing header braces will be treated as standard braces. * - * @param state the closing header bracket breaking mode. + * @param state the closing header brace breaking mode. */ -void ASFormatter::setBreakClosingHeaderBracketsMode(bool state) +void ASFormatter::setBreakClosingHeaderBracesMode(bool state) { - shouldBreakClosingHeaderBrackets = state; + shouldBreakClosingHeaderBraces = state; } /** @@ -2061,17 +2129,17 @@ } /** - * set option to attach closing brackets + * set option to attach closing braces * * @param state true = attach, false = don't attach. */ -void ASFormatter::setAttachClosingBracketMode(bool state) +void ASFormatter::setAttachClosingBraceMode(bool state) { - attachClosingBracketMode = state; + attachClosingBraceMode = state; } /** - * set option to attach class brackets + * set option to attach class braces * * @param state true = attach, false = use style default. */ @@ -2081,7 +2149,7 @@ } /** - * set option to attach extern "C" brackets + * set option to attach extern "C" braces * * @param state true = attach, false = use style default. */ @@ -2091,7 +2159,7 @@ } /** - * set option to attach namespace brackets + * set option to attach namespace braces * * @param state true = attach, false = use style default. */ @@ -2101,7 +2169,7 @@ } /** - * set option to attach inline brackets + * set option to attach inline braces * * @param state true = attach, false = use style default. */ @@ -2110,6 +2178,11 @@ shouldAttachInline = state; } +void ASFormatter::setAttachClosingWhile(bool state) +{ + shouldAttachClosingWhile = state; +} + /** * set option to break/not break one-line blocks * @@ -2393,8 +2466,8 @@ endOfCodeReached = true; return false; } - if (appendOpeningBracket) - currentLine = "{"; // append bracket that was removed from the previous line + if (appendOpeningBrace) + currentLine = "{"; // append brace that was removed from the previous line else { currentLine = sourceIterator->nextLine(emptyLineWasDeleted); @@ -2442,19 +2515,19 @@ initNewLine(); currentChar = currentLine[charNum]; - if (isInBracketRunIn && previousNonWSChar == '{' && !isInComment) + if (isInBraceRunIn && previousNonWSChar == '{' && !isInComment) isInLineBreak = false; - isInBracketRunIn = false; + isInBraceRunIn = false; if (currentChar == '\t' && shouldConvertTabs) convertTabToSpaces(); - // check for an empty line inside a command bracket. + // check for an empty line inside a command brace. // if yes then read the next line (calls getNextLine recursively). // must be after initNewLine. if (shouldDeleteEmptyLines && lineIsEmpty - && isBracketType((*bracketTypeStack)[bracketTypeStack->size() - 1], COMMAND_TYPE)) + && isBraceType((*braceTypeStack)[braceTypeStack->size() - 1], COMMAND_TYPE)) { if (!shouldBreakBlocks || previousNonWSChar == '{' || !commentAndHeaderFollows()) { @@ -2522,9 +2595,9 @@ lineIsLineCommentOnly = false; lineEndsInCommentOnly = false; doesLineStartComment = false; - currentLineBeginsWithBracket = false; + currentLineBeginsWithBrace = false; lineIsEmpty = false; - currentLineFirstBracketNum = string::npos; + currentLineFirstBraceNum = string::npos; tabIncrementIn = 0; // bypass whitespace at the start of a line @@ -2549,8 +2622,8 @@ } else if (isSequenceReached("{")) { - currentLineBeginsWithBracket = true; - currentLineFirstBracketNum = charNum; + currentLineBeginsWithBrace = true; + currentLineFirstBraceNum = charNum; size_t firstText = currentLine.find_first_not_of(" \t", charNum + 1); if (firstText != string::npos) { @@ -2723,24 +2796,24 @@ } /** - * check if the currently reached open-bracket (i.e. '{') + * check if the currently reached open-brace (i.e. '{') * opens a: * - a definition type block (such as a class or namespace), * - a command block (such as a method block) * - a static array * this method takes for granted that the current character - * is an opening bracket. + * is an opening brace. * * @return the type of the opened block. */ -BracketType ASFormatter::getBracketType() +BraceType ASFormatter::getBraceType() { assert(currentChar == '{'); - BracketType returnVal = NULL_TYPE; + BraceType returnVal = NULL_TYPE; if ((previousNonWSChar == '=' - || isBracketType(bracketTypeStack->back(), ARRAY_TYPE)) + || isBraceType(braceTypeStack->back(), ARRAY_TYPE)) && previousCommandChar != ')' && !isNonParenHeader) returnVal = ARRAY_TYPE; @@ -2748,30 +2821,31 @@ { returnVal = DEFINITION_TYPE; if (foundNamespaceHeader) - returnVal = (BracketType)(returnVal | NAMESPACE_TYPE); + returnVal = (BraceType)(returnVal | NAMESPACE_TYPE); else if (foundClassHeader) - returnVal = (BracketType)(returnVal | CLASS_TYPE); + returnVal = (BraceType)(returnVal | CLASS_TYPE); else if (foundStructHeader) - returnVal = (BracketType)(returnVal | STRUCT_TYPE); + returnVal = (BraceType)(returnVal | STRUCT_TYPE); else if (foundInterfaceHeader) - returnVal = (BracketType)(returnVal | INTERFACE_TYPE); + returnVal = (BraceType)(returnVal | INTERFACE_TYPE); } else if (isInEnum) { - returnVal = (BracketType)(ARRAY_TYPE | ENUM_TYPE); + returnVal = (BraceType)(ARRAY_TYPE | ENUM_TYPE); } else { bool isCommandType = (foundPreCommandHeader || foundPreCommandMacro - || (currentHeader != NULL && isNonParenHeader) + || (currentHeader != nullptr && isNonParenHeader) || (previousCommandChar == ')') || (previousCommandChar == ':' && !foundQuestionMark) || (previousCommandChar == ';') || ((previousCommandChar == '{' || previousCommandChar == '}') - && isPreviousBracketBlockRelated) + && isPreviousBraceBlockRelated) || (isInClassInitializer && (!isLegalNameChar(previousNonWSChar) || foundPreCommandHeader)) + || foundTrailingReturnType || isInObjCMethodDefinition || isInObjCInterface || isJavaStaticConstructor @@ -2797,24 +2871,24 @@ if (foundOneLineBlock > 0) { - returnVal = (BracketType) (returnVal | SINGLE_LINE_TYPE); + returnVal = (BraceType) (returnVal | SINGLE_LINE_TYPE); if (breakCurrentOneLineBlock) - returnVal = (BracketType) (returnVal | BREAK_BLOCK_TYPE); + returnVal = (BraceType) (returnVal | BREAK_BLOCK_TYPE); if (foundOneLineBlock == 3) - returnVal = (BracketType)(returnVal | EMPTY_BLOCK_TYPE); + returnVal = (BraceType)(returnVal | EMPTY_BLOCK_TYPE); } - if (isBracketType(returnVal, ARRAY_TYPE)) + if (isBraceType(returnVal, ARRAY_TYPE)) { - if (isNonInStatementArrayBracket()) + if (isNonInStatementArrayBrace()) { - returnVal = (BracketType)(returnVal | ARRAY_NIS_TYPE); + returnVal = (BraceType)(returnVal | ARRAY_NIS_TYPE); isNonInStatementArray = true; isImmediatelyPostNonInStmt = false; // in case of "},{" - nonInStatementBracket = formattedLine.length() - 1; + nonInStatementBrace = formattedLine.length() - 1; } - if (isUniformInitializerBracket()) - returnVal = (BracketType)(returnVal | INIT_TYPE); + if (isUniformInitializerBrace()) + returnVal = (BraceType)(returnVal | INIT_TYPE); } return returnVal; @@ -2943,14 +3017,18 @@ //check for rvalue reference if (currentChar == '&' && nextChar == '&') { + if (lastWord == "auto") + return true; if (previousNonWSChar == '>') return true; - string followingText = peekNextText(currentLine.substr(charNum + 2)); + string followingText; + if ((int) currentLine.length() > charNum + 2) + followingText = peekNextText(currentLine.substr(charNum + 2)); if (followingText.length() > 0 && followingText[0] == ')') return true; - if (currentHeader != NULL || isInPotentialCalculation) + if (currentHeader != nullptr || isInPotentialCalculation) return false; - if (parenStack->back() > 0 && isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) + if (parenStack->back() > 0 && isBraceType(braceTypeStack->back(), COMMAND_TYPE)) return false; return true; } @@ -2966,7 +3044,7 @@ || currentHeader == &AS_QFOREACH) return true; - if (isBracketType(bracketTypeStack->back(), ARRAY_TYPE) + if (isBraceType(braceTypeStack->back(), ARRAY_TYPE) && isLegalNameChar(lastWord[0]) && isLegalNameChar(nextChar) && previousNonWSChar != ')') @@ -2983,7 +3061,7 @@ // if followed by an assignment it is a pointer or reference // if followed by semicolon it is a pointer or reference in range-based for const string* followingOperator = getFollowingOperator(); - if (followingOperator + if (followingOperator != nullptr && followingOperator != &AS_MULT && followingOperator != &AS_BIT_AND) { @@ -2992,8 +3070,8 @@ return false; } - if (isBracketType(bracketTypeStack->back(), COMMAND_TYPE) - || blockParenCount > 0) + if (isBraceType(braceTypeStack->back(), COMMAND_TYPE) + || squareBracketCount > 0) return false; return true; } @@ -3083,7 +3161,7 @@ // check first char on the line if (charNum == (int) currentLine.find_first_not_of(" \t") - && (isBracketType(bracketTypeStack->back(), COMMAND_TYPE) + && (isBraceType(braceTypeStack->back(), COMMAND_TYPE) || parenStack->back() != 0)) return true; @@ -3102,7 +3180,7 @@ || (previousNonWSChar == '*' && currentChar == '&')) return false; - if (!isBracketType(bracketTypeStack->back(), COMMAND_TYPE) + if (!isBraceType(braceTypeStack->back(), COMMAND_TYPE) && parenStack->back() == 0) return false; @@ -3173,7 +3251,7 @@ * * @return whether word is a pointer or reference variable. */ -bool ASFormatter::isPointerOrReferenceVariable(string& word) const +bool ASFormatter::isPointerOrReferenceVariable(const string& word) const { return (word == "char" || word == "int" @@ -3211,9 +3289,9 @@ bool ASFormatter::isInSwitchStatement() const { assert(isInLineComment || isInComment); - if (!preBracketHeaderStack->empty()) - for (size_t i = 1; i < preBracketHeaderStack->size(); i++) - if (preBracketHeaderStack->at(i) == &AS_SWITCH) + if (!preBraceHeaderStack->empty()) + for (size_t i = 1; i < preBraceHeaderStack->size(); i++) + if (preBraceHeaderStack->at(i) == &AS_SWITCH) return true; return false; } @@ -3239,20 +3317,20 @@ } /** - * check if an array bracket should NOT have an in-statement indent + * check if an array brace should NOT have an in-statement indent * * @return the array is non in-statement */ -bool ASFormatter::isNonInStatementArrayBracket() const +bool ASFormatter::isNonInStatementArrayBrace() const { bool returnVal = false; char nextChar = peekNextChar(); - // if this opening bracket begins the line there will be no inStatement indent - if (currentLineBeginsWithBracket - && charNum == (int) currentLineFirstBracketNum + // if this opening brace begins the line there will be no inStatement indent + if (currentLineBeginsWithBrace + && charNum == (int) currentLineFirstBraceNum && nextChar != '}') returnVal = true; - // if an opening bracket ends the line there will be no inStatement indent + // if an opening brace ends the line there will be no inStatement indent if (isWhiteSpace(nextChar) || isBeforeAnyLineEndComment(charNum) || nextChar == '{') @@ -3282,7 +3360,7 @@ bool isInComment_ = false; bool isInQuote_ = false; bool hasText = false; - int bracketCount = 0; + int braceCount = 0; int lineLength = line.length(); char quoteChar_ = ' '; char ch = ' '; @@ -3335,13 +3413,13 @@ if (ch == '{') { - ++bracketCount; + ++braceCount; continue; } if (ch == '}') { - --bracketCount; - if (bracketCount == 0) + --braceCount; + if (braceCount == 0) { // is this an array? if (parenStack->back() == 0 && prevCh != '}') @@ -3391,14 +3469,14 @@ } /** - * peek at the next char to determine if it is an opening bracket. + * peek at the next char to determine if it is an opening brace. * will look ahead in the input file if necessary. * this determines a java static constructor. * * @param startChar position on currentLine to start the search - * @return true if the next word is an opening bracket. + * @return true if the next word is an opening brace. */ -bool ASFormatter::isNextCharOpeningBracket(int startChar) const +bool ASFormatter::isNextCharOpeningBrace(int startChar) const { bool retVal = false; string nextText = peekNextText(currentLine.substr(startChar)); @@ -3437,10 +3515,10 @@ } /** -* Determine if an opening array-type bracket should have a leading space pad. +* Determine if an opening array-type brace should have a leading space pad. * This is to identify C++11 uniform initializers. */ -bool ASFormatter::isUniformInitializerBracket() const +bool ASFormatter::isUniformInitializerBrace() const { if (isCStyle() && !isInEnum && !isImmediatelyPostPreprocessor) { @@ -3461,7 +3539,7 @@ bool isInQuote_ = false; int semiCount_ = 0; int parenCount_ = 0; - int bracketCount_ = 0; + int braceCount_ = 0; for (size_t i = 0; i < currentLine.length(); i++) { @@ -3505,13 +3583,13 @@ continue; if (currentLine[i] == '{') { - ++bracketCount_; + ++braceCount_; } if (currentLine[i] == '}') { - --bracketCount_; + --braceCount_; } - if (bracketCount_ > 0) + if (braceCount_ > 0) continue; if (currentLine[i] == ';') { @@ -3530,24 +3608,25 @@ * @param firstLine the first line to check * @return the next non-whitespace substring. */ -string ASFormatter::peekNextText(const string& firstLine, bool endOnEmptyLine /*false*/, bool shouldReset /*false*/) const +string ASFormatter::peekNextText(const string& firstLine, + bool endOnEmptyLine /*false*/, + shared_ptr streamArg /*nullptr*/) const { bool isFirstLine = true; - bool needReset = shouldReset; string nextLine_ = firstLine; size_t firstChar = string::npos; + shared_ptr stream = streamArg; + if (stream == nullptr) // Borland may need == 0 + stream = make_shared(sourceIterator); // find the first non-blank text, bypassing all comments. bool isInComment_ = false; - while (sourceIterator->hasMoreLines() || isFirstLine) + while (stream->hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else - { - nextLine_ = sourceIterator->peekNextLine(); - needReset = true; - } + nextLine_ = stream->peekNextLine(); firstChar = nextLine_.find_first_not_of(" \t"); if (firstChar == string::npos) @@ -3586,8 +3665,6 @@ nextLine_ = ""; else nextLine_ = nextLine_.substr(firstChar); - if (needReset) - sourceIterator->peekReset(); return nextLine_; } @@ -3638,8 +3715,8 @@ } /** - * append the current bracket inside the end of line comments - * currentChar contains the bracket, it will be appended to formattedLine + * append the current brace inside the end of line comments + * currentChar contains the brace, it will be appended to formattedLine * formattedLineCommentNum is the comment location on formattedLine */ void ASFormatter::appendCharInsideComments() @@ -3663,7 +3740,7 @@ } beg++; - // insert the bracket + // insert the brace if (end - beg < 3) // is there room to insert? formattedLine.insert(beg, 3 - end + beg, ' '); if (formattedLine[beg] == '\t') // don't pad with a tab @@ -3687,8 +3764,9 @@ void ASFormatter::padOperators(const string* newOperator) { assert(shouldPadOperators); - assert(newOperator != NULL); + assert(newOperator != nullptr); + char nextNonWSChar = ASBase::peekNextChar(currentLine, charNum); bool shouldPad = (newOperator != &AS_SCOPE_RESOLUTION && newOperator != &AS_PLUS_PLUS && newOperator != &AS_MINUS_MINUS @@ -3697,7 +3775,7 @@ && newOperator != &AS_ARROW && !(newOperator == &AS_COLON && !foundQuestionMark // objC methods && (isInObjCMethodDefinition || isInObjCInterface - || isInObjCSelector || blockParenCount)) + || isInObjCSelector || squareBracketCount != 0)) && !(newOperator == &AS_MINUS && isInExponent()) && !(newOperator == &AS_PLUS && isInExponent()) && !((newOperator == &AS_PLUS || newOperator == &AS_MINUS) // check for unary plus or minus @@ -3707,7 +3785,6 @@ || previousNonWSChar == ',' || previousNonWSChar == ':' || previousNonWSChar == '{')) - && !isCharImmediatelyPostOperator //? // commented out in release 2.05.1 - doesn't seem to do anything??? //x && !((newOperator == &AS_MULT || newOperator == &AS_BIT_AND || newOperator == &AS_AND) //x && isPointerOrReference()) @@ -3721,9 +3798,15 @@ && ASBase::peekNextChar(currentLine, charNum + 1) == '>') && !(newOperator == &AS_GR && previousNonWSChar == '?') && !(newOperator == &AS_QUESTION // check for Java wildcard + && isJavaStyle() && (previousNonWSChar == '<' - || ASBase::peekNextChar(currentLine, charNum) == '>' - || ASBase::peekNextChar(currentLine, charNum) == '.')) + || nextNonWSChar == '>' + || nextNonWSChar == '.')) + && !(newOperator == &AS_QUESTION // check for C# null conditional operator + && isSharpStyle() + && (nextNonWSChar == '.' + || nextNonWSChar == '[')) + && !isCharImmediatelyPostOperator && !isInCase && !isInAsm && !isInAsmOneLine @@ -3755,8 +3838,6 @@ && peekNextChar() == '[') ) appendSpaceAfter(); - - previousOperator = newOperator; } /** @@ -3778,10 +3859,12 @@ int itemAlignment = (currentChar == '*' || currentChar == '^') ? pa : ((ra == REF_SAME_AS_PTR) ? pa : ra); // check for ** and && + int ptrLength = 1; char peekedChar = peekNextChar(); if ((currentChar == '*' && peekedChar == '*') || (currentChar == '&' && peekedChar == '&')) { + ptrLength = 2; size_t nextChar = currentLine.find_first_not_of(" \t", charNum + 2); if (nextChar == string::npos) peekedChar = ' '; @@ -3819,7 +3902,9 @@ } else // pointerAlignment == PTR_ALIGN_NONE { - formattedLine.append(1, currentChar); + formattedLine.append(ptrLength, currentChar); + if (ptrLength > 1) + goForward(ptrLength - 1); } } @@ -4192,7 +4277,7 @@ size_t i = formattedLine.find_last_not_of(" \t"); if (i != string::npos) { - // if last char is a bracket the previous whitespace is an indent + // if last char is a brace the previous whitespace is an indent if (formattedLine[i] == '{') spacesOutsideToDelete = 0; else if (isCharImmediatelyPostPointerOrReference) @@ -4203,12 +4288,12 @@ lastChar = formattedLine[i]; // if previous word is a header, it will be a paren header string prevWord = getPreviousWord(formattedLine, formattedLine.length()); - const string* prevWordH = NULL; + const string* prevWordH = nullptr; if (shouldPadHeader && prevWord.length() > 0 && isCharPotentialHeader(prevWord, 0)) - prevWordH = ASBeautifier::findHeader(prevWord, 0, headers); - if (prevWordH != NULL) + prevWordH = ASBase::findHeader(prevWord, 0, headers); + if (prevWordH != nullptr) prevIsParenHeader = true; else if (prevWord == AS_RETURN) // don't unpad prevIsParenHeader = true; @@ -4217,7 +4302,7 @@ prevIsParenHeader = true; else if (isCStyle() && prevWord == AS_THROW && shouldPadHeader) // don't unpad prevIsParenHeader = true; - else if (prevWord == "and" || prevWord == "or") // don't unpad + else if (prevWord == "and" || prevWord == "or" || prevWord == "in") // don't unpad prevIsParenHeader = true; // don't unpad variables else if (prevWord == "bool" @@ -4559,70 +4644,70 @@ } /** - * format opening bracket as attached or broken - * currentChar contains the bracket - * the brackets will be appended to the current formattedLine or a new formattedLine as necessary + * format opening brace as attached or broken + * currentChar contains the brace + * the braces will be appended to the current formattedLine or a new formattedLine as necessary * the calling function should have a continue statement after calling this method * - * @param bracketType the type of bracket to be formatted. + * @param braceType the type of brace to be formatted. */ -void ASFormatter::formatOpeningBracket(BracketType bracketType) +void ASFormatter::formatOpeningBrace(BraceType braceType) { - assert(!isBracketType(bracketType, ARRAY_TYPE)); + assert(!isBraceType(braceType, ARRAY_TYPE)); assert(currentChar == '{'); - parenStack->push_back(0); + parenStack->emplace_back(0); - bool breakBracket = isCurrentBracketBroken(); + bool breakBrace = isCurrentBraceBroken(); - if (breakBracket) + if (breakBrace) { - if (isBeforeAnyComment() && isOkToBreakBlock(bracketType)) + if (isBeforeAnyComment() && isOkToBreakBlock(braceType)) { // if comment is at line end leave the comment on this line - if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBracket) + if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBrace) { - currentChar = ' '; // remove bracket from current line + currentChar = ' '; // remove brace from current line if (parenStack->size() > 1) parenStack->pop_back(); currentLine[charNum] = currentChar; - appendOpeningBracket = true; // append bracket to following line + appendOpeningBrace = true; // append brace to following line } - // else put comment after the bracket + // else put comment after the brace else if (!isBeforeMultipleLineEndComments(charNum)) breakLine(); } - else if (!isBracketType(bracketType, SINGLE_LINE_TYPE)) + else if (!isBraceType(braceType, SINGLE_LINE_TYPE)) { formattedLine = rtrim(formattedLine); breakLine(); } - else if ((shouldBreakOneLineBlocks || isBracketType(bracketType, BREAK_BLOCK_TYPE)) - && !isBracketType(bracketType, EMPTY_BLOCK_TYPE)) + else if ((shouldBreakOneLineBlocks || isBraceType(braceType, BREAK_BLOCK_TYPE)) + && !isBraceType(braceType, EMPTY_BLOCK_TYPE)) breakLine(); else if (!isInLineBreak) appendSpacePad(); appendCurrentChar(); - // should a following comment break from the bracket? - // must break the line AFTER the bracket + // should a following comment break from the brace? + // must break the line AFTER the brace if (isBeforeComment() && formattedLine.length() > 0 && formattedLine[0] == '{' - && isOkToBreakBlock(bracketType) - && (bracketFormatMode == BREAK_MODE - || bracketFormatMode == LINUX_MODE)) + && isOkToBreakBlock(braceType) + && (braceFormatMode == BREAK_MODE + || braceFormatMode == LINUX_MODE)) { shouldBreakLineAtNextChar = true; } } - else // attach bracket + else // attach brace { - // are there comments before the bracket? + // are there comments before the brace? if (isCharImmediatelyPostComment || isCharImmediatelyPostLineComment) { - if (isOkToBreakBlock(bracketType) + if (isOkToBreakBlock(braceType) && !(isCharImmediatelyPostComment && isCharImmediatelyPostLineComment) // don't attach if two comments on the line && !isImmediatelyPostPreprocessor // && peekNextChar() != '}' // don't attach { } // removed release 2.03 @@ -4648,20 +4733,20 @@ // if a blank line precedes this don't attach if (isEmptyLine(formattedLine)) appendCurrentChar(); // don't attach - else if (isOkToBreakBlock(bracketType) + else if (isOkToBreakBlock(braceType) && !(isImmediatelyPostPreprocessor - && currentLineBeginsWithBracket)) + && currentLineBeginsWithBrace)) { - if (!isBracketType(bracketType, EMPTY_BLOCK_TYPE)) + if (!isBraceType(braceType, EMPTY_BLOCK_TYPE)) { appendSpacePad(); appendCurrentChar(false); // OK to attach testForTimeToSplitFormattedLine(); // line length will have changed - // should a following comment attach with the bracket? + // should a following comment attach with the brace? // insert spaces to reposition the comment if (isBeforeComment() && !isBeforeMultipleLineEndComments(charNum) - && (!isBeforeAnyLineEndComment(charNum) || currentLineBeginsWithBracket)) + && (!isBeforeAnyLineEndComment(charNum) || currentLineBeginsWithBrace)) { shouldBreakLineAtNextChar = true; currentLine.insert(charNum + 1, charNum + 1, ' '); @@ -4673,7 +4758,7 @@ } else { - if (currentLineBeginsWithBracket && charNum == (int) currentLineFirstBracketNum) + if (currentLineBeginsWithBrace && charNum == (int) currentLineFirstBraceNum) { appendSpacePad(); appendCurrentChar(false); // attach @@ -4697,15 +4782,15 @@ } /** - * format closing bracket - * currentChar contains the bracket + * format closing brace + * currentChar contains the brace * the calling function should have a continue statement after calling this method * - * @param bracketType the type of the opening bracket for this closing bracket. + * @param braceType the type of the opening brace for this closing brace. */ -void ASFormatter::formatClosingBracket(BracketType bracketType) +void ASFormatter::formatClosingBrace(BraceType braceType) { - assert(!isBracketType(bracketType, ARRAY_TYPE)); + assert(!isBraceType(braceType, ARRAY_TYPE)); assert(currentChar == '}'); // parenStack must contain one entry @@ -4713,21 +4798,21 @@ parenStack->pop_back(); // mark state of immediately after empty block - // this state will be used for locating brackets that appear immediately AFTER an empty block (e.g. '{} \n}'). + // this state will be used for locating braces that appear immediately AFTER an empty block (e.g. '{} \n}'). if (previousCommandChar == '{') isImmediatelyPostEmptyBlock = true; - if (attachClosingBracketMode) + if (attachClosingBraceMode) { // for now, namespaces and classes will be attached. Uncomment the lines below to break. if ((isEmptyLine(formattedLine) // if a blank line precedes this || isCharImmediatelyPostLineComment || isCharImmediatelyPostComment || (isImmediatelyPostPreprocessor && (int) currentLine.find_first_not_of(" \t") == charNum) -// || (isBracketType(bracketType, CLASS_TYPE) && isOkToBreakBlock(bracketType) && previousNonWSChar != '{') -// || (isBracketType(bracketType, NAMESPACE_TYPE) && isOkToBreakBlock(bracketType) && previousNonWSChar != '{') +// || (isBraceType(braceType, CLASS_TYPE) && isOkToBreakBlock(braceType) && previousNonWSChar != '{') +// || (isBraceType(braceType, NAMESPACE_TYPE) && isOkToBreakBlock(braceType) && previousNonWSChar != '{') ) - && (!isBracketType(bracketType, SINGLE_LINE_TYPE) || isOkToBreakBlock(bracketType))) + && (!isBraceType(braceType, SINGLE_LINE_TYPE) || isOkToBreakBlock(braceType))) { breakLine(); appendCurrentChar(); // don't attach @@ -4735,15 +4820,15 @@ else { if (previousNonWSChar != '{' - && (!isBracketType(bracketType, SINGLE_LINE_TYPE) - || isOkToBreakBlock(bracketType))) + && (!isBraceType(braceType, SINGLE_LINE_TYPE) + || isOkToBreakBlock(braceType))) appendSpacePad(); appendCurrentChar(false); // attach } } - else if (!isBracketType(bracketType, EMPTY_BLOCK_TYPE) - && (isBracketType(bracketType, BREAK_BLOCK_TYPE) - || isOkToBreakBlock(bracketType))) + else if (!isBraceType(braceType, EMPTY_BLOCK_TYPE) + && (isBraceType(braceType, BREAK_BLOCK_TYPE) + || isOkToBreakBlock(braceType))) { breakLine(); appendCurrentChar(); @@ -4758,13 +4843,13 @@ appendSpaceAfter(); if (shouldBreakBlocks - && currentHeader != NULL + && currentHeader != nullptr && !isHeaderInMultiStatementLine && parenStack->back() == 0) { if (currentHeader == &AS_CASE || currentHeader == &AS_DEFAULT) { - // do not yet insert a line if "break" statement is outside the brackets + // do not yet insert a line if "break" statement is outside the braces string nextText = peekNextText(currentLine.substr(charNum + 1)); if (nextText.length() > 0 && nextText.substr(0, 5) != "break") @@ -4776,30 +4861,30 @@ } /** - * format array brackets as attached or broken - * determine if the brackets can have an inStatement indent - * currentChar contains the bracket - * the brackets will be appended to the current formattedLine or a new formattedLine as necessary + * format array braces as attached or broken + * determine if the braces can have an inStatement indent + * currentChar contains the brace + * the braces will be appended to the current formattedLine or a new formattedLine as necessary * the calling function should have a continue statement after calling this method * - * @param bracketType the type of bracket to be formatted, must be an ARRAY_TYPE. - * @param isOpeningArrayBracket indicates if this is the opening bracket for the array block. + * @param braceType the type of brace to be formatted, must be an ARRAY_TYPE. + * @param isOpeningArrayBrace indicates if this is the opening brace for the array block. */ -void ASFormatter::formatArrayBrackets(BracketType bracketType, bool isOpeningArrayBracket) +void ASFormatter::formatArrayBraces(BraceType braceType, bool isOpeningArrayBrace) { - assert(isBracketType(bracketType, ARRAY_TYPE)); + assert(isBraceType(braceType, ARRAY_TYPE)); assert(currentChar == '{' || currentChar == '}'); if (currentChar == '{') { - // is this the first opening bracket in the array? - if (isOpeningArrayBracket) + // is this the first opening brace in the array? + if (isOpeningArrayBrace) { - if (bracketFormatMode == ATTACH_MODE - || bracketFormatMode == LINUX_MODE) + if (braceFormatMode == ATTACH_MODE + || braceFormatMode == LINUX_MODE) { // break an enum if mozilla - if (isBracketType(bracketType, ENUM_TYPE) + if (isBraceType(braceType, ENUM_TYPE) && formattingStyle == STYLE_MOZILLA) { isInLineBreak = true; @@ -4809,17 +4894,17 @@ else if ((isImmediatelyPostPreprocessor || (formattedLine.length() > 0 && formattedLine[formattedLine.length() - 1] == '\\')) - && currentLineBeginsWithBracket) + && currentLineBeginsWithBrace) { isInLineBreak = true; appendCurrentChar(); // don't attach } else if (isCharImmediatelyPostComment) { - // TODO: attach bracket to line-end comment + // TODO: attach brace to line-end comment appendCurrentChar(); // don't attach } - else if (isCharImmediatelyPostLineComment && !isBracketType(bracketType, SINGLE_LINE_TYPE)) + else if (isCharImmediatelyPostLineComment && !isBraceType(braceType, SINGLE_LINE_TYPE)) { appendCharInsideComments(); } @@ -4830,17 +4915,17 @@ appendCurrentChar(); // don't attach else { - // if bracket is broken or not an assignment - if (currentLineBeginsWithBracket - && !isBracketType(bracketType, SINGLE_LINE_TYPE)) + // if brace is broken or not an assignment + if (currentLineBeginsWithBrace + && !isBraceType(braceType, SINGLE_LINE_TYPE)) { appendSpacePad(); appendCurrentChar(false); // OK to attach // TODO: debug the following line testForTimeToSplitFormattedLine(); // line length will have changed - if (currentLineBeginsWithBracket - && (int) currentLineFirstBracketNum == charNum) + if (currentLineBeginsWithBrace + && (int) currentLineFirstBraceNum == charNum) shouldBreakLineAtNextChar = true; } else @@ -4848,7 +4933,7 @@ if (previousNonWSChar != '(') { // don't space pad C++11 uniform initialization - if (!isBracketType(bracketType, INIT_TYPE)) + if (!isBraceType(braceType, INIT_TYPE)) appendSpacePad(); } appendCurrentChar(); @@ -4856,57 +4941,57 @@ } } } - else if (bracketFormatMode == BREAK_MODE) + else if (braceFormatMode == BREAK_MODE) { if (isWhiteSpace(peekNextChar()) && !isInVirginLine) breakLine(); else if (isBeforeAnyComment()) { // do not break unless comment is at line end - if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBracket) + if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBrace) { - currentChar = ' '; // remove bracket from current line - appendOpeningBracket = true; // append bracket to following line + currentChar = ' '; // remove brace from current line + appendOpeningBrace = true; // append brace to following line } } if (!isInLineBreak && previousNonWSChar != '(') { // don't space pad C++11 uniform initialization - if (!isBracketType(bracketType, INIT_TYPE)) + if (!isBraceType(braceType, INIT_TYPE)) appendSpacePad(); } appendCurrentChar(); - if (currentLineBeginsWithBracket - && (int) currentLineFirstBracketNum == charNum - && !isBracketType(bracketType, SINGLE_LINE_TYPE)) + if (currentLineBeginsWithBrace + && (int) currentLineFirstBraceNum == charNum + && !isBraceType(braceType, SINGLE_LINE_TYPE)) shouldBreakLineAtNextChar = true; } - else if (bracketFormatMode == RUN_IN_MODE) + else if (braceFormatMode == RUN_IN_MODE) { if (isWhiteSpace(peekNextChar()) && !isInVirginLine) breakLine(); else if (isBeforeAnyComment()) { // do not break unless comment is at line end - if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBracket) + if (isBeforeAnyLineEndComment(charNum) && !currentLineBeginsWithBrace) { - currentChar = ' '; // remove bracket from current line - appendOpeningBracket = true; // append bracket to following line + currentChar = ' '; // remove brace from current line + appendOpeningBrace = true; // append brace to following line } } if (!isInLineBreak && previousNonWSChar != '(') { // don't space pad C++11 uniform initialization - if (!isBracketType(bracketType, INIT_TYPE)) + if (!isBraceType(braceType, INIT_TYPE)) appendSpacePad(); } appendCurrentChar(); } - else if (bracketFormatMode == NONE_MODE) + else if (braceFormatMode == NONE_MODE) { - if (currentLineBeginsWithBracket - && charNum == (int) currentLineFirstBracketNum) + if (currentLineBeginsWithBrace + && charNum == (int) currentLineFirstBraceNum) { appendCurrentChar(); // don't attach } @@ -4915,29 +5000,29 @@ if (previousNonWSChar != '(') { // don't space pad C++11 uniform initialization - if (!isBracketType(bracketType, INIT_TYPE)) + if (!isBraceType(braceType, INIT_TYPE)) appendSpacePad(); } appendCurrentChar(false); // OK to attach } } } - else // not the first opening bracket + else // not the first opening brace { - if (bracketFormatMode == RUN_IN_MODE) + if (braceFormatMode == RUN_IN_MODE) { if (previousNonWSChar == '{' - && bracketTypeStack->size() > 2 - && !isBracketType((*bracketTypeStack)[bracketTypeStack->size() - 2], - SINGLE_LINE_TYPE)) + && braceTypeStack->size() > 2 + && !isBraceType((*braceTypeStack)[braceTypeStack->size() - 2], + SINGLE_LINE_TYPE)) formatArrayRunIn(); } else if (!isInLineBreak && !isWhiteSpace(peekNextChar()) && previousNonWSChar == '{' - && bracketTypeStack->size() > 2 - && !isBracketType((*bracketTypeStack)[bracketTypeStack->size() - 2], - SINGLE_LINE_TYPE)) + && braceTypeStack->size() > 2 + && !isBraceType((*braceTypeStack)[braceTypeStack->size() - 2], + SINGLE_LINE_TYPE)) formatArrayRunIn(); appendCurrentChar(); @@ -4945,7 +5030,7 @@ } else if (currentChar == '}') { - if (attachClosingBracketMode) + if (attachClosingBraceMode) { if (isEmptyLine(formattedLine) // if a blank line precedes this || isImmediatelyPostPreprocessor @@ -4960,10 +5045,10 @@ } else { - // does this close the first opening bracket in the array? + // does this close the first opening brace in the array? // must check if the block is still a single line because of anonymous statements - if (!isBracketType(bracketType, INIT_TYPE) - && (!isBracketType(bracketType, SINGLE_LINE_TYPE) + if (!isBraceType(braceType, INIT_TYPE) + && (!isBraceType(braceType, SINGLE_LINE_TYPE) || formattedLine.find('{') == string::npos)) breakLine(); appendCurrentChar(); @@ -4983,23 +5068,23 @@ */ void ASFormatter::formatRunIn() { - assert(bracketFormatMode == RUN_IN_MODE || bracketFormatMode == NONE_MODE); + assert(braceFormatMode == RUN_IN_MODE || braceFormatMode == NONE_MODE); // keep one line blocks returns true without indenting the run-in if (formattingStyle != STYLE_PICO - && !isOkToBreakBlock(bracketTypeStack->back())) + && !isOkToBreakBlock(braceTypeStack->back())) return; // true; - // make sure the line begins with a bracket + // make sure the line begins with a brace size_t lastText = formattedLine.find_last_not_of(" \t"); if (lastText == string::npos || formattedLine[lastText] != '{') return; // false; - // make sure the bracket is broken + // make sure the brace is broken if (formattedLine.find_first_not_of(" \t{") != string::npos) return; // false; - if (isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE)) + if (isBraceType(braceTypeStack->back(), NAMESPACE_TYPE)) return; // false; bool extraIndent = false; @@ -5009,8 +5094,8 @@ // cannot attach a class modifier without indent-classes if (isCStyle() && isCharPotentialHeader(currentLine, charNum) - && (isBracketType(bracketTypeStack->back(), CLASS_TYPE) - || (isBracketType(bracketTypeStack->back(), STRUCT_TYPE) + && (isBraceType(braceTypeStack->back(), CLASS_TYPE) + || (isBraceType(braceTypeStack->back(), STRUCT_TYPE) && isInIndentableStruct))) { if (findKeyword(currentLine, charNum, AS_PUBLIC) @@ -5035,8 +5120,8 @@ // extra indent for switch statements if (getSwitchIndent() - && !preBracketHeaderStack->empty() - && preBracketHeaderStack->back() == &AS_SWITCH + && !preBraceHeaderStack->empty() + && preBraceHeaderStack->back() == &AS_SWITCH && ((isLegalNameChar(currentChar) && !findKeyword(currentLine, charNum, AS_CASE)))) extraIndent = true; @@ -5050,8 +5135,8 @@ if (extraHalfIndent) { int indentLength_ = getIndentLength(); - horstmannIndentChars = indentLength_ / 2; - formattedLine.append(horstmannIndentChars - 1, ' '); + runInIndentChars = indentLength_ / 2; + formattedLine.append(runInIndentChars - 1, ' '); } else if (getForceTabIndentation() && getIndentLength() != getTabLength()) { @@ -5065,33 +5150,33 @@ // replace spaces indents with tab indents size_t tabCount = indent.length() / tabLength_; // truncate extra spaces indent.replace(0U, tabCount * tabLength_, tabCount, '\t'); - horstmannIndentChars = indentLength_; - if (indent[0] == ' ') // allow for bracket + runInIndentChars = indentLength_; + if (indent[0] == ' ') // allow for brace indent.erase(0, 1); formattedLine.append(indent); } else if (getIndentString() == "\t") { appendChar('\t', false); - horstmannIndentChars = 2; // one for { and one for tab + runInIndentChars = 2; // one for { and one for tab if (extraIndent) { appendChar('\t', false); - horstmannIndentChars++; + runInIndentChars++; } } else // spaces { int indentLength_ = getIndentLength(); formattedLine.append(indentLength_ - 1, ' '); - horstmannIndentChars = indentLength_; + runInIndentChars = indentLength_; if (extraIndent) { formattedLine.append(indentLength_, ' '); - horstmannIndentChars += indentLength_; + runInIndentChars += indentLength_; } } - isInBracketRunIn = true; + isInBraceRunIn = true; } /** @@ -5099,9 +5184,9 @@ */ void ASFormatter::formatArrayRunIn() { - assert(isBracketType(bracketTypeStack->back(), ARRAY_TYPE)); + assert(isBraceType(braceTypeStack->back(), ARRAY_TYPE)); - // make sure the bracket is broken + // make sure the brace is broken if (formattedLine.find_first_not_of(" \t{") != string::npos) return; @@ -5117,55 +5202,55 @@ if (getIndentString() == "\t") { appendChar('\t', false); - horstmannIndentChars = 2; // one for { and one for tab + runInIndentChars = 2; // one for { and one for tab } else { int indent = getIndentLength(); formattedLine.append(indent - 1, ' '); - horstmannIndentChars = indent; + runInIndentChars = indent; } - isInBracketRunIn = true; + isInBraceRunIn = true; isInLineBreak = false; } /** - * delete a bracketTypeStack vector object - * BracketTypeStack did not work with the DeleteContainer template + * delete a braceTypeStack vector object + * BraceTypeStack did not work with the DeleteContainer template */ -void ASFormatter::deleteContainer(vector*& container) +void ASFormatter::deleteContainer(vector*& container) { - if (container != NULL) + if (container != nullptr) { container->clear(); delete (container); - container = NULL; + container = nullptr; } } /** * delete a vector object * T is the type of vector - * used for all vectors except bracketTypeStack + * used for all vectors except braceTypeStack */ template void ASFormatter::deleteContainer(T& container) { - if (container != NULL) + if (container != nullptr) { container->clear(); delete (container); - container = NULL; + container = nullptr; } } /** - * initialize a BracketType vector object - * BracketType did not work with the DeleteContainer template + * initialize a braceType vector object + * braceType did not work with the DeleteContainer template */ -void ASFormatter::initContainer(vector*& container, vector* value) +void ASFormatter::initContainer(vector*& container, vector* value) { - if (container != NULL) + if (container != nullptr) deleteContainer(container); container = value; } @@ -5173,14 +5258,14 @@ /** * initialize a vector object * T is the type of vector - * used for all vectors except bracketTypeStack + * used for all vectors except braceTypeStack */ template void ASFormatter::initContainer(T& container, T value) { // since the ASFormatter object is never deleted, // the existing vectors must be deleted before creating new ones - if (container != NULL) + if (container != nullptr) deleteContainer(container); container = value; } @@ -5210,19 +5295,19 @@ /** * is it ok to break this block? */ -bool ASFormatter::isOkToBreakBlock(BracketType bracketType) const +bool ASFormatter::isOkToBreakBlock(BraceType braceType) const { - // Actually, there should not be an ARRAY_TYPE bracket here. + // Actually, there should not be an ARRAY_TYPE brace here. // But this will avoid breaking a one line block when there is. // Otherwise they will be formatted differently on consecutive runs. - if (isBracketType(bracketType, ARRAY_TYPE) - && isBracketType(bracketType, SINGLE_LINE_TYPE)) + if (isBraceType(braceType, ARRAY_TYPE) + && isBraceType(braceType, SINGLE_LINE_TYPE)) return false; - if (isBracketType(bracketType, COMMAND_TYPE) - && isBracketType(bracketType, EMPTY_BLOCK_TYPE)) + if (isBraceType(braceType, COMMAND_TYPE) + && isBraceType(braceType, EMPTY_BLOCK_TYPE)) return false; - if (!isBracketType(bracketType, SINGLE_LINE_TYPE) - || isBracketType(bracketType, BREAK_BLOCK_TYPE) + if (!isBraceType(braceType, SINGLE_LINE_TYPE) + || isBraceType(braceType, BREAK_BLOCK_TYPE) || shouldBreakOneLineBlocks) return true; return false; @@ -5241,30 +5326,30 @@ /** * Check for a following header when a comment is reached. * firstLine must contain the start of the comment. - * return value is a pointer to the header or NULL. + * return value is a pointer to the header or nullptr. */ const string* ASFormatter::checkForHeaderFollowingComment(const string& firstLine) const { assert(isInComment || isInLineComment); assert(shouldBreakElseIfs || shouldBreakBlocks || isInSwitchStatement()); // look ahead to find the next non-comment text - bool endOnEmptyLine = (currentHeader == NULL); + bool endOnEmptyLine = (currentHeader == nullptr); if (isInSwitchStatement()) endOnEmptyLine = false; string nextText = peekNextText(firstLine, endOnEmptyLine); if (nextText.length() == 0 || !isCharPotentialHeader(nextText, 0)) - return NULL; + return nullptr; - return ASBeautifier::findHeader(nextText, 0, headers); + return ASBase::findHeader(nextText, 0, headers); } /** * process preprocessor statements. * charNum should be the index of the #. * - * delete bracketTypeStack entries added by #if if a #else is found. - * prevents double entries in the bracketTypeStack. + * delete braceTypeStack entries added by #if if a #else is found. + * prevents double entries in the braceTypeStack. */ void ASFormatter::processPreprocessor() { @@ -5277,17 +5362,17 @@ if (currentLine.compare(preproc, 2, "if") == 0) { - preprocBracketTypeStackSize = bracketTypeStack->size(); + preprocBraceTypeStackSize = braceTypeStack->size(); } else if (currentLine.compare(preproc, 4, "else") == 0) { // delete stack entries added in #if // should be replaced by #else - if (preprocBracketTypeStackSize > 0) + if (preprocBraceTypeStackSize > 0) { - int addedPreproc = bracketTypeStack->size() - preprocBracketTypeStackSize; + int addedPreproc = braceTypeStack->size() - preprocBraceTypeStackSize; for (int i = 0; i < addedPreproc; i++) - bracketTypeStack->pop_back(); + braceTypeStack->pop_back(); } } } @@ -5302,26 +5387,24 @@ assert(shouldDeleteEmptyLines && shouldBreakBlocks); // is the next line a comment - if (!sourceIterator->hasMoreLines()) + auto stream = make_shared(sourceIterator); + if (!stream->hasMoreLines()) return false; - string nextLine_ = sourceIterator->peekNextLine(); + string nextLine_ = stream->peekNextLine(); size_t firstChar = nextLine_.find_first_not_of(" \t"); if (firstChar == string::npos || !(nextLine_.compare(firstChar, 2, "//") == 0 || nextLine_.compare(firstChar, 2, "/*") == 0)) - { - sourceIterator->peekReset(); return false; - } // find the next non-comment text, and reset - string nextText = peekNextText(nextLine_, false, true); + string nextText = peekNextText(nextLine_, false, stream); if (nextText.length() == 0 || !isCharPotentialHeader(nextText, 0)) return false; - const string* newHeader = ASBeautifier::findHeader(nextText, 0, headers); + const string* newHeader = ASBase::findHeader(nextText, 0, headers); - if (newHeader == NULL) + if (newHeader == nullptr) return false; // if a closing header, reset break unless break is requested @@ -5335,108 +5418,109 @@ } /** - * determine if a bracket should be attached or broken - * uses brackets in the bracketTypeStack - * the last bracket in the bracketTypeStack is the one being formatted - * returns true if the bracket should be broken + * determine if a brace should be attached or broken + * uses braces in the braceTypeStack + * the last brace in the braceTypeStack is the one being formatted + * returns true if the brace should be broken */ -bool ASFormatter::isCurrentBracketBroken() const +bool ASFormatter::isCurrentBraceBroken() const { - assert(bracketTypeStack->size() > 1); + assert(braceTypeStack->size() > 1); - bool breakBracket = false; - size_t stackEnd = bracketTypeStack->size() - 1; + bool breakBrace = false; + size_t stackEnd = braceTypeStack->size() - 1; - // check bracket modifiers + // check brace modifiers if (shouldAttachExternC - && isBracketType((*bracketTypeStack)[stackEnd], EXTERN_TYPE)) + && isBraceType((*braceTypeStack)[stackEnd], EXTERN_TYPE)) { return false; } if (shouldAttachNamespace - && isBracketType((*bracketTypeStack)[stackEnd], NAMESPACE_TYPE)) + && isBraceType((*braceTypeStack)[stackEnd], NAMESPACE_TYPE)) { return false; } if (shouldAttachClass - && (isBracketType((*bracketTypeStack)[stackEnd], CLASS_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd], INTERFACE_TYPE))) + && (isBraceType((*braceTypeStack)[stackEnd], CLASS_TYPE) + || isBraceType((*braceTypeStack)[stackEnd], INTERFACE_TYPE))) { return false; } if (shouldAttachInline && isCStyle() // for C++ only - && bracketFormatMode != RUN_IN_MODE - && isBracketType((*bracketTypeStack)[stackEnd], COMMAND_TYPE)) + && braceFormatMode != RUN_IN_MODE + && !(currentLineBeginsWithBrace && peekNextChar() == '/') + && isBraceType((*braceTypeStack)[stackEnd], COMMAND_TYPE)) { size_t i; - for (i = 1; i < bracketTypeStack->size(); i++) - if (isBracketType((*bracketTypeStack)[i], CLASS_TYPE) - || isBracketType((*bracketTypeStack)[i], STRUCT_TYPE)) + for (i = 1; i < braceTypeStack->size(); i++) + if (isBraceType((*braceTypeStack)[i], CLASS_TYPE) + || isBraceType((*braceTypeStack)[i], STRUCT_TYPE)) return false; } - // check brackets - if (isBracketType((*bracketTypeStack)[stackEnd], EXTERN_TYPE)) + // check braces + if (isBraceType((*braceTypeStack)[stackEnd], EXTERN_TYPE)) { - if (currentLineBeginsWithBracket - || bracketFormatMode == RUN_IN_MODE) - breakBracket = true; + if (currentLineBeginsWithBrace + || braceFormatMode == RUN_IN_MODE) + breakBrace = true; } - else if (bracketFormatMode == NONE_MODE) + else if (braceFormatMode == NONE_MODE) { - if (currentLineBeginsWithBracket - && (int) currentLineFirstBracketNum == charNum) - breakBracket = true; + if (currentLineBeginsWithBrace + && (int) currentLineFirstBraceNum == charNum) + breakBrace = true; } - else if (bracketFormatMode == BREAK_MODE || bracketFormatMode == RUN_IN_MODE) + else if (braceFormatMode == BREAK_MODE || braceFormatMode == RUN_IN_MODE) { - breakBracket = true; + breakBrace = true; } - else if (bracketFormatMode == LINUX_MODE) + else if (braceFormatMode == LINUX_MODE) { // break a namespace if NOT stroustrup or mozilla - if (isBracketType((*bracketTypeStack)[stackEnd], NAMESPACE_TYPE)) + if (isBraceType((*braceTypeStack)[stackEnd], NAMESPACE_TYPE)) { if (formattingStyle != STYLE_STROUSTRUP && formattingStyle != STYLE_MOZILLA) - breakBracket = true; + breakBrace = true; } // break a class or interface if NOT stroustrup - else if (isBracketType((*bracketTypeStack)[stackEnd], CLASS_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd], INTERFACE_TYPE)) + else if (isBraceType((*braceTypeStack)[stackEnd], CLASS_TYPE) + || isBraceType((*braceTypeStack)[stackEnd], INTERFACE_TYPE)) { if (formattingStyle != STYLE_STROUSTRUP) - breakBracket = true; + breakBrace = true; } - // break a struct if mozilla - an enum is processed as an array bracket - else if (isBracketType((*bracketTypeStack)[stackEnd], STRUCT_TYPE)) + // break a struct if mozilla - an enum is processed as an array brace + else if (isBraceType((*braceTypeStack)[stackEnd], STRUCT_TYPE)) { if (formattingStyle == STYLE_MOZILLA) - breakBracket = true; + breakBrace = true; } - // break the first bracket if a function - else if (isBracketType((*bracketTypeStack)[stackEnd], COMMAND_TYPE)) + // break the first brace if a function + else if (isBraceType((*braceTypeStack)[stackEnd], COMMAND_TYPE)) { if (stackEnd == 1) { - breakBracket = true; + breakBrace = true; } else if (stackEnd > 1) { - // break the first bracket after these if a function - if (isBracketType((*bracketTypeStack)[stackEnd - 1], NAMESPACE_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd - 1], CLASS_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd - 1], ARRAY_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd - 1], STRUCT_TYPE) - || isBracketType((*bracketTypeStack)[stackEnd - 1], EXTERN_TYPE)) + // break the first brace after these if a function + if (isBraceType((*braceTypeStack)[stackEnd - 1], NAMESPACE_TYPE) + || isBraceType((*braceTypeStack)[stackEnd - 1], CLASS_TYPE) + || isBraceType((*braceTypeStack)[stackEnd - 1], ARRAY_TYPE) + || isBraceType((*braceTypeStack)[stackEnd - 1], STRUCT_TYPE) + || isBraceType((*braceTypeStack)[stackEnd - 1], EXTERN_TYPE)) { - breakBracket = true; + breakBrace = true; } } } } - return breakBracket; + return breakBrace; } /** @@ -5482,10 +5566,10 @@ // Check for a following header. // For speed do not check multiple comment lines more than once. // For speed do not check shouldBreakBlocks if previous line is empty, a comment, or a '{'. - const string* followingHeader = NULL; + const string* followingHeader = nullptr; if ((doesLineStartComment && !isImmediatelyPostCommentOnly - && isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) + && isBraceType(braceTypeStack->back(), COMMAND_TYPE)) && (shouldBreakElseIfs || isInSwitchStatement() || (shouldBreakBlocks @@ -5502,25 +5586,25 @@ && !isImmediatelyPostComment && !isImmediatelyPostLineComment) { - if (isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE)) + if (isBraceType(braceTypeStack->back(), NAMESPACE_TYPE)) { // namespace run-in is always broken. isInLineBreak = true; } - else if (bracketFormatMode == NONE_MODE) + else if (braceFormatMode == NONE_MODE) { // should a run-in statement be attached? - if (currentLineBeginsWithBracket) + if (currentLineBeginsWithBrace) formatRunIn(); } - else if (bracketFormatMode == ATTACH_MODE) + else if (braceFormatMode == ATTACH_MODE) { - // if the bracket was not attached? + // if the brace was not attached? if (formattedLine.length() > 0 && formattedLine[0] == '{' - && !isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE)) + && !isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE)) isInLineBreak = true; } - else if (bracketFormatMode == RUN_IN_MODE) + else if (braceFormatMode == RUN_IN_MODE) { // should a run-in statement be attached? if (formattedLine.length() > 0 && formattedLine[0] == '{') @@ -5545,7 +5629,7 @@ // Break before the comment if a header follows the line comment. // But not break if previous line is empty, a comment, or a '{'. if (shouldBreakBlocks - && followingHeader != NULL + && followingHeader != nullptr && !isImmediatelyPostEmptyLine && previousCommandChar != '{') { @@ -5560,7 +5644,7 @@ } if (previousCommandChar == '}') - currentHeader = NULL; + currentHeader = nullptr; } /** @@ -5580,9 +5664,9 @@ lineEndsInCommentOnly = true; if (peekNextChar() == '}' && previousCommandChar != ';' - && !isBracketType(bracketTypeStack->back(), ARRAY_TYPE) + && !isBraceType(braceTypeStack->back(), ARRAY_TYPE) && !isInPreprocessor - && isOkToBreakBlock(bracketTypeStack->back())) + && isOkToBreakBlock(braceTypeStack->back())) { isInLineBreak = true; shouldBreakLineAtNextChar = true; @@ -5639,10 +5723,10 @@ // Check for a following header. // For speed do not check multiple comment lines more than once. // For speed do not check shouldBreakBlocks if previous line is empty, a comment, or a '{'. - const string* followingHeader = NULL; + const string* followingHeader = nullptr; if ((lineIsLineCommentOnly && !isImmediatelyPostCommentOnly - && isBracketType(bracketTypeStack->back(), COMMAND_TYPE)) + && isBraceType(braceTypeStack->back(), COMMAND_TYPE)) && (shouldBreakElseIfs || isInSwitchStatement() || (shouldBreakBlocks @@ -5651,7 +5735,7 @@ followingHeader = checkForHeaderFollowingComment(currentLine.substr(charNum)); // do not indent if in column 1 or 2 - // or in a namespace before the opening bracket + // or in a namespace before the opening brace if ((!shouldIndentCol1Comments && !lineCommentNoIndent) || foundNamespaceHeader) { @@ -5671,26 +5755,26 @@ && !isImmediatelyPostComment && !isImmediatelyPostLineComment) { - if (bracketFormatMode == NONE_MODE) + if (braceFormatMode == NONE_MODE) { - if (currentLineBeginsWithBracket) + if (currentLineBeginsWithBrace) formatRunIn(); } - else if (bracketFormatMode == RUN_IN_MODE) + else if (braceFormatMode == RUN_IN_MODE) { if (!lineCommentNoIndent) formatRunIn(); else isInLineBreak = true; } - else if (bracketFormatMode == BREAK_MODE) + else if (braceFormatMode == BREAK_MODE) { if (formattedLine.length() > 0 && formattedLine[0] == '{') isInLineBreak = true; } else { - if (currentLineBeginsWithBracket) + if (currentLineBeginsWithBrace) isInLineBreak = true; } } @@ -5710,7 +5794,7 @@ // Break before the comment if a header follows the line comment. // But do not break if previous line is empty, a comment, or a '{'. if (shouldBreakBlocks - && followingHeader != NULL + && followingHeader != nullptr && !isImmediatelyPostEmptyLine && previousCommandChar != '{') { @@ -5725,7 +5809,7 @@ } if (previousCommandChar == '}') - currentHeader = NULL; + currentHeader = nullptr; // if tabbed input don't convert the immediately following tabs to spaces if (getIndentString() == "\t" && lineCommentNoIndent) @@ -5841,31 +5925,31 @@ else if (isSharpStyle() && previousChar == '@') isInVerbatimQuote = true; - // a quote following a bracket is an array + // a quote following a brace is an array if (previousCommandChar == '{' && !isImmediatelyPostComment && !isImmediatelyPostLineComment && isNonInStatementArray - && !isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE) + && !isBraceType(braceTypeStack->back(), SINGLE_LINE_TYPE) && !isWhiteSpace(peekNextChar())) { - if (bracketFormatMode == NONE_MODE) + if (braceFormatMode == NONE_MODE) { - if (currentLineBeginsWithBracket) + if (currentLineBeginsWithBrace) formatRunIn(); } - else if (bracketFormatMode == RUN_IN_MODE) + else if (braceFormatMode == RUN_IN_MODE) { formatRunIn(); } - else if (bracketFormatMode == BREAK_MODE) + else if (braceFormatMode == BREAK_MODE) { if (formattedLine.length() > 0 && formattedLine[0] == '{') isInLineBreak = true; } else { - if (currentLineBeginsWithBracket) + if (currentLineBeginsWithBrace) isInLineBreak = true; } } @@ -5874,8 +5958,8 @@ } /** - * get the next line comment adjustment that results from breaking a closing bracket. - * the bracket must be on the same line as the closing header. + * get the next line comment adjustment that results from breaking a closing brace. + * the brace must be on the same line as the closing header. * i.e "} else" changed to "} else". */ int ASFormatter::getNextLineCommentAdjustment() @@ -5883,9 +5967,9 @@ assert(foundClosingHeader && previousNonWSChar == '}'); if (charNum < 1) // "else" is in column 1 return 0; - size_t lastBracket = currentLine.rfind('}', charNum - 1); - if (lastBracket != string::npos) - return (lastBracket - charNum); // return a negative number + size_t lastBrace = currentLine.rfind('}', charNum - 1); + if (lastBrace != string::npos) + return (lastBrace - charNum); // return a negative number return 0; } @@ -5897,9 +5981,9 @@ /** * get the current line comment adjustment that results from attaching - * a closing header to a closing bracket. - * the bracket must be on the line previous to the closing header. - * the adjustment is 2 chars, one for the bracket and one for the space. + * a closing header to a closing brace. + * the brace must be on the line previous to the closing header. + * the adjustment is 2 chars, one for the brace and one for the space. * i.e "} else" changed to "} else". */ int ASFormatter::getCurrentLineCommentAdjustment() @@ -5907,8 +5991,8 @@ assert(foundClosingHeader && previousNonWSChar == '}'); if (charNum < 1) return 2; - size_t lastBracket = currentLine.rfind('}', charNum - 1); - if (lastBracket == string::npos) + size_t lastBrace = currentLine.rfind('}', charNum - 1); + if (lastBrace == string::npos) return 2; return 0; } @@ -5941,30 +6025,37 @@ } /** - * check if a line break is needed when a closing bracket + * check if a line break is needed when a closing brace * is followed by a closing header. - * the break depends on the bracketFormatMode and other factors. + * the break depends on the braceFormatMode and other factors. */ void ASFormatter::isLineBreakBeforeClosingHeader() { assert(foundClosingHeader && previousNonWSChar == '}'); - if (bracketFormatMode == BREAK_MODE - || bracketFormatMode == RUN_IN_MODE - || attachClosingBracketMode) + + if (currentHeader == &AS_WHILE && shouldAttachClosingWhile) + { + appendClosingHeader(); + return; + } + + if (braceFormatMode == BREAK_MODE + || braceFormatMode == RUN_IN_MODE + || attachClosingBraceMode) { isInLineBreak = true; } - else if (bracketFormatMode == NONE_MODE) + else if (braceFormatMode == NONE_MODE) { - if (shouldBreakClosingHeaderBrackets - || getBracketIndent() || getBlockIndent()) + if (shouldBreakClosingHeaderBraces + || getBraceIndent() || getBlockIndent()) { isInLineBreak = true; } else { appendSpacePad(); - // is closing bracket broken? + // is closing brace broken? size_t i = currentLine.find_first_not_of(" \t"); if (i != string::npos && currentLine[i] == '}') isInLineBreak = false; @@ -5973,31 +6064,17 @@ isAppendPostBlockEmptyLineRequested = false; } } - // bracketFormatMode == ATTACH_MODE, LINUX_MODE + // braceFormatMode == ATTACH_MODE, LINUX_MODE else { - if (shouldBreakClosingHeaderBrackets - || getBracketIndent() || getBlockIndent()) + if (shouldBreakClosingHeaderBraces + || getBraceIndent() || getBlockIndent()) { isInLineBreak = true; } else { - // if a blank line does not precede this - // or last line is not a one line block, attach header - bool previousLineIsEmpty = isEmptyLine(formattedLine); - int previousLineIsOneLineBlock = 0; - size_t firstBracket = findNextChar(formattedLine, '{'); - if (firstBracket != string::npos) - previousLineIsOneLineBlock = isOneLineBlockReached(formattedLine, firstBracket); - if (!previousLineIsEmpty - && previousLineIsOneLineBlock == 0) - { - isInLineBreak = false; - appendSpacePad(); - spacePadNum = 0; // don't count as comment padding - } - + appendClosingHeader(); if (shouldBreakBlocks) isAppendPostBlockEmptyLineRequested = false; } @@ -6005,11 +6082,32 @@ } /** - * Add brackets to a single line statement following a header. - * Brackets are not added if the proper conditions are not met. - * Brackets are added to the currentLine. + * Append a closing header to the previous closing brace, if possible + */ +void ASFormatter::appendClosingHeader() +{ + // if a blank line does not precede this + // or last line is not a one line block, attach header + bool previousLineIsEmpty = isEmptyLine(formattedLine); + int previousLineIsOneLineBlock = 0; + size_t firstBrace = findNextChar(formattedLine, '{'); + if (firstBrace != string::npos) + previousLineIsOneLineBlock = isOneLineBlockReached(formattedLine, firstBrace); + if (!previousLineIsEmpty + && previousLineIsOneLineBlock == 0) + { + isInLineBreak = false; + appendSpacePad(); + spacePadNum = 0; // don't count as comment padding + } +} + +/** + * Add braces to a single line statement following a header. + * braces are not added if the proper conditions are not met. + * braces are added to the currentLine. */ -bool ASFormatter::addBracketsToStatement() +bool ASFormatter::addBracesToStatement() { assert(isImmediatelyPostHeader); @@ -6027,13 +6125,13 @@ if (currentHeader == &AS_WHILE && foundClosingHeader) // do-while return false; - // do not bracket an empty statement + // do not brace an empty statement if (currentChar == ';') return false; // do not add if a header follows if (isCharPotentialHeader(currentLine, charNum)) - if (findHeader(headers) != NULL) + if (findHeader(headers) != nullptr) return false; // find the next semi-colon @@ -6043,19 +6141,19 @@ if (nextSemiColon == string::npos) return false; - // add closing bracket before changing the line length + // add closing brace before changing the line length if (nextSemiColon == currentLine.length() - 1) currentLine.append(" }"); else currentLine.insert(nextSemiColon + 1, " }"); - // add opening bracket + // add opening brace currentLine.insert(charNum, "{ "); assert(computeChecksumIn("{}")); currentChar = '{'; if ((int) currentLine.find_first_not_of(" \t") == charNum) - currentLineBeginsWithBracket = true; + currentLineBeginsWithBrace = true; // remove extra spaces - if (!shouldAddOneLineBrackets) + if (!shouldAddOneLineBraces) { size_t lastText = formattedLine.find_last_not_of(" \t"); if ((formattedLine.length() - 1) - lastText > 1) @@ -6065,11 +6163,11 @@ } /** - * Remove brackets from a single line statement following a header. - * Brackets are not removed if the proper conditions are not met. - * The first bracket is replaced by a space. + * Remove braces from a single line statement following a header. + * braces are not removed if the proper conditions are not met. + * The first brace is replaced by a space. */ -bool ASFormatter::removeBracketsFromStatement() +bool ASFormatter::removeBracesFromStatement() { assert(isImmediatelyPostHeader); assert(currentChar == '{'); @@ -6085,23 +6183,22 @@ return false; bool isFirstLine = true; - bool needReset = false; string nextLine_; // leave nextLine_ empty if end of line comment follows - if (!isBeforeAnyLineEndComment(charNum) || currentLineBeginsWithBracket) + if (!isBeforeAnyLineEndComment(charNum) || currentLineBeginsWithBrace) nextLine_ = currentLine.substr(charNum + 1); size_t nextChar = 0; // find the first non-blank text - while (sourceIterator->hasMoreLines() || isFirstLine) + ASPeekStream stream(sourceIterator); + while (stream.hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else { - nextLine_ = sourceIterator->peekNextLine(); + nextLine_ = stream.peekNextLine(); nextChar = 0; - needReset = true; } nextChar = nextLine_.find_first_not_of(" \t", nextChar); @@ -6109,57 +6206,42 @@ break; } - // don't remove if comments or a header follow the bracket + // don't remove if comments or a header follow the brace if ((nextLine_.compare(nextChar, 2, "/*") == 0) || (nextLine_.compare(nextChar, 2, "//") == 0) || (isCharPotentialHeader(nextLine_, nextChar) - && ASBeautifier::findHeader(nextLine_, nextChar, headers) != NULL)) - { - if (needReset) - sourceIterator->peekReset(); + && ASBase::findHeader(nextLine_, nextChar, headers) != nullptr)) return false; - } // find the next semi-colon size_t nextSemiColon = nextChar; if (nextLine_[nextChar] != ';') nextSemiColon = findNextChar(nextLine_, ';', nextChar + 1); if (nextSemiColon == string::npos) - { - if (needReset) - sourceIterator->peekReset(); return false; - } - // find the closing bracket + // find the closing brace isFirstLine = true; nextChar = nextSemiColon + 1; - while (sourceIterator->hasMoreLines() || isFirstLine) + while (stream.hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else { - nextLine_ = sourceIterator->peekNextLine(); + nextLine_ = stream.peekNextLine(); nextChar = 0; - needReset = true; } nextChar = nextLine_.find_first_not_of(" \t", nextChar); if (nextChar != string::npos) break; } if (nextLine_.length() == 0 || nextLine_[nextChar] != '}') - { - if (needReset) - sourceIterator->peekReset(); return false; - } - // remove opening bracket + // remove opening brace currentLine[charNum] = currentChar = ' '; assert(adjustChecksumIn(-'{')); - if (needReset) - sourceIterator->peekReset(); return true; } @@ -6171,7 +6253,7 @@ * @param searchStart the start position on the line (default is 0). * @return the position on the line or string::npos if not found. */ -size_t ASFormatter::findNextChar(string& line, char searchChar, int searchStart /*0*/) const +size_t ASFormatter::findNextChar(const string& line, char searchChar, int searchStart /*0*/) const { // find the next searchChar size_t i; @@ -6208,7 +6290,7 @@ if (line[i] == searchChar) break; - // for now don't process C# 'delegate' brackets + // for now don't process C# 'delegate' braces // do this last in case the search char is a '{' if (line[i] == '{') return string::npos; @@ -6226,29 +6308,26 @@ * @param index the current line index. * @return true if the struct has access modifiers. */ -bool ASFormatter::isStructAccessModified(string& firstLine, size_t index) const +bool ASFormatter::isStructAccessModified(const string& firstLine, size_t index) const { assert(firstLine[index] == '{'); assert(isCStyle()); bool isFirstLine = true; - bool needReset = false; - size_t bracketCount = 1; + size_t braceCount = 1; string nextLine_ = firstLine.substr(index + 1); + ASPeekStream stream(sourceIterator); // find the first non-blank text, bypassing all comments and quotes. bool isInComment_ = false; bool isInQuote_ = false; char quoteChar_ = ' '; - while (sourceIterator->hasMoreLines() || isFirstLine) + while (stream.hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else - { - nextLine_ = sourceIterator->peekNextLine(); - needReset = true; - } + nextLine_ = stream.peekNextLine(); // parse the line for (size_t i = 0; i < nextLine_.length(); i++) { @@ -6290,36 +6369,26 @@ i = nextLine_.length(); continue; } - // handle brackets + // handle braces if (nextLine_[i] == '{') - ++bracketCount; + ++braceCount; if (nextLine_[i] == '}') - --bracketCount; - if (bracketCount == 0) - { - if (needReset) - sourceIterator->peekReset(); + --braceCount; + if (braceCount == 0) return false; - } // check for access modifiers if (isCharPotentialHeader(nextLine_, i)) { if (findKeyword(nextLine_, i, AS_PUBLIC) || findKeyword(nextLine_, i, AS_PRIVATE) || findKeyword(nextLine_, i, AS_PROTECTED)) - { - if (needReset) - sourceIterator->peekReset(); return true; - } string name = getCurrentWord(nextLine_, i); i += name.length() - 1; } } // end of for loop } // end of while loop - if (needReset) - sourceIterator->peekReset(); return false; } @@ -6330,14 +6399,13 @@ * @param index the current line index. * @return true if the block is indentable. */ -bool ASFormatter::isIndentablePreprocessorBlock(string& firstLine, size_t index) +bool ASFormatter::isIndentablePreprocessorBlock(const string& firstLine, size_t index) { assert(firstLine[index] == '#'); bool isFirstLine = true; - bool needReset = false; bool isInIndentableBlock = false; - bool blockContainsBrackets = false; + bool blockContainsBraces = false; bool blockContainsDefineContinuation = false; bool isInClassConstructor = false; bool isPotentialHeaderGuard = false; // ifndef is first preproc statement @@ -6345,20 +6413,18 @@ int numBlockIndents = 0; int lineParenCount = 0; string nextLine_ = firstLine.substr(index); + auto stream = make_shared(sourceIterator); // find end of the block, bypassing all comments and quotes. bool isInComment_ = false; bool isInQuote_ = false; char quoteChar_ = ' '; - while (sourceIterator->hasMoreLines() || isFirstLine) + while (stream->hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else - { - nextLine_ = sourceIterator->peekNextLine(); - needReset = true; - } + nextLine_ = stream->peekNextLine(); // parse the line for (size_t i = 0; i < nextLine_.length(); i++) { @@ -6437,7 +6503,7 @@ } // handle exceptions if (nextLine_[i] == '{' || nextLine_[i] == '}') - blockContainsBrackets = true; + blockContainsBraces = true; else if (nextLine_[i] == '(') ++lineParenCount; else if (nextLine_[i] == ')') @@ -6451,7 +6517,7 @@ isInClassConstructor = true; } // bypass unnecessary parsing - must exit BOTH loops - if (blockContainsBrackets || isInClassConstructor || blockContainsDefineContinuation) + if (blockContainsBraces || isInClassConstructor || blockContainsDefineContinuation) goto EndOfWhileLoop; } // end of for loop, end of line if (lineParenCount != 0) @@ -6461,7 +6527,7 @@ preprocBlockEnd = sourceIterator->tellg(); if (preprocBlockEnd < 0) preprocBlockEnd = sourceIterator->getStreamLength(); - if (blockContainsBrackets + if (blockContainsBraces || isInClassConstructor || blockContainsDefineContinuation || lineParenCount != 0 @@ -6469,7 +6535,7 @@ isInIndentableBlock = false; // find next executable instruction // this WILL RESET the get pointer - string nextText = peekNextText("", false, needReset); + string nextText = peekNextText("", false, stream); // bypass header include guards if (isFirstPreprocConditional) { @@ -6487,7 +6553,7 @@ return isInIndentableBlock; } -bool ASFormatter::isNDefPreprocStatement(string& nextLine_, string& preproc) const +bool ASFormatter::isNDefPreprocStatement(const string& nextLine_, const string& preproc) const { if (preproc == "ifndef") return true; @@ -6511,7 +6577,7 @@ * @param index the current line index. * @return true if the statement is EXEC SQL. */ -bool ASFormatter::isExecSQL(string& line, size_t index) const +bool ASFormatter::isExecSQL(const string& line, size_t index) const { if (line[index] != 'e' && line[index] != 'E') // quick check to reject most return false; @@ -6651,25 +6717,22 @@ } bool isFirstLine = true; - bool needReset = false; int parenDepth_ = 0; int maxTemplateDepth = 0; templateDepth = 0; string nextLine_ = currentLine.substr(charNum); + ASPeekStream stream(sourceIterator); - // find the angle brackets, bypassing all comments and quotes. + // find the angle braces, bypassing all comments and quotes. bool isInComment_ = false; bool isInQuote_ = false; char quoteChar_ = ' '; - while (sourceIterator->hasMoreLines() || isFirstLine) + while (stream.hasMoreLines() || isFirstLine) { if (isFirstLine) isFirstLine = false; else - { - nextLine_ = sourceIterator->peekNextLine(); - needReset = true; - } + nextLine_ = stream.peekNextLine(); // parse the line for (size_t i = 0; i < nextLine_.length(); i++) { @@ -6731,7 +6794,7 @@ isInTemplate = true; templateDepth = maxTemplateDepth; } - goto exitFromSearch; + return; } continue; } @@ -6745,14 +6808,16 @@ continue; // this is not a template -> leave... isInTemplate = false; - goto exitFromSearch; + templateDepth = 0; + return; } else if (nextLine_.compare(i, 2, AS_AND) == 0 || nextLine_.compare(i, 2, AS_OR) == 0) { // this is not a template -> leave... isInTemplate = false; - goto exitFromSearch; + templateDepth = 0; + return; } else if (currentChar_ == ',' // comma, e.g. A || currentChar_ == '&' // reference, e.g. A @@ -6774,17 +6839,12 @@ // this is not a template -> leave... isInTemplate = false; templateDepth = 0; - goto exitFromSearch; + return; } string name = getCurrentWord(nextLine_, i); i += name.length() - 1; - } // end of for loop - } // end of while loop - - // goto needed to exit from two loops -exitFromSearch: - if (needReset) - sourceIterator->peekReset(); + } // end for loop + } // end while loop } void ASFormatter::updateFormattedLineSplitPoints(char appendedChar) @@ -6801,11 +6861,11 @@ if (nextChar == '/') return; - // don't split before or after a bracket + // don't split before or after a brace if (appendedChar == '{' || appendedChar == '}' || previousNonWSChar == '{' || previousNonWSChar == '}' || nextChar == '{' || nextChar == '}' - || currentChar == '{' || currentChar == '}') // currentChar tests for an appended bracket + || currentChar == '{' || currentChar == '}') // currentChar tests for an appended brace return; // don't split before or after a block paren @@ -6940,7 +7000,8 @@ else if (sequence == "+" || sequence == "-" || sequence == "?") { if (charNum > 0 - && !isInExponent() + && !(sequence == "+" && isInExponent()) + && !(sequence == "-" && isInExponent()) && (isLegalNameChar(currentLine[charNum - 1]) || currentLine[charNum - 1] == ')' || currentLine[charNum - 1] == ']' @@ -6956,7 +7017,7 @@ else if (sequence == "=" || sequence == ":") { // split BEFORE if the line is too long - // do NOT use <= here, must allow for a bracket attached to an array + // do NOT use <= here, must allow for a brace attached to an array size_t splitPoint = 0; if (formattedLine.length() < maxCodeLength) splitPoint = formattedLine.length(); @@ -7020,16 +7081,16 @@ || isInTemplate) return false; - if (!isOkToBreakBlock(bracketTypeStack->back()) && currentChar != '{') + if (!isOkToBreakBlock(braceTypeStack->back()) && currentChar != '{') { shouldKeepLineUnbroken = true; clearFormattedLineSplitPoints(); return false; } - if (isBracketType(bracketTypeStack->back(), ARRAY_TYPE)) + if (isBraceType(braceTypeStack->back(), ARRAY_TYPE)) { shouldKeepLineUnbroken = true; - if (!isBracketType(bracketTypeStack->back(), ARRAY_NIS_TYPE)) + if (!isBraceType(braceTypeStack->back(), ARRAY_NIS_TYPE)) clearFormattedLineSplitPoints(); return false; } @@ -7292,10 +7353,10 @@ // find next word size_t nextNum = currentLine.find_first_not_of(" \t", charNum + 1); if (nextNum == string::npos) - return NULL; + return nullptr; if (!isLegalNameChar(currentLine[nextNum])) - return NULL; + return nullptr; // bypass next word and following spaces while (nextNum < currentLine.length()) @@ -7309,9 +7370,9 @@ if (nextNum >= currentLine.length() || !isCharPotentialOperator(currentLine[nextNum]) || currentLine[nextNum] == '/') // comment - return NULL; + return nullptr; - const string* newOperator = ASBeautifier::findOperator(currentLine, nextNum, operators); + const string* newOperator = ASBase::findOperator(currentLine, nextNum, operators); return newOperator; } @@ -7319,7 +7380,7 @@ bool ASFormatter::isArrayOperator() const { assert(currentChar == '*' || currentChar == '&' || currentChar == '^'); - assert(isBracketType(bracketTypeStack->back(), ARRAY_TYPE)); + assert(isBraceType(braceTypeStack->back(), ARRAY_TYPE)); // find next word size_t nextNum = currentLine.find_first_not_of(" \t", charNum + 1); @@ -7358,6 +7419,7 @@ foundPreDefinitionHeader = false; foundPreCommandHeader = false; foundPreCommandMacro = false; + foundTrailingReturnType = false; foundCastOperator = false; isInPotentialCalculation = false; isSharpAccessor = false; @@ -7368,7 +7430,7 @@ isInEnum = false; isInExternC = false; elseHeaderFollowsComments = false; - nonInStatementBracket = 0; + nonInStatementBrace = 0; while (!questionMarkStack->empty()) questionMarkStack->pop_back(); } @@ -7382,7 +7444,6 @@ bool isFirstLine = true; bool haveFirstColon = false; bool foundMethodColon = false; - bool needReset = false; bool isInComment_ = false; bool isInQuote_ = false; char quoteChar_ = ' '; @@ -7390,15 +7451,13 @@ int colonAdjust = 0; int colonAlign = 0; string nextLine_ = currentLine; + ASPeekStream stream(sourceIterator); // peek next line while (sourceIterator->hasMoreLines() || isFirstLine) { if (!isFirstLine) - { - nextLine_ = sourceIterator->peekNextLine(); - needReset = true; - } + nextLine_ = stream.peekNextLine(); // parse the line haveFirstColon = false; nextLine_ = ASBeautifier::trim(nextLine_); @@ -7448,7 +7507,7 @@ if (nextLine_[i] == ']') { --sqBracketCount; - if (!sqBracketCount) + if (sqBracketCount == 0) goto EndOfWhileLoop; // end of method call } if (nextLine_[i] == '[') @@ -7487,8 +7546,6 @@ EndOfWhileLoop: if (!foundMethodColon) colonAlign = -1; - if (needReset) - sourceIterator->peekReset(); return colonAlign; } diff -Nru astyle-2.06/src/ASLocalizer.cpp astyle-3.0.1/src/ASLocalizer.cpp --- astyle-2.06/src/ASLocalizer.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASLocalizer.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASLocalizer.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. // // File encoding for this file is UTF-8 WITHOUT a byte order mark (BOM). // русский 中文(简体) 日本語 한국의 @@ -43,12 +43,6 @@ #include #endif -#ifdef __DMC__ - // digital mars doesn't have these - const size_t SUBLANG_CHINESE_MACAU = 5; - const size_t LANG_HINDI = 57; -#endif - #ifdef __VMS #define __USE_STD_IOSTREAM 1 #include @@ -96,11 +90,11 @@ m_langID = "en"; m_lcid = 0; m_subLangID.clear(); - m_translation = NULL; + m_translation = nullptr; // Not all compilers support the C++ function locale::global(locale("")); char* localeName = setlocale(LC_ALL, ""); - if (localeName == NULL) // use the english (ascii) defaults + if (localeName == nullptr) // use the english (ascii) defaults { fprintf(stderr, "\n%s\n\n", "Cannot set native locale, reverting to English"); setTranslationClass(); @@ -256,10 +250,10 @@ { assert(m_langID.length()); // delete previously set (--ascii option) - if (m_translation) + if (m_translation != nullptr) { delete m_translation; - m_translation = NULL; + m_translation = nullptr; } if (m_langID == "bg") m_translation = new Bulgarian; @@ -319,7 +313,7 @@ // Add a string pair to the translation vector. { pair entry(english, translated); - m_translation.push_back(entry); + m_translation.emplace_back(entry); } string Translation::convertToMultiByte(const wstring& wideStr) const @@ -327,8 +321,8 @@ // Return an empty string if an error occurs. { static bool msgDisplayed = false; - // get length of the output excluding the NULL and validate the parameters - size_t mbLen = wcstombs(NULL, wideStr.c_str(), 0); + // get length of the output excluding the nullptr and validate the parameters + size_t mbLen = wcstombs(nullptr, wideStr.c_str(), 0); if (mbLen == string::npos) { if (!msgDisplayed) @@ -340,7 +334,7 @@ } // convert the characters char* mbStr = new (nothrow) char[mbLen + 1]; - if (mbStr == NULL) + if (mbStr == nullptr) { if (!msgDisplayed) { diff -Nru astyle-2.06/src/ASLocalizer.h astyle-3.0.1/src/ASLocalizer.h --- astyle-2.06/src/ASLocalizer.h 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASLocalizer.h 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASLocalizer.h -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. #ifndef ASLOCALIZER_H diff -Nru astyle-2.06/src/ASResource.cpp astyle-3.0.1/src/ASResource.cpp --- astyle-2.06/src/ASResource.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/ASResource.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // ASResource.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. //----------------------------------------------------------------------------- // headers @@ -16,51 +16,72 @@ namespace astyle { // -const string ASResource::AS_IF = string("if"); -const string ASResource::AS_ELSE = string("else"); -const string ASResource::AS_FOR = string("for"); -const string ASResource::AS_DO = string("do"); -const string ASResource::AS_WHILE = string("while"); -const string ASResource::AS_SWITCH = string("switch"); +const string ASResource::_AS_EXCEPT = string("__except"); +const string ASResource::_AS_FINALLY = string("__finally"); +const string ASResource::_AS_TRY = string("__try"); +const string ASResource::AS_ADD = string("add"); +const string ASResource::AS_AUTO = string("auto"); +const string ASResource::AS_AUTORELEASEPOOL = string("autoreleasepool"); const string ASResource::AS_CASE = string("case"); -const string ASResource::AS_DEFAULT = string("default"); +const string ASResource::AS_CATCH = string("catch"); const string ASResource::AS_CLASS = string("class"); -const string ASResource::AS_VOLATILE = string("volatile"); -const string ASResource::AS_INTERRUPT = string("interrupt"); -const string ASResource::AS_NOEXCEPT = string("noexcept"); -const string ASResource::AS_AUTORELEASEPOOL = string("autoreleasepool"); -const string ASResource::AS_STRUCT = string("struct"); -const string ASResource::AS_UNION = string("union"); -const string ASResource::AS_INTERFACE = string("interface"); -const string ASResource::AS_NAMESPACE = string("namespace"); -const string ASResource::AS_MODULE = string("module"); // CORBA IDL module definition +const string ASResource::AS_CONST = string("const"); +const string ASResource::AS_CONST_CAST = string("const_cast"); +const string ASResource::AS_DEFAULT = string("default"); +const string ASResource::AS_DELEGATE = string("delegate"); +const string ASResource::AS_DELETE = string("delete"); +const string ASResource::AS_DO = string("do"); +const string ASResource::AS_DYNAMIC_CAST = string("dynamic_cast"); +const string ASResource::AS_ELSE = string("else"); const string ASResource::AS_END = string("end"); -const string ASResource::AS_SELECTOR = string("selector"); -const string ASResource::AS_EXTERN = string("extern"); const string ASResource::AS_ENUM = string("enum"); -const string ASResource::AS_PUBLIC = string("public"); -const string ASResource::AS_PROTECTED = string("protected"); +const string ASResource::AS_EXTERN = string("extern"); +const string ASResource::AS_FINAL = string("final"); +const string ASResource::AS_FINALLY = string("finally"); +const string ASResource::AS_FIXED = string("fixed"); +const string ASResource::AS_FOR = string("for"); +const string ASResource::AS_FOREACH = string("foreach"); +const string ASResource::AS_FOREVER = string("forever"); +const string ASResource::AS_GET = string("get"); +const string ASResource::AS_IF = string("if"); +const string ASResource::AS_INTERFACE = string("interface"); +const string ASResource::AS_INTERRUPT = string("interrupt"); +const string ASResource::AS_LET = string("let"); +const string ASResource::AS_LOCK = string("lock"); +const string ASResource::AS_MODULE = string("module"); // CORBA IDL module definition +const string ASResource::AS_NAMESPACE = string("namespace"); +const string ASResource::AS_NEW = string("new"); +const string ASResource::AS_NOEXCEPT = string("noexcept"); +const string ASResource::AS_NS_DURING = string("NS_DURING"); +const string ASResource::AS_NS_HANDLER = string("NS_HANDLER"); +const string ASResource::AS_OPERATOR = string("operator"); +const string ASResource::AS_OVERRIDE = string("override"); const string ASResource::AS_PRIVATE = string("private"); +const string ASResource::AS_PROTECTED = string("protected"); +const string ASResource::AS_PUBLIC = string("public"); +const string ASResource::AS_QFOREACH = string("Q_FOREACH"); +const string ASResource::AS_QFOREVER = string("Q_FOREVER"); +const string ASResource::AS_REINTERPRET_CAST = string("reinterpret_cast"); +const string ASResource::AS_REMOVE = string("remove"); +const string ASResource::AS_SEALED = string("sealed"); +const string ASResource::AS_SELECTOR = string("selector"); +const string ASResource::AS_SET = string("set"); const string ASResource::AS_STATIC = string("static"); +const string ASResource::AS_STATIC_CAST = string("static_cast"); +const string ASResource::AS_STRUCT = string("struct"); +const string ASResource::AS_SWITCH = string("switch"); const string ASResource::AS_SYNCHRONIZED = string("synchronized"); -const string ASResource::AS_OPERATOR = string("operator"); const string ASResource::AS_TEMPLATE = string("template"); -const string ASResource::AS_TRY = string("try"); -const string ASResource::AS_CATCH = string("catch"); const string ASResource::AS_THROW = string("throw"); -const string ASResource::AS_FINALLY = string("finally"); -const string ASResource::AS_USING = string("using"); -const string ASResource::_AS_TRY = string("__try"); -const string ASResource::_AS_FINALLY = string("__finally"); -const string ASResource::_AS_EXCEPT = string("__except"); const string ASResource::AS_THROWS = string("throws"); -const string ASResource::AS_CONST = string("const"); -const string ASResource::AS_SEALED = string("sealed"); -const string ASResource::AS_OVERRIDE = string("override"); +const string ASResource::AS_TRY = string("try"); +const string ASResource::AS_UNCHECKED = string("unchecked"); +const string ASResource::AS_UNION = string("union"); +const string ASResource::AS_UNSAFE = string("unsafe"); +const string ASResource::AS_USING = string("using"); +const string ASResource::AS_VOLATILE = string("volatile"); const string ASResource::AS_WHERE = string("where"); -const string ASResource::AS_LET = string("let"); -const string ASResource::AS_NEW = string("new"); -const string ASResource::AS_DELETE = string("delete"); +const string ASResource::AS_WHILE = string("while"); const string ASResource::AS_ASM = string("asm"); const string ASResource::AS__ASM__ = string("__asm__"); @@ -73,8 +94,8 @@ const string ASResource::AS_BAR_EL = string("#el"); const string ASResource::AS_BAR_ENDIF = string("#endif"); -const string ASResource::AS_OPEN_BRACKET = string("{"); -const string ASResource::AS_CLOSE_BRACKET = string("}"); +const string ASResource::AS_OPEN_BRACE = string("{"); +const string ASResource::AS_CLOSE_BRACE = string("}"); const string ASResource::AS_OPEN_LINE_COMMENT = string("//"); const string ASResource::AS_OPEN_COMMENT = string("/*"); const string ASResource::AS_CLOSE_COMMENT = string("*/"); @@ -134,28 +155,6 @@ const string ASResource::AS_COMMA = string(","); const string ASResource::AS_SEMICOLON = string(";"); -const string ASResource::AS_QFOREACH = string("Q_FOREACH"); -const string ASResource::AS_QFOREVER = string("Q_FOREVER"); -const string ASResource::AS_FOREVER = string("forever"); -const string ASResource::AS_FOREACH = string("foreach"); -const string ASResource::AS_LOCK = string("lock"); -const string ASResource::AS_UNSAFE = string("unsafe"); -const string ASResource::AS_FIXED = string("fixed"); -const string ASResource::AS_GET = string("get"); -const string ASResource::AS_SET = string("set"); -const string ASResource::AS_ADD = string("add"); -const string ASResource::AS_REMOVE = string("remove"); -const string ASResource::AS_DELEGATE = string("delegate"); -const string ASResource::AS_UNCHECKED = string("unchecked"); - -const string ASResource::AS_CONST_CAST = string("const_cast"); -const string ASResource::AS_DYNAMIC_CAST = string("dynamic_cast"); -const string ASResource::AS_REINTERPRET_CAST = string("reinterpret_cast"); -const string ASResource::AS_STATIC_CAST = string("static_cast"); - -const string ASResource::AS_NS_DURING = string("NS_DURING"); -const string ASResource::AS_NS_HANDLER = string("NS_HANDLER"); - /** * Sort comparison function. * Compares the length of the value of pointers in the vectors. @@ -187,24 +186,33 @@ */ void ASResource::buildAssignmentOperators(vector* assignmentOperators) { - assignmentOperators->push_back(&AS_ASSIGN); - assignmentOperators->push_back(&AS_PLUS_ASSIGN); - assignmentOperators->push_back(&AS_MINUS_ASSIGN); - assignmentOperators->push_back(&AS_MULT_ASSIGN); - assignmentOperators->push_back(&AS_DIV_ASSIGN); - assignmentOperators->push_back(&AS_MOD_ASSIGN); - assignmentOperators->push_back(&AS_OR_ASSIGN); - assignmentOperators->push_back(&AS_AND_ASSIGN); - assignmentOperators->push_back(&AS_XOR_ASSIGN); + const size_t elements = 15; + static bool reserved = false; + if (!reserved) + { + assignmentOperators->reserve(elements); + reserved = true; + } + + assignmentOperators->emplace_back(&AS_ASSIGN); + assignmentOperators->emplace_back(&AS_PLUS_ASSIGN); + assignmentOperators->emplace_back(&AS_MINUS_ASSIGN); + assignmentOperators->emplace_back(&AS_MULT_ASSIGN); + assignmentOperators->emplace_back(&AS_DIV_ASSIGN); + assignmentOperators->emplace_back(&AS_MOD_ASSIGN); + assignmentOperators->emplace_back(&AS_OR_ASSIGN); + assignmentOperators->emplace_back(&AS_AND_ASSIGN); + assignmentOperators->emplace_back(&AS_XOR_ASSIGN); // Java - assignmentOperators->push_back(&AS_GR_GR_GR_ASSIGN); - assignmentOperators->push_back(&AS_GR_GR_ASSIGN); - assignmentOperators->push_back(&AS_LS_LS_ASSIGN); + assignmentOperators->emplace_back(&AS_GR_GR_GR_ASSIGN); + assignmentOperators->emplace_back(&AS_GR_GR_ASSIGN); + assignmentOperators->emplace_back(&AS_LS_LS_ASSIGN); // Unknown - assignmentOperators->push_back(&AS_LS_LS_LS_ASSIGN); + assignmentOperators->emplace_back(&AS_LS_LS_LS_ASSIGN); + assert(assignmentOperators->size() < elements); sort(assignmentOperators->begin(), assignmentOperators->end(), sortOnLength); } @@ -216,10 +224,21 @@ */ void ASResource::buildCastOperators(vector* castOperators) { - castOperators->push_back(&AS_CONST_CAST); - castOperators->push_back(&AS_DYNAMIC_CAST); - castOperators->push_back(&AS_REINTERPRET_CAST); - castOperators->push_back(&AS_STATIC_CAST); + const size_t elements = 5; + static bool reserved = false; + if (!reserved) + { + castOperators->reserve(elements); + reserved = true; + } + + castOperators->emplace_back(&AS_CONST_CAST); + castOperators->emplace_back(&AS_DYNAMIC_CAST); + castOperators->emplace_back(&AS_REINTERPRET_CAST); + castOperators->emplace_back(&AS_STATIC_CAST); + + assert(castOperators->size() < elements); + sort(castOperators->begin(), castOperators->end(), sortOnName); } /** @@ -230,57 +249,67 @@ */ void ASResource::buildHeaders(vector* headers, int fileType, bool beautifier) { - headers->push_back(&AS_IF); - headers->push_back(&AS_ELSE); - headers->push_back(&AS_FOR); - headers->push_back(&AS_WHILE); - headers->push_back(&AS_DO); - headers->push_back(&AS_SWITCH); - headers->push_back(&AS_CASE); - headers->push_back(&AS_DEFAULT); - headers->push_back(&AS_TRY); - headers->push_back(&AS_CATCH); - headers->push_back(&AS_QFOREACH); // QT - headers->push_back(&AS_QFOREVER); // QT - headers->push_back(&AS_FOREACH); // QT & C# - headers->push_back(&AS_FOREVER); // Qt & Boost + const size_t elements = 25; + static bool reserved = false; + if (!reserved) + { + headers->reserve(elements); + reserved = true; + } + + headers->emplace_back(&AS_IF); + headers->emplace_back(&AS_ELSE); + headers->emplace_back(&AS_FOR); + headers->emplace_back(&AS_WHILE); + headers->emplace_back(&AS_DO); + headers->emplace_back(&AS_SWITCH); + headers->emplace_back(&AS_CASE); + headers->emplace_back(&AS_DEFAULT); + headers->emplace_back(&AS_TRY); + headers->emplace_back(&AS_CATCH); + headers->emplace_back(&AS_QFOREACH); // QT + headers->emplace_back(&AS_QFOREVER); // QT + headers->emplace_back(&AS_FOREACH); // QT & C# + headers->emplace_back(&AS_FOREVER); // Qt & Boost if (fileType == C_TYPE) { - headers->push_back(&_AS_TRY); // __try - headers->push_back(&_AS_FINALLY); // __finally - headers->push_back(&_AS_EXCEPT); // __except + headers->emplace_back(&_AS_TRY); // __try + headers->emplace_back(&_AS_FINALLY); // __finally + headers->emplace_back(&_AS_EXCEPT); // __except } if (fileType == JAVA_TYPE) { - headers->push_back(&AS_FINALLY); - headers->push_back(&AS_SYNCHRONIZED); + headers->emplace_back(&AS_FINALLY); + headers->emplace_back(&AS_SYNCHRONIZED); } if (fileType == SHARP_TYPE) { - headers->push_back(&AS_FINALLY); - headers->push_back(&AS_LOCK); - headers->push_back(&AS_FIXED); - headers->push_back(&AS_GET); - headers->push_back(&AS_SET); - headers->push_back(&AS_ADD); - headers->push_back(&AS_REMOVE); - headers->push_back(&AS_USING); + headers->emplace_back(&AS_FINALLY); + headers->emplace_back(&AS_LOCK); + headers->emplace_back(&AS_FIXED); + headers->emplace_back(&AS_GET); + headers->emplace_back(&AS_SET); + headers->emplace_back(&AS_ADD); + headers->emplace_back(&AS_REMOVE); + headers->emplace_back(&AS_USING); } if (beautifier) { if (fileType == C_TYPE) { - headers->push_back(&AS_TEMPLATE); + headers->emplace_back(&AS_TEMPLATE); } if (fileType == JAVA_TYPE) { - headers->push_back(&AS_STATIC); // for static constructor + headers->emplace_back(&AS_STATIC); // for static constructor } } + + assert(headers->size() < elements); sort(headers->begin(), headers->end(), sortOnName); } @@ -292,9 +321,9 @@ */ void ASResource::buildIndentableHeaders(vector* indentableHeaders) { - indentableHeaders->push_back(&AS_RETURN); + indentableHeaders->emplace_back(&AS_RETURN); - sort(indentableHeaders->begin(), indentableHeaders->end(), sortOnName); +// sort(indentableHeaders->begin(), indentableHeaders->end(), sortOnName); } /** @@ -305,24 +334,33 @@ */ void ASResource::buildIndentableMacros(vector* >* indentableMacros) { - typedef pair macro_pair; + const size_t elements = 10; + static bool reserved = false; + if (!reserved) + { + indentableMacros->reserve(elements); + reserved = true; + } // the pairs must be retained in memory because of pair pointers + typedef pair macro_pair; static const macro_pair macros[] = { // wxWidgets - macro_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"), + macro_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"), macro_pair("wxBEGIN_EVENT_TABLE", "wxEND_EVENT_TABLE"), // MFC - macro_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"), - macro_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"), - macro_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"), - macro_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"), + macro_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"), + macro_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"), + macro_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"), + macro_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"), }; - size_t elements = sizeof(macros) / sizeof(macros[0]); - for (size_t i = 0; i < elements; i++) - indentableMacros->push_back(¯os[i]); + size_t entries = sizeof(macros) / sizeof(macros[0]); + for (size_t i = 0; i < entries; i++) + indentableMacros->emplace_back(¯os[i]); + + assert(indentableMacros->size() < elements); } /** @@ -333,21 +371,30 @@ */ void ASResource::buildNonAssignmentOperators(vector* nonAssignmentOperators) { - nonAssignmentOperators->push_back(&AS_EQUAL); - nonAssignmentOperators->push_back(&AS_PLUS_PLUS); - nonAssignmentOperators->push_back(&AS_MINUS_MINUS); - nonAssignmentOperators->push_back(&AS_NOT_EQUAL); - nonAssignmentOperators->push_back(&AS_GR_EQUAL); - nonAssignmentOperators->push_back(&AS_GR_GR_GR); - nonAssignmentOperators->push_back(&AS_GR_GR); - nonAssignmentOperators->push_back(&AS_LS_EQUAL); - nonAssignmentOperators->push_back(&AS_LS_LS_LS); - nonAssignmentOperators->push_back(&AS_LS_LS); - nonAssignmentOperators->push_back(&AS_ARROW); - nonAssignmentOperators->push_back(&AS_AND); - nonAssignmentOperators->push_back(&AS_OR); - nonAssignmentOperators->push_back(&AS_LAMBDA); + const size_t elements = 15; + static bool reserved = false; + if (!reserved) + { + nonAssignmentOperators->reserve(elements); + reserved = true; + } + + nonAssignmentOperators->emplace_back(&AS_EQUAL); + nonAssignmentOperators->emplace_back(&AS_PLUS_PLUS); + nonAssignmentOperators->emplace_back(&AS_MINUS_MINUS); + nonAssignmentOperators->emplace_back(&AS_NOT_EQUAL); + nonAssignmentOperators->emplace_back(&AS_GR_EQUAL); + nonAssignmentOperators->emplace_back(&AS_GR_GR_GR); + nonAssignmentOperators->emplace_back(&AS_GR_GR); + nonAssignmentOperators->emplace_back(&AS_LS_EQUAL); + nonAssignmentOperators->emplace_back(&AS_LS_LS_LS); + nonAssignmentOperators->emplace_back(&AS_LS_LS); + nonAssignmentOperators->emplace_back(&AS_ARROW); + nonAssignmentOperators->emplace_back(&AS_AND); + nonAssignmentOperators->emplace_back(&AS_OR); + nonAssignmentOperators->emplace_back(&AS_LAMBDA); + assert(nonAssignmentOperators->size() < elements); sort(nonAssignmentOperators->begin(), nonAssignmentOperators->end(), sortOnLength); } @@ -360,45 +407,55 @@ */ void ASResource::buildNonParenHeaders(vector* nonParenHeaders, int fileType, bool beautifier) { - nonParenHeaders->push_back(&AS_ELSE); - nonParenHeaders->push_back(&AS_DO); - nonParenHeaders->push_back(&AS_TRY); - nonParenHeaders->push_back(&AS_CATCH); // can be paren or non-paren - nonParenHeaders->push_back(&AS_CASE); // can be paren or non-paren - nonParenHeaders->push_back(&AS_DEFAULT); - nonParenHeaders->push_back(&AS_QFOREVER); // QT - nonParenHeaders->push_back(&AS_FOREVER); // Boost + const size_t elements = 20; + static bool reserved = false; + if (!reserved) + { + nonParenHeaders->reserve(elements); + reserved = true; + } + + nonParenHeaders->emplace_back(&AS_ELSE); + nonParenHeaders->emplace_back(&AS_DO); + nonParenHeaders->emplace_back(&AS_TRY); + nonParenHeaders->emplace_back(&AS_CATCH); // can be paren or non-paren + nonParenHeaders->emplace_back(&AS_CASE); // can be paren or non-paren + nonParenHeaders->emplace_back(&AS_DEFAULT); + nonParenHeaders->emplace_back(&AS_QFOREVER); // QT + nonParenHeaders->emplace_back(&AS_FOREVER); // Boost if (fileType == C_TYPE) { - nonParenHeaders->push_back(&_AS_TRY); // __try - nonParenHeaders->push_back(&_AS_FINALLY); // __finally + nonParenHeaders->emplace_back(&_AS_TRY); // __try + nonParenHeaders->emplace_back(&_AS_FINALLY); // __finally } if (fileType == JAVA_TYPE) { - nonParenHeaders->push_back(&AS_FINALLY); + nonParenHeaders->emplace_back(&AS_FINALLY); } if (fileType == SHARP_TYPE) { - nonParenHeaders->push_back(&AS_FINALLY); - nonParenHeaders->push_back(&AS_GET); - nonParenHeaders->push_back(&AS_SET); - nonParenHeaders->push_back(&AS_ADD); - nonParenHeaders->push_back(&AS_REMOVE); + nonParenHeaders->emplace_back(&AS_FINALLY); + nonParenHeaders->emplace_back(&AS_GET); + nonParenHeaders->emplace_back(&AS_SET); + nonParenHeaders->emplace_back(&AS_ADD); + nonParenHeaders->emplace_back(&AS_REMOVE); } if (beautifier) { if (fileType == C_TYPE) { - nonParenHeaders->push_back(&AS_TEMPLATE); + nonParenHeaders->emplace_back(&AS_TEMPLATE); } if (fileType == JAVA_TYPE) { - nonParenHeaders->push_back(&AS_STATIC); + nonParenHeaders->emplace_back(&AS_STATIC); } } + + assert(nonParenHeaders->size() < elements); sort(nonParenHeaders->begin(), nonParenHeaders->end(), sortOnName); } @@ -410,54 +467,65 @@ */ void ASResource::buildOperators(vector* operators, int fileType) { - operators->push_back(&AS_PLUS_ASSIGN); - operators->push_back(&AS_MINUS_ASSIGN); - operators->push_back(&AS_MULT_ASSIGN); - operators->push_back(&AS_DIV_ASSIGN); - operators->push_back(&AS_MOD_ASSIGN); - operators->push_back(&AS_OR_ASSIGN); - operators->push_back(&AS_AND_ASSIGN); - operators->push_back(&AS_XOR_ASSIGN); - operators->push_back(&AS_EQUAL); - operators->push_back(&AS_PLUS_PLUS); - operators->push_back(&AS_MINUS_MINUS); - operators->push_back(&AS_NOT_EQUAL); - operators->push_back(&AS_GR_EQUAL); - operators->push_back(&AS_GR_GR_GR_ASSIGN); - operators->push_back(&AS_GR_GR_ASSIGN); - operators->push_back(&AS_GR_GR_GR); - operators->push_back(&AS_GR_GR); - operators->push_back(&AS_LS_EQUAL); - operators->push_back(&AS_LS_LS_LS_ASSIGN); - operators->push_back(&AS_LS_LS_ASSIGN); - operators->push_back(&AS_LS_LS_LS); - operators->push_back(&AS_LS_LS); - operators->push_back(&AS_QUESTION_QUESTION); - operators->push_back(&AS_LAMBDA); - operators->push_back(&AS_ARROW); - operators->push_back(&AS_AND); - operators->push_back(&AS_OR); - operators->push_back(&AS_SCOPE_RESOLUTION); - operators->push_back(&AS_PLUS); - operators->push_back(&AS_MINUS); - operators->push_back(&AS_MULT); - operators->push_back(&AS_DIV); - operators->push_back(&AS_MOD); - operators->push_back(&AS_QUESTION); - operators->push_back(&AS_COLON); - operators->push_back(&AS_ASSIGN); - operators->push_back(&AS_LS); - operators->push_back(&AS_GR); - operators->push_back(&AS_NOT); - operators->push_back(&AS_BIT_OR); - operators->push_back(&AS_BIT_AND); - operators->push_back(&AS_BIT_NOT); - operators->push_back(&AS_BIT_XOR); + const size_t elements = 50; + static bool reserved = false; + if (!reserved) + { + operators->reserve(elements); + reserved = true; + } + + + operators->emplace_back(&AS_PLUS_ASSIGN); + operators->emplace_back(&AS_MINUS_ASSIGN); + operators->emplace_back(&AS_MULT_ASSIGN); + operators->emplace_back(&AS_DIV_ASSIGN); + operators->emplace_back(&AS_MOD_ASSIGN); + operators->emplace_back(&AS_OR_ASSIGN); + operators->emplace_back(&AS_AND_ASSIGN); + operators->emplace_back(&AS_XOR_ASSIGN); + operators->emplace_back(&AS_EQUAL); + operators->emplace_back(&AS_PLUS_PLUS); + operators->emplace_back(&AS_MINUS_MINUS); + operators->emplace_back(&AS_NOT_EQUAL); + operators->emplace_back(&AS_GR_EQUAL); + operators->emplace_back(&AS_GR_GR_GR_ASSIGN); + operators->emplace_back(&AS_GR_GR_ASSIGN); + operators->emplace_back(&AS_GR_GR_GR); + operators->emplace_back(&AS_GR_GR); + operators->emplace_back(&AS_LS_EQUAL); + operators->emplace_back(&AS_LS_LS_LS_ASSIGN); + operators->emplace_back(&AS_LS_LS_ASSIGN); + operators->emplace_back(&AS_LS_LS_LS); + operators->emplace_back(&AS_LS_LS); + operators->emplace_back(&AS_QUESTION_QUESTION); + operators->emplace_back(&AS_LAMBDA); + operators->emplace_back(&AS_ARROW); + operators->emplace_back(&AS_AND); + operators->emplace_back(&AS_OR); + operators->emplace_back(&AS_SCOPE_RESOLUTION); + operators->emplace_back(&AS_PLUS); + operators->emplace_back(&AS_MINUS); + operators->emplace_back(&AS_MULT); + operators->emplace_back(&AS_DIV); + operators->emplace_back(&AS_MOD); + operators->emplace_back(&AS_QUESTION); + operators->emplace_back(&AS_COLON); + operators->emplace_back(&AS_ASSIGN); + operators->emplace_back(&AS_LS); + operators->emplace_back(&AS_GR); + operators->emplace_back(&AS_NOT); + operators->emplace_back(&AS_BIT_OR); + operators->emplace_back(&AS_BIT_AND); + operators->emplace_back(&AS_BIT_NOT); + operators->emplace_back(&AS_BIT_XOR); if (fileType == C_TYPE) { - operators->push_back(&AS_GCC_MIN_ASSIGN); - operators->push_back(&AS_GCC_MAX_ASSIGN); + operators->emplace_back(&AS_GCC_MIN_ASSIGN); + operators->emplace_back(&AS_GCC_MAX_ASSIGN); } + + assert(operators->size() < elements); sort(operators->begin(), operators->end(), sortOnLength); } @@ -470,27 +538,37 @@ */ void ASResource::buildPreBlockStatements(vector* preBlockStatements, int fileType) { - preBlockStatements->push_back(&AS_CLASS); + const size_t elements = 10; + static bool reserved = false; + if (!reserved) + { + preBlockStatements->reserve(elements); + reserved = true; + } + + preBlockStatements->emplace_back(&AS_CLASS); if (fileType == C_TYPE) { - preBlockStatements->push_back(&AS_STRUCT); - preBlockStatements->push_back(&AS_UNION); - preBlockStatements->push_back(&AS_NAMESPACE); - preBlockStatements->push_back(&AS_MODULE); // for CORBA IDL - preBlockStatements->push_back(&AS_INTERFACE); // for CORBA IDL + preBlockStatements->emplace_back(&AS_STRUCT); + preBlockStatements->emplace_back(&AS_UNION); + preBlockStatements->emplace_back(&AS_NAMESPACE); + preBlockStatements->emplace_back(&AS_MODULE); // for CORBA IDL + preBlockStatements->emplace_back(&AS_INTERFACE); // for CORBA IDL } if (fileType == JAVA_TYPE) { - preBlockStatements->push_back(&AS_INTERFACE); - preBlockStatements->push_back(&AS_THROWS); + preBlockStatements->emplace_back(&AS_INTERFACE); + preBlockStatements->emplace_back(&AS_THROWS); } if (fileType == SHARP_TYPE) { - preBlockStatements->push_back(&AS_INTERFACE); - preBlockStatements->push_back(&AS_NAMESPACE); - preBlockStatements->push_back(&AS_WHERE); - preBlockStatements->push_back(&AS_STRUCT); + preBlockStatements->emplace_back(&AS_INTERFACE); + preBlockStatements->emplace_back(&AS_NAMESPACE); + preBlockStatements->emplace_back(&AS_WHERE); + preBlockStatements->emplace_back(&AS_STRUCT); } + + assert(preBlockStatements->size() < elements); sort(preBlockStatements->begin(), preBlockStatements->end(), sortOnName); } @@ -500,64 +578,84 @@ * NOTE: Cannot be both a header and a preCommandHeader. * * A preCommandHeader is in a function definition between - * the closing paren and the opening bracket. + * the closing paren and the opening brace. * e.g. in "void foo() const {}", "const" is a preCommandHeader. */ void ASResource::buildPreCommandHeaders(vector* preCommandHeaders, int fileType) { + const size_t elements = 10; + static bool reserved = false; + if (!reserved) + { + preCommandHeaders->reserve(elements); + reserved = true; + } + if (fileType == C_TYPE) { - preCommandHeaders->push_back(&AS_CONST); - preCommandHeaders->push_back(&AS_VOLATILE); - preCommandHeaders->push_back(&AS_INTERRUPT); - preCommandHeaders->push_back(&AS_NOEXCEPT); - preCommandHeaders->push_back(&AS_OVERRIDE); - preCommandHeaders->push_back(&AS_SEALED); // Visual C only - preCommandHeaders->push_back(&AS_AUTORELEASEPOOL); // Obj-C only + preCommandHeaders->emplace_back(&AS_CONST); + preCommandHeaders->emplace_back(&AS_FINAL); + preCommandHeaders->emplace_back(&AS_INTERRUPT); + preCommandHeaders->emplace_back(&AS_NOEXCEPT); + preCommandHeaders->emplace_back(&AS_OVERRIDE); + preCommandHeaders->emplace_back(&AS_VOLATILE); + preCommandHeaders->emplace_back(&AS_SEALED); // Visual C only + preCommandHeaders->emplace_back(&AS_AUTORELEASEPOOL); // Obj-C only } if (fileType == JAVA_TYPE) { - preCommandHeaders->push_back(&AS_THROWS); + preCommandHeaders->emplace_back(&AS_THROWS); } if (fileType == SHARP_TYPE) { - preCommandHeaders->push_back(&AS_WHERE); + preCommandHeaders->emplace_back(&AS_WHERE); } + assert(preCommandHeaders->size() < elements); sort(preCommandHeaders->begin(), preCommandHeaders->end(), sortOnName); } /** * Build the vector of pre-definition headers. * Used by ONLY ASFormatter.cpp - * NOTE: Do NOT add 'enum' here. It is an array type bracket. + * NOTE: Do NOT add 'enum' here. It is an array type brace. * NOTE: Do NOT add 'extern' here. Do not want an extra indent. * * @param preDefinitionHeaders a reference to the vector to be built. */ void ASResource::buildPreDefinitionHeaders(vector* preDefinitionHeaders, int fileType) { - preDefinitionHeaders->push_back(&AS_CLASS); + const size_t elements = 10; + static bool reserved = false; + if (!reserved) + { + preDefinitionHeaders->reserve(elements); + reserved = true; + } + + preDefinitionHeaders->emplace_back(&AS_CLASS); if (fileType == C_TYPE) { - preDefinitionHeaders->push_back(&AS_STRUCT); - preDefinitionHeaders->push_back(&AS_UNION); - preDefinitionHeaders->push_back(&AS_NAMESPACE); - preDefinitionHeaders->push_back(&AS_MODULE); // for CORBA IDL - preDefinitionHeaders->push_back(&AS_INTERFACE); // for CORBA IDL + preDefinitionHeaders->emplace_back(&AS_STRUCT); + preDefinitionHeaders->emplace_back(&AS_UNION); + preDefinitionHeaders->emplace_back(&AS_NAMESPACE); + preDefinitionHeaders->emplace_back(&AS_MODULE); // for CORBA IDL + preDefinitionHeaders->emplace_back(&AS_INTERFACE); // for CORBA IDL } if (fileType == JAVA_TYPE) { - preDefinitionHeaders->push_back(&AS_INTERFACE); + preDefinitionHeaders->emplace_back(&AS_INTERFACE); } if (fileType == SHARP_TYPE) { - preDefinitionHeaders->push_back(&AS_STRUCT); - preDefinitionHeaders->push_back(&AS_INTERFACE); - preDefinitionHeaders->push_back(&AS_NAMESPACE); + preDefinitionHeaders->emplace_back(&AS_STRUCT); + preDefinitionHeaders->emplace_back(&AS_INTERFACE); + preDefinitionHeaders->emplace_back(&AS_NAMESPACE); } + + assert(preDefinitionHeaders->size() < elements); sort(preDefinitionHeaders->begin(), preDefinitionHeaders->end(), sortOnName); } @@ -565,6 +663,46 @@ * ASBase Functions * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// check if a specific line position contains a header. +const string* ASBase::findHeader(const string& line, int i, + const vector* possibleHeaders) const +{ + assert(isCharPotentialHeader(line, i)); + // check the word + size_t maxHeaders = possibleHeaders->size(); + for (size_t p = 0; p < maxHeaders; p++) + { + const string* header = (*possibleHeaders)[p]; + const size_t wordEnd = i + header->length(); + if (wordEnd > line.length()) + continue; + int result = (line.compare(i, header->length(), *header)); + if (result > 0) + continue; + if (result < 0) + break; + // check that this is not part of a longer word + if (wordEnd == line.length()) + return header; + if (isLegalNameChar(line[wordEnd])) + continue; + const char peekChar = peekNextChar(line, wordEnd - 1); + // is not a header if part of a definition + if (peekChar == ',' || peekChar == ')') + break; + // the following accessor definitions are NOT headers + // goto default; is NOT a header + // default(int) keyword in C# is NOT a header + else if ((header == &AS_GET + || header == &AS_SET + || header == &AS_DEFAULT) + && (peekChar == ';' || peekChar == '(' || peekChar == '=')) + break; + return header; + } + return nullptr; +} + // check if a specific line position contains a keyword. bool ASBase::findKeyword(const string& line, int i, const string& keyword) const { @@ -582,12 +720,32 @@ if (isLegalNameChar(line[wordEnd])) return false; // is not a keyword if part of a definition - const char peekChar = peekNextChar(line, (int)wordEnd - 1); + const char peekChar = peekNextChar(line, (int) wordEnd - 1); if (peekChar == ',' || peekChar == ')') return false; return true; } +// check if a specific line position contains an operator. +const string* ASBase::findOperator(const string& line, int i, + const vector* possibleOperators) const +{ + assert(isCharPotentialOperator(line[i])); + // find the operator in the vector + // the vector contains the LONGEST operators first + // must loop thru the entire vector + size_t maxOperators = possibleOperators->size(); + for (size_t p = 0; p < maxOperators; p++) + { + const size_t wordEnd = i + (*(*possibleOperators)[p]).length(); + if (wordEnd > line.length()) + continue; + if (line.compare(i, (*(*possibleOperators)[p]).length(), *(*possibleOperators)[p]) == 0) + return (*possibleOperators)[p]; + } + return nullptr; +} + // get the current word on a line // index must point to the beginning of the word string ASBase::getCurrentWord(const string& line, size_t index) const @@ -608,7 +766,7 @@ { if (isWhiteSpace(ch)) return false; - if ((unsigned) ch > 127) + if ((unsigned char) ch > 127) return false; return (isalnum((unsigned char) ch) || ch == '.' || ch == '_' diff -Nru astyle-2.06/src/astyle.h astyle-3.0.1/src/astyle.h --- astyle-2.06/src/astyle.h 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/astyle.h 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // astyle.h -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. #ifndef ASTYLE_H #define ASTYLE_H @@ -19,6 +19,7 @@ #include #include // for cout +#include #include #include @@ -38,6 +39,10 @@ #pragma warn -8004 // variable is assigned a value that is never used #endif +#ifdef __GNUC__ + #pragma GCC diagnostic ignored "-Wconversion" +#endif + #ifdef __INTEL_COMPILER #pragma warning(disable: 383) // value copied to temporary, reference to temporary used #pragma warning(disable: 981) // operands are evaluated in unspecified order @@ -84,17 +89,17 @@ STYLE_LISP }; -enum BracketMode +enum BraceMode { NONE_MODE, ATTACH_MODE, BREAK_MODE, LINUX_MODE, - RUN_IN_MODE // broken brackets + RUN_IN_MODE // broken braces }; // maximun value for int is 16,384 (total value of 32,767) -enum BracketType +enum BraceType { NULL_TYPE = 0, NAMESPACE_TYPE = 1, // also a DEFINITION_TYPE @@ -190,14 +195,40 @@ }; //----------------------------------------------------------------------------- +// Class ASPeekStream +// A small class using RAII to peek ahead in the ASSourceIterator stream +// and to reset the ASSourceIterator pointer in the destructor. +// It enables a return from anywhere in the method. +//----------------------------------------------------------------------------- + +class ASPeekStream +{ +private: + ASSourceIterator* sourceIterator; + bool needReset; // reset sourceIterator to the original position + +public: + explicit ASPeekStream(ASSourceIterator* sourceIterator_) + { sourceIterator = sourceIterator_; needReset = false; } + + ~ASPeekStream() + { if (needReset) sourceIterator->peekReset(); } + + bool hasMoreLines() const + { return sourceIterator->hasMoreLines(); } + + string peekNextLine() + { needReset = true; return sourceIterator->peekNextLine(); } +}; + + +//----------------------------------------------------------------------------- // Class ASResource //----------------------------------------------------------------------------- class ASResource { public: - ASResource() {} - virtual ~ASResource() {} void buildAssignmentOperators(vector* assignmentOperators); void buildCastOperators(vector* castOperators); void buildHeaders(vector* headers, int fileType, bool beautifier = false); @@ -223,14 +254,15 @@ static const string AS_END; static const string AS_SELECTOR; static const string AS_EXTERN, AS_ENUM; - static const string AS_STATIC, AS_CONST, AS_SEALED, AS_OVERRIDE, AS_VOLATILE, AS_NEW, AS_DELETE; + static const string AS_FINAL, AS_OVERRIDE; + static const string AS_STATIC, AS_CONST, AS_SEALED, AS_VOLATILE, AS_NEW, AS_DELETE; static const string AS_NOEXCEPT, AS_INTERRUPT, AS_AUTORELEASEPOOL; static const string AS_WHERE, AS_LET, AS_SYNCHRONIZED; static const string AS_OPERATOR, AS_TEMPLATE; - static const string AS_OPEN_BRACKET, AS_CLOSE_BRACKET; + static const string AS_OPEN_BRACE, AS_CLOSE_BRACE; static const string AS_OPEN_LINE_COMMENT, AS_OPEN_COMMENT, AS_CLOSE_COMMENT; static const string AS_BAR_DEFINE, AS_BAR_INCLUDE, AS_BAR_IF, AS_BAR_EL, AS_BAR_ENDIF; - static const string AS_RETURN; + static const string AS_AUTO, AS_RETURN; static const string AS_CIN, AS_COUT, AS_CERR; static const string AS_ASSIGN, AS_PLUS_ASSIGN, AS_MINUS_ASSIGN, AS_MULT_ASSIGN; static const string AS_DIV_ASSIGN, AS_MOD_ASSIGN, AS_XOR_ASSIGN, AS_OR_ASSIGN, AS_AND_ASSIGN; @@ -258,7 +290,7 @@ // Functions definitions are at the end of ASResource.cpp. //----------------------------------------------------------------------------- -class ASBase +class ASBase : protected ASResource { private: // all variables should be set by the "init" function @@ -275,7 +307,11 @@ bool isWhiteSpace(char ch) const { return (ch == ' ' || ch == '\t'); } protected: // functions definitions are at the end of ASResource.cpp + const string* findHeader(const string& line, int i, + const vector* possibleHeaders) const; bool findKeyword(const string& line, int i, const string& keyword) const; + const string* findOperator(const string& line, int i, + const vector* possibleOperators) const; string getCurrentWord(const string& line, size_t index) const; bool isDigit(char ch) const; bool isLegalNameChar(char ch) const; @@ -290,7 +326,7 @@ // Class ASBeautifier //----------------------------------------------------------------------------- -class ASBeautifier : protected ASResource, protected ASBase +class ASBeautifier : protected ASBase { public: ASBeautifier(); @@ -304,8 +340,10 @@ void setDefaultTabLength(); void setEmptyLineFill(bool state); void setForceTabXIndentation(int length); + void setAfterParenIndent(bool state); void setJavaStyle(); void setLabelIndent(bool state); + void setMaxContinuationIndentLength(int max); void setMaxInStatementIndentLength(int max); void setMinConditionalIndentOption(int min); void setMinConditionalIndentLength(); @@ -326,7 +364,7 @@ string getIndentString() const; string getNextWord(const string& line, size_t currPos) const; bool getAlignMethodColon() const; - bool getBracketIndent() const; + bool getBraceIndent() const; bool getBlockIndent() const; bool getCaseIndent() const; bool getClassIndent() const; @@ -340,23 +378,19 @@ protected: void deleteBeautifierVectors(); - const string* findHeader(const string& line, int i, - const vector* possibleHeaders) const; - const string* findOperator(const string& line, int i, - const vector* possibleOperators) const; int getNextProgramCharDistance(const string& line, int i) const; - int indexOf(vector& container, const string* element) const; + int indexOf(const vector& container, const string* element) const; void setBlockIndent(bool state); - void setBracketIndent(bool state); - void setBracketIndentVtk(bool state); + void setBraceIndent(bool state); + void setBraceIndentVtk(bool state); string extractPreprocessorStatement(const string& line) const; string trim(const string& str) const; string rtrim(const string& str) const; // variables set by ASFormatter - must be updated in activeBeautifierStack int inLineNumber; - int horstmannIndentInStatement; - int nonInStatementBracket; + int runInIndentContinuation; + int nonInStatementBrace; int objCColonAlignSubsequent; // for subsequent lines not counting indent bool lineCommentNoBeautify; bool isElseHeaderIndent; @@ -371,18 +405,18 @@ private: // functions ASBeautifier(const ASBeautifier& other); // inline functions - ASBeautifier& operator=(ASBeautifier&); // not to be implemented + ASBeautifier& operator=(ASBeautifier&); // not to be implemented void adjustObjCMethodDefinitionIndentation(const string& line_); void adjustObjCMethodCallIndentation(const string& line_); void adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHeaderIndent); void computePreliminaryIndentation(); void parseCurrentLine(const string& line); - void popLastInStatementIndent(); + void popLastContinuationIndent(); void processPreprocessor(const string& preproc, const string& line); - void registerInStatementIndent(const string& line, int i, int spaceIndentCount_, - int tabIncrementIn, int minIndent, bool updateParenStack); - void registerInStatementIndentColon(const string& line, int i, int tabIncrementIn); + void registerContinuationIndent(const string& line, int i, int spaceIndentCount_, + int tabIncrementIn, int minIndent, bool updateParenStack); + void registerContinuationIndentColon(const string& line, int i, int tabIncrementIn); void initVectors(); void initTempStacksContainer(vector*>*& container, vector*>* value); @@ -392,15 +426,15 @@ int adjustIndentCountForBreakElseIfComments() const; int computeObjCColonAlignment(const string& line, int colonAlignPosition) const; int convertTabToSpaces(int i, int tabIncrementIn) const; - int getInStatementIndentAssign(const string& line, size_t currPos) const; - int getInStatementIndentComma(const string& line, size_t currPos) const; - int getObjCFollowingKeyword(const string& line, int BracketPos) const; + int getContinuationIndentAssign(const string& line, size_t currPos) const; + int getContinuationIndentComma(const string& line, size_t currPos) const; + int getObjCFollowingKeyword(const string& line, int bracePos) const; bool isIndentedPreprocessor(const string& line, size_t currPos) const; bool isLineEndComment(const string& line, int startPos) const; bool isPreprocessorConditionalCplusplus(const string& line) const; bool isInPreprocessorUnterminatedComment(const string& line); bool statementEndsWithComma(const string& line, int index) const; - string& getIndentedLineReturn(string& newLine, const string& originalLine) const; + const string& getIndentedLineReturn(const string& newLine, const string& originalLine) const; string getIndentedSpaceEquivalent(const string& line_) const; string preLineWS(int lineIndentCount, int lineSpaceIndentCount) const; template void deleteContainer(T& container); @@ -424,12 +458,12 @@ vector* activeBeautifierStackLengthStack; vector* headerStack; vector* >* tempStacks; - vector* blockParenDepthStack; + vector* squareBracketDepthStack; vector* blockStatementStack; vector* parenStatementStack; - vector* bracketBlockStateStack; - vector* inStatementIndentStack; - vector* inStatementIndentStackSizeStack; + vector* braceBlockStateStack; + vector* continuationIndentStack; + vector* continuationIndentStackSizeStack; vector* parenIndentStack; vector >* preprocIndentStack; @@ -448,20 +482,20 @@ bool isInAsmBlock; bool isInComment; bool isInPreprocessorComment; - bool isInHorstmannComment; + bool isInRunInComment; bool isInCase; bool isInQuestion; - bool isInStatement; + bool isContinuation; bool isInHeader; bool isInTemplate; bool isInDefine; bool isInDefineDefinition; bool classIndent; bool isIndentModeOff; - bool isInClassHeader; // is in a class before the opening bracket + bool isInClassHeader; // is in a class before the opening brace bool isInClassHeaderTab; // is in an indentable class header line bool isInClassInitializer; // is in a class after the ':' initializer - bool isInClass; // is in a class after the opening bracket + bool isInClass; // is in a class after the opening brace bool isInObjCMethodDefinition; bool isInObjCMethodCall; bool isInObjCMethodCallFirst; @@ -476,9 +510,10 @@ bool switchIndent; bool caseIndent; bool namespaceIndent; - bool bracketIndent; - bool bracketIndentVtk; bool blockIndent; + bool braceIndent; + bool braceIndentVtk; + bool shouldIndentAfterParen; bool labelIndent; bool shouldIndentPreprocDefine; bool isInConditional; @@ -492,12 +527,12 @@ bool blockCommentNoIndent; bool blockCommentNoBeautify; bool previousLineProbationTab; - bool lineBeginsWithOpenBracket; - bool lineBeginsWithCloseBracket; + bool lineBeginsWithOpenBrace; + bool lineBeginsWithCloseBrace; bool lineBeginsWithComma; bool lineIsCommentOnly; bool lineIsLineCommentOnly; - bool shouldIndentBrackettedLine; + bool shouldIndentBracedLine; bool isInSwitch; bool foundPreCommandHeader; bool foundPreCommandMacro; @@ -506,7 +541,7 @@ int indentCount; int spaceIndentCount; int spaceIndentObjCMethodAlignment; - int bracketPosObjCMethodAlignment; + int bracePosObjCMethodAlignment; int colonIndentObjCMethodAlignment; int lineOpeningBlocksNum; int lineClosingBlocksNum; @@ -518,10 +553,10 @@ int tabLength; int continuationIndent; int blockTabCount; - int maxInStatementIndent; + int maxContinuationIndent; int classInitializerIndents; int templateDepth; - int blockParenCount; + int squareBracketCount; int prevFinalLineSpaceIndentCount; int prevFinalLineIndentCount; int defineIndentCount; @@ -547,16 +582,16 @@ void enhance(string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL); private: // functions - void convertForceTabIndentToSpaces(string& line) const; - void convertSpaceIndentToForceTab(string& line) const; - size_t findCaseColon(string& line, size_t caseIndex) const; - int indentLine(string& line, int indent) const; - bool isBeginDeclareSectionSQL(string& line, size_t index) const; - bool isEndDeclareSectionSQL(string& line, size_t index) const; - bool isOneLineBlockReached(const string& line, int startChar) const; - void parseCurrentLine(string& line, bool isInPreprocessor, bool isInSQL); - size_t processSwitchBlock(string& line, size_t index); - int unindentLine(string& line, int unindent) const; + void convertForceTabIndentToSpaces(string& line) const; + void convertSpaceIndentToForceTab(string& line) const; + size_t findCaseColon(const string& line, size_t caseIndex) const; + int indentLine(string& line, int indent) const; + bool isBeginDeclareSectionSQL(const string& line, size_t index) const; + bool isEndDeclareSectionSQL(const string& line, size_t index) const; + bool isOneLineBlockReached(const string& line, int startChar) const; + void parseCurrentLine(string& line, bool isInPreprocessor, bool isInSQL); + size_t processSwitchBlock(string& line, size_t index); + int unindentLine(string& line, int unindent) const; private: // options from command line or options file @@ -577,10 +612,10 @@ char quoteChar; // unindent variables - int bracketCount; + int braceCount; int switchDepth; int eventPreprocDepth; - bool lookingForCaseBracket; + bool lookingForCaseBrace; bool unindentNextLine; bool shouldUnindentLine; bool shouldUnindentComment; @@ -589,7 +624,7 @@ // contains variables used to unindent the case blocks struct SwitchVariables { - int switchBracketCount; + int switchBraceCount; int unindentDepth; bool unindentCase; }; @@ -623,16 +658,17 @@ LineEndFormat getLineEndFormat() const; bool getIsLineReady() const; void setFormattingStyle(FormatStyle style); - void setAddBracketsMode(bool state); - void setAddOneLineBracketsMode(bool state); - void setRemoveBracketsMode(bool state); + void setAddBracesMode(bool state); + void setAddOneLineBracesMode(bool state); + void setRemoveBracesMode(bool state); void setAttachClass(bool state); + void setAttachClosingWhile(bool state); void setAttachExternC(bool state); void setAttachNamespace(bool state); void setAttachInline(bool state); - void setBracketFormatMode(BracketMode mode); + void setBraceFormatMode(BraceMode mode); void setBreakAfterMode(bool state); - void setBreakClosingHeaderBracketsMode(bool state); + void setBreakClosingHeaderBracesMode(bool state); void setBreakBlocksMode(bool state); void setBreakClosingHeaderBlocksMode(bool state); void setBreakElseIfsMode(bool state); @@ -667,6 +703,14 @@ size_t getChecksumOut() const; int getChecksumDiff() const; int getFormatterFileType() const; + // retained for compatability with release 2.06 + // "Brackets" have been changed to "Braces" in 3.0 + // they are referenced only by the old "bracket" options + void setAddBracketsMode(bool state); + void setAddOneLineBracketsMode(bool state); + void setRemoveBracketsMode(bool state); + void setBreakClosingHeaderBracketsMode(bool state); + private: // functions ASFormatter(const ASFormatter& copy); // not to be implemented @@ -674,12 +718,12 @@ template void deleteContainer(T& container); template void initContainer(T& container, T value); char peekNextChar() const; - BracketType getBracketType(); + BraceType getBraceType(); bool adjustChecksumIn(int adjustment); bool computeChecksumIn(const string& currentLine_); bool computeChecksumOut(const string& beautifiedLine); - bool addBracketsToStatement(); - bool removeBracketsFromStatement(); + bool addBracesToStatement(); + bool removeBracesFromStatement(); bool commentAndHeaderFollows(); bool getNextChar(); bool getNextLine(bool emptyLineWasDeleted = false); @@ -688,32 +732,32 @@ bool isBeforeAnyComment() const; bool isBeforeAnyLineEndComment(int startPos) const; bool isBeforeMultipleLineEndComments(int startPos) const; - bool isBracketType(BracketType a, BracketType b) const; + bool isBraceType(BraceType a, BraceType b) const; bool isClassInitializer() const; bool isClosingHeader(const string* header) const; - bool isCurrentBracketBroken() const; + bool isCurrentBraceBroken() const; bool isDereferenceOrAddressOf() const; - bool isExecSQL(string& line, size_t index) const; + bool isExecSQL(const string& line, size_t index) const; bool isEmptyLine(const string& line) const; bool isExternC() const; bool isMultiStatementLine() const; bool isNextWordSharpNonParenHeader(int startChar) const; - bool isNonInStatementArrayBracket() const; + bool isNonInStatementArrayBrace() const; bool isOkToSplitFormattedLine(); bool isPointerOrReference() const; bool isPointerOrReferenceCentered() const; - bool isPointerOrReferenceVariable(string& word) const; + bool isPointerOrReferenceVariable(const string& word) const; bool isSharpStyleWithParen(const string* header) const; - bool isStructAccessModified(string& firstLine, size_t index) const; - bool isIndentablePreprocessorBlock(string& firstLine, size_t index); - bool isNDefPreprocStatement(string& nextLine_, string& preproc) const; + bool isStructAccessModified(const string& firstLine, size_t index) const; + bool isIndentablePreprocessorBlock(const string& firstLine, size_t index); + bool isNDefPreprocStatement(const string& nextLine_, const string& preproc) const; bool isUnaryOperator() const; - bool isUniformInitializerBracket() const; + bool isUniformInitializerBrace() const; bool isImmediatelyPostCast() const; bool isInExponent() const; bool isInSwitchStatement() const; - bool isNextCharOpeningBracket(int startChar) const; - bool isOkToBreakBlock(BracketType bracketType) const; + bool isNextCharOpeningBrace(int startChar) const; + bool isOkToBreakBlock(BraceType braceType) const; bool isOperatorPaddingDisabled() const; bool pointerSymbolFollows() const; int findObjCColonAlignment() const; @@ -723,6 +767,7 @@ void adjustComments(); void appendChar(char ch, bool canBreakLine); void appendCharInsideComments(); + void appendClosingHeader(); void appendOperator(const string& sequence, bool canBreakLine = true); void appendSequence(const string& sequence, bool canBreakLine = true); void appendSpacePad(); @@ -734,17 +779,17 @@ void checkIfTemplateOpener(); void clearFormattedLineSplitPoints(); void convertTabToSpaces(); - void deleteContainer(vector*& container); + void deleteContainer(vector*& container); void formatArrayRunIn(); void formatRunIn(); - void formatArrayBrackets(BracketType bracketType, bool isOpeningArrayBracket); - void formatClosingBracket(BracketType bracketType); + void formatArrayBraces(BraceType braceType, bool isOpeningArrayBrace); + void formatClosingBrace(BraceType braceType); void formatCommentBody(); void formatCommentOpener(); void formatCommentCloser(); void formatLineCommentBody(); void formatLineCommentOpener(); - void formatOpeningBracket(BracketType bracketType); + void formatOpeningBrace(BraceType braceType); void formatQuoteBody(); void formatQuoteOpener(); void formatPointerOrReference(); @@ -755,7 +800,7 @@ void fixOptionVariableConflicts(); void goForward(int i); void isLineBreakBeforeClosingHeader(); - void initContainer(vector*& container, vector* value); + void initContainer(vector*& container, vector* value); void initNewLine(); void padObjCMethodColon(); void padObjCMethodPrefix(); @@ -765,17 +810,19 @@ void padParens(); void processPreprocessor(); void resetEndOfStatement(); - void setAttachClosingBracketMode(bool state); + void setAttachClosingBraceMode(bool state); void stripCommentPrefix(); void testForTimeToSplitFormattedLine(); void trimContinuationLine(); void updateFormattedLineSplitPointsPointerOrReference(size_t index); size_t findFormattedLineSplitPoint() const; - size_t findNextChar(string& line, char searchChar, int searchStart = 0) const; + size_t findNextChar(const string& line, char searchChar, int searchStart = 0) const; const string* checkForHeaderFollowingComment(const string& firstLine) const; const string* getFollowingOperator() const; string getPreviousWord(const string& line, int currPos) const; - string peekNextText(const string& firstLine, bool endOnEmptyLine = false, bool shouldReset = false) const; + string peekNextText(const string& firstLine, + bool endOnEmptyLine = false, + shared_ptr streamArg = nullptr) const; private: // variables int formatterFileType; @@ -791,8 +838,8 @@ ASSourceIterator* sourceIterator; ASEnhancer* enhancer; - vector* preBracketHeaderStack; - vector* bracketTypeStack; + vector* preBraceHeaderStack; + vector* braceTypeStack; vector* parenStack; vector* structStack; vector* questionMarkStack; @@ -802,7 +849,6 @@ string readyFormattedLine; string verbatimDelimiter; const string* currentHeader; - const string* previousOperator; // used ONLY by pad-oper char currentChar; char previousChar; char previousNonWSChar; @@ -810,17 +856,17 @@ char quoteChar; streamoff preprocBlockEnd; int charNum; - int horstmannIndentChars; + int runInIndentChars; int nextLineSpacePadNum; int objCColonAlign; - int preprocBracketTypeStackSize; + int preprocBraceTypeStackSize; int spacePadNum; int tabIncrementIn; int templateDepth; - int blockParenCount; + int squareBracketCount; size_t checksumIn; size_t checksumOut; - size_t currentLineFirstBracketNum; // first bracket location on currentLine + size_t currentLineFirstBraceNum; // first brace location on currentLine size_t formattedLineCommentNum; // comment location on formattedLine size_t leadingSpaces; size_t maxCodeLength; @@ -839,8 +885,8 @@ size_t previousReadyFormattedLineLength; FormatStyle formattingStyle; - BracketMode bracketFormatMode; - BracketType previousBracketType; + BraceMode braceFormatMode; + BraceType previousBraceType; PointerAlign pointerAlignment; ReferenceAlign referenceAlignment; ObjCColonPad objCColonPadMode; @@ -862,6 +908,7 @@ bool shouldAttachExternC; bool shouldAttachNamespace; bool shouldAttachClass; + bool shouldAttachClosingWhile; bool shouldAttachInline; bool isInLineComment; bool isInComment; @@ -893,6 +940,7 @@ bool foundInterfaceHeader; bool foundPreCommandHeader; bool foundPreCommandMacro; + bool foundTrailingReturnType; bool foundCastOperator; bool isInLineBreak; bool endOfAsmReached; @@ -907,7 +955,7 @@ bool isLineReady; bool elseHeaderFollowsComments; bool caseHeaderFollowsComments; - bool isPreviousBracketBlockRelated; + bool isPreviousBraceBlockRelated; bool isInPotentialCalculation; bool isCharImmediatelyPostComment; bool isPreviousCharPostComment; @@ -925,19 +973,19 @@ bool isInObjCReturnType; bool isInObjCSelector; bool breakCurrentOneLineBlock; - bool shouldRemoveNextClosingBracket; - bool isInBracketRunIn; - bool currentLineBeginsWithBracket; - bool attachClosingBracketMode; + bool shouldRemoveNextClosingBrace; + bool isInBraceRunIn; + bool currentLineBeginsWithBrace; + bool attachClosingBraceMode; bool shouldBreakOneLineBlocks; bool shouldBreakOneLineHeaders; bool shouldBreakOneLineStatements; - bool shouldBreakClosingHeaderBrackets; + bool shouldBreakClosingHeaderBraces; bool shouldBreakElseIfs; bool shouldBreakLineAfterLogical; - bool shouldAddBrackets; - bool shouldAddOneLineBrackets; - bool shouldRemoveBrackets; + bool shouldAddBraces; + bool shouldAddOneLineBraces; + bool shouldRemoveBraces; bool shouldPadMethodColon; bool shouldPadMethodPrefix; bool shouldReparseCurrentChar; @@ -947,7 +995,7 @@ bool shouldPadParamType; bool shouldUnPadParamType; bool shouldDeleteEmptyLines; - bool needHeaderOpeningBracket; + bool needHeaderOpeningBrace; bool shouldBreakLineAtNextChar; bool shouldKeepLineUnbroken; bool passedSemicolon; @@ -972,7 +1020,7 @@ bool isIndentableProprocessor; bool isIndentableProprocessorBlock; bool prependEmptyLine; - bool appendOpeningBracket; + bool appendOpeningBrace; bool foundClosingHeader; bool isInHeader; bool isImmediatelyPostHeader; @@ -984,27 +1032,19 @@ private: // inline functions // append the CURRENT character (curentChar) to the current formatted line. void appendCurrentChar(bool canBreakLine = true) - { - appendChar(currentChar, canBreakLine); - } + { appendChar(currentChar, canBreakLine); } // check if a specific sequence exists in the current placement of the current line bool isSequenceReached(const char* sequence) const - { - return currentLine.compare(charNum, strlen(sequence), sequence) == 0; - } + { return currentLine.compare(charNum, strlen(sequence), sequence) == 0; } // call ASBase::findHeader for the current character const string* findHeader(const vector* headers_) - { - return ASBeautifier::findHeader(currentLine, charNum, headers_); - } + { return ASBase::findHeader(currentLine, charNum, headers_); } // call ASBase::findOperator for the current character - const string* findOperator(const vector* headers_) - { - return ASBeautifier::findOperator(currentLine, charNum, headers_); - } + const string* findOperator(const vector* operators_) + { return ASBase::findOperator(currentLine, charNum, operators_); } }; // Class ASFormatter //----------------------------------------------------------------------------- @@ -1014,7 +1054,7 @@ bool sortOnLength(const string* a, const string* b); bool sortOnName(const string* a, const string* b); -} // end of astyle namespace +} // namespace astyle // end of astyle namespace -------------------------------------------------- diff -Nru astyle-2.06/src/astyle_main.cpp astyle-3.0.1/src/astyle_main.cpp --- astyle-2.06/src/astyle_main.cpp 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/astyle_main.cpp 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // astyle_main.cpp -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * AStyle_main source file map. @@ -17,7 +17,7 @@ * // Windows specific * // Linux specific * ASOptions methods - * Utf8_16 methods + * ASEncoding methods * } // end of astyle namespace * Global Area --------------------------- * Java Native Interface functions @@ -78,8 +78,6 @@ // // console build variables #ifndef ASTYLE_LIB - ASConsole* g_console = NULL; // class to encapsulate console variables - ostream* _err = &cerr; // direct error messages to cerr #ifdef _WIN32 char g_fileSeparator = '\\'; // Windows file separator bool g_isCaseSensitive = false; // Windows IS NOT case sensitive @@ -96,7 +94,7 @@ jmethodID g_mid; #endif -const char* g_version = "2.06"; +const char* g_version = "3.0.1"; //----------------------------------------------------------------------------- // ASStreamIterator class @@ -323,6 +321,36 @@ #ifndef ASTYLE_LIB +ASConsole::ASConsole(ASFormatter& formatterArg) : formatter(formatterArg) +{ + errorStream = &cerr; + // command line options + isRecursive = false; + isDryRun = false; + noBackup = false; + preserveDate = false; + isVerbose = false; + isQuiet = false; + isFormattedOnly = false; + ignoreExcludeErrors = false; + ignoreExcludeErrorsDisplay = false; + optionsFileRequired = false; + useAscii = false; + // other variables + bypassBrowserOpen = false; + hasWildcard = false; + filesAreIdentical = true; + lineEndsMixed = false; + origSuffix = ".orig"; + mainDirectoryLength = 0; + filesFormatted = 0; + filesUnchanged = 0; + linesOut = 0; +} + +ASConsole::~ASConsole() +{} + // rewrite a stringstream converting the line ends void ASConsole::convertLineEnds(ostringstream& out, int lineEnd) { @@ -441,14 +469,14 @@ // error exit without a message void ASConsole::error() const { - (*_err) << _("\nArtistic Style has terminated") << endl; + (*errorStream) << _("\nArtistic Style has terminated") << endl; exit(EXIT_FAILURE); } // error exit with a message void ASConsole::error(const char* why, const char* what) const { - (*_err) << why << ' ' << what << endl; + (*errorStream) << why << ' ' << what << endl; error(); } @@ -460,6 +488,18 @@ */ void ASConsole::formatCinToCout() { + // check for files from --stdin= and --stdout= + if (!stdPathIn.empty()) + { + if (!freopen(stdPathIn.c_str(), "r", stdin)) + error("Cannot open input file", stdPathIn.c_str()); + } + if (!stdPathOut.empty()) + { + if (!freopen(stdPathOut.c_str(), "w", stdout)) + error("Cannot open output file", stdPathOut.c_str()); + + } // Using cin.tellg() causes problems with both Windows and Linux. // The Windows problem occurs when the input is not Windows line-ends. // The tellg() will be out of sequence with the get() statements. @@ -470,7 +510,7 @@ stringstream outStream; char ch; inStream->get(ch); - while (!inStream->eof()) + while (!inStream->eof() && !inStream->fail()) { outStream.put(ch); inStream->get(ch); @@ -496,7 +536,7 @@ } else { - // this can happen if the file if missing a closing bracket and break-blocks is requested + // this can happen if the file if missing a closing brace and break-blocks is requested if (formatter.getIsLineReady()) { setOutputEOL(lineEndFormat, streamIterator.getOutputEOL()); @@ -554,7 +594,7 @@ else { streamIterator.saveLastInputLine(); // to compare the last input line - // this can happen if the file if missing a closing bracket and break-blocks is requested + // this can happen if the file if missing a closing brace and break-blocks is requested if (formatter.getIsLineReady()) { setOutputEOL(lineEndFormat, streamIterator.getOutputEOL()); @@ -617,7 +657,7 @@ vector argvOptions; for (int i = 1; i < argc; i++) { - argvOptions.push_back(string(argv[i])); + argvOptions.emplace_back(string(argv[i])); } return argvOptions; } @@ -707,9 +747,28 @@ { return preserveDate; } // for unit testing +string ASConsole::getStdPathIn() const +{ return stdPathIn; } + +// for unit testing +string ASConsole::getStdPathOut() const +{ return stdPathOut; } + +// for unit testing void ASConsole::setBypassBrowserOpen(bool state) { bypassBrowserOpen = state; } +// for unit testing +ostream* ASConsole::getErrorStream() const +{ + return errorStream; +} + +void ASConsole::setErrorStream(ostream* errStreamPtr) +{ + errorStream = errStreamPtr; +} + string ASConsole::getParam(const string& arg, const char* op) { return arg.substr(strlen(op)); @@ -744,7 +803,7 @@ if (!fin) error("Cannot open input file", fileName_.c_str()); char* data = new (nothrow) char[blockSize]; - if (!data) + if (data == nullptr) error("Cannot allocate memory for input file", fileName_.c_str()); fin.read(data, blockSize); if (fin.bad()) @@ -755,14 +814,14 @@ error(_("Cannot process UTF-32 encoding"), fileName_.c_str()); bool firstBlock = true; bool isBigEndian = (encoding == UTF_16BE); - while (dataSize) + while (dataSize != 0) { if (encoding == UTF_16LE || encoding == UTF_16BE) { // convert utf-16 to utf-8 size_t utf8Size = utf8_16.utf8LengthFromUtf16(data, dataSize, isBigEndian); char* utf8Out = new (nothrow) char[utf8Size]; - if (!utf8Out) + if (utf8Out == nullptr) error("Cannot allocate memory for utf-8 conversion", fileName_.c_str()); size_t utf8Len = utf8_16.utf16ToUtf8(data, dataSize, isBigEndian, firstBlock, utf8Out); assert(utf8Len == utf8Size); @@ -815,6 +874,12 @@ void ASConsole::setPreserveDate(bool state) { preserveDate = state; } +void ASConsole::setStdPathIn(const string& path) +{ stdPathIn = path; } + +void ASConsole::setStdPathOut(const string& path) +{ stdPathOut = path; } + // set outputEOL variable void ASConsole::setOutputEOL(LineEndFormat lineEndFormat, const string& currentEOL) { @@ -848,15 +913,15 @@ LPSTR msgBuf; DWORD lastError = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, lastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPSTR) &msgBuf, 0, - NULL + nullptr ); // Display the string. - (*_err) << "Error (" << lastError << ") " << msgBuf << endl; + (*errorStream) << "Error (" << lastError << ") " << msgBuf << endl; // Free the buffer. LocalFree(msgBuf); } @@ -922,7 +987,7 @@ if (isPathExclued(subDirectoryPath)) printMsg(_("Exclude %s\n"), subDirectoryPath.substr(mainDirectoryLength)); else - subDirectory.push_back(subDirectoryPath); + subDirectory.emplace_back(subDirectoryPath); continue; } @@ -936,7 +1001,7 @@ if (isExcluded) printMsg(_("Exclude %s\n"), filePathName.substr(mainDirectoryLength)); else - fileName.push_back(filePathName); + fileName.emplace_back(filePathName); } } while (FindNextFile(hFind, &findFileData) != 0); @@ -982,17 +1047,17 @@ // format the number using the Windows API if (lcid == 0) lcid = LOCALE_USER_DEFAULT; - int outSize = ::GetNumberFormat(lcid, 0, number.c_str(), NULL, NULL, 0); + int outSize = ::GetNumberFormat(lcid, 0, number.c_str(), nullptr, nullptr, 0); char* outBuf = new (nothrow) char[outSize]; - if (outBuf == NULL) + if (outBuf == nullptr) return number; - ::GetNumberFormat(lcid, 0, number.c_str(), NULL, outBuf, outSize); + ::GetNumberFormat(lcid, 0, number.c_str(), nullptr, outBuf, outSize); string formattedNum(outBuf); delete[] outBuf; // remove the decimal - int decSize = ::GetLocaleInfo(lcid, LOCALE_SDECIMAL, NULL, 0); + int decSize = ::GetLocaleInfo(lcid, LOCALE_SDECIMAL, nullptr, 0); char* decBuf = new (nothrow) char[decSize]; - if (decBuf == NULL) + if (decBuf == nullptr) return number; ::GetLocaleInfo(lcid, LOCALE_SDECIMAL, decBuf, decSize); size_t i = formattedNum.rfind(decBuf); @@ -1007,7 +1072,7 @@ /** * WINDOWS function to open a HTML file in the default browser. */ -void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const +void ASConsole::launchDefaultBrowser(const char* filePathIn /*nullptr*/) const { struct stat statbuf; const char* envPaths[] = { "PROGRAMFILES(X86)", "PROGRAMFILES" }; @@ -1016,7 +1081,7 @@ for (size_t i = 0; i < pathsLen; i++) { const char* envPath = getenv(envPaths[i]); - if (envPath == NULL) + if (envPath == nullptr) continue; htmlDefaultPath = envPath; if (htmlDefaultPath.length() > 0 @@ -1030,11 +1095,11 @@ // build file path string htmlFilePath; - if (filePathIn == NULL) + if (filePathIn == nullptr) htmlFilePath = htmlDefaultPath + "astyle.html"; else { - if (strpbrk(filePathIn, "\\/") == NULL) + if (strpbrk(filePathIn, "\\/") == nullptr) htmlFilePath = htmlDefaultPath + filePathIn; else htmlFilePath = filePathIn; @@ -1075,7 +1140,7 @@ string ASConsole::getCurrentDirectory(const string& fileName_) const { char* currdir = getenv("PWD"); - if (currdir == NULL) + if (currdir == nullptr) error("Cannot find file", fileName_.c_str()); return string(currdir); } @@ -1097,14 +1162,14 @@ errno = 0; DIR* dp = opendir(directory.c_str()); - if (dp == NULL) + if (dp == nullptr) error(_("Cannot open directory"), directory.c_str()); // save the first fileName entry for this recursion const unsigned firstEntry = fileName.size(); // save files and sub directories - while ((entry = readdir(dp)) != NULL) + while ((entry = readdir(dp)) != nullptr) { // get file status string entryFilepath = directory + g_fileSeparator + entry->d_name; @@ -1127,7 +1192,7 @@ if (isPathExclued(entryFilepath)) printMsg(_("Exclude %s\n"), entryFilepath.substr(mainDirectoryLength)); else - subDirectory.push_back(entryFilepath); + subDirectory.emplace_back(entryFilepath); continue; } @@ -1137,12 +1202,12 @@ // check exclude before wildcmp to avoid "unmatched exclude" error bool isExcluded = isPathExclued(entryFilepath); // save file name if wildcard match - if (wildcmp(wildcard.c_str(), entry->d_name)) + if (wildcmp(wildcard.c_str(), entry->d_name) != 0) { if (isExcluded) printMsg(_("Exclude %s\n"), entryFilepath.substr(mainDirectoryLength)); else - fileName.push_back(entryFilepath); + fileName.emplace_back(entryFilepath); } } } @@ -1175,7 +1240,7 @@ * size_t is for compatibility with the Windows function. * @return The formatted number. */ -string ASConsole::getNumberFormat(int num, size_t) const +string ASConsole::getNumberFormat(int num, size_t /*lcid*/) const { #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__BORLANDC__) || defined(__GNUC__) // Compilers that don't support C++ locales should still support this assert. @@ -1246,7 +1311,7 @@ * see http://portland.freedesktop.org/wiki/ * This is installed on most modern distributions. */ -void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const +void ASConsole::launchDefaultBrowser(const char* filePathIn /*nullptr*/) const { struct stat statbuf; string htmlDefaultPath = "/usr/share/doc/astyle/html/"; @@ -1254,11 +1319,11 @@ // build file path string htmlFilePath; - if (filePathIn == NULL) + if (filePathIn == nullptr) htmlFilePath = htmlDefaultPath + htmlDefaultFile; else { - if (strpbrk(filePathIn, "\\/") == NULL) + if (strpbrk(filePathIn, "\\/") == nullptr) htmlFilePath = htmlDefaultPath + filePathIn; else htmlFilePath = filePathIn; @@ -1272,7 +1337,7 @@ // get search paths const char* envPaths = getenv("PATH"); - if (envPaths == NULL) + if (envPaths == nullptr) envPaths = "?"; size_t envlen = strlen(envPaths); char* paths = new char[envlen + 1]; @@ -1286,7 +1351,7 @@ #endif string searchPath; char* searchDir = strtok(paths, ":"); - while (searchDir != NULL) + while (searchDir != nullptr) { searchPath = searchDir; if (searchPath.length() > 0 @@ -1295,17 +1360,17 @@ searchPath.append(fileOpen); if (stat(searchPath.c_str(), &statbuf) == 0 && (statbuf.st_mode & S_IFREG)) break; - searchDir = strtok(NULL, ":"); + searchDir = strtok(nullptr, ":"); } delete[] paths; - if (searchDir == NULL) + if (searchDir == nullptr) error(_("Command is not installed"), fileOpen); // browser open will be bypassed in test programs printf(_("Opening HTML documentation %s\n"), htmlFilePath.c_str()); if (!bypassBrowserOpen) { - execlp(fileOpen, fileOpen, htmlFilePath.c_str(), NULL); + execlp(fileOpen, fileOpen, htmlFilePath.c_str(), nullptr); // execlp will NOT return if successful error(_("Command execute failure"), fileOpen); } @@ -1314,7 +1379,7 @@ #endif // _WIN32 // get individual file names from the command-line file path -void ASConsole::getFilePaths(string& filePath) +void ASConsole::getFilePaths(const string& filePath) { fileName.clear(); targetDirectory = string(); @@ -1379,7 +1444,7 @@ string entryFilepath = targetDirectory + g_fileSeparator + targetFilename; struct stat statbuf; if (stat(entryFilepath.c_str(), &statbuf) == 0 && (statbuf.st_mode & S_IFREG)) - fileName.push_back(entryFilepath); + fileName.emplace_back(entryFilepath); } // check for unprocessed excludes @@ -1542,7 +1607,7 @@ cout << " the preliminary '--'.\n"; cout << endl; cout << "Disable Formatting:\n"; - cout << "----------------------\n"; + cout << "-------------------\n"; cout << " Disable Block\n"; cout << " Blocks of code can be disabled with the comment tags *INDENT-OFF*\n"; cout << " and *INDENT-ON*. It must be contained in a one-line comment.\n"; @@ -1551,74 +1616,74 @@ cout << " Padding of operators can be disabled on a single line using the\n"; cout << " comment tag *NOPAD*. It must be contained in a line-end comment.\n"; cout << endl; - cout << "Bracket Style Options:\n"; - cout << "----------------------\n"; - cout << " default bracket style\n"; - cout << " If no bracket style is requested, the opening brackets will not be\n"; - cout << " changed and closing brackets will be broken from the preceding line.\n"; + cout << "Brace Style Options:\n"; + cout << "--------------------\n"; + cout << " default brace style\n"; + cout << " If no brace style is requested, the opening braces will not be\n"; + cout << " changed and closing braces will be broken from the preceding line.\n"; cout << endl; cout << " --style=allman OR --style=bsd OR --style=break OR -A1\n"; cout << " Allman style formatting/indenting.\n"; - cout << " Broken brackets.\n"; + cout << " Broken braces.\n"; cout << endl; cout << " --style=java OR --style=attach OR -A2\n"; cout << " Java style formatting/indenting.\n"; - cout << " Attached brackets.\n"; + cout << " Attached braces.\n"; cout << endl; cout << " --style=kr OR --style=k&r OR --style=k/r OR -A3\n"; cout << " Kernighan & Ritchie style formatting/indenting.\n"; - cout << " Linux brackets.\n"; + cout << " Linux braces.\n"; cout << endl; cout << " --style=stroustrup OR -A4\n"; cout << " Stroustrup style formatting/indenting.\n"; - cout << " Stroustrup brackets.\n"; + cout << " Linux braces.\n"; cout << endl; cout << " --style=whitesmith OR -A5\n"; cout << " Whitesmith style formatting/indenting.\n"; - cout << " Broken, indented brackets.\n"; + cout << " Broken, indented braces.\n"; cout << " Indented class blocks and switch blocks.\n"; cout << endl; cout << " --style=vtk OR -A15\n"; cout << " VTK style formatting/indenting.\n"; - cout << " Broken, indented brackets except for opening brackets.\n"; + cout << " Broken, indented braces except for the opening braces.\n"; cout << endl; cout << " --style=banner OR -A6\n"; cout << " Banner style formatting/indenting.\n"; - cout << " Attached, indented brackets.\n"; + cout << " Attached, indented braces.\n"; cout << endl; cout << " --style=gnu OR -A7\n"; cout << " GNU style formatting/indenting.\n"; - cout << " Broken brackets, indented blocks.\n"; + cout << " Broken braces, indented blocks.\n"; cout << endl; cout << " --style=linux OR --style=knf OR -A8\n"; cout << " Linux style formatting/indenting.\n"; - cout << " Linux brackets, minimum conditional indent is one-half indent.\n"; + cout << " Linux braces, minimum conditional indent is one-half indent.\n"; cout << endl; - cout << " --style=horstmann OR -A9\n"; + cout << " --style=horstmann OR --style=run-in OR -A9\n"; cout << " Horstmann style formatting/indenting.\n"; - cout << " Run-in brackets, indented switches.\n"; + cout << " Run-in braces, indented switches.\n"; cout << endl; cout << " --style=1tbs OR --style=otbs OR -A10\n"; cout << " One True Brace Style formatting/indenting.\n"; - cout << " Linux brackets, add brackets to all conditionals.\n"; + cout << " Linux braces, add braces to all conditionals.\n"; cout << endl; cout << " --style=google OR -A14\n"; cout << " Google style formatting/indenting.\n"; - cout << " Attached brackets, indented class modifiers.\n"; + cout << " Attached braces, indented class modifiers.\n"; cout << endl; cout << " --style=mozilla OR -A16\n"; cout << " Mozilla style formatting/indenting.\n"; - cout << " Linux brackets, with broken brackets for structs and enums,\n"; - cout << " and attached brackets for namespaces.\n"; + cout << " Linux braces, with broken braces for structs and enums,\n"; + cout << " and attached braces for namespaces.\n"; cout << endl; cout << " --style=pico OR -A11\n"; cout << " Pico style formatting/indenting.\n"; - cout << " Run-in opening brackets and attached closing brackets.\n"; + cout << " Run-in opening braces and attached closing braces.\n"; cout << " Uses keep one line blocks and keep one line statements.\n"; cout << endl; cout << " --style=lisp OR -A12\n"; cout << " Lisp style formatting/indenting.\n"; - cout << " Attached opening brackets and attached closing brackets.\n"; + cout << " Attached opening braces and attached closing braces.\n"; cout << " Uses keep one line statements.\n"; cout << endl; cout << "Tab Options:\n"; @@ -1646,19 +1711,22 @@ cout << " from the indent length. This may cause the indentation to be\n"; cout << " a mix of both spaces and tabs. This option sets the tab length.\n"; cout << endl; - cout << "Bracket Modify Options:\n"; - cout << "-----------------------\n"; + cout << "Brace Modify Options:\n"; + cout << "---------------------\n"; cout << " --attach-namespaces OR -xn\n"; - cout << " Attach brackets to a namespace statement.\n"; + cout << " Attach braces to a namespace statement.\n"; cout << endl; cout << " --attach-classes OR -xc\n"; - cout << " Attach brackets to a class statement.\n"; + cout << " Attach braces to a class statement.\n"; cout << endl; cout << " --attach-inlines OR -xl\n"; - cout << " Attach brackets to class inline function definitions.\n"; + cout << " Attach braces to class inline function definitions.\n"; cout << endl; cout << " --attach-extern-c OR -xk\n"; - cout << " Attach brackets to an extern \"C\" statement.\n"; + cout << " Attach braces to an extern \"C\" statement.\n"; + cout << endl; + cout << " --attach-closing-while OR -xV\n"; + cout << " Attach closing while of do-while to the closing brace.\n"; cout << endl; cout << "Indentation Options:\n"; cout << "--------------------\n"; @@ -1681,6 +1749,10 @@ cout << " --indent-namespaces OR -N\n"; cout << " Indent the contents of namespace blocks.\n"; cout << endl; + cout << " --indent-after-parens OR -xU\n"; + cout << " Indent, instead of align, continuation lines following lines\n"; + cout << " that contain an opening paren '(' or an assignment '='. \n"; + cout << endl; cout << " --indent-continuation=# OR -xt#\n"; cout << " Indent continuation lines an additional # indents.\n"; cout << " The valid values are 0 thru 4 indents.\n"; @@ -1692,7 +1764,7 @@ cout << " flushed completely to the left (which is the default).\n"; cout << endl; cout << " --indent-preproc-block OR -xW\n"; - cout << " Indent preprocessor blocks at bracket level 0.\n"; + cout << " Indent preprocessor blocks at brace level 0.\n"; cout << " Without this option the preprocessor block is not indented.\n"; cout << endl; cout << " --indent-preproc-cond OR -xw\n"; @@ -1715,8 +1787,8 @@ cout << " 3 - indent at least one-half an additional indent.\n"; cout << " The default value is 2, two additional indents.\n"; cout << endl; - cout << " --max-instatement-indent=# OR -M#\n"; - cout << " Indent a maximal # spaces in a continuous statement,\n"; + cout << " --max-continuation-indent=# OR -M#\n"; + cout << " Indent a maximal # spaces in a continuation line,\n"; cout << " relative to the previous line.\n"; cout << " The valid values are 40 thru 120.\n"; cout << " The default value is 40.\n"; @@ -1782,8 +1854,8 @@ cout << endl; cout << "Formatting Options:\n"; cout << "-------------------\n"; - cout << " --break-closing-brackets OR -y\n"; - cout << " Break brackets before closing headers (e.g. 'else', 'catch', ...).\n"; + cout << " --break-closing-braces OR -y\n"; + cout << " Break braces before closing headers (e.g. 'else', 'catch', ...).\n"; cout << " Use with --style=java, --style=kr, --style=stroustrup,\n"; cout << " --style=linux, or --style=1tbs.\n"; cout << endl; @@ -1794,15 +1866,15 @@ cout << " Break one line headers (e.g. 'if', 'while', 'else', ...) from a\n"; cout << " statement residing on the same line.\n"; cout << endl; - cout << " --add-brackets OR -j\n"; - cout << " Add brackets to unbracketed one line conditional statements.\n"; + cout << " --add-braces OR -j\n"; + cout << " Add braces to unbraced one line conditional statements.\n"; cout << endl; - cout << " --add-one-line-brackets OR -J\n"; - cout << " Add one line brackets to unbracketed one line conditional\n"; + cout << " --add-one-line-braces OR -J\n"; + cout << " Add one line braces to unbraced one line conditional\n"; cout << " statements.\n"; cout << endl; - cout << " --remove-brackets OR -xj\n"; - cout << " Remove brackets from a bracketed one line conditional statements.\n"; + cout << " --remove-braces OR -xj\n"; + cout << " Remove braces from a braced one line conditional statements.\n"; cout << endl; cout << " --keep-one-line-blocks OR -O\n"; cout << " Don't break blocks residing completely on one line.\n"; @@ -1977,7 +2049,7 @@ // process options from the command line and options file // build the vectors fileNameVector, excludeVector, optionsVector, and fileOptionsVector -void ASConsole::processOptions(vector& argvOptions) +void ASConsole::processOptions(const vector& argvOptions) { string arg; bool ok = true; @@ -2033,12 +2105,12 @@ } else if (arg[0] == '-') { - optionsVector.push_back(arg); + optionsVector.emplace_back(arg); } else // file-name { standardizePath(arg); - fileNameVector.push_back(arg); + fileNameVector.emplace_back(arg); } } @@ -2048,19 +2120,19 @@ if (optionsFileName.empty()) { char* env = getenv("ARTISTIC_STYLE_OPTIONS"); - if (env != NULL) + if (env != nullptr) setOptionsFileName(env); } if (optionsFileName.empty()) { char* env = getenv("HOME"); - if (env != NULL) + if (env != nullptr) setOptionsFileName(string(env) + "/.astylerc"); } if (optionsFileName.empty()) { char* env = getenv("USERPROFILE"); - if (env != NULL) + if (env != nullptr) setOptionsFileName(string(env) + "/astylerc"); } if (!optionsFileName.empty()) @@ -2068,7 +2140,7 @@ } // create the options file vector and parse the options for errors - ASOptions options(formatter); + ASOptions options(formatter, *this); if (!optionsFileName.empty()) { ifstream optionsIn(optionsFileName.c_str()); @@ -2088,8 +2160,8 @@ } if (!ok) { - (*_err) << options.getOptionErrors() << endl; - (*_err) << _("For help on options type 'astyle -h'") << endl; + (*errorStream) << options.getOptionErrors() << endl; + (*errorStream) << _("For help on options type 'astyle -h'") << endl; error(); } @@ -2098,8 +2170,8 @@ string(_("Invalid command line options:"))); if (!ok) { - (*_err) << options.getOptionErrors() << endl; - (*_err) << _("For help on options type 'astyle -h'") << endl; + (*errorStream) << options.getOptionErrors() << endl; + (*errorStream) << _("For help on options type 'astyle -h'") << endl; error(); } } @@ -2107,7 +2179,7 @@ // remove a file and check for an error void ASConsole::removeFile(const char* fileName_, const char* errMsg) const { - if (remove(fileName_)) + if (remove(fileName_) != 0) { if (errno == ENOENT) // no file is OK errno = 0; @@ -2227,7 +2299,7 @@ // get the date time_t lt; char str[20]; - lt = time(NULL); + lt = time(nullptr); struct tm* ptr = localtime(<); strftime(str, 20, "%x", ptr); // print the header @@ -2308,7 +2380,7 @@ void ASConsole::updateExcludeVector(const string& suffixParam) { - excludeVector.push_back(suffixParam); + excludeVector.emplace_back(suffixParam); standardizePath(excludeVector.back(), true); excludeHitsVector.push_back(false); } @@ -2333,7 +2405,7 @@ // Modified to compare case insensitive for Windows int ASConsole::wildcmp(const char* wild, const char* data) const { - const char* cp = NULL, *mp = NULL; + const char* cp = nullptr, *mp = nullptr; bool cmpval; while ((*data) && (*wild != '*')) @@ -2443,7 +2515,7 @@ if (statErr) { perror("errno message"); - (*_err) << "********* Cannot preserve file date" << endl; + (*errorStream) << "********* Cannot preserve file date" << endl; } } } @@ -2461,17 +2533,17 @@ fpAlloc fpMemoryAlloc) const // memory allocation function) { const char* utf8In = convertUtf16ToUtf8(pSourceIn); - if (utf8In == NULL) + if (utf8In == nullptr) { fpErrorHandler(121, "Cannot convert input utf-16 to utf-8."); - return NULL; + return nullptr; } const char* utf8Options = convertUtf16ToUtf8(pOptions); - if (utf8Options == NULL) + if (utf8Options == nullptr) { delete[] utf8In; fpErrorHandler(122, "Cannot convert options utf-16 to utf-8."); - return NULL; + return nullptr; } // call the Artistic Style formatting function // cannot use the callers memory allocation here @@ -2482,19 +2554,19 @@ // finished with these delete[] utf8In; delete[] utf8Options; - utf8In = NULL; - utf8Options = NULL; + utf8In = nullptr; + utf8Options = nullptr; // AStyle error has already been sent - if (utf8Out == NULL) - return NULL; + if (utf8Out == nullptr) + return nullptr; // convert text to wide char and return it utf16_t* utf16Out = convertUtf8ToUtf16(utf8Out, fpMemoryAlloc); delete[] utf8Out; - utf8Out = NULL; - if (utf16Out == NULL) + utf8Out = nullptr; + if (utf16Out == nullptr) { fpErrorHandler(123, "Cannot convert output utf-8 to utf-16."); - return NULL; + return nullptr; } return utf16Out; } @@ -2514,16 +2586,16 @@ */ utf16_t* ASLibrary::convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc) const { - if (utf8In == NULL) - return NULL; + if (utf8In == nullptr) + return nullptr; char* data = const_cast(utf8In); size_t dataSize = strlen(utf8In); bool isBigEndian = utf8_16.getBigEndian(); // return size is in number of CHARs, not utf16_t size_t utf16Size = (utf8_16.utf16LengthFromUtf8(data, dataSize) + sizeof(utf16_t)); char* utf16Out = fpMemoryAlloc((long)utf16Size); - if (utf16Out == NULL) - return NULL; + if (utf16Out == nullptr) + return nullptr; #ifdef NDEBUG utf8_16.utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out); #else @@ -2541,16 +2613,16 @@ */ char* ASLibrary::convertUtf16ToUtf8(const utf16_t* utf16In) const { - if (utf16In == NULL) - return NULL; + if (utf16In == nullptr) + return nullptr; char* data = reinterpret_cast(const_cast(utf16In)); // size must be in chars size_t dataSize = utf8_16.utf16len(utf16In) * sizeof(utf16_t); bool isBigEndian = utf8_16.getBigEndian(); size_t utf8Size = utf8_16.utf8LengthFromUtf16(data, dataSize, isBigEndian) + 1; char* utf8Out = new (nothrow) char[utf8Size]; - if (utf8Out == NULL) - return NULL; + if (utf8Out == nullptr) + return nullptr; #ifdef NDEBUG utf8_16.utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out); #else @@ -2568,6 +2640,16 @@ // used by both console and library builds //----------------------------------------------------------------------------- +#ifdef ASTYLE_LIB +ASOptions::ASOptions(ASFormatter& formatterArg) + : formatter(formatterArg) +{ } +#else +ASOptions::ASOptions(ASFormatter& formatterArg, ASConsole& consoleArg) + : formatter(formatterArg), console(consoleArg) +{ } +#endif + /** * parse the options vector * optionsVector can be either a fileOptionsVector (options file) or an optionsVector (command line) @@ -2656,7 +2738,7 @@ { formatter.setFormattingStyle(STYLE_LINUX); } - else if ( isOption(arg, "style=horstmann") ) + else if ( isOption(arg, "style=horstmann") || isOption(arg, "style=run-in") ) { formatter.setFormattingStyle(STYLE_HORSTMANN); } @@ -2827,10 +2909,10 @@ else formatter.setMinConditionalIndentOption(minIndent); } - else if ( isParamOption(arg, "M", "max-instatement-indent=") ) + else if ( isParamOption(arg, "M", "max-continuation-indent=") ) { int maxIndent = 40; - string maxIndentParam = getParam(arg, "M", "max-instatement-indent="); + string maxIndentParam = getParam(arg, "M", "max-continuation-indent="); if (maxIndentParam.length() > 0) maxIndent = atoi(maxIndentParam.c_str()); if (maxIndent < 40) @@ -2838,7 +2920,7 @@ else if (maxIndent > 120) isOptionError(arg, errorInfo); else - formatter.setMaxInStatementIndentLength(maxIndent); + formatter.setMaxContinuationIndentLength(maxIndent); } else if ( isOption(arg, "N", "indent-namespaces") ) { @@ -2860,6 +2942,10 @@ { formatter.setCaseIndent(true); } + else if ( isOption(arg, "xU", "indent-after-parens") ) + { + formatter.setAfterParenIndent(true); + } else if ( isOption(arg, "L", "indent-labels") ) { formatter.setLabelIndent(true); @@ -2876,9 +2962,9 @@ { formatter.setPreprocConditionalIndent(true); } - else if ( isOption(arg, "y", "break-closing-brackets") ) + else if ( isOption(arg, "y", "break-closing-braces") ) { - formatter.setBreakClosingHeaderBracketsMode(true); + formatter.setBreakClosingHeaderBracesMode(true); } else if ( isOption(arg, "O", "keep-one-line-blocks") ) { @@ -2954,17 +3040,17 @@ { formatter.setBreakOneLineHeadersMode(true); } - else if ( isOption(arg, "j", "add-brackets") ) + else if ( isOption(arg, "j", "add-braces") ) { - formatter.setAddBracketsMode(true); + formatter.setAddBracesMode(true); } - else if ( isOption(arg, "J", "add-one-line-brackets") ) + else if ( isOption(arg, "J", "add-one-line-braces") ) { - formatter.setAddOneLineBracketsMode(true); + formatter.setAddOneLineBracesMode(true); } - else if ( isOption(arg, "xj", "remove-brackets") ) + else if ( isOption(arg, "xj", "remove-braces") ) { - formatter.setRemoveBracketsMode(true); + formatter.setRemoveBracesMode(true); } else if ( isOption(arg, "Y", "indent-col1-comments") ) { @@ -3062,6 +3148,10 @@ { formatter.setAttachClass(true); } + else if ( isOption(arg, "xV", "attach-closing-while") ) + { + formatter.setAttachClosingWhile(true); + } else if ( isOption(arg, "xk", "attach-extern-c") ) { formatter.setAttachExternC(true); @@ -3123,15 +3213,45 @@ { formatter.setObjCColonPaddingMode(COLON_PAD_BEFORE); } - // depreciated options //////////////////////////////////////////////////////////////////////////////////////////// - else if ( isOption(arg, "indent-preprocessor") ) // depreciated release 2.04 + // depreciated options //////////////////////////////////////////////////////////////////////// + else if ( isOption(arg, "indent-preprocessor") ) // depreciated release 2.04 { formatter.setPreprocDefineIndent(true); } - else if ( isOption(arg, "style=ansi") ) // depreciated release 2.05 + else if ( isOption(arg, "style=ansi") ) // depreciated release 2.05 { formatter.setFormattingStyle(STYLE_ALLMAN); } + // depreciated in release 3.0 ///////////////////////////////////////////////////////////////// + else if ( isOption(arg, "break-closing-brackets") ) // depreciated release 3.0 + { + formatter.setBreakClosingHeaderBracketsMode(true); + } + else if ( isOption(arg, "add-brackets") ) // depreciated release 3.0 + { + formatter.setAddBracketsMode(true); + } + else if ( isOption(arg, "add-one-line-brackets") ) // depreciated release 3.0 + { + formatter.setAddOneLineBracketsMode(true); + } + else if ( isOption(arg, "remove-brackets") ) // depreciated release 3.0 + { + formatter.setRemoveBracketsMode(true); + } + else if ( isParamOption(arg, "max-instatement-indent=") ) // depreciated release 3.0 + { + int maxIndent = 40; + string maxIndentParam = getParam(arg, "max-instatement-indent="); + if (maxIndentParam.length() > 0) + maxIndent = atoi(maxIndentParam.c_str()); + if (maxIndent < 40) + isOptionError(arg, errorInfo); + else if (maxIndent > 120) + isOptionError(arg, errorInfo); + else + formatter.setMaxInStatementIndentLength(maxIndent); + } // NOTE: Removed in release 2.04. // else if ( isOption(arg, "b", "brackets=break") ) // { @@ -3153,66 +3273,66 @@ // { // formatter.setBracketFormatMode(RUN_IN_MODE); // } - // end depreciated options //////////////////////////////////////////////////////////////////////////////////////// + // end depreciated options //////////////////////////////////////////////////////////////////// #ifdef ASTYLE_LIB - // End of options used by GUI ///////////////////////////////////////////////////////////////////////////////////// + // End of options used by GUI ///////////////////////////////////////////////////////////////// else isOptionError(arg, errorInfo); #else - // Options used by only console /////////////////////////////////////////////////////////////////////////////////// + // Options used by only console /////////////////////////////////////////////////////////////// else if ( isOption(arg, "n", "suffix=none") ) { - g_console->setNoBackup(true); + console.setNoBackup(true); } else if ( isParamOption(arg, "suffix=") ) { string suffixParam = getParam(arg, "suffix="); if (suffixParam.length() > 0) { - g_console->setOrigSuffix(suffixParam); + console.setOrigSuffix(suffixParam); } } else if ( isParamOption(arg, "exclude=") ) { string suffixParam = getParam(arg, "exclude="); if (suffixParam.length() > 0) - g_console->updateExcludeVector(suffixParam); + console.updateExcludeVector(suffixParam); } else if ( isOption(arg, "r", "R") || isOption(arg, "recursive") ) { - g_console->setIsRecursive(true); + console.setIsRecursive(true); } else if (isOption(arg, "dry-run")) { - g_console->setIsDryRun(true); + console.setIsDryRun(true); } else if ( isOption(arg, "Z", "preserve-date") ) { - g_console->setPreserveDate(true); + console.setPreserveDate(true); } else if ( isOption(arg, "v", "verbose") ) { - g_console->setIsVerbose(true); + console.setIsVerbose(true); } else if ( isOption(arg, "Q", "formatted") ) { - g_console->setIsFormattedOnly(true); + console.setIsFormattedOnly(true); } else if ( isOption(arg, "q", "quiet") ) { - g_console->setIsQuiet(true); + console.setIsQuiet(true); } else if ( isOption(arg, "i", "ignore-exclude-errors") ) { - g_console->setIgnoreExcludeErrors(true); + console.setIgnoreExcludeErrors(true); } else if ( isOption(arg, "xi", "ignore-exclude-errors-x") ) { - g_console->setIgnoreExcludeErrorsAndDisplay(true); + console.setIgnoreExcludeErrorsAndDisplay(true); } else if ( isOption(arg, "X", "errors-to-stdout") ) { - _err = &cout; + console.setErrorStream(&cout); } else if ( isOption(arg, "lineend=windows") ) { @@ -3241,6 +3361,18 @@ else if (lineendType == 3) formatter.setLineEndFormat(LINEEND_MACOLD); } + else if ( isParamOption(arg, "stdin=") ) + { + string path = getParam(arg, "stdin="); + console.standardizePath(path); + console.setStdPathIn(path); + } + else if ( isParamOption(arg, "stdout=") ) + { + string path = getParam(arg, "stdout="); + console.standardizePath(path); + console.setStdPathOut(path); + } else isOptionError(arg, errorInfo); #endif @@ -3290,7 +3422,7 @@ while (in); if (currentToken.length() != 0) - optionsVector.push_back(currentToken); + optionsVector.emplace_back(currentToken); isInQuote = false; } } @@ -3343,11 +3475,11 @@ } //---------------------------------------------------------------------------- -// Utf8_16 class +// ASEncoding class //---------------------------------------------------------------------------- // Return true if an int is big endian. -bool Utf8_16::getBigEndian() const +bool ASEncoding::getBigEndian() const { short int word = 0x0001; char* byte = (char*) &word; @@ -3355,14 +3487,14 @@ } // Swap the two low order bytes of a 16 bit integer value. -int Utf8_16::swap16bit(int value) const +int ASEncoding::swap16bit(int value) const { return ( ((value & 0xff) << 8) | ((value & 0xff00) >> 8) ); } // Return the length of a utf-16 C string. // The length is in number of utf16_t. -size_t Utf8_16::utf16len(const utf16* utf16In) const +size_t ASEncoding::utf16len(const utf16* utf16In) const { size_t length = 0; while (*utf16In++ != '\0') @@ -3375,7 +3507,7 @@ // Modified for Artistic Style by Jim Pattee. // Compute the length of an output utf-8 file given a utf-16 file. // Input inLen is the size in BYTES (not wchar_t). -size_t Utf8_16::utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const +size_t ASEncoding::utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const { size_t len = 0; size_t wcharLen = inLen / 2; @@ -3403,7 +3535,7 @@ // Copyright (C) 2002 Scott Kirkwood. // Modified for Artistic Style by Jim Pattee. // Convert a utf-8 file to utf-16. -size_t Utf8_16::utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const +size_t ASEncoding::utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const { int nCur = 0; ubyte* pRead = reinterpret_cast(utf8In); @@ -3479,7 +3611,7 @@ // Modified for Artistic Style by Jim Pattee. // Compute the length of an output utf-16 file given a utf-8 file. // Return value is the size in BYTES (not wchar_t). -size_t Utf8_16::utf16LengthFromUtf8(const char* utf8In, size_t len) const +size_t ASEncoding::utf16LengthFromUtf8(const char* utf8In, size_t len) const { size_t ulen = 0; size_t charLen; @@ -3508,8 +3640,8 @@ // Copyright (C) 2002 Scott Kirkwood. // Modified for Artistic Style by Jim Pattee. // Convert a utf-16 file to utf-8. -size_t Utf8_16::utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian, - bool firstBlock, char* utf8Out) const +size_t ASEncoding::utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian, + bool firstBlock, char* utf8Out) const { int nCur16 = 0; int nCur = 0; @@ -3602,7 +3734,7 @@ //---------------------------------------------------------------------------- -} // end of astyle namespace +} // namespace astyle //---------------------------------------------------------------------------- @@ -3638,20 +3770,20 @@ // get the method ID jclass cls = env->GetObjectClass(obj); g_mid = env->GetMethodID(cls, "ErrorHandler", "(ILjava/lang/String;)V"); - if (g_mid == 0) + if (g_mid == nullptr) { cout << "Cannot find java method ErrorHandler" << endl; return textErr; } // convert jstring to char* - const char* textIn = env->GetStringUTFChars(textInJava, NULL); - const char* options = env->GetStringUTFChars(optionsJava, NULL); + const char* textIn = env->GetStringUTFChars(textInJava, nullptr); + const char* options = env->GetStringUTFChars(optionsJava, nullptr); // call the C++ formatting function char* textOut = AStyleMain(textIn, options, javaErrorHandler, javaMemoryAlloc); // if an error message occurred it was displayed by errorHandler - if (textOut == NULL) + if (textOut == nullptr) return textErr; // release memory @@ -3701,23 +3833,23 @@ fpError fpErrorHandler, // error handler function fpAlloc fpMemoryAlloc) // memory allocation function { - if (fpErrorHandler == NULL) // cannot display a message if no error handler - return NULL; + if (fpErrorHandler == nullptr) // cannot display a message if no error handler + return nullptr; - if (pSourceIn == NULL) + if (pSourceIn == nullptr) { fpErrorHandler(101, "No pointer to source input."); - return NULL; + return nullptr; } - if (pOptions == NULL) + if (pOptions == nullptr) { fpErrorHandler(102, "No pointer to AStyle options."); - return NULL; + return nullptr; } - if (fpMemoryAlloc == NULL) + if (fpMemoryAlloc == nullptr) { fpErrorHandler(103, "No pointer to memory allocation function."); - return NULL; + return nullptr; } #ifndef _WIN32 // check size of utf16_t on Linux @@ -3725,7 +3857,7 @@ if (sizeof(utf16_t) != sizeCheck) { fpErrorHandler(104, "Unsigned short is not the correct size."); - return NULL; + return nullptr; } #endif @@ -3749,23 +3881,23 @@ fpError fpErrorHandler, // error handler function fpAlloc fpMemoryAlloc) // memory allocation function { - if (fpErrorHandler == NULL) // cannot display a message if no error handler - return NULL; + if (fpErrorHandler == nullptr) // cannot display a message if no error handler + return nullptr; - if (pSourceIn == NULL) + if (pSourceIn == nullptr) { fpErrorHandler(101, "No pointer to source input."); - return NULL; + return nullptr; } - if (pOptions == NULL) + if (pOptions == nullptr) { fpErrorHandler(102, "No pointer to AStyle options."); - return NULL; + return nullptr; } - if (fpMemoryAlloc == NULL) + if (fpMemoryAlloc == nullptr) { fpErrorHandler(103, "No pointer to memory allocation function."); - return NULL; + return nullptr; } ASFormatter formatter; @@ -3792,7 +3924,7 @@ out << streamIterator.getOutputEOL(); else { - // this can happen if the file if missing a closing bracket and break-blocks is requested + // this can happen if the file if missing a closing brace and break-blocks is requested if (formatter.getIsLineReady()) { out << streamIterator.getOutputEOL(); @@ -3803,10 +3935,10 @@ size_t textSizeOut = out.str().length(); char* pTextOut = fpMemoryAlloc((long)textSizeOut + 1); // call memory allocation function - if (pTextOut == NULL) + if (pTextOut == nullptr) { fpErrorHandler(120, "Allocation failure on output."); - return NULL; + return nullptr; } strcpy(pTextOut, out.str().c_str()); @@ -3838,25 +3970,20 @@ { // create objects ASFormatter formatter; - g_console = new ASConsole(formatter); + auto console = make_shared(formatter); // process command line and options file // build the vectors fileNameVector, optionsVector, and fileOptionsVector vector argvOptions; - argvOptions = g_console->getArgvOptions(argc, argv); - g_console->processOptions(argvOptions); + argvOptions = console->getArgvOptions(argc, argv); + console->processOptions(argvOptions); // if no files have been given, use cin for input and cout for output - if (g_console->fileNameVectorIsEmpty()) - { - g_console->formatCinToCout(); - return EXIT_SUCCESS; - } - - // process entries in the fileNameVector - g_console->processFiles(); + if (!console->fileNameVectorIsEmpty()) + console->processFiles(); + else + console->formatCinToCout(); - delete g_console; return EXIT_SUCCESS; } diff -Nru astyle-2.06/src/astyle_main.h astyle-3.0.1/src/astyle_main.h --- astyle-2.06/src/astyle_main.h 2016-12-26 18:41:09.000000000 +0000 +++ astyle-3.0.1/src/astyle_main.h 2017-05-31 00:26:37.000000000 +0000 @@ -1,7 +1,7 @@ // astyle_main.h -// Copyright (c) 2016 by Jim Pattee . +// Copyright (c) 2017 by Jim Pattee . // This code is licensed under the MIT License. -// License.txt describes the conditions under which this software may be distributed. +// License.md describes the conditions under which this software may be distributed. #ifndef ASTYLE_MAIN_H #define ASTYLE_MAIN_H @@ -22,7 +22,7 @@ using std::time_t; #endif -#if defined(_MSC_VER) || defined(__DMC__) +#if defined(_MSC_VER) #include #include #else @@ -160,10 +160,11 @@ }; //---------------------------------------------------------------------------- -// Utf8_16 class for utf8/16 conversions +// ASEncoding class for utf8/16 conversions +// used by both console and library builds //---------------------------------------------------------------------------- -class Utf8_16 +class ASEncoding { private: typedef unsigned short utf16; // 16 bits @@ -191,19 +192,27 @@ // ASOptions class for options processing // used by both console and library builds //---------------------------------------------------------------------------- +class ASConsole; class ASOptions { public: - explicit ASOptions(ASFormatter& formatterArg) : formatter(formatterArg) {} +#ifdef ASTYLE_LIB + ASOptions(ASFormatter& formatterArg); +#else + ASOptions(ASFormatter& formatterArg, ASConsole& consoleArg); +#endif string getOptionErrors() const; void importOptions(istream& in, vector& optionsVector); bool parseOptions(vector& optionsVector, const string& errorInfo); private: // variables - ASFormatter& formatter; // reference to the ASFormatter object + ASFormatter& formatter; stringstream optionErrors; // option error messages +#ifndef ASTYLE_LIB + ASConsole& console; // DO NOT USE for ASTYLE_LIB +#endif // functions ASOptions(const ASOptions&); // copy constructor not to be implemented @@ -229,6 +238,7 @@ private: // variables ASFormatter& formatter; // reference to the ASFormatter object ASLocalizer localizer; // ASLocalizer object + ostream* errorStream; // direct error messages to cerr or cout // command line options bool isRecursive; // recursive option bool isDryRun; // dry-run option @@ -251,12 +261,14 @@ bool lineEndsMixed; // output has mixed line ends int linesOut; // number of output lines - Utf8_16 utf8_16; // utf8/16 conversion methods + ASEncoding utf8_16; // utf8/16 conversion methods string outputEOL; // current line end string prevEOL; // previous line end string optionsFileName; // file path and name of the options file to use string origSuffix; // suffix= option + string stdPathIn; // path to input from stdin= + string stdPathOut; // path to output from stdout= string targetDirectory; // path to the directory being processed string targetFilename; // file name being processed @@ -267,34 +279,9 @@ vector fileOptionsVector; // options from the options file vector fileName; // files to be processed including path -public: // variables - explicit ASConsole(ASFormatter& formatterArg) : formatter(formatterArg) - { - // command line options - isRecursive = false; - isDryRun = false; - noBackup = false; - preserveDate = false; - isVerbose = false; - isQuiet = false; - isFormattedOnly = false; - ignoreExcludeErrors = false; - ignoreExcludeErrorsDisplay = false; - optionsFileRequired = false; - useAscii = false; - // other variables - bypassBrowserOpen = false; - hasWildcard = false; - filesAreIdentical = true; - lineEndsMixed = false; - origSuffix = ".orig"; - mainDirectoryLength = 0; - filesFormatted = 0; - filesUnchanged = 0; - linesOut = 0; - } - public: // functions + explicit ASConsole(ASFormatter& formatterArg); + ~ASConsole(); void convertLineEnds(ostringstream& out, int lineEnd); FileEncoding detectEncoding(const char* data, size_t dataSize) const; void error() const; @@ -302,6 +289,7 @@ void formatCinToCout(); vector getArgvOptions(int argc, char** argv) const; bool fileNameVectorIsEmpty() const; + ostream* getErrorStream() const; bool getFilesAreIdentical() const; int getFilesFormatted() const; bool getIgnoreExcludeErrors() const; @@ -315,13 +303,16 @@ bool getNoBackup() const; bool getPreserveDate() const; string getLanguageID() const; - string getNumberFormat(int num, size_t = 0) const; + string getNumberFormat(int num, size_t lcid = 0) const; string getNumberFormat(int num, const char* groupingArg, const char* separator) const; string getOptionsFileName() const; string getOrigSuffix() const; + string getStdPathIn() const; + string getStdPathOut() const; void processFiles(); - void processOptions(vector& argvOptions); + void processOptions(const vector& argvOptions); void setBypassBrowserOpen(bool state); + void setErrorStream(ostream* errStreamPtr); void setIgnoreExcludeErrors(bool state); void setIgnoreExcludeErrorsAndDisplay(bool state); void setIsDryRun(bool state); @@ -333,6 +324,8 @@ void setOptionsFileName(const string& name); void setOrigSuffix(const string& suffix); void setPreserveDate(bool state); + void setStdPathIn(const string& path); + void setStdPathOut(const string& path); void standardizePath(string& path, bool removeBeginningSeparator = false) const; bool stringEndsWith(const string& str, const string& suffix) const; void updateExcludeVector(const string& suffixParam); @@ -344,19 +337,20 @@ vector getFileName() const; private: // functions - ASConsole& operator=(ASConsole&); // not to be implemented + ASConsole(const ASConsole&); // copy constructor not to be implemented + ASConsole& operator=(ASConsole&); // assignment operator not to be implemented void correctMixedLineEnds(ostringstream& out); void formatFile(const string& fileName_); string getCurrentDirectory(const string& fileName_) const; void getFileNames(const string& directory, const string& wildcard); - void getFilePaths(string& filePath); + void getFilePaths(const string& filePath); string getParam(const string& arg, const char* op); void initializeOutputEOL(LineEndFormat lineEndFormat); bool isOption(const string& arg, const char* op); bool isOption(const string& arg, const char* a, const char* b); bool isParamOption(const string& arg, const char* option); bool isPathExclued(const string& subPath); - void launchDefaultBrowser(const char* filePathIn = NULL) const; + void launchDefaultBrowser(const char* filePathIn = nullptr) const; void printHelp() const; void printMsg(const char* msg, const string& data) const; void printSeparatingLine() const; @@ -388,13 +382,13 @@ // virtual functions are mocked in testing utf16_t* formatUtf16(const utf16_t*, const utf16_t*, fpError, fpAlloc) const; virtual utf16_t* convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc) const; - virtual char* convertUtf16ToUtf8(const utf16_t* pSourceIn) const; + virtual char* convertUtf16ToUtf8(const utf16_t* utf16In) const; private: static char* STDCALL tempMemoryAllocation(unsigned long memoryNeeded); private: - Utf8_16 utf8_16; // utf8/16 conversion methods + ASEncoding utf8_16; // utf8/16 conversion methods }; #endif // ASTYLE_LIB @@ -437,10 +431,10 @@ // they are called externally and are NOT part of the namespace //----------------------------------------------------------------------------- #ifdef ASTYLE_LIB -extern "C" EXPORT char* STDCALL AStyleMain(const char* sourceIn, - const char* optionsIn, - fpError errorHandler, - fpAlloc memoryAlloc); +extern "C" EXPORT char* STDCALL AStyleMain(const char* pSourceIn, + const char* pOptions, + fpError fpErrorHandler, + fpAlloc fpMemoryAlloc); extern "C" EXPORT const char* STDCALL AStyleGetVersion(void); #endif // ASTYLE_LIB