Upgrade to SVN r511

This commit is contained in:
Peter Vingelmann 2016-09-09 00:17:30 +02:00
parent c8638db9b4
commit a80ed8000a
18 changed files with 3519 additions and 3295 deletions

21
LICENSE.txt Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
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.

File diff suppressed because it is too large Load Diff

BIN
doc/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View File

@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Artistic Style - Install Information</title> <title>Artistic Style - Install Information</title>
@ -12,401 +12,335 @@
<body> <body>
<h1>Artistic Style Install Information <h1>Artistic Style Install Information</h1>
</h1>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<h3 id="Contents"> <h3 id="Contents">Contents</h3>
Contents
</h3>
<p class="contents1"> <p class="contents1">
<a class="contents" href="#_Artistic_Style_Versions">Artistic Style Versions</a> <a class="contents" href="#_Artistic_Style_Versions">Artistic Style Versions</a></p>
</p>
<p class="contents1"> <p class="contents1">
<a class="contents" href="#_Linux_Version">Linux Version</a> <a class="contents" href="#_Linux_Version">Linux Version</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_GCC_Compiler">GCC Compiler</a> <a class="contents" href="#_GCC_Compiler">GCC Compiler</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Other_Makefile_Options">Other Makefile Options</a> <a class="contents" href="#_Clang_Compiler">Clang Compiler</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Clang_Compiler">Clang Compiler</a> <a class="contents" href="#_Intel_Compiler">Intel Compiler</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Intel_Compiler">Intel Compiler</a> <a class="contents" href="#_Other_Makefile_Targets">Other Makefile Targets</a></p>
</p>
<p class="contents1"> <p class="contents1">
<a class="contents" href="#_Mac_OS_X_Version">Mac OS X Version</a> <a class="contents" href="#_Mac_OS_Version">Mac OS Version</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Xcode">Xcode</a> <a class="contents" href="#_Xcode">Xcode</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Makefile">Makefile</a> <a class="contents" href="#_Makefile">Makefile</a></p>
</p>
<p class="contents1"> <p class="contents1">
<a class="contents" href="#_Windows_Version">Windows Version</a> <a class="contents" href="#_Windows_Version">Windows Version</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Precompiled_Executable">Precompiled Executable</a> <a class="contents" href="#_Precompiled_Executable">Precompiled Executable</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Visual_C++_Compiler">Visual C++ Compiler</a> <a class="contents" href="#_Visual_C++_Compiler">Visual C++ Compiler</a></p>
</p>
<p class="contents2"> <p class="contents2">
<a class="contents" href="#_Other_Compilers">Other Compilers</a> <a class="contents" href="#_Other_Compilers">Other Compilers</a></p>
</p>
<p class="contents1"> <p class="contents1">
<a class="contents" href="#_Compiler_Options">Compiler Options</a> <a class="contents" href="#_Compiler_Options">Compiler Options</a></p>
</p>
<h3 id="_Artistic_Style_Versions"> <h3 id="_Artistic_Style_Versions">Artistic Style Versions</h3>
Artistic Style Versions
</h3>
<p> <p>
astyle_x.x_linux.tar.gz is the <b>Linux </b>version of Artistic Style. It contains the source code, documentation, astyle_x.x_linux.tar.gz is the <strong>Linux </strong>version of Artistic Style. It contains the source code,
and makefiles. The Linux Version compile instructions below give information for compiling the source code. documentation, and makefiles. The Linux Version compile instructions below give information for compiling the
</p> source code.</p>
<p> <p>
astyle_x.x_macosx.tar.gz is the <b>Mac OS X </b>version of Artistic Style. It contains the source code, documentation, astyle_x.x_macos.tar.gz is the <strong>Mac OS </strong>version of Artistic Style. It contains the source code,
Xcode project files, and a makefile. The Mac OS X Version compile instructions below give information for compiling documentation, Xcode project files, and a makefile. The Mac OS Version compile instructions below give information
the source code. for compiling the source code.</p>
</p>
<p> <p>
astyle_x.x_windows.zip is the <b>Windows </b>version of Artistic Style. It contains the source code, documentation, astyle_x.x_windows.zip is the <strong>Windows </strong>version of Artistic Style. It contains the source code,
Visual C project files, and an executable. The Windows Version compile instructions below give information for documentation, Visual C project files, and an executable. The Windows Version compile instructions below give
compiling the source code. information for compiling the source code.</p>
</p>
<p> <p>
Only one platform is supported in each distribution package. If you use Artistic Style on more than one platform Only one platform is supported in each distribution package. If you use Artistic Style on more than one platform
you will need to download packages for each platform. The main difference in platforms is the build directories you will need to download packages for each platform. The main difference in platforms is the build directories
and the line endings. Most compilers and development packages will accept any type of line ending. The source and the line endings. Most compilers and development packages will accept any type of line ending. The source
code and documentation are the same for all distributions. code and documentation are the same for all distributions.</p>
</p>
<h3 id="_Linux_Version"> <h3 id="_Linux_Version">Linux Version</h3>
Linux Version
</h3>
<h4 id="_GCC_Compiler"> <h4 id="_GCC_Compiler">GCC Compiler</h4>
GCC Compiler
</h4>
<p> <p>
To compile using the GCC compiler you must have GCC (3.1 or better) installed. To compile using the GCC compiler you must have GCC (3.1 or better) installed.</p>
</p>
<p> <p>
The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the
astyle/build/gcc directory. The executables will be in the astyle/build/gcc/bin directory. To build the command astyle/build/gcc directory. The executables will be in the astyle/build/gcc/bin directory. To build the command
line configuration enter the following: line configuration enter the following:</p>
</p>
<pre>cd astyle/build/gcc<br />make <pre>cd astyle/build/gcc<br />make
</pre> </pre>
<p> <p>
To build the other astyle configurations you can enter the file name or a symbolic name. Entering "make astyle" To build the other astyle configurations you can enter the file name or a symbolic name. Entering "make astyle"
or "make release" will build the command line configuration. Following are the symbolic names and file names (in or "make release" will build the command line configuration. Following are the symbolic names and file names (in
parens) of the various configurations: parens) of the various configurations:</p>
</p>
<ul> <ul>
<li><b>release </b>builds the Artistic Style command line program (astyle). This is the default option.</li> <li><strong>release </strong>builds the Artistic Style command line program (astyle). This is the default option.
<li><b>shared </b>builds the Artistic Style program as a shared library (libastyle.so).</li>
<li><b>static </b>builds the Artistic Style program as a static library (libastyle.a).</li>
<li><b>debug </b>builds the Artistic Style command line program with debugging information (astyled).</li>
<li><b>shareddebug </b>builds the Artistic Style program as a shared library with debugging information (libastyled.so).
</li> </li>
<li><b>staticdebug </b>builds the Artistic Style program as a static library with debugging information (libastyled.a). <li><strong>shared </strong>builds the Artistic Style program as a shared library (libastyle.so).</li>
<li><strong>static </strong>builds the Artistic Style program as a static library (libastyle.a).</li>
<li><strong>debug </strong>builds the Artistic Style command line program with debugging information (astyled).
</li> </li>
<li><b>all </b>builds all the above configurations. <li><strong>shareddebug </strong>builds the Artistic Style program as a shared library with debugging information
(libastyled.so).
</li>
<li><strong>staticdebug </strong>builds the Artistic Style program as a static library with debugging information
(libastyled.a).
</li>
<li><strong>all </strong>builds all the above configurations.
<p> <p>
The following Java shared library builds are separate from the above. They include a Java Native Interface (JNI) 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. and require that the Java Development Kit (JDK) be installed. The environment variable JAVA_HOME should be defined.
It defines the install directory for the JDK. The makefile also has default install directories for Java 5 and It defines the install directory for the JDK. The makefile also has default install directories for Java 5 and
6. If the compile cannot find the file jni.h, either set the variable or change the value in the makefile. 6. If the compile cannot find the file jni.h, either set the variable or change the value in the
</p> makefile.</p>
</li> </li>
<li><b>java </b>builds the Artistic Style program as a shared library which includes the JNI (libastylej.so).</li> <li><strong>java </strong>builds the Artistic Style program as a shared library which includes the JNI (libastylej.so).
<li><b>javadebug </b>builds the Artistic Style program as a shared library which includes the JNI and debugging information </li>
<li><strong>javadebug </strong>builds the Artistic Style program as a shared library which includes the JNI and debugging
information
(libastylejd.so).</li> (libastylejd.so).</li>
<li><span style="font-weight: bold;">javaall </span>builds all the above java configurations.</li> <li><span style="font-weight: bold;">javaall </span>builds all the above java configurations.</li>
</ul> </ul>
<p> <p>
More than one configuration can be built at the same time. For example, to build all the release configurations More than one configuration can be built at the same time. For example, to build all the release configurations
enter: enter:</p>
</p>
<pre>cd astyle/build/gcc<br />make release shared static</pre> <pre>cd astyle/build/gcc<br />make release shared static</pre>
<p>
The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
options.</p>
<h4 id="_Other_Makefile_Options"> <h4 id="_Clang_Compiler">Clang Compiler</h4>
Other Makefile Options
</h4>
<p>
The following makefile options are available for GCC, Clang, Intel, and Mac.
</p>
<h5>clean
</h5>
<p>
Removes the object and executable files for all configurations.
</p>
<p>
To remove the files for all configurations:
</p>
<pre>make clean
</pre>
<h5>cleanobj
</h5>
<p>
Removes the object files for all configurations. The executables will not be removed.
</p>
<p>
To remove only the object files for all configurations:
</p>
<pre>make cleanobj
</pre>
<h5>install
</h5>
<p>
Installs the
astyle executable and documentation files. The default is /usr/bin for the executable and /usr/share/doc/astyle
for the documentation. You must have the appropriate permissions to use install.
</p>
<p>
To install the astyle to the default directories:
</p>
<pre>sudo make install
</pre>
<p>
To install astyle to a different bin directory set a value for the macro $(prefix). For example to install the
executable to a user's home directory (/home/<i>user</i>/bin):
</p>
<pre>sudo make prefix=$HOME install
</pre>
<h5>uninstall
</h5>
<p>
Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.
</p>
<p>
To uninstall astyle from the default directories:
</p>
<pre>sudo make uninstall
</pre>
<p>
To uninstall the files from a different directory set a value for the macro $(prefix). For example to uninstall
the files from a user's home directory (/home/<i>user</i>):
</p>
<pre> sudo make prefix=$HOME uninstall
</pre>
<p>
NOTE: The uninstall option will NOT remove the .astylerc files from the users home directories. The files must
be removed individually for each user.
</p>
<h4 id="_Clang_Compiler">
Clang Compiler
</h4>
<p>
The Clang Compiler release 2.9.11 has a problem finding object files on
some distributions (Ubuntu based). There is a script file, copyfiles.sh, that will copy three object files to
the clang build directory so they can be linked. The directory may need to be modified for your distribution.
Or, you may not need it at all. This problem has been fixed in version 3.0.
</p>
<p> <p>
Clang has a static analyzer that finds potential bugs in C/C++ and Objective-C programs. It can be run as a standalone Clang has a static analyzer that finds potential bugs in C/C++ and Objective-C programs. It can be run as a standalone
tool from the command-line, and runs in tandem with a build. There is a script file, analyze.sh, that will run tool from the command-line, and runs in tandem with a build. There is a script file, analyze.sh, that will run
the analysis on Artistic Style. the analysis on Artistic Style.</p>
</p>
<p> <p>
The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the
astyle/build/clang directory. The executables will be in the astyle/build/clang/bin directory. To build the command astyle/build/clang directory. The executables will be in the astyle/build/clang/bin directory. To build the command
line configuration enter the following: line configuration enter the following:</p>
</p>
<pre>cd astyle/build/clang<br />make <pre>cd astyle/build/clang<br />make
</pre> </pre>
<p> <p>
To build the other astyle configurations you can enter the file name or a symbolic name. The configurations for 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 <a href="#_GCC_Compiler">GCC compiler</a>. More than one configuration can be Clang are the same as for the <a href="#_GCC_Compiler">GCC compiler</a>. More than one configuration can be
built at the same time. For example, to build all the release configurations enter: built at the same time. For example, to build all the release configurations enter:</p>
</p>
<pre>cd astyle/build/clang<br />make release shared static <pre>cd astyle/build/clang<br />make release shared static
</pre> </pre>
<p> <p>
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the GCC compiler. The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
</p> options.</p>
<h4 id="_Intel_Compiler"> <h4 id="_Intel_Compiler">Intel Compiler</h4>
Intel Compiler
</h4>
<p> <p>
These procedures and the makefile are for recent versions of the compiler. They may not work for earlier versions. 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". Instructions for your compiler are in the compiler documentation file "get_started_lc.htm".</p>
</p>
<p> <p>
To compile the source there are environment variables that must be set by running the compiler environment script 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 compilervars.sh (or compilervars.csh) with an argument that specifies the target architecture. If this has not
been done already enter: "<strong>source &nbsp;&lt;install-dir&gt;/bin/compilervars.sh&nbsp;&lt;arg&gt;</strong>", been done already enter: "<strong>source &nbsp;&lt;install-dir&gt;/bin/compilervars.sh&nbsp;&lt;arg&gt;</strong>",
where &lt;install-dir&gt; is the directory where the compiler is installed and &lt;arg&gt; is <strong>ia32 </strong> where &lt;install-dir&gt; is the directory where the compiler is installed and &lt;arg&gt; is <strong>ia32 </strong>
or <strong>intel64</strong>. If this is not done "make" will display an error message "*** The compiler environment or <strong>intel64</strong>. 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 variables are not set." On an Intel x64 platform installed in the default directory the instruction would
</p> be</p>
<pre>source /opt/intel/bin/compilervars.sh intel64</pre> <pre>source /opt/intel/bin/compilervars.sh intel64</pre>
<p> <p>
The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the 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 astyle/build/intel directory. The output executables will be in the astyle/build/intel/bin directory. To build
the command line configuration enter the following: the command line configuration enter the following:</p>
</p>
<pre>cd astyle/build/intel<br />make</pre> <pre>cd astyle/build/intel<br />make</pre>
<p> <p>
To build the other astyle configurations you can enter the file name or a symbolic name. The configuration names 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 <a href="#_GCC_Compiler">GCC compiler</a>. More than one configuration can be for Intel are the same as for the <a href="#_GCC_Compiler">GCC compiler</a>. More than one configuration can be
built at the same time. For example, to build the entire debug configurations enter: built at the same time. For example, to build the entire debug configurations enter:</p>
</p>
<pre>cd astyle/build/intel<br />make debug shareddebug staticdebug</pre> <pre>cd astyle/build/intel<br />make debug shareddebug staticdebug</pre>
<p> <p>
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the GCC compiler. The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
</p> options.</p>
<h3 id="_Mac_OS_X_Version"> <h4 id="_Other_Makefile_Targets">Other Makefile Targets</h4>
Mac OS X Version
</h3> <p>
The following makefile targets are available for GCC, Clang, Intel, and Mac.</p>
<h5>clean</h5>
<p>
Removes the object and executable files for all configurations.</p>
<p>
To remove the files for all configurations:</p>
<pre>make clean
</pre>
<h5>cleanobj</h5>
<p>
Removes the object files for all configurations. The executables will not be removed.</p>
<p>
To remove only the object files for all configurations:</p>
<pre>make cleanobj
</pre>
<h5>install</h5>
<p>
Installs the
astyle executable and documentation files. The default is /usr/bin for the executable and /usr/share/doc/astyle
for the documentation. You must have the appropriate permissions to use install.</p>
<p>
To install the astyle to the default directories:</p>
<pre>sudo make install
</pre>
<p>
To install astyle to a different bin directory set a value for the macro $(prefix). For example to install the
executable to a user's home directory (/home/<i>user</i>/bin):</p>
<pre>sudo make prefix=$HOME install
</pre>
<h5>uninstall</h5>
<p>
Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.</p>
<p>
To uninstall astyle from the default directories:</p>
<pre>sudo make uninstall
</pre>
<p>
To uninstall the files from a different directory set a value for the macro $(prefix). For example to uninstall
the files from a user's home directory (/home/<i>user</i>):</p>
<pre> sudo make prefix=$HOME uninstall
</pre>
<p>
NOTE: The uninstall option will NOT remove the .astylerc files from the users home directories. The files must
be removed individually for each user.</p>
<h3 id="_Mac_OS_Version">Mac OS Version</h3>
<h4 id="_Xcode">Xcode</h4> <h4 id="_Xcode">Xcode</h4>
<p> <p>
Artistic Style workspace and project files for the Xcode development environment are available in the &quot;build/xcode&quot; Artistic Style workspace and project files for the Xcode development environment are available in the &quot;build/xcode&quot;
directory. A workspace can be used to build a single project or all the projects. The project files have Debug directory. A workspace can be used to build a single project or all the projects. The project files have Debug
and Release configurations. The following projects are available. and Release configurations. The following projects are available.</p>
</p>
<ul> <ul>
<li><b>AStyle</b> builds the Artistic Style command line program (astyle). </li> <li><strong>AStyle</strong> builds the Artistic Style command line program (astyle). </li>
<li><b>AStyleA</b> builds the Artistic Style program as a Static Library (libastyle.a). This can be statically <li><strong>AStyleA</strong> builds the Artistic Style program as a Static Library (libastyle.a). This can be statically
linked with an executable.</li> linked with an executable.</li>
<li><b>AStyleDylib</b> builds the Artistic Style program as a Dynamic Library (libastyle.dylib). It can be used with C/C++, Objective <li><strong>AStyleDylib</strong> builds the Artistic Style program as a Dynamic Library (libastyle.dylib). It can
C, C#, and Python programs.</li> be used with C/C++, Objective C, C#, and Python programs.</li>
<li><b>AStyleJava</b> builds the Artistic Style program as a Dynamic Library (libastylej.dylib) that can be called <li><strong>AStyleJava</strong> builds the Artistic Style program as a Dynamic Library (libastylej.dylib) that can
from a Java program. The Java Development (JDK) is required for the project to compile. The Project Properties be called from a Java program. The Java Development (JDK) is required for the project to compile. The Project
must have an include path to the JDK include directory. The output dylib can also be called from a C++ or C# Properties must have an include path to the JDK include directory. The output dylib can also be called from a
program.</li> C++ or C# program.</li>
</ul> </ul>
<h5>install</h5> <h5>install</h5>
<p> <p>
Only the astyle executable is installed. The library project installs are sent to UninstalledProjects in Only the astyle executable is installed. The library project installs are sent to UninstalledProjects in
the Build directory. The following instructions are for the astyle executable and documentation files. The default the Build directory. The following instructions are for the astyle executable and documentation files. The default
install directory is /usr/bin for the executable and /usr/share/doc/astyle install directory is /usr/bin for the executable and /usr/share/doc/astyle
for the documentation. You must have the appropriate permissions to use install. for the documentation. You must have the appropriate permissions to use install.
If sudo is not used for the install an error will occur during the build. If sudo is not used for the install an error will occur during the build.</p>
</p>
<p> <p>
To install the astyle executable to the default directory: To install the astyle executable to the default directory:</p>
</p>
<pre>cd astyle/build/xcode <pre>cd astyle/build/xcode
sudo xcodebuild install -project AStyle.xcodeproj sudo xcodebuild install -project AStyle.xcodeproj
</pre> </pre>
<p> <p>
A script is used to install the documentation A script is used to install the documentation
from the same directory. from the same directory.</p>
</p>
<pre>sudo bash install.sh <pre>sudo bash install.sh
</pre> </pre>
<h5>uninstall
</h5> <h5>uninstall</h5>
<p> <p>
Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall. Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.</p>
</p>
<p> <p>
A script is used to uninstall astyle and the documentation: A script is used to uninstall astyle and the documentation:</p>
</p>
<pre>sudo bash uninstall.sh <pre>sudo bash uninstall.sh
</pre> </pre>
<p> <p>
NOTE: The uninstall option will NOT remove the .astylerc files from the users home directories. The files must NOTE: The uninstall option will NOT remove the .astylerc files from the users home directories. The files must
be removed individually for each user. be removed individually for each user.</p>
</p>
<h4 id="_Makefile">Makefile</h4> <h4 id="_Makefile">Makefile</h4>
<p> <p>
The Artistic Style makefile compile uses the OS X &quot;Command Line Tools&quot;. If you have Xcode 4.3 or newer The Artistic Style makefile compile uses the Mac OS &quot;Command Line Tools&quot;. If you have Xcode 4.3 or newer
the command line tools, such as &quot;make&quot;, are NOT installed by default. They must be downloaded and installed the command line tools, such as &quot;make&quot;, are NOT installed by default. They must be downloaded and installed
separately. Once everything is successfully installed you should see &quot;make&quot; and other command line developer separately. Once everything is successfully installed you should see &quot;make&quot; and other command line developer
tools in /usr/bin. tools in /usr/bin.</p>
</p>
<p> <p>
The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the The build has no autoconf dependency. To build the Artistic Style configurations use the makefile located in the
astyle/build/mac directory. The executables will be in the astyle/build/mac/bin directory. To build the command astyle/build/mac directory. The executables will be in the astyle/build/mac/bin directory. To build the command
line configuration enter the following: line configuration enter the following:</p>
</p>
<pre>cd astyle/build/mac<br />make <pre>cd astyle/build/mac<br />make
</pre> </pre>
<p> <p>
To build the other astyle configurations you can enter the file name or a symbolic name. The configurations for 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 <a href="#_GCC_Compiler">Linux GCC compiler</a>. More than one configuration can be Mac are the same as for the <a href="#_GCC_Compiler">Linux GCC compiler</a>. More than one configuration can be
built at the same time. For example, to build all the release configurations enter: built at the same time. For example, to build all the release configurations enter:</p>
</p>
<pre>cd astyle/build/mac<br />make release shared static <pre>cd astyle/build/mac<br />make release shared static
</pre> </pre>
<p> <p>
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the Linux GCC compiler. The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
</p> options.</p>
<h3 id="_Windows_Version"> <h3 id="_Windows_Version">Windows Version</h3>
Windows Version
</h3>
<h4 id="_Precompiled_Executable"> <h4 id="_Precompiled_Executable">Precompiled Executable</h4>
Precompiled Executable
</h4>
<p> <p>
In addition to the source files, the Windows distribution package contains an Artistic Style Win32 executable 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 follow the following instructions. (AStyle.exe). If you prefer to compile the executable yourself follow the following instructions.</p>
</p>
<h4 id="_Visual_C++_Compiler"> <h4 id="_Visual_C++_Compiler">Visual C++ Compiler</h4>
Visual C++ Compiler
</h4>
<p> <p>
There are configuration and project files for There are
several versions of the Visual C compiler. Open the AStyle configuration solution and project files for
file in the appropriate &quot;build&quot; directory. All project files have Debug, Release and Static configurations. several versions of the Visual C compiler. Open an Artistic Style solution
file in the appropriate &quot;build&quot; directory. All projects have Debug, Release and Static configurations.
Debug file output will be in the &quot;debug&quot; directory. Release file output will be in the &quot;bin&quot; Debug file output will be in the &quot;debug&quot; directory. Release file output will be in the &quot;bin&quot;
directory. Static file output will be in the "binstatic" directory. The following solution files are available. directory. Static file output will be in the "binstatic" directory. The following solution files are
</p> available.</p>
<ul> <ul>
<li><b>All AStyle </b>builds the release and the debug configurations for all the following.</li> <li><strong>All AStyle ll AStyle </strong>builds the release and the debug configurations for all the following.
<li><b>AStyle </b>builds the Artistic Style command line program (AStyle.exe). This project has an extra "Static" </li>
option. It is the same as the "Release" build except that it is linked with a static runtime library. This is <li><strong>AStyle </strong>builds the Artistic Style command line program (AStyle.exe). This project has an extra
needed if the executable is to be run on a system without Visual Studio installed. The builds for this configuration "Static" option. It is the same as the "Release" build except that it is linked with a static runtime library.
are placed in a separate &quot;binstatic&quot; directory. </li> This is needed if the executable is to be run on a system without Visual Studio installed. The builds for this
<li><b>AStyleDll </b>builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will also build configuration are placed in a separate &quot;binstatic&quot; directory. </li>
an exports library and a static library for linking the dll. </li> <li><strong>AStyleDll </strong>builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will
<li><b>AStyleJava </b>builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can be called also build an exports library and a static library for linking the dll. </li>
from a Java program. The Java Development (JDK) is required for the project to compile. The Project Properties <li><strong>AStyleJava </strong>builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can
must have an include path to the JDK include and include/win32 directories. This is set in &quot;Project &gt; be called from a Java program. The Java Development (JDK) is required for the project to compile. The Project
Properties &gt; C/C++ &gt; General &gt; Additional&nbsp;Include&nbsp;Directories&quot;. The default setting is Properties must have an include path to the JDK include and include/win32 directories. This is set in &quot;Project
for the JDK to be installed in the default directory, but it may not be the most current release. The output DLL &gt; Properties &gt; C/C++ &gt; General &gt; Additional&nbsp;Include&nbsp;Directories&quot;. The default setting
can also be called from a C++ or C# program.</li> is for the JDK to be installed in the default directory, but it may not be the most current release. The output
<li><b>AStyleLib </b>builds the Artistic Style program as a Static Library (libAStyle.lib). This can be statically DLL can also be called from a C++ or C# program.</li>
linked to a calling program.</li> <li><strong>AStyleLib </strong>builds the Artistic Style program as a Static Library (libAStyle.lib). This can be
statically linked to a calling program.</li>
</ul> </ul>
<h4 id="_Other_Compilers"> <h4 id="_Other_Compilers">Other Compilers</h4>
Other Compilers
</h4>
<p> <p>
To use other compilers a project file must be built using a development environment. To use other compilers a project file must be built using a development environment.</p>
</p>
<ul> <ul>
<li>Create a project using the compiler's development environment.</li> <li>Create a project using the compiler's development environment.</li>
<li>Add to the project all the .cpp and .h files in the "src" directory.</li> <li>Add to the project all the .cpp and .h files in the "src" directory.</li>
@ -414,61 +348,32 @@ sudo xcodebuild install -project AStyle.xcodeproj
<li>Compile.</li> <li>Compile.</li>
</ul> </ul>
<h3 id="_Compiler_Options"> <h3 id="_Compiler_Options">Compiler Options</h3>
Compiler Options
</h3>
<p> <p>
No macro definitions are required to compile the executable. To compile as a static or shared (dynamic) library No macro definitions are required to compile the executable. To compile as a static or shared (dynamic) library
define the macro ASTYLE_LIB. To compile a Java shared (dynamic) library define the macro ASTYLE_JNI. The define the macro ASTYLE_LIB. To compile a Java shared (dynamic) library define the macro ASTYLE_JNI. The
option ASTYLE_NO_EXPORTS is sometimes needed for static libraries to prevent compiler error and warning option ASTYLE_NO_EXPORTS is sometimes needed for static libraries to prevent compiler error and warning
messages. Use the appropriate compiler and linker options to compile the static or shared library. Add debug messages. Use the appropriate compiler and linker options to compile the static or shared library. Add debug
options to compile the debug versions. options to compile the debug versions.</p>
</p>
<p> <p>
Artistic Style is a small program and it is best to optimize for speed. The debug configurations are not usually 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 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 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 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 used. Use whole program optimization if your compiler supports it. There may be other options you can use depending
on the compiler. on the compiler.</p>
</p>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<center style="margin-left: -0.4in;"> <p style="margin-left: -0.4in; text-align: center;">
<a href="http://sourceforge.net/projects/astyle"> <a href="http://sourceforge.net/projects/astyle">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" />
</a> </a></p>
</center>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://sourceforge.net/apps/piwik/astyle/" : "http://sourceforge.net/apps/piwik/astyle/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) { }
</script>
<noscript>
<p>
<img src="http://sourceforge.net/apps/piwik/astyle/piwik.php?idsite=1" style="border: 0" alt="" />
</p>
</noscript>
<!-- End Piwik Tag -->
</body> </body>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Artistic Style - News</title> <title>Artistic Style - News</title>
@ -15,167 +15,332 @@
<h1>Artistic Style News</h1> <h1>Artistic Style News</h1>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<h3>Artistic Style 2.06&nbsp; (Pending)</h3>
<p>
A new option, &quot;pad-comma&quot;, will add a space following a comma. The option &quot;pad-oper&quot;
has not been changed and will also add a space following a comma.</p>
<p>
All spaces before a comma are now removed. Use the &quot;disable formatting&quot; comment tags if there are arrays
with vertical alignment where this is not wanted.</p>
<p>
New Objective-C options "pad-return-type" and &quot;unpad-return-type&quot; will
add or remove space padding after the Objective-C return type. It is described in the "Objective-C"
section of the documentation.</p>
<p>
The Objective-C align-method-colon has been changed for method declarations and definitions.
For multi-line arguments when the first keyword is shorter than the others the colons are aligned on the
longest line instead of the first line. The alignment includes room for the indentation. This aligns all colons
after the first line for a better appaerance. Arguments that do not have a short keyword in the first line will
remain the same. This style conforms to the Google Objective-C Style Guide.</p>
<p>
The Objective-C align-method-colon option is now applied to Objective-C method calls in
addition to method declarations and definitions.</p>
<p>
Processing for C++14 single-quote digit separators has been added.</p>
<p>
Translations have been added for Bulgarian, Estonian, Greek, Hungarian, Norwegian, and Romanian. The translations
were done with an automated translation program, Google Translate, so they may not be the best translation possible.
The translations are at the end of ASLocalizer.cpp in the form of an English-Translation pair. If you correct
a translation, send the source as a bug report and it will be included in the next release. To add a language,
see &quot;Internationalization&quot; in the &quot;General Information&quot; section of the documentation.</p>
<p>
The C# example in the Developer Information has been updated. Objects for the AStyle callback functions are no
longer required. These have been removed and the delegates used instead.</p>
<p>
There is a new C# example in the Developer Information that loads the AStyle shared library using explicit linking.
This allows the shared library name to be changed so that a program compiled with &quot;Any CPU&quot; can load
either a 32-bit or 64-bit shared library.</p>
<p>
&nbsp;</p>
<h4>Visual Studio 2015 UTF-8 Files</h4>
<p>
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).&nbsp; With Visual Studio 2015 there has been a change in how UTF-8 files
without a BOM are processed. The new procedure is described
<a href="https://blogs.msdn.microsoft.com/vcblog/2016/02/22/new-options-for-managing-character-sets-in-the-microsoft-cc-compiler/"
target="_blank" title="open new window">here</a>.
It affects only the language translations in the &quot;.exe&quot; file. The shared libraries and static libraries
are not affected. It is necessary only if you are unsin a translation other than English.</p>
<p>
In addition to the &quot;auto detect...&quot; option in Tools &gt; Options... &gt; Text Editor &gt; General, an
additional compiler option is required. The option &quot;/source&#8209;charset:utf&#8209;8&quot; must be added
to the project properties at C++ &gt; Command Line, Additional Options. Since the non&#8209;unicode files in Artistic
Style are ASCII, the option can be applied to the entire project instead of just one file. This option has been
added in the files distributed with Artistic Style. There is also a new &quot;/validate&#8209;charset&quot; option,
which gets turned on automatically with the above option. This switch enables the validation of the UTF-8 input
files.</p>
<p>
This compiler option was not available until Update 2 of Visual Studio. If you are using an earlier version of
2015, a BOM should be added to the file using File &gt; &quot;Advanced Save Options...&quot;. Change the encoding
to &quot;Unicode (UTF-8 with signature) - Codepage 65001&quot;. </p>
<p>
In the above &quot;Visual C++ Team Blog&quot; Microsoft mentions that in a future major release of the compiler,
they would like to change default handling of BOM-less files to assume UTF-8.</p>
<h4>New Software License</h4>
<p>
The Artisic Style software license has changed. It is now under the MIT license. This is a permissive license
which can be used in proprietory software and does NOT require modified Artistic Style source code be made available.
It is compatable 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
use it.</p>
<p>
If there are problems with the license change send an email to Artistic Style and its use will be approved on
a individual basis.</p>
<h4>Assignment Operator Alignment</h4>
<p>
Visual Studio 2013 and 2015 have an Edit option &quot;Align Assignments&quot; that will align assignment operators
across multiple lines. There is also an extension named &quot;Code alignment&quot; that will align the code on
other items as well. Other development environments may have something similar. These will selectively align the
data and allow for customization of the format.</p>
<p>
These options and extensions can be used with Artistic Style. If you choose to do this, the space padding will
be maintained and the alignment will be preserved.</p>
<h4>Microsoft Clang Compiler</h4>
<p>
The Microsoft Clang Compiler is available starting with Visual Studio 2015 Update 2. It is usually used for Android
or iOS support but the CodeGen support can be used with Windows. It will require modification of the Visual Studio
2015 project files.</p>
<p>
The Clang compiler can be installed from the Visual Studio 2015 install program by selecting the &quot;Clang
with Microsoft CodeGen&quot; option. If Visual Studio 2015 Update 2 or 3 is already installed, Clang can be installed
by selecting File &gt; New &gt; Project &gt; Visual C++ &gt; Cross Platform, select &quot;Install Clang with Microsoft
CodeGen&quot;.</p>
<p>
To use Clang open a Visual Studio 2015 AStyle Solution. Make the following change to all configurations: </p>
<ul>
<li>General &gt; Platform Toolset, select &quot;Clang with Microsoft CodeGen&quot;.</li>
</ul>
<p>
Make sure to hit &quot;Apply&quot; before editing other properties to let the project system load the corresponding
toolset definition.</p>
<p>
The Update 2 and 3 releases do not provide any support for automatic migration of values between Visual Studio
2015 and Clang. The invalid properties must be fixed manually manually. These properties may change with
subsequent Visual Studio updates.</p>
<p>
The properties that need changing in Visual Studio 2015 Update 2 and 3 are:</p>
<ul>
<li>C/C++ &gt; General &gt; Debug Information Format, select &quot;Full Debug Information (DWARF2)&quot; for Debug
or &quot;None&quot; for Release.</li>
<li>C/C++ &gt; General &gt; Warning Level, select &quot;Enable All Warnings&quot;.</li>
<li>C/C++ &gt; Optimization &gt; Optimization, select an appropriate valid value for each configuration.</li>
<li>C/C++ &gt; Code Generation &gt; Enable C++ Exceptions, select &quot;Yes&quot; for Debug or &quot;No&quot; for
Release.</li>
<li>C/C++ &gt; Precompiled Headers &gt; Precompiled Header, select &quot;Not Using Precompiled Headers&quot;.</li>
</ul>
<p>
The following is needed if you are building an executable instead of a static or dynamic library.
The properties must be Clang-compatible options which start with &quot;-&quot;&nbsp; instead of &quot;/&quot;.
The new opton &quot;/source-charset:utf-8&quot; can NOT be used with Clang. If necessary, remove it from C/C++
&gt; Command Line &gt; Additional Options.</p>
<ul>
<li>C/C++ &gt; Preprocessor &gt; Preprocessor Definitions, add &quot;&nbsp;__STDC__=0&quot;.
</li>
<li>C/C++ &gt; Command Line &gt; Additional Options, enter &quot;-Wno-macro-redefined&quot;.
</li>
</ul>
<p>
The project should now compile and run.</p>
<h4>Artistic Style Wx</h4>
<p>
There is a new GUI test program AStyleWx that uses wxWidgets. This replaces the old AStyleWin program. AStyleWx
is multi-platform. It has more features simply because they are easier to implement with wxWidgets.</p>
<p>
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. </p>
<p>
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.</p>
<h4>Windows XP</h4>
<p>
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, there are no compiler
switches, #pragmas, or hints. But 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.</p>
<p>
If you are using XP, Artistic Style should be compiled on the XP machine. Compiling on XP with any
compiler should produce an XP executable.</p>
<p>
To compile on a non-XP machine for use on XP, using a compiler other than Visaul Studio should always
produce an XP executable. Using Vusual 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:</p>
<ul>
<li>&quot;Windows XP Support for C++&quot; must be installed. It is available as an option in the Visual Studio install
and can be installed as a modification to the current install.</li>
<li>In the Artistic Style Properties, change General &gt; Platform Toolset, to &quot;Windows XP&quot; for your Visual
Studio version.</li>
<li>In the Artistic Style Properties, change C/C++ &gt; Preprocessor &gt; Preprocessor Definitions to include
_USING_V110_SDK71_.</li>
<li>Change other Properties if you want, such as Output Directory or Target Name.</li>
<li>Compile. The output should be executable on Windows XP. It will also execute on the later versions of Windows.
</li>
</ul>
<p>
In newer releases of Visual Studio 2015, the &quot;Universal CRT&quot; files have been moved. There is a
notification at <a href="https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/">https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/</a>.
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.</p>
<h4>Acknowledgments</h4>
<p>
Thanks to David Faure for their contributions.</p>
<h3>Artistic Style 2.05&nbsp; (November 2014)</h3> <h3>Artistic Style 2.05&nbsp; (November 2014)</h3>
<p>Release 2.05.1 (December 2014) is a maintenance release and no new features were added. A list of changes is in <p>
Release 2.05.1 (December 2014) 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 2.05 release.</p> the Release Notes. The following information is for the original 2.05 release.</p>
<p> <p>
A new bracket style option, &quot;style=vtk&quot;, has been added. It uses indented brackets, like Whitesmith, A new bracket style option, &quot;style=vtk&quot;, has been added. It uses indented brackets, like Whitesmith,
except opening brackets for classes, functions, and methods are not indented. A complete description of the VTK except opening brackets for classes, functions, and methods are not indented. A complete description of the VTK
style is available at the &quot;Visualization Toolkit&quot; website (http://www.vtk.org/). style is available at the &quot;Visualization Toolkit&quot; website (http://www.vtk.org/).</p>
</p>
<p> <p>
A new preprocessor indent option "indent-preproc-block" will indent preprocessor block statements one additional A new preprocessor indent option "indent-preproc-block" will indent preprocessor block statements one additional
indent. The block must be top-level, or included within a namespace, and there are restrictions on what can be indent. The block must be top-level, or included within a namespace, and there are restrictions on what can be
indented. indented.
The option is described in the "Indentation Options" section of the documentation. The option is described in the "Indentation Options" section of the documentation.</p>
</p>
<p> <p>
A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as usual. A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as
</p> usual.</p>
<p> <p>
Formatting of source code may now be disabled for portions of a program by embedding special comment tags in the Formatting of source code may now be disabled for portions of a program by embedding special comment tags in the
program. These are described in a new &quot;Disable Formatting&quot; section of the documentation. They work the program. These are described in a new &quot;Disable Formatting&quot; section of the documentation. They work the
same as in other formatters. There are tags to disable formatting for a block of code, and a tag to disable formatting same as in other formatters. There are tags to disable formatting for a block of code, and a tag to disable formatting
of a single line. This should allow any custom formatting to be retained. of a single line. This should allow any custom formatting to be retained.</p>
</p>
<p> <p>
The product version number has been added to the filename of shared library (DLL) compiles. This will allow multiple The product version number has been added to the filename of shared library (DLL) compiles. This will allow multiple
versions of a shared library on the same system without conflicts. versions of a shared library on the same system without conflicts.</p>
</p>
<p> <p>
An attribute &#39;__attribute__ ((visibility (&quot;default&quot;)))&#39; has been added to exported functions An attribute &#39;__attribute__ ((visibility (&quot;default&quot;)))&#39; has been added to exported functions
on Linux shared libraries. This allows the option &quot;-fvisibility=hidden&quot; to be used on dynamic library on Linux shared libraries. This allows the option &quot;-fvisibility=hidden&quot; to be used on dynamic library
compiles. According to the GNU documentation, &quot;Using this feature can very substantially improve linking compiles. According to the GNU documentation, &quot;Using this feature can very substantially improve linking
and load times of shared object libraries, produce more optimized code, provide near-perfect API export and prevent and load times of shared object libraries, produce more optimized code, provide near-perfect API export and prevent
symbol clashes. It is strongly recommended that you use this in any shared objects you distribute.&quot; symbol clashes. It is strongly recommended that you use this in any shared objects you distribute.&quot;</p>
</p>
<p> <p>
Improvements have been made in the formatting of C++11 uniform initializers (enclosed by brackets). The opening Improvements have been made in the formatting of C++11 uniform initializers (enclosed by brackets). The opening
bracket will not be space padded unless it is padded initially. The closing bracket will not be broken from the bracket will not be space padded unless it is padded initially. The closing bracket will not be broken from the
final line unless it is broken initially. And the known problems with uniform initializers in class constructors final line unless it is broken initially. And the known problems with uniform initializers in class constructors
have been fixed. have been fixed.</p>
</p>
<p> <p>
The Windows compiler definition ASTYLE_NO_VCX (no Visual Studio exports) has been changed to ASTYLE_NO_EXPORTS. The Windows compiler definition ASTYLE_NO_VCX (no Visual Studio exports) has been changed to ASTYLE_NO_EXPORTS.
It is sometimes needed for static libraries on other compilers to prevent error and warning messages. It is sometimes needed for static libraries on other compilers to prevent error and warning messages.</p>
</p>
<p> <p>
Qt and Boost macros foreach, forever, Q_FOREACH, and Q_FOREVER will now be recognized as headers. Qt and Boost macros foreach, forever, Q_FOREACH, and Q_FOREVER will now be recognized as headers.</p>
</p>
<p> <p>
The main documentation for Artistic Style is in HTML format. Until now there has not been a way to display it The main documentation for Artistic Style is in HTML format. Until now there has not been a way to display it
from the astyle console program. A new option, "html" or "-!" will display the help documentation in the default from the astyle console program. A new option, "html" or "-!" will display the help documentation in the default
browser. This documentation is more complete than the astyle "help" option. It includes examples, and has an index browser. This documentation is more complete than the astyle "help" option. It includes examples, and has an index
for easier navigation. Since astyle is typically run from a script this should allow an easy way to access the for easier navigation. Since astyle is typically run from a script this should allow an easy way to access the
documentation. The option is available only from the command line. documentation. The option is available only from the command line.</p>
</p>
<p> <p>
The new "html" option assumes the documentation is installed in the standard install path. This is /usr/share/doc/astyle/html The new "html" option assumes the documentation is installed in the standard install path. This is /usr/share/doc/astyle/html
for Linux and the path %programfiles%\AStyle\doc for Windows. If it is installed to a different directory, use for Linux and the path %programfiles%\AStyle\doc for Windows. If it is installed to a different directory, use
the variation "html=&lt;actual_install_path&gt;astyle.html. This option can also be used to open other HTML files. the variation "html=&lt;actual_install_path&gt;astyle.html. This option can also be used to open other HTML files.
More information is in the "Command Line Only" section of the documentation. More information is in the "Command Line Only" section of the documentation.</p>
</p>
<p> <p>
The "html" option on Linux uses the script "xdg-open" from the install package "xdg-utils" to find the default The "html" option on Linux uses the script "xdg-open" from the install package "xdg-utils" to find the default
browser. This should be available on most systems. &nbsp;If it is not available on your system you can file a browser. This should be available on most systems. &nbsp;If it is not available on your system you can file a
bug report requesting a change. It would be helpful if you could determine how it is done before filing the report. bug report requesting a change. It would be helpful if you could determine how it is done before filing the report.
You can also file a bug report if the documentation is not installed to the above "default" directories. The HTML You can also file a bug report if the documentation is not installed to the above "default" directories. The HTML
documentation takes quite a bit of effort to maintain and I would like to make it easily available. documentation takes quite a bit of effort to maintain and I would like to make it easily available.</p>
</p>
<p> <p>
The "help" option has been changed to send the output to stdout instead of stderr. This will allow piping and The "help" option has been changed to send the output to stdout instead of stderr. This will allow piping and
redirection of the output. A common way to use the option on Linux is "astyle --help&nbsp;|&nbsp;less", which redirection of the output. A common way to use the option on Linux is "astyle --help&nbsp;|&nbsp;less", which
will page the display. The "version" option has also been changed to stdout. will page the display. The "version" option has also been changed to stdout.</p>
</p>
<p> <p>
A shared library error handler argument has been changed from &quot;char*&quot; to &quot;const char*&quot;. In A shared library error handler argument has been changed from &quot;char*&quot; to &quot;const char*&quot;. In
some cases this may cause compile errors in a user program until the references have been changed. some cases this may cause compile errors in a user program until the references have been changed.</p>
</p>
<p> <p>
The "Indent Style" topic on Wikipedia states that the "ANSI" style refers to K&amp;R style brackets The "Indent Style" topic on Wikipedia states that the "ANSI" style refers to K&amp;R style brackets
and not Allman style as used by Artistic Style. The option "style=ansi" is therefore being depreciated and will and not Allman style as used by Artistic Style. The option "style=ansi" is therefore being depreciated and will
be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or style=break). be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or
</p> style=break).</p>
<p> <p>
Some of the documentation has been removed from the distribution package. It still contains all files needed to Some of the documentation has been removed from the distribution package. It still contains all files needed to
install and run Artistic Style. The included files can be used without an Internet connection. install and run Artistic Style. The included files can be used without an Internet connection.</p>
</p>
<p> <p>
There are now build files available for Xcode on Mac. The makefile is still available for those who want it. Both There are now build files available for Xcode on Mac. The makefile is still available for those who want it. Both
now use the LLVM Clang compiler. There has been a now use the LLVM Clang compiler. There has been a
change to the makefile debug locations to make them similar to Xcode. The &quot;Install Instructions&quot; have change to the makefile debug locations to make them similar to Xcode. The &quot;Install Instructions&quot; have
been updated for both. been updated for both.</p>
</p>
<p> <p>
The Python Example in the Developer Information now supports Iron Python. The The Python Example in the Developer Information now supports Iron Python. The
programming instructions are sometimes different since the ctypes module works differently. The example script programming instructions are sometimes different since the ctypes module works differently. The example script
documents the differences. If you use Python Tools for Visual Studio, it now installs in the Express editions documents the differences. If you use Python Tools for Visual Studio, it now installs in the Express editions
(beginning with release 2.1). Node.js can also be installed in Visual Studio Express. (beginning with release 2.1). Node.js can also be installed in Visual Studio Express.</p>
</p>
<p> <p>
The executable in the Windows distribution package is now compiled with Visual Studio 2013 and will no longer The executable in the Windows distribution package is now compiled with Visual Studio 2013 and will no longer
work on XP. If you are using XP, Artistic Style will need to be recompiled on the XP machine. work on XP. If you are using XP, Artistic Style will need to be recompiled on the XP machine.</p>
</p>
<p> <p>
A new <a href="http://www.visualstudio.com/news/vs2013-community-vs" target="astyle" title="open new window">Visual A new <a href="http://www.visualstudio.com/news/vs2013-community-vs" target="_blank" title="open new window">Visual
Studio Community Edition</a> has been released. It is free, combines all of the Express editions into a single Studio Community Edition</a> has been released. It is free, combines all of the Express editions into a single
development environment, and allows the addition of Visual Studio extensions. There is an development environment, and allows the addition of Visual Studio extensions. There is an
<a href="https://visualstudiogallery.msdn.microsoft.com/2f3f04cd-2866-4e47-a671-d1cc9cc3fb02" target="astyle" title="open new window"> <a href="https://visualstudiogallery.msdn.microsoft.com/2f3f04cd-2866-4e47-a671-d1cc9cc3fb02" target="_blank" title="open new window">
AStyle Extension</a> available for installation. It has a graphic interface, adds menu entries, and can be AStyle Extension</a> available for installation. It has a graphic interface, adds menu entries, and can be
used from within Visual Studio. To install it search the &quot;Extensions and Updates&quot;, &quot;Online&quot; used from within Visual Studio. To install it search the &quot;Extensions and Updates&quot;, &quot;Online&quot;
entry for &quot;astyle&quot;. entry for &quot;astyle&quot;.</p>
</p>
<p> <p>
Thanks to Peter A. Bigot, HyungKi Jeong, David Faure, and Carl Moore for their contributions. Thanks to Peter A. Bigot, HyungKi Jeong, David Faure, and Carl Moore for their contributions.</p>
</p>
<h3>Artistic Style 2.04&nbsp; (November 2013)</h3> <h3>Artistic Style 2.04&nbsp; (November 2013)</h3>
<p> <p>
With a new Artistic Style release some unchanged source files will be formatted because of changes to Artistic With a new Artistic Style release some unchanged source files will be formatted because of changes to Artistic
Style. You may want to format your source before making program changes in order to bring it up to date. Style. You may want to format your source before making program changes in order to bring it up to date.</p>
</p>
<p> <p>
A new programming language, Objective&#8209;C, has been added to Artistic Style. Four new options, "align&#8209;method&#8209;colon", A new programming language, Objective&#8209;C, has been added to Artistic Style. Four new options, "align&#8209;method&#8209;colon",
"pad&#8209;method&#8209;colon=", "pad&#8209;method&#8209;prefix", and "unpad&#8209;method&#8209;prefix" have been "pad&#8209;method&#8209;colon=", "pad&#8209;method&#8209;prefix", and "unpad&#8209;method&#8209;prefix" have been
added to format the methods. The options are described in a new "Objective&#8209;C" section in the documentation. added to format the methods. The options are described in a new "Objective&#8209;C" section in the documentation.
These new options affect only Objective&#8209;C source code. They have no effect on the other programming languages. These new options affect only Objective&#8209;C source code. They have no effect on the other programming
</p> languages.</p>
<p> <p>
Because of the longer continuation indents sometimes needed for Objective&#8209;C, the option "max-instatement-indent" Because of the longer continuation indents sometimes needed for Objective&#8209;C, the option "max-instatement-indent"
may need to be increased. If you are not getting the paren and square bracket alignment you want, try increasing may need to be increased. If you are not getting the paren and square bracket alignment you want, try increasing
this value. The default minimum is 40 and the maximum is 120. this value. The default minimum is 40 and the maximum is 120.</p>
</p>
<p> <p>
A new bracket style option, "style=google", has been added. It uses attached brackets and indents the class access A new bracket style option, "style=google", has been added. It uses attached brackets and indents the class access
modifiers one-half indent.&nbsp; A complete description of the Google style is available at the google&#8209;styleguide modifiers one-half indent.&nbsp; A complete description of the Google style is available at the google&#8209;styleguide
website (https://code.google.com/p/google-styleguide/). The website has standards for several programming languages website (https://code.google.com/p/google-styleguide/). The website has standards for several programming languages
along with a python program to verify the style and an emacs script for using the style. along with a python program to verify the style and an emacs script for using the style.</p>
</p>
<p> <p>
A new indent option "indent-modifiers" will indent class access modifiers (public, protected, or 'private) one-half 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 documentation. indent. The rest of the class is not indented. It is described in the "Indentation Options" section of the
</p> documentation.</p>
<p> <p>
Four new bracket modify options, "attach-namespaces", "attach-classes", "attach-inlines", and "attach-extern-c", Four new bracket modify options, "attach-namespaces", "attach-classes", "attach-inlines", and "attach-extern-c",
can be used to modify your selected bracket style. They are described in a new "Bracket Modify Options" section can be used to modify your selected bracket style. They are described in a new "Bracket Modify Options" section
of the documentation. of the documentation.</p>
</p>
<p> <p>
A new option, "remove-brackets", will remove brackets from conditional statements. The statement must be a single A new option, "remove-brackets", will remove brackets from conditional statements. The statement must be a single
statement on a single line. It is described in the "Formatting Options" section of the documentation. statement on a single line. It is described in the "Formatting Options" section of the documentation.</p>
</p>
<p> <p>
A new option, "indent-preproc-cond", will indent preprocessor conditional statements (#if #elif, #else, #endif). A new option, "indent-preproc-cond", will indent preprocessor conditional statements (#if #elif, #else, #endif).
It is described in the "Indentation Options" section of the documentation. The option "indent-preprocessor" has It is described in the "Indentation Options" section of the documentation. The option "indent-preprocessor" has
been deprecated and will be removed in a future release. Use "indent-preproc-define" instead. The processing of been deprecated and will be removed in a future release. Use "indent-preproc-define" instead. The processing of
preprocessor #define statements has not changed. preprocessor #define statements has not changed.</p>
</p>
<p> <p>
A new option, "remove-comment-prefix", will remove a leading '*' from multi-line comments. It is described in A new option, "remove-comment-prefix", will remove a leading '*' from multi-line comments. It is described in
the "Formatting Options" section of the documentation. With the syntax coloring of modern editors a leading '*' the "Formatting Options" section of the documentation. With the syntax coloring of modern editors a leading '*'
@ -183,125 +348,102 @@
The idea is that a style that is hard to maintain will discourage modification and updating. The converted style The idea is that a style that is hard to maintain will discourage modification and updating. The converted style
should retain most of the formatting within the comment and result in a comment that is easier to maintain. For should retain most of the formatting within the comment and result in a comment that is easier to maintain. For
consistency the option also indents multi-line comments that are not preceded by the '*'. This may slightly modify consistency the option also indents multi-line comments that are not preceded by the '*'. This may slightly modify
the indentation of any commented-out code. the indentation of any commented-out code.</p>
</p>
<p> <p>
The option "pad-first-paren-out" was fixed to not pad if the following paren is empty. This makes the option consistent The option "pad-first-paren-out" was fixed to not pad if the following paren is empty. This makes the option consistent
with "pad-paren-out". To fix empty parens that have been padded run with the option "unpad-paren" in addition with "pad-paren-out". To fix empty parens that have been padded run with the option "unpad-paren" in addition
to "pad-first-paren-out". This needs to be done only once. to "pad-first-paren-out". This needs to be done only once.</p>
</p>
<p> <p>
Processing of C++11 raw string literals has been added. Processing of C++11 raw string literals has been added.</p>
</p>
<p> <p>
The compiler definition ASTYLE_NO_VCX (no Visual Studio exports) has been changed to ASTYLE_NO_EXPORTS and can The compiler definition ASTYLE_NO_VCX (no Visual Studio exports) has been changed to ASTYLE_NO_EXPORTS and can
be used with any Windows compiler. The Clang compiler needs this option to avoid errors on dynamic libraries. be used with any Windows compiler. The Clang compiler needs this option to avoid errors on dynamic libraries.
It removes the "__declspec(dllexport)" It removes the "__declspec(dllexport)"
definition from exported functions. Linux compilers do not use this. definition from exported functions. Linux compilers do not use this.</p>
</p>
<p> <p>
A new shared object (DLL) entry point, AStyleMainUtf16, has been added for processing C# UTF-16 strings. C# does A new shared object (DLL) entry point, AStyleMainUtf16, has been added for processing C# UTF-16 strings. C# does
not have built in functions for converting the UTF-16 strings to UTF-8. This entry point will accept UTF-16 strings, not have built in functions for converting the UTF-16 strings to UTF-8. This entry point will accept UTF-16 strings,
format the source code, and return UTF-16 strings. The error handling function and version number still use UTF-8 format the source code, and return UTF-16 strings. The error handling function and version number still use UTF-8
strings. The C# example program in the "Developer Information" shows the new calling procedure. Changes from the strings. The C# example program in the "Developer Information" shows the new calling procedure. Changes from the
previous release are marked in the example. previous release are marked in the example.</p>
</p>
<p> <p>
C# strings are UTF-16 on both Windows and Linux. C# does not use the UTF-32 wchar_t strings on Linux. Qt also C# strings are UTF-16 on both Windows and Linux. C# does not use the UTF-32 wchar_t strings on Linux. Qt also
uses UTF-16 on both Windows and Linux, but has built in UTF-8 conversion functions. Qt strings can be converted uses UTF-16 on both Windows and Linux, but has built in UTF-8 conversion functions. Qt strings can be converted
to UTF-8 by Qt, or the new entry point can be used. There may be other "managed code" applications on Linux that to UTF-8 by Qt, or the new entry point can be used. There may be other "managed code" applications on Linux that
use UTF-16. use UTF-16.</p>
</p>
<p> <p>
The "Links" page has two new sections for links mentioned in previous versions of Artistic Style. It links to The "Links" page has two new sections for links mentioned in previous versions of Artistic Style. It links to
free software and other information. free software and other information.</p>
</p>
<p> <p>
The "Developer Information" section has a new example and download for calling Artistic Style from an Objective&#8209;C The "Developer Information" section has a new example and download for calling Artistic Style from an Objective&#8209;C
program. Since it is another "C" language the only thing needed is to link the program with a library build of program. Since it is another "C" language the only thing needed is to link the program with a library build of
Artistic Style. The example was developed on Windows and Linux using the GNUstep project. Since the example is Artistic Style. The example was developed on Windows and Linux using the GNUstep project. Since the example is
a console program the problems with the GNUstep GUI have been avoided. It has not been tested on a Mac, but should a console program the problems with the GNUstep GUI have been avoided. It has not been tested on a Mac, but should
be close to working. The "Developer Information" section also has new page for "Objective&#8209;C on Windows and be close to working. The "Developer Information" section also has new page for "Objective&#8209;C on Windows and
Linux" which has information on compiling and running the example on those systems. Linux" which has information on compiling and running the example on those systems.</p>
</p>
<p> <p>
The executable included in the Windows distribution was compiled with Visual Studio 2010 (platform toolset v100). The executable included in the Windows distribution was compiled with Visual Studio 2010 (platform toolset v100).
Higher releases contain dependencies on Windows API functions that exist only on Windows Vista, Windows 7, and Higher releases contain dependencies on Windows API functions that exist only on Windows Vista, Windows 7, and
Windows 8. This means that applications built with a Visual Studio 2012 C++ compiler would fail to load and execute Windows 8. This means that applications built with a Visual Studio 2012 C++ compiler would fail to load and execute
on Windows XP. on Windows XP.</p>
</p>
<p> <p>
If you are using Windows Vista or higher, and have a Visual Studio 2012 or higher compiler available, recompiling If you are using Windows Vista or higher, and have a Visual Studio 2012 or higher compiler available, recompiling
will probably result in faster execution. If you use a compiler other than Visual Studio, you can probably get will probably result in faster execution. 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 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. move semantics will probably result in faster execution.</p>
</p>
<p> <p>
Thanks to Evmenov Georgiy, Matthew Woehlke, Jiang, Ruzzz, and beta100100 for their contributions. Thanks to Evmenov Georgiy, Matthew Woehlke, Jiang, Ruzzz, and beta100100 for their contributions.</p>
</p>
<h3>Artistic Style 2.03&nbsp; (April 2013)</h3> <h3>Artistic Style 2.03&nbsp; (April 2013)</h3>
<p> <p>
With a new Artistic Style release some unchanged source files will be formatted because of changes to Artistic With a new Artistic Style release some unchanged source files will be formatted because of changes to Artistic
Style. You may want to format your source before making program changes in order to bring it up to date. Style. You may want to format your source before making program changes in order to bring it up to date.</p>
</p>
<p> <p>
A new option, "max-code-length=#" or "xC#", will limit the length of code on a line. A new option "break&#8209;after&#8209;logical", A new option, "max-code-length=#" or "xC#", will limit the length of code on a line. A new option "break&#8209;after&#8209;logical",
or "xL", will modify a line break for conditionals. See the documentation for details. or "xL", will modify a line break for conditionals. See the documentation for details.</p>
</p>
<p> <p>
A new option, "pad-first-paren-out" or "xd", will pad only the first paren in a series on the outside. See the A new option, "pad-first-paren-out" or "xd", will pad only the first paren in a series on the outside. See the
documentation for details. documentation for details.</p>
</p>
<p> <p>
A new option, "indent=force-tab-tab=#" or "xT#", will allow force tab indents with a tab length that is different A new option, "indent=force-tab-tab=#" or "xT#", will allow force tab indents with a tab length that is different
than the indent length. See the documentation for details. than the indent length. See the documentation for details.</p>
</p>
<p> <p>
The short option for delete-empty-lines has changed from "xd" to "xe". The short option for delete-empty-lines has changed from "xd" to "xe".</p>
</p>
<p> <p>
The C++11 standard for range-based "for" loops, "enum" with a base type, and rvalue references is now supported. The C++11 standard for range-based "for" loops, "enum" with a base type, and rvalue references is now supported.
The formatting of rvalue references is determined from the existing &quot;align-pointer&quot; and &quot;align-reference&quot; The formatting of rvalue references is determined from the existing &quot;align-pointer&quot; and &quot;align-reference&quot;
options. options.</p>
</p>
<p> <p>
Closing the ending angle brackets of templates is now allowed by the C++11 standard. A new option, &quot;close-templates&quot; Closing the ending angle brackets of templates is now allowed by the C++11 standard. A new option, &quot;close-templates&quot;
or "xy", will close the whitespace in the angle brackets of template definitions. Be sure your compiler supports or "xy", will close the whitespace in the angle brackets of template definitions. Be sure your compiler supports
this before making the changes. this before making the changes.</p>
</p>
<p> <p>
The C/C++ keyword 'extern "C"' in a preprocessor no longer causes an extra indent. The C/C++ keyword 'extern "C"' in a preprocessor no longer causes an extra indent.</p>
</p>
<p> <p>
Formatting of C++/CLI managed pointers (the &#39;^&#39; character) has been added to the &quot;align-pointer&quot; Formatting of C++/CLI managed pointers (the &#39;^&#39; character) has been added to the &quot;align-pointer&quot;
option. option.</p>
</p>
<p> <p>
&nbsp;The breaking of switch &quot;default&quot; statements has been fixed. The &quot;default&quot; statements &nbsp;The breaking of switch &quot;default&quot; statements has been fixed. The &quot;default&quot; statements
that have been incorrectly broken will be fixed in this release. that have been incorrectly broken will be fixed in this release.</p>
</p>
<p> <p>
The byte order mark (BOM) has been removed from ASLocalizer.cpp for all platforms. The encoding of the file is The byte order mark (BOM) has been removed from ASLocalizer.cpp for all platforms. The encoding of the file is
UTF-8. Many Windows editors can now recognize UTF-8 encoding without the BOM. Visual Studio has an option that UTF-8. Many Windows editors can now recognize UTF-8 encoding without the BOM. Visual Studio has an option that
needs to be set. With others. such as CodeBlocks, identification is automatic. On Linux, UTF-8 is the default needs to be set. With others. such as CodeBlocks, identification is automatic. On Linux, UTF-8 is the default
encoding. encoding.</p>
</p>
<p> <p>
Translations have been added for Dutch, Finnish, Italian, Japanese, Korean, Polish, Portuguese, Russian, Swedish, Translations have been added for Dutch, Finnish, Italian, Japanese, Korean, Polish, Portuguese, Russian, Swedish,
and Ukrainian. The translations were done with an automated translation program, Google Translate, so they may and Ukrainian. The translations were done with an automated translation program, Google Translate, so they may
not be the best translation possible. The translations are at the end of ASLocalizer.cpp in the form of an English&#8209;Translation not be the best translation possible. The translations are at the end of ASLocalizer.cpp in the form of an English&#8209;Translation
pair. If you correct a translation, send the source as a bug report and it will be included in the next release. pair. If you correct a translation, send the source as a bug report and it will be included in the next release.
To add a language, see "Internationalization" in the "General Information" section of the documentation. Send To add a language, see "Internationalization" in the "General Information" section of the documentation. Send
the addition as a bug report and it will be included in the next release. the addition as a bug report and it will be included in the next release.</p>
</p>
<p> <p>
There is a new Linux makefile for the Clang Compiler. Clang is a free compiler can be installed as a package on 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, 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 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 documentation. version can be installed on a Windows platform. There is more information in the Install Information
</p> documentation.</p>
<p> <p>
Visual Studio automatically creates an import library and an export file when you link a program that contains Visual Studio automatically creates an import library and an export file when you link a program that contains
exports. It will do this for even a static library if it contains a __declspec(dllexport) definition. The Artistic exports. It will do this for even a static library if it contains a __declspec(dllexport) definition. The Artistic
@ -310,32 +452,28 @@
to eliminate the files from the output. Use this only for static libraries or when the AStyle source is included to eliminate the files from the output. Use this only for static libraries or when the AStyle source is included
in the compile. Do NOT use this when compiled as a shared (dynamic) library. It is effective only for Visual Studio in the compile. Do NOT use this when compiled as a shared (dynamic) library. It is effective only for Visual Studio
2012. It will NOT work with previous versions. It has no effect with other compilers since they require a separate 2012. It will NOT work with previous versions. It has no effect with other compilers since they require a separate
option to create the import library and export files. option to create the import library and export files.</p>
</p>
<p> <p>
The executable included in the Windows distribution was compiled with Visual Studio 2010 (platform toolset v100). The executable included in the Windows distribution was compiled with Visual Studio 2010 (platform toolset v100).
Visual Studio 2012 (platform toolset v110) contains dependencies on Windows API functions that exist only on Windows Visual Studio 2012 (platform toolset v110) contains dependencies on Windows API functions that exist only on Windows
Vista, Windows 7, and Windows 8. This means that applications built with a Visual Studio 2012 C++ compiler would Vista, Windows 7, and Windows 8. This means that applications built with a Visual Studio 2012 C++ compiler would
fail to load and execute on Windows XP. Artistic Style was therefore compiled with Visual Studio 2010 to work fail to load and execute on Windows XP. Artistic Style was therefore compiled with Visual Studio 2010 to work
on computers using Windows XP. on computers using Windows XP.</p>
</p>
<p> <p>
If you are using Windows Vista or higher, and have the Visual Studio 2012 compiler available, recompiling with If you are using Windows Vista or higher, and have the Visual Studio 2012 compiler available, recompiling with
Visual Studio 2012 will probably result in faster execution. The Windows distribution has Visual Studio 2012 project Visual Studio 2012 will probably result in faster execution. The Windows distribution has Visual Studio 2012 project
files available. files available.</p>
</p>
<p> <p>
If you use a compiler other than Visual Studio, you can probably get better execution by compiling using the C++11 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 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 releases.). execution. (To use C++11 on GCC and MinGW use the option --std=c++0x). This may change on future compiler
</p> releases.</p>
<p> <p>
The "Developer Information" page has a new example and download for calling Artistic Style from a Python script. The "Developer Information" page has a new example and download for calling Artistic Style from a Python script.
It will run with both Python 2 and Python 3. Using Python 3 shows an example of formatting a Unicode string with It will run with both Python 2 and Python 3. Using Python 3 shows an example of formatting a Unicode string with
Artistic Style. Unicode strings must be encoded to UTF-8 before formatting and decoded back to Unicode afterward. Artistic Style. Unicode strings must be encoded to UTF-8 before formatting and decoded back to Unicode afterward.
The example script shows the technique for doing this. It also shows how to set up the function pointers and allocate The example script shows the technique for doing this. It also shows how to set up the function pointers and allocate
memory in Python. memory in Python.</p>
</p>
<p> <p>
If you use Visual Studio on Windows, it can now be used for Python development. Python Tools for Visual Studio If you use Visual Studio on Windows, it can now be used for Python development. Python Tools for Visual Studio
(PTVS) is a free and open source plug-in for Visual Studio 2010 that supports Python and Iron Python. Other interpreters (PTVS) is a free and open source plug-in for Visual Studio 2010 that supports Python and Iron Python. Other interpreters
@ -343,52 +481,23 @@
best thing is the Visual Studio debugging support using the .NET debugger and the normal Visual Studio debugger. best thing is the Visual Studio debugging support using the .NET debugger and the normal Visual Studio debugger.
It enables you to set break points, step through functions, change the current statement, inspect local variables, It enables you to set break points, step through functions, change the current statement, inspect local variables,
and perform other operations while debugging. It is best to use it with a project file, a minor irritation for and perform other operations while debugging. It is best to use it with a project file, a minor irritation for
single page scripts. And there are some minor bugs. But overall it works quite well. single page scripts. And there are some minor bugs. But overall it works quite well.</p>
</p>
<p> <p>
Thanks to Christopher Sean Morrison, Keith OHara, louis6g, and J for their contributions. Thanks to Christopher Sean Morrison, Keith OHara, louis6g, and J for their contributions.</p>
</p>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<p> <p>
<strong>Previous releases are available in the <a href="http://astyle.sourceforge.net/newsArchives.html">News Archives</a>.</strong> <strong>Previous releases are available in the
</p> <a href="http://astyle.sourceforge.net/newsArchives.html">News Archives</a>.</strong></p>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<center style="margin-left: -0.4in;"> <p style="margin-left: -0.4in; text-align: center;">
<a href="http://sourceforge.net/projects/astyle"> <a href="http://sourceforge.net/projects/astyle">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a></p>
</center>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://sourceforge.net/apps/piwik/astyle/" : "http://sourceforge.net/apps/piwik/astyle/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) { }
</script>
<noscript>
<p>
<img src="http://sourceforge.net/apps/piwik/astyle/piwik.php?idsite=1" style="border: 0" alt="" />
</p>
</noscript>
<!-- End Piwik Tag -->
</body> </body>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Artistic Style - Release Notes</title> <title>Artistic Style - Release Notes</title>
@ -15,8 +15,40 @@
<h1>Artistic Style Release Notes</h1> <h1>Artistic Style Release Notes</h1>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<h3>Artistic Style 2.06&nbsp; (Pending)</h3>
<ul>
<li>Add new Objective&#8209;C options "pad-return-type" (-xq) and "unpad-return-type" (-xr).</li>
<li>Add new option pad-comma (#100).</li>
<li>Add removing spaces before a comma (#100).</li>
<li>Add formatting of C++14 single-quote digit separators (#337).</li>
<li>Add translations for Bulgarian, Estonian, Greek, Hungarian, Norwegian, and Romanian.</li>
<li>Remove lineend option from formatCinToCout function, only Windows lineends are allowed.</li>
<li>Improve align-method-colon and apply to Objective&#8209;C method calls.</li>
<li>Improve recognition of header guards in preprocessor statememts.</li>
<li>Improve recognition of C++11 uniform initializer brackets (#381).</li>
<li>Change align-method-colon short first line to align on the longest line instead of the first line.</li>
<li>Fix not recognizing an escaped space character within a quote (#403).</li>
<li>Fix attaching &quot;if&quot; statements to a #else preprocessor directive (#356).</li>
<li>Fix not clearing global variables for a new file (#364).</li>
<li>Fix not recognizing an rvalue reference in a template (#404).</li>
<li>Fix C# to recognize &quot;using&quot; as a header.</li>
<li>Fix C# to always recognize &quot;forever&quot; as a header.</li>
<li>Fix end of line comments for &quot;pad-method-prefix&quot; and &quot;unpad-method-prefix&quot;.</li>
<li>Fix end of line comments for &quot;pad-method-colon&quot;.</li>
<li>Refactoring:
<ul>
<li>Consolidate scattered ASFormatter conditional statements into a padParenObjC method.</li>
<li>Remove ASBase methods from being inlined as class definitions.</li>
<li>Replace C char arrays in astyle_main.cpp with C++ strings.</li>
<li>Return language translation as a mutable variable.</li>
<li>Portability changes for additional compiler support (#352).</li>
<li>Minor changes based on results of the Clang-Tidy. </li>
</ul>
</li>
</ul>
<h3>Artistic Style 2.05.1&nbsp; (December 2014)</h3> <h3>Artistic Style 2.05.1&nbsp; (December 2014)</h3>
@ -79,7 +111,7 @@
<li>Fix indentation of C# &quot;let&quot; statements.</li> <li>Fix indentation of C# &quot;let&quot; statements.</li>
<li>Fix a few omissions with &quot;fill-empty-lines&quot;.</li> <li>Fix a few omissions with &quot;fill-empty-lines&quot;.</li>
<li>Fix file read to read 64K blocks of data.</li> <li>Fix file read to read 64K blocks of data.</li>
<li>Refactor to un-obfuscate (clarify) the code, and improve design and decomposition:: <li>Refactor to un-obfuscate (clarify) the code, and improve design and decomposition:
<ul> <ul>
<li>Extract class Utf8_16 from ASConsole. </li> <li>Extract class Utf8_16 from ASConsole. </li>
<li>Replace Linux dependency on iconv with a Utf8_16 class for ASLibrary.</li> <li>Replace Linux dependency on iconv with a Utf8_16 class for ASLibrary.</li>
@ -234,47 +266,19 @@
</ul> </ul>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<p> <p>
<strong>Previous releases are available in the <a href="http://astyle.sourceforge.net/notesArchives.html">Release <strong>Previous releases are available in the <a href="http://astyle.sourceforge.net/notesArchives.html">Release
Notes Archives</a>.</strong> Notes Archives</a>.</strong></p>
</p>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<center style="margin-left: -0.4in;"> <p style="margin-left: -0.4in; text-align: center;">
<a href="http://sourceforge.net/projects/astyle"> <a href="http://sourceforge.net/projects/astyle">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a></p>
</center>
<p> <p>
&nbsp; &nbsp;</p>
</p>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://sourceforge.net/apps/piwik/astyle/" : "http://sourceforge.net/apps/piwik/astyle/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) { }
</script>
<noscript>
<p>
<img src="http://sourceforge.net/apps/piwik/astyle/piwik.php?idsite=1" style="border: 0" alt="" />
</p>
</noscript>
<!-- End Piwik Tag -->
</body> </body>

View File

@ -7,7 +7,6 @@
* p.contents entries are for the table of contents * p.contents entries are for the table of contents
* a.contents are table of contents links (not underlined) * a.contents are table of contents links (not underlined)
* a.links are links (underlined) * a.links are links (underlined)
* .footer is the image table at the bottom of the page
* img does not have a border * img does not have a border
* pre is a predefined format for formatting code * pre is a predefined format for formatting code
*/ */
@ -19,7 +18,7 @@ h1 { color: #0000A0; text-align: center; font-style: italic; margin-top: 18pt; m
h2.large { color: #0000A0; text-align: center; font-size: x-large; 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; } 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; } h3 { color: #0000A0; margin-top: 0.4in; margin-left: -0.4in; }
h4 { color: #0000A0; } h4 { color: #0000A0; margin-top: 0.3in; }
p.noindent { margin-left: -0.4in; } p.noindent { margin-left: -0.4in; }
p.contents1 { font-size: 105%; margin-top: 0in; margin-left: 0in; margin-bottom: 0in; margin-right: 0in; } p.contents1 { font-size: 105%; margin-top: 0in; margin-left: 0in; margin-bottom: 0in; margin-right: 0in; }
@ -31,9 +30,6 @@ a.contents:hover { color: #F00000; text-decoration: none; }
a:link, a:visited { color: #0000A0; text-decoration: underline; } a:link, a:visited { color: #0000A0; text-decoration: underline; }
a:hover { color: #F00000; text-decoration: underline; } a:hover { color: #F00000; text-decoration: underline; }
center.footer { margin-left: -0.4in; margin-top: 0.25in; }
h2.footer { font-size: x-large; margin-top: 0; margin-left: 0; }
img { border: none; } img { border: none; }
pre { margin-left: 0.3in; color: navy; font-weight: bold; } pre { margin-left: 0.3in; color: navy; font-weight: bold; }

View File

@ -1,7 +1,6 @@
# Make file for GCC compiler on Linux or compatible OS # Make file for GCC compiler on Linux or compatible OS
# The license.html file describes the conditions under which this software may be distributed.
# list of source files # list of source files for astyle
SRC = astyle_main.cpp \ SRC = astyle_main.cpp \
ASBeautifier.cpp \ ASBeautifier.cpp \
ASFormatter.cpp \ ASFormatter.cpp \
@ -9,6 +8,13 @@ SRC = astyle_main.cpp \
ASLocalizer.cpp \ ASLocalizer.cpp \
ASResource.cpp ASResource.cpp
# list of source files for libraries without ASLocalizer
SRCx = astyle_main.cpp \
ASBeautifier.cpp \
ASFormatter.cpp \
ASEnhancer.cpp \
ASResource.cpp
# source directories # source directories
vpath %.cpp ../../src vpath %.cpp ../../src
vpath %.h ../../src vpath %.h ../../src
@ -24,15 +30,12 @@ ifndef prefix
prefix=/usr prefix=/usr
endif endif
SYSCONF_PATH=$(prefix)/share/doc/astyle SYSCONF_PATH=$(prefix)/share/doc/astyle
# the path was changed in release 2.01
# SYSCONF_PATH_OLD may be removed at the appropriate time
SYSCONF_PATH_OLD=$(prefix)/share/astyle
# define macros # define macros
bindir = bin bindir = bin
objdir = obj objdir = obj
ipath=$(prefix)/bin ipath=$(prefix)/bin
CBASEFLAGS = -W -Wall -fno-rtti -fno-exceptions CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions
JAVAINCS = -I$(JAVA_HOME)/include JAVAINCS = -I$(JAVA_HOME)/include
CXX = clang++ CXX = clang++
INSTALL=install -o $(USER) -g $(USER) INSTALL=install -o $(USER) -g $(USER)
@ -67,54 +70,54 @@ endif
# a suffix is added for each build # a suffix is added for each build
OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC)) OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC))
OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC)) OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC))
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRC)) OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRCx))
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRC)) OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRCx))
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRC)) OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRCx))
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRC)) OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRCx))
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRC)) OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRCx))
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRC)) OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRCx))
# define object file rule (with the suffix) for each build # define object file rule (with the suffix) for each build
# OBJ # OBJ
$(objdir)/%.o: %.cpp astyle.h astyle_main.h $(objdir)/%.o: %.cpp astyle.h astyle_main.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSr) -c -o $@ $< $(CXX) $(CFLAGSr) -c $< -o $@
# OBJd # OBJd
$(objdir)/%_d.o: %.cpp astyle.h astyle_main.h $(objdir)/%_d.o: %.cpp astyle.h astyle_main.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSd) -c -o $@ $< $(CXX) $(CFLAGSd) -c $< -o $@
# OBJs # OBJs
$(objdir)/%_s.o: %.cpp astyle.h $(objdir)/%_s.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSs) -c -o $@ $< $(CXX) $(CFLAGSs) -c $< -o $@
# OBJsd # OBJsd
$(objdir)/%_sd.o: %.cpp astyle.h $(objdir)/%_sd.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsd) -c -o $@ $< $(CXX) $(CFLAGSsd) -c $< -o $@
# OBJa # OBJa
$(objdir)/%_a.o: %.cpp astyle.h $(objdir)/%_a.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSa) -c -o $@ $< $(CXX) $(CFLAGSa) -c $< -o $@
# OBJad # OBJad
$(objdir)/%_ad.o: %.cpp astyle.h $(objdir)/%_ad.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSad) -c -o $@ $< $(CXX) $(CFLAGSad) -c $< -o $@
# OBJsj # OBJsj
$(objdir)/%_sj.o: %.cpp astyle.h $(objdir)/%_sj.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsj) -c -o $@ $< $(CXX) $(CFLAGSsj) -c $< -o $@
# OBJsjd # OBJsjd
$(objdir)/%_sjd.o: %.cpp astyle.h $(objdir)/%_sjd.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsjd) -c -o $@ $< $(CXX) $(CFLAGSsjd) -c $< -o $@
################################################## ##################################################
# define build dependencies for each command # define build dependencies for each command
@ -131,16 +134,16 @@ astyled: $(OBJd)
$(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^
@ echo @ echo
shared: libastyle-2.05.1.so shared: libastyle.so
libastyle-2.05.1.so: $(OBJs) libastyle.so: $(OBJs)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^
@ echo @ echo
shareddebug: libastyle-2.05.1d.so shareddebug: libastyled.so
libastyle-2.05.1d.so: $(OBJsd) libastyled.so: $(OBJsd)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^
@ echo @ echo
static: libastyle.a static: libastyle.a
@ -155,16 +158,16 @@ libastyled.a: $(OBJad)
ar crs $(bindir)/$@ $^ ar crs $(bindir)/$@ $^
@ echo @ echo
java: libastyle-2.05.1j.so java: libastylej.so
libastyle-2.05.1j.so: $(OBJsj) libastylej.so: $(OBJsj)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^
@ echo @ echo
javadebug: libastyle-2.05.1jd.so javadebug: libastylejd.so
libastyle-2.05.1jd.so: $(OBJsjd) libastylejd.so: $(OBJsjd)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^
@ echo @ echo
all: release debug shared shareddebug static staticdebug all: release debug shared shareddebug static staticdebug
@ -181,19 +184,17 @@ install:
$(INSTALL) -m 755 -d $(ipath) $(INSTALL) -m 755 -d $(ipath)
@$(INSTALL) -m 755 $(bindir)/astyle $(ipath) @$(INSTALL) -m 755 $(bindir)/astyle $(ipath)
@if [ -d $(SYSCONF_PATH)/html ]; then \
rm -rf $(SYSCONF_PATH)/html; \
fi
$(INSTALL) -m 755 -d $(SYSCONF_PATH) $(INSTALL) -m 755 -d $(SYSCONF_PATH)
@mkdir -p $(SYSCONF_PATH)/html; @mkdir -p $(SYSCONF_PATH)/html;
@for files in ../../doc/*.html ../../doc/*.css; \ @for files in ../../doc/*.html ../../doc/*.css; \
do \ do \
$(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \ $(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \
done done
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
rm -rf $(SYSCONF_PATH_OLD); \
fi
uninstall: uninstall:
rm -f $(ipath)/astyle rm -f $(ipath)/astyle
rm -rf $(SYSCONF_PATH) rm -rf $(SYSCONF_PATH)
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
rm -rf $(SYSCONF_PATH_OLD); \
fi

View File

@ -1,7 +1,6 @@
# Make file for GCC compiler on Linux or compatible OS # Make file for GCC compiler on Linux or compatible OS
# The license.html file describes the conditions under which this software may be distributed.
# list of source files # list of source files for astyle
SRC = astyle_main.cpp \ SRC = astyle_main.cpp \
ASBeautifier.cpp \ ASBeautifier.cpp \
ASFormatter.cpp \ ASFormatter.cpp \
@ -9,6 +8,13 @@ SRC = astyle_main.cpp \
ASLocalizer.cpp \ ASLocalizer.cpp \
ASResource.cpp ASResource.cpp
# list of source files for libraries without ASLocalizer
SRCx = astyle_main.cpp \
ASBeautifier.cpp \
ASFormatter.cpp \
ASEnhancer.cpp \
ASResource.cpp
# source directories # source directories
vpath %.cpp ../../src vpath %.cpp ../../src
vpath %.h ../../src vpath %.h ../../src
@ -24,15 +30,12 @@ ifndef prefix
prefix=/usr prefix=/usr
endif endif
SYSCONF_PATH=$(prefix)/share/doc/astyle SYSCONF_PATH=$(prefix)/share/doc/astyle
# the path was changed in release 2.01
# SYSCONF_PATH_OLD may be removed at the appropriate time
SYSCONF_PATH_OLD=$(prefix)/share/astyle
# define macros # define macros
bindir = bin bindir = bin
objdir = obj objdir = obj
ipath=$(prefix)/bin ipath=$(prefix)/bin
CBASEFLAGS = -W -Wall -fno-rtti -fno-exceptions CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions
JAVAINCS = -I$(JAVA_HOME)/include JAVAINCS = -I$(JAVA_HOME)/include
CXX = g++ CXX = g++
INSTALL=install -o $(USER) -g $(USER) INSTALL=install -o $(USER) -g $(USER)
@ -67,54 +70,54 @@ endif
# a suffix is added for each build # a suffix is added for each build
OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC)) OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC))
OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC)) OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC))
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRC)) OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRCx))
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRC)) OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRCx))
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRC)) OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRCx))
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRC)) OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRCx))
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRC)) OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRCx))
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRC)) OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRCx))
# define object file rule (with the suffix) for each build # define object file rule (with the suffix) for each build
# OBJ # OBJ
$(objdir)/%.o: %.cpp astyle.h astyle_main.h $(objdir)/%.o: %.cpp astyle.h astyle_main.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSr) -c -o $@ $< $(CXX) $(CFLAGSr) -c $< -o $@
# OBJd # OBJd
$(objdir)/%_d.o: %.cpp astyle.h astyle_main.h $(objdir)/%_d.o: %.cpp astyle.h astyle_main.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSd) -c -o $@ $< $(CXX) $(CFLAGSd) -c $< -o $@
# OBJs # OBJs
$(objdir)/%_s.o: %.cpp astyle.h $(objdir)/%_s.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSs) -c -o $@ $< $(CXX) $(CFLAGSs) -c $< -o $@
# OBJsd # OBJsd
$(objdir)/%_sd.o: %.cpp astyle.h $(objdir)/%_sd.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsd) -c -o $@ $< $(CXX) $(CFLAGSsd) -c $< -o $@
# OBJa # OBJa
$(objdir)/%_a.o: %.cpp astyle.h $(objdir)/%_a.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSa) -c -o $@ $< $(CXX) $(CFLAGSa) -c $< -o $@
# OBJad # OBJad
$(objdir)/%_ad.o: %.cpp astyle.h $(objdir)/%_ad.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSad) -c -o $@ $< $(CXX) $(CFLAGSad) -c $< -o $@
# OBJsj # OBJsj
$(objdir)/%_sj.o: %.cpp astyle.h $(objdir)/%_sj.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsj) -c -o $@ $< $(CXX) $(CFLAGSsj) -c $< -o $@
# OBJsjd # OBJsjd
$(objdir)/%_sjd.o: %.cpp astyle.h $(objdir)/%_sjd.o: %.cpp astyle.h
@ mkdir -p $(objdir) @ mkdir -p $(objdir)
$(CXX) $(CFLAGSsjd) -c -o $@ $< $(CXX) $(CFLAGSsjd) -c $< -o $@
################################################## ##################################################
# define build dependencies for each command # define build dependencies for each command
@ -131,16 +134,16 @@ astyled: $(OBJd)
$(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^
@ echo @ echo
shared: libastyle-2.05.1.so shared: libastyle.so
libastyle-2.05.1.so: $(OBJs) libastyle.so: $(OBJs)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^
@ echo @ echo
shareddebug: libastyle-2.05.1d.so shareddebug: libastyled.so
libastyle-2.05.1d.so: $(OBJsd) libastyled.so: $(OBJsd)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^
@ echo @ echo
static: libastyle.a static: libastyle.a
@ -155,16 +158,16 @@ libastyled.a: $(OBJad)
ar crs $(bindir)/$@ $^ ar crs $(bindir)/$@ $^
@ echo @ echo
java: libastyle-2.05.1j.so java: libastylej.so
libastyle-2.05.1j.so: $(OBJsj) libastylej.so: $(OBJsj)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^
@ echo @ echo
javadebug: libastyle-2.05.1jd.so javadebug: libastylejd.so
libastyle-2.05.1jd.so: $(OBJsjd) libastylejd.so: $(OBJsjd)
@ mkdir -p $(bindir) @ mkdir -p $(bindir)
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^ $(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^
@ echo @ echo
all: release debug shared shareddebug static staticdebug all: release debug shared shareddebug static staticdebug
@ -181,19 +184,17 @@ install:
$(INSTALL) -m 755 -d $(ipath) $(INSTALL) -m 755 -d $(ipath)
@$(INSTALL) -m 755 $(bindir)/astyle $(ipath) @$(INSTALL) -m 755 $(bindir)/astyle $(ipath)
@if [ -d $(SYSCONF_PATH)/html ]; then \
rm -rf $(SYSCONF_PATH)/html; \
fi
$(INSTALL) -m 755 -d $(SYSCONF_PATH) $(INSTALL) -m 755 -d $(SYSCONF_PATH)
@mkdir -p $(SYSCONF_PATH)/html; @mkdir -p $(SYSCONF_PATH)/html;
@for files in ../../doc/*.html ../../doc/*.css; \ @for files in ../../doc/*.html ../../doc/*.css; \
do \ do \
$(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \ $(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \
done done
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
rm -rf $(SYSCONF_PATH_OLD); \
fi
uninstall: uninstall:
rm -f $(ipath)/astyle rm -f $(ipath)/astyle
rm -rf $(SYSCONF_PATH) rm -rf $(SYSCONF_PATH)
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
rm -rf $(SYSCONF_PATH_OLD); \
fi

View File

@ -1,39 +1,29 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ASBeautifier.cpp
* ASBeautifier.cpp // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
* // This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
* //-----------------------------------------------------------------------------
* This file is a part of Artistic Style - an indentation and // headers
* reformatting tool for C, C++, C# and Java source files. //-----------------------------------------------------------------------------
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "astyle.h" #include "astyle.h"
#include <algorithm> #include <algorithm>
//-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
namespace astyle { namespace astyle {
//
// this must be global // this must be global
static int g_preprocessorCppExternCBracket; static int g_preprocessorCppExternCBracket;
//-----------------------------------------------------------------------------
// ASBeautifier class
//-----------------------------------------------------------------------------
/** /**
* ASBeautifier's constructor * ASBeautifier's constructor
* This constructor is called only once for each source file. * This constructor is called only once for each source file.
@ -41,8 +31,6 @@ static int g_preprocessorCppExternCBracket;
*/ */
ASBeautifier::ASBeautifier() ASBeautifier::ASBeautifier()
{ {
g_preprocessorCppExternCBracket = 0;
waitingBeautifierStack = NULL; waitingBeautifierStack = NULL;
activeBeautifierStack = NULL; activeBeautifierStack = NULL;
waitingBeautifierStackLengthStack = NULL; waitingBeautifierStackLengthStack = NULL;
@ -101,7 +89,7 @@ ASBeautifier::ASBeautifier()
* *
* Must explicitly call the base class copy constructor. * Must explicitly call the base class copy constructor.
*/ */
ASBeautifier::ASBeautifier(const ASBeautifier &other) : ASBase(other) ASBeautifier::ASBeautifier(const ASBeautifier& other) : ASBase(other)
{ {
// these don't need to copy the stack // these don't need to copy the stack
waitingBeautifierStack = NULL; waitingBeautifierStack = NULL;
@ -158,6 +146,7 @@ ASBeautifier::ASBeautifier(const ASBeautifier &other) : ASBase(other)
inLineNumber = other.inLineNumber; inLineNumber = other.inLineNumber;
horstmannIndentInStatement = other.horstmannIndentInStatement; horstmannIndentInStatement = other.horstmannIndentInStatement;
nonInStatementBracket = other.nonInStatementBracket; nonInStatementBracket = other.nonInStatementBracket;
objCColonAlignSubsequent = other.objCColonAlignSubsequent;
lineCommentNoBeautify = other.lineCommentNoBeautify; lineCommentNoBeautify = other.lineCommentNoBeautify;
isElseHeaderIndent = other.isElseHeaderIndent; isElseHeaderIndent = other.isElseHeaderIndent;
isCaseHeaderCommentIndent = other.isCaseHeaderCommentIndent; isCaseHeaderCommentIndent = other.isCaseHeaderCommentIndent;
@ -302,6 +291,7 @@ void ASBeautifier::init(ASSourceIterator* iter)
sourceIterator = iter; sourceIterator = iter;
initVectors(); initVectors();
ASBase::init(getFileType()); ASBase::init(getFileType());
g_preprocessorCppExternCBracket = 0;
initContainer(waitingBeautifierStack, new vector<ASBeautifier*>); initContainer(waitingBeautifierStack, new vector<ASBeautifier*>);
initContainer(activeBeautifierStack, new vector<ASBeautifier*>); initContainer(activeBeautifierStack, new vector<ASBeautifier*>);
@ -409,6 +399,7 @@ void ASBeautifier::init(ASSourceIterator* iter)
inLineNumber = 0; inLineNumber = 0;
horstmannIndentInStatement = 0; horstmannIndentInStatement = 0;
nonInStatementBracket = 0; nonInStatementBracket = 0;
objCColonAlignSubsequent = 0;
} }
/* /*
@ -736,6 +727,16 @@ bool ASBeautifier::getForceTabIndentation(void) const
return shouldForceTabIndentation; return shouldForceTabIndentation;
} }
/**
* Get the state of the Objective-C align method colon option.
*
* @return state of shouldAlignMethodColon option.
*/
bool ASBeautifier::getAlignMethodColon(void) const
{
return shouldAlignMethodColon;
}
/** /**
* get the state of the block indentation option. * get the state of the block indentation option.
* *
@ -854,10 +855,10 @@ int ASBeautifier::getTabLength(void) const
* @return the indented line. * @return the indented line.
* @param originalLine the original unindented line. * @param originalLine the original unindented line.
*/ */
string ASBeautifier::beautify(const string &originalLine) string ASBeautifier::beautify(const string& originalLine)
{ {
string line; string line;
bool isInQuoteContinuation = isInVerbatimQuote | haveLineContinuationChar; bool isInQuoteContinuation = isInVerbatimQuote || haveLineContinuationChar;
currentHeader = NULL; currentHeader = NULL;
lastLineHeader = NULL; lastLineHeader = NULL;
@ -965,7 +966,7 @@ string ASBeautifier::beautify(const string &originalLine)
{ {
if (isInIndentablePreprocBlock) if (isInIndentablePreprocBlock)
return preLineWS(preprocBlockIndent, 0); return preLineWS(preprocBlockIndent, 0);
else if (!headerStack->empty() || isInEnum) if (!headerStack->empty() || isInEnum)
return preLineWS(prevFinalLineIndentCount, prevFinalLineSpaceIndentCount); return preLineWS(prevFinalLineIndentCount, prevFinalLineSpaceIndentCount);
// must fall thru here // must fall thru here
} }
@ -1075,10 +1076,8 @@ string ASBeautifier::beautify(const string &originalLine)
// and then remove it from the active beautifier stack and delete it. // and then remove it from the active beautifier stack and delete it.
if (!backslashEndsPrevLine && isInDefineDefinition && !isInDefine) if (!backslashEndsPrevLine && isInDefineDefinition && !isInDefine)
{ {
ASBeautifier* defineBeautifier;
isInDefineDefinition = false; isInDefineDefinition = false;
defineBeautifier = activeBeautifierStack->back(); ASBeautifier* defineBeautifier = activeBeautifierStack->back();
activeBeautifierStack->pop_back(); activeBeautifierStack->pop_back();
string indentedLine = defineBeautifier->beautify(line); string indentedLine = defineBeautifier->beautify(line);
@ -1099,6 +1098,7 @@ string ASBeautifier::beautify(const string &originalLine)
activeBeautifierStack->back()->inLineNumber = inLineNumber; activeBeautifierStack->back()->inLineNumber = inLineNumber;
activeBeautifierStack->back()->horstmannIndentInStatement = horstmannIndentInStatement; activeBeautifierStack->back()->horstmannIndentInStatement = horstmannIndentInStatement;
activeBeautifierStack->back()->nonInStatementBracket = nonInStatementBracket; activeBeautifierStack->back()->nonInStatementBracket = nonInStatementBracket;
activeBeautifierStack->back()->objCColonAlignSubsequent = objCColonAlignSubsequent;
activeBeautifierStack->back()->lineCommentNoBeautify = lineCommentNoBeautify; activeBeautifierStack->back()->lineCommentNoBeautify = lineCommentNoBeautify;
activeBeautifierStack->back()->isElseHeaderIndent = isElseHeaderIndent; activeBeautifierStack->back()->isElseHeaderIndent = isElseHeaderIndent;
activeBeautifierStack->back()->isCaseHeaderCommentIndent = isCaseHeaderCommentIndent; activeBeautifierStack->back()->isCaseHeaderCommentIndent = isCaseHeaderCommentIndent;
@ -1143,6 +1143,9 @@ string ASBeautifier::beautify(const string &originalLine)
if (shouldAlignMethodColon) if (shouldAlignMethodColon)
{ {
colonIndentObjCMethodDefinition = line.find(':'); colonIndentObjCMethodDefinition = line.find(':');
int objCColonAlignSubsequentIndent = objCColonAlignSubsequent + indentLength;
if (objCColonAlignSubsequentIndent > colonIndentObjCMethodDefinition)
colonIndentObjCMethodDefinition = objCColonAlignSubsequentIndent;
} }
else if (inStatementIndentStack->empty() else if (inStatementIndentStack->empty()
|| inStatementIndentStack->back() == 0) || inStatementIndentStack->back() == 0)
@ -1209,10 +1212,10 @@ string ASBeautifier::beautify(const string &originalLine)
return indentedLine; return indentedLine;
} }
string &ASBeautifier::getIndentedLineReturn(string &newLine, const string &originalLine) const string& ASBeautifier::getIndentedLineReturn(string& newLine, const string& originalLine) const
{ {
if (isIndentModeOff) if (isIndentModeOff)
return const_cast<string &>(originalLine); return const_cast<string&>(originalLine);
return newLine; return newLine;
} }
@ -1246,10 +1249,9 @@ string ASBeautifier::preLineWS(int lineIndentCount, int lineSpaceIndentCount) co
/** /**
* register an in-statement indent. * register an in-statement indent.
*/ */
void ASBeautifier::registerInStatementIndent(const string &line, int i, int spaceTabCount_, void ASBeautifier::registerInStatementIndent(const string& line, int i, int spaceTabCount_,
int tabIncrementIn, int minIndent, bool updateParenStack) int tabIncrementIn, int minIndent, bool updateParenStack)
{ {
int inStatementIndent;
int remainingCharNum = line.length() - i; int remainingCharNum = line.length() - i;
int nextNonWSChar = getNextProgramCharDistance(line, i); int nextNonWSChar = getNextProgramCharDistance(line, i);
@ -1281,7 +1283,7 @@ void ASBeautifier::registerInStatementIndent(const string &line, int i, int spac
tabIncrement += convertTabToSpaces(j, tabIncrement); tabIncrement += convertTabToSpaces(j, tabIncrement);
} }
inStatementIndent = i + nextNonWSChar + spaceTabCount_ + tabIncrement; int inStatementIndent = i + nextNonWSChar + spaceTabCount_ + tabIncrement;
// check for run-in statement // check for run-in statement
if (i > 0 && line[0] == '{') if (i > 0 && line[0] == '{')
@ -1309,7 +1311,7 @@ void ASBeautifier::registerInStatementIndent(const string &line, int i, int spac
/** /**
* Register an in-statement indent for a class header or a class initializer colon. * Register an in-statement indent for a class header or a class initializer colon.
*/ */
void ASBeautifier::registerInStatementIndentColon(const string &line, int i, int tabIncrementIn) void ASBeautifier::registerInStatementIndentColon(const string& line, int i, int tabIncrementIn)
{ {
assert(line[i] == ':'); assert(line[i] == ':');
assert(isInClassInitializer || isInClassHeaderTab); assert(isInClassInitializer || isInClassHeaderTab);
@ -1351,7 +1353,7 @@ pair<int, int> ASBeautifier::computePreprocessorIndent()
* get distance to the next non-white space, non-comment character in the line. * get distance to the next non-white space, non-comment character in the line.
* if no such character exists, return the length remaining to the end of the line. * if no such character exists, return the length remaining to the end of the line.
*/ */
int ASBeautifier::getNextProgramCharDistance(const string &line, int i) const int ASBeautifier::getNextProgramCharDistance(const string& line, int i) const
{ {
bool inComment = false; bool inComment = false;
int remainingCharNum = line.length() - i; int remainingCharNum = line.length() - i;
@ -1376,7 +1378,7 @@ int ASBeautifier::getNextProgramCharDistance(const string &line, int i) const
{ {
if (line.compare(i + charDistance, 2, "//") == 0) if (line.compare(i + charDistance, 2, "//") == 0)
return remainingCharNum; return remainingCharNum;
else if (line.compare(i + charDistance, 2, "/*") == 0) if (line.compare(i + charDistance, 2, "/*") == 0)
{ {
charDistance++; charDistance++;
inComment = true; inComment = true;
@ -1390,7 +1392,7 @@ int ASBeautifier::getNextProgramCharDistance(const string &line, int i) const
} }
// check if a specific line position contains a header. // check if a specific line position contains a header.
const string* ASBeautifier::findHeader(const string &line, int i, const string* ASBeautifier::findHeader(const string& line, int i,
const vector<const string*>* possibleHeaders) const const vector<const string*>* possibleHeaders) const
{ {
assert(isCharPotentialHeader(line, i)); assert(isCharPotentialHeader(line, i));
@ -1428,7 +1430,7 @@ const string* ASBeautifier::findHeader(const string &line, int i,
} }
// check if a specific line position contains an operator. // check if a specific line position contains an operator.
const string* ASBeautifier::findOperator(const string &line, int i, const string* ASBeautifier::findOperator(const string& line, int i,
const vector<const string*>* possibleOperators) const const vector<const string*>* possibleOperators) const
{ {
assert(isCharPotentialOperator(line[i])); assert(isCharPotentialOperator(line[i]));
@ -1454,14 +1456,13 @@ const string* ASBeautifier::findOperator(const string &line, int i,
* @param container a vector of strings. * @param container a vector of strings.
* @param element the element to find . * @param element the element to find .
*/ */
int ASBeautifier::indexOf(vector<const string*> &container, const string* element) const int ASBeautifier::indexOf(vector<const string*>& container, const string* element) const
{ {
vector<const string*>::const_iterator where; vector<const string*>::const_iterator where;
where = find(container.begin(), container.end(), element); where = find(container.begin(), container.end(), element);
if (where == container.end()) if (where == container.end())
return -1; return -1;
else
return (int) (where - container.begin()); return (int) (where - container.begin());
} }
@ -1483,9 +1484,8 @@ int ASBeautifier::convertTabToSpaces(int i, int tabIncrementIn) const
* @return the trimmed line. * @return the trimmed line.
* @param str the line to trim. * @param str the line to trim.
*/ */
string ASBeautifier::trim(const string &str) const string ASBeautifier::trim(const string& str) const
{ {
int start = 0; int start = 0;
int end = str.length() - 1; int end = str.length() - 1;
@ -1509,7 +1509,7 @@ string ASBeautifier::trim(const string &str) const
* @return the trimmed line. * @return the trimmed line.
* @param str the line to trim. * @param str the line to trim.
*/ */
string ASBeautifier::rtrim(const string &str) const string ASBeautifier::rtrim(const string& str) const
{ {
size_t len = str.length(); size_t len = str.length();
size_t end = str.find_last_not_of(" \t"); size_t end = str.find_last_not_of(" \t");
@ -1524,7 +1524,7 @@ string ASBeautifier::rtrim(const string &str) const
* Copy tempStacks for the copy constructor. * Copy tempStacks for the copy constructor.
* The value of the vectors must also be copied. * The value of the vectors must also be copied.
*/ */
vector<vector<const string*>*>* ASBeautifier::copyTempStacks(const ASBeautifier &other) const vector<vector<const string*>*>* ASBeautifier::copyTempStacks(const ASBeautifier& other) const
{ {
vector<vector<const string*>*>* tempStacksNew = new vector<vector<const string*>*>; vector<vector<const string*>*>* tempStacksNew = new vector<vector<const string*>*>;
vector<vector<const string*>*>::iterator iter; vector<vector<const string*>*>::iterator iter;
@ -1560,7 +1560,7 @@ void ASBeautifier::deleteBeautifierVectors()
* used for all vectors except tempStacks * used for all vectors except tempStacks
*/ */
template<typename T> template<typename T>
void ASBeautifier::deleteContainer(T &container) void ASBeautifier::deleteContainer(T& container)
{ {
if (container != NULL) if (container != NULL)
{ {
@ -1576,7 +1576,7 @@ void ASBeautifier::deleteContainer(T &container)
* Therefore the ASBeautifier objects have to be deleted in addition to the * Therefore the ASBeautifier objects have to be deleted in addition to the
* ASBeautifier pointer entries. * ASBeautifier pointer entries.
*/ */
void ASBeautifier::deleteBeautifierContainer(vector<ASBeautifier*>* &container) void ASBeautifier::deleteBeautifierContainer(vector<ASBeautifier*>*& container)
{ {
if (container != NULL) if (container != NULL)
{ {
@ -1597,7 +1597,7 @@ void ASBeautifier::deleteBeautifierContainer(vector<ASBeautifier*>* &container)
* The tempStacks is a vector of pointers to strings allocated with the 'new' operator. * The tempStacks is a vector of pointers to strings allocated with the 'new' operator.
* Therefore the strings have to be deleted in addition to the tempStacks entries. * Therefore the strings have to be deleted in addition to the tempStacks entries.
*/ */
void ASBeautifier::deleteTempStacksContainer(vector<vector<const string*>*>* &container) void ASBeautifier::deleteTempStacksContainer(vector<vector<const string*>*>*& container)
{ {
if (container != NULL) if (container != NULL)
{ {
@ -1618,7 +1618,7 @@ void ASBeautifier::deleteTempStacksContainer(vector<vector<const string*>*>* &co
* T is the type of vector used for all vectors * T is the type of vector used for all vectors
*/ */
template<typename T> template<typename T>
void ASBeautifier::initContainer(T &container, T value) void ASBeautifier::initContainer(T& container, T value)
{ {
// since the ASFormatter object is never deleted, // since the ASFormatter object is never deleted,
// the existing vectors must be deleted before creating new ones // the existing vectors must be deleted before creating new ones
@ -1632,7 +1632,7 @@ void ASBeautifier::initContainer(T &container, T value)
* The tempStacks is a vector of pointers to strings allocated with the 'new' operator. * The tempStacks is a vector of pointers to strings allocated with the 'new' operator.
* Any residual entries are deleted before the vector is initialized. * Any residual entries are deleted before the vector is initialized.
*/ */
void ASBeautifier::initTempStacksContainer(vector<vector<const string*>*>* &container, void ASBeautifier::initTempStacksContainer(vector<vector<const string*>*>*& container,
vector<vector<const string*>*>* value) vector<vector<const string*>*>* value)
{ {
if (container != NULL) if (container != NULL)
@ -1647,7 +1647,7 @@ void ASBeautifier::initTempStacksContainer(vector<vector<const string*>*>* &cont
* *
* @return true if line ends with a comma, otherwise false. * @return true if line ends with a comma, otherwise false.
*/ */
bool ASBeautifier::statementEndsWithComma(const string &line, int index) const bool ASBeautifier::statementEndsWithComma(const string& line, int index) const
{ {
assert(line[index] == '='); assert(line[index] == '=');
@ -1685,7 +1685,8 @@ bool ASBeautifier::statementEndsWithComma(const string &line, int index) const
continue; continue;
} }
if (ch == '"' || ch == '\'') if (ch == '"'
|| (ch == '\'' && !isDigitSeparator(line, i)))
{ {
isInQuote_ = true; isInQuote_ = true;
quoteChar_ = ch; quoteChar_ = ch;
@ -1730,7 +1731,7 @@ bool ASBeautifier::statementEndsWithComma(const string &line, int index) const
* *
* @return is before a line-end comment. * @return is before a line-end comment.
*/ */
bool ASBeautifier::isLineEndComment(const string &line, int startPos) const bool ASBeautifier::isLineEndComment(const string& line, int startPos) const
{ {
assert(line.compare(startPos, 2, "/*") == 0); assert(line.compare(startPos, 2, "/*") == 0);
@ -1750,7 +1751,7 @@ bool ASBeautifier::isLineEndComment(const string &line, int startPos) const
* *
* @return is the index to the previous word (the in statement indent). * @return is the index to the previous word (the in statement indent).
*/ */
int ASBeautifier::getInStatementIndentAssign(const string &line, size_t currPos) const int ASBeautifier::getInStatementIndentAssign(const string& line, size_t currPos) const
{ {
assert(line[currPos] == '='); assert(line[currPos] == '=');
@ -1778,7 +1779,7 @@ int ASBeautifier::getInStatementIndentAssign(const string &line, size_t currPos)
* *
* @return is the indent to the second word on the line (the in statement indent). * @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::getInStatementIndentComma(const string& line, size_t currPos) const
{ {
assert(line[currPos] == ','); assert(line[currPos] == ',');
@ -1811,7 +1812,7 @@ int ASBeautifier::getInStatementIndentComma(const string &line, size_t currPos)
* *
* @return is the next word or an empty string if none found. * @return is the next word or an empty string if none found.
*/ */
string ASBeautifier::getNextWord(const string &line, size_t currPos) const string ASBeautifier::getNextWord(const string& line, size_t currPos) const
{ {
size_t lineLength = line.length(); size_t lineLength = line.length();
// get the last legal word (may be a number) // get the last legal word (may be a number)
@ -1839,7 +1840,7 @@ string ASBeautifier::getNextWord(const string &line, size_t currPos) const
* *
* @return is true or false. * @return is true or false.
*/ */
bool ASBeautifier::isIndentedPreprocessor(const string &line, size_t currPos) const bool ASBeautifier::isIndentedPreprocessor(const string& line, size_t currPos) const
{ {
assert(line[0] == '#'); assert(line[0] == '#');
string nextWord = getNextWord(line, currPos); string nextWord = getNextWord(line, currPos);
@ -1885,7 +1886,7 @@ bool ASBeautifier::isIndentedPreprocessor(const string &line, size_t currPos) co
* *
* @return is true or false. * @return is true or false.
*/ */
bool ASBeautifier::isPreprocessorConditionalCplusplus(const string &line) const bool ASBeautifier::isPreprocessorConditionalCplusplus(const string& line) const
{ {
string preproc = trim(line.substr(1)); string preproc = trim(line.substr(1));
if (preproc.compare(0, 5, "ifdef") == 0 && getNextWord(preproc, 4) == "__cplusplus") if (preproc.compare(0, 5, "ifdef") == 0 && getNextWord(preproc, 4) == "__cplusplus")
@ -1917,7 +1918,7 @@ bool ASBeautifier::isPreprocessorConditionalCplusplus(const string &line) const
* *
* @return is true or false. * @return is true or false.
*/ */
bool ASBeautifier::isInPreprocessorUnterminatedComment(const string &line) bool ASBeautifier::isInPreprocessorUnterminatedComment(const string& line)
{ {
if (!isInPreprocessorComment) if (!isInPreprocessorComment)
{ {
@ -1952,7 +1953,7 @@ int ASBeautifier::getBeautifierFileType() const
/** /**
* Process preprocessor statements and update the beautifier stacks. * Process preprocessor statements and update the beautifier stacks.
*/ */
void ASBeautifier::processPreprocessor(const string &preproc, const string &line) void ASBeautifier::processPreprocessor(const string& preproc, const string& line)
{ {
// When finding a multi-lined #define statement, the original beautifier // When finding a multi-lined #define statement, the original beautifier
// 1. sets its isInDefineDefinition flag // 1. sets its isInDefineDefinition flag
@ -1965,14 +1966,12 @@ void ASBeautifier::processPreprocessor(const string &preproc, const string &line
{ {
if (!isInDefineDefinition) if (!isInDefineDefinition)
{ {
ASBeautifier* defineBeautifier;
// this is the original beautifier // this is the original beautifier
isInDefineDefinition = true; isInDefineDefinition = true;
// push a new beautifier into the active stack // push a new beautifier into the active stack
// this beautifier will be used for the indentation of this define // this beautifier will be used for the indentation of this define
defineBeautifier = new ASBeautifier(*this); ASBeautifier* defineBeautifier = new ASBeautifier(*this);
activeBeautifierStack->push_back(defineBeautifier); activeBeautifierStack->push_back(defineBeautifier);
} }
else else
@ -2012,8 +2011,8 @@ void ASBeautifier::processPreprocessor(const string &preproc, const string &line
} }
else if (preproc == "endif") else if (preproc == "endif")
{ {
int stackLength; int stackLength = 0;
ASBeautifier* beautifier; ASBeautifier* beautifier = NULL;
if (waitingBeautifierStackLengthStack != NULL && !waitingBeautifierStackLengthStack->empty()) if (waitingBeautifierStackLengthStack != NULL && !waitingBeautifierStackLengthStack->empty())
{ {
@ -2145,7 +2144,7 @@ void ASBeautifier::computePreliminaryIndentation()
&& (*headerStack)[headerStack->size() - 2] == &AS_CLASS && (*headerStack)[headerStack->size() - 2] == &AS_CLASS
&& (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET && (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET
&& lineBeginsWithCloseBracket && lineBeginsWithCloseBracket
&& bracketBlockStateStack->back() == true) && bracketBlockStateStack->back())
--indentCount; --indentCount;
// unindent an indented switch closing bracket... // unindent an indented switch closing bracket...
@ -2283,7 +2282,7 @@ int ASBeautifier::adjustIndentCountForBreakElseIfComments() const
* Extract a preprocessor statement without the #. * Extract a preprocessor statement without the #.
* If a error occurs an empty string is returned. * If a error occurs an empty string is returned.
*/ */
string ASBeautifier::extractPreprocessorStatement(const string &line) const string ASBeautifier::extractPreprocessorStatement(const string& line) const
{ {
string preproc; string preproc;
size_t start = line.find_first_not_of("#/ \t"); size_t start = line.find_first_not_of("#/ \t");
@ -2305,6 +2304,7 @@ void ASBeautifier::clearObjCMethodDefinitionAlignment()
spaceIndentCount = 0; spaceIndentCount = 0;
spaceIndentObjCMethodDefinition = 0; spaceIndentObjCMethodDefinition = 0;
colonIndentObjCMethodDefinition = 0; colonIndentObjCMethodDefinition = 0;
objCColonAlignSubsequent = 0;
isInObjCMethodDefinition = false; isInObjCMethodDefinition = false;
isImmediatelyPostObjCMethodDefinition = false; isImmediatelyPostObjCMethodDefinition = false;
if (!inStatementIndentStack->empty()) if (!inStatementIndentStack->empty())
@ -2317,7 +2317,7 @@ void ASBeautifier::clearObjCMethodDefinitionAlignment()
* If it cannot be aligned indentLength is returned and a new colon * If it cannot be aligned indentLength is returned and a new colon
* position is calculated. * position is calculated.
*/ */
int ASBeautifier::computeObjCColonAlignment(string &line, int colonAlignPosition) const int ASBeautifier::computeObjCColonAlignment(string& line, int colonAlignPosition) const
{ {
int colonPosition = line.find(':'); int colonPosition = line.find(':');
if (colonPosition < 0 || colonPosition > colonAlignPosition) if (colonPosition < 0 || colonPosition > colonAlignPosition)
@ -2328,7 +2328,7 @@ int ASBeautifier::computeObjCColonAlignment(string &line, int colonAlignPosition
/** /**
* Parse the current line to update indentCount and spaceIndentCount. * Parse the current line to update indentCount and spaceIndentCount.
*/ */
void ASBeautifier::parseCurrentLine(const string &line) void ASBeautifier::parseCurrentLine(const string& line)
{ {
bool isInLineComment = false; bool isInLineComment = false;
bool isInOperator = false; bool isInOperator = false;
@ -2347,15 +2347,7 @@ void ASBeautifier::parseCurrentLine(const string &line)
if (isInBeautifySQL) if (isInBeautifySQL)
continue; continue;
if (isWhiteSpace(ch))
{
if (ch == '\t')
tabIncrementIn += convertTabToSpaces(i, tabIncrementIn);
continue;
}
// handle special characters (i.e. backslash+character such as \n, \t, ...) // handle special characters (i.e. backslash+character such as \n, \t, ...)
if (isInQuote && !isInVerbatimQuote) if (isInQuote && !isInVerbatimQuote)
{ {
if (isSpecialChar) if (isSpecialChar)
@ -2380,8 +2372,18 @@ void ASBeautifier::parseCurrentLine(const string &line)
else if (isInDefine && ch == '\\') else if (isInDefine && ch == '\\')
continue; continue;
// bypass whitespace here
if (isWhiteSpace(ch))
{
if (ch == '\t')
tabIncrementIn += convertTabToSpaces(i, tabIncrementIn);
continue;
}
// handle quotes (such as 'x' and "Hello Dolly") // handle quotes (such as 'x' and "Hello Dolly")
if (!(isInComment || isInLineComment) && (ch == '"' || ch == '\'')) if (!(isInComment || isInLineComment)
&& (ch == '"'
|| (ch == '\'' && !isDigitSeparator(line, i))))
{ {
if (!isInQuote) if (!isInQuote)
{ {
@ -2807,11 +2809,15 @@ void ASBeautifier::parseCurrentLine(const string &line)
const string* newHeader = findHeader(line, i, headers); const string* newHeader = findHeader(line, i, headers);
// Qt headers may be variables in C++ // Qt headers may be variables in C++
if (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH) if (isCStyle()
&& (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH))
{ {
if (line.find_first_of("=;", i) != string::npos) if (line.find_first_of("=;", i) != string::npos)
newHeader = NULL; newHeader = NULL;
} }
else if (newHeader == &AS_USING
&& ASBeautifier::peekNextChar(line, i + (*newHeader).length() - 1) != '(')
newHeader = NULL;
if (newHeader != NULL) if (newHeader != NULL)
{ {
@ -2820,10 +2826,8 @@ void ASBeautifier::parseCurrentLine(const string &line)
isInHeader = true; isInHeader = true;
vector<const string*>* lastTempStack; vector<const string*>* lastTempStack = NULL;;
if (tempStacks->empty()) if (!tempStacks->empty())
lastTempStack = NULL;
else
lastTempStack = tempStacks->back(); lastTempStack = tempStacks->back();
// if a new block is opened, push a new stack into tempStacks to hold the // if a new block is opened, push a new stack into tempStacks to hold the
@ -3027,8 +3031,7 @@ void ASBeautifier::parseCurrentLine(const string &line)
} }
else if (isDigit(peekNextChar(line, i))) else if (isDigit(peekNextChar(line, i)))
{ {
// found a bit field // found a bit field - do nothing special
// so do nothing special
} }
else if (isCStyle() && isInClass && prevNonSpaceCh != ')') else if (isCStyle() && isInClass && prevNonSpaceCh != ')')
{ {
@ -3477,5 +3480,4 @@ void ASBeautifier::parseCurrentLine(const string &line)
} // end of for loop * end of for loop * end of for loop * end of for loop * end of for loop * } // end of for loop * end of for loop * end of for loop * end of for loop * end of for loop *
} }
} // end namespace astyle } // end namespace astyle

View File

@ -1,33 +1,23 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ASEnhancer.cpp
* ASEnhancer.cpp // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
* // This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
* //-----------------------------------------------------------------------------
* This file is a part of Artistic Style - an indentation and // headers
* reformatting tool for C, C++, C# and Java source files. //-----------------------------------------------------------------------------
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "astyle.h" #include "astyle.h"
//-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
namespace astyle { namespace astyle {
//
//-----------------------------------------------------------------------------
// ASEnhancer class
//-----------------------------------------------------------------------------
/** /**
* ASEnhancer constructor * ASEnhancer constructor
@ -108,7 +98,7 @@ void ASEnhancer::init(int _fileType,
* *
* @param line the original formatted line will be updated if necessary. * @param line the original formatted line will be updated if necessary.
*/ */
void ASEnhancer::enhance(string &line, bool isInNamespace, bool isInPreprocessor, bool isInSQL) void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL)
{ {
shouldUnindentLine = true; shouldUnindentLine = true;
shouldUnindentComment = false; shouldUnindentComment = false;
@ -174,7 +164,7 @@ void ASEnhancer::enhance(string &line, bool isInNamespace, bool isInPreprocessor
* *
* @param line a reference to the line that will be converted. * @param line a reference to the line that will be converted.
*/ */
void ASEnhancer::convertForceTabIndentToSpaces(string &line) const void ASEnhancer::convertForceTabIndentToSpaces(string& line) const
{ {
// replace tab indents with spaces // replace tab indents with spaces
for (size_t i = 0; i < line.length(); i++) for (size_t i = 0; i < line.length(); i++)
@ -195,15 +185,14 @@ void ASEnhancer::convertForceTabIndentToSpaces(string &line) const
* *
* @param line a reference to the line that will be converted. * @param line a reference to the line that will be converted.
*/ */
void ASEnhancer::convertSpaceIndentToForceTab(string &line) const void ASEnhancer::convertSpaceIndentToForceTab(string& line) const
{ {
assert(tabLength > 0); assert(tabLength > 0);
// replace leading spaces with tab indents // replace leading spaces with tab indents
size_t newSpaceIndentLength = line.find_first_not_of(" \t"); size_t newSpaceIndentLength = line.find_first_not_of(" \t");
size_t tabCount = newSpaceIndentLength / tabLength; // truncate extra spaces size_t tabCount = newSpaceIndentLength / tabLength; // truncate extra spaces
line.erase(0U, tabCount * tabLength); line.replace(0U, tabCount * tabLength, tabCount, '\t');
line.insert(0U, tabCount, '\t');
} }
/** /**
@ -213,7 +202,7 @@ void ASEnhancer::convertSpaceIndentToForceTab(string &line) const
* @param caseIndex the line index of the case statement. * @param caseIndex the line index of the case statement.
* @return the line index of the colon. * @return the line index of the colon.
*/ */
size_t ASEnhancer::findCaseColon(string &line, size_t caseIndex) const size_t ASEnhancer::findCaseColon(string& line, size_t caseIndex) const
{ {
size_t i = caseIndex; size_t i = caseIndex;
bool isInQuote_ = false; bool isInQuote_ = false;
@ -238,7 +227,8 @@ size_t ASEnhancer::findCaseColon(string &line, size_t caseIndex) const
continue; // must close quote before continuing continue; // must close quote before continuing
} }
} }
if (line[i] == '\'' || line[i] == '\"') // check opening quote if (line[i] == '"' // check opening quote
|| (line[i] == '\'' && !isDigitSeparator(line, i)))
{ {
isInQuote_ = true; isInQuote_ = true;
quoteChar_ = line[i]; quoteChar_ = line[i];
@ -263,13 +253,13 @@ size_t ASEnhancer::findCaseColon(string &line, size_t caseIndex) const
* @param indent the number of tabsets to insert. * @param indent the number of tabsets to insert.
* @return the number of characters inserted. * @return the number of characters inserted.
*/ */
int ASEnhancer::indentLine(string &line, int indent) const int ASEnhancer::indentLine(string& line, int indent) const
{ {
if (line.length() == 0 if (line.length() == 0
&& !emptyLineFill) && !emptyLineFill)
return 0; return 0;
size_t charsToInsert; size_t charsToInsert = 0;
if (forceTab && indentLength != tabLength) if (forceTab && indentLength != tabLength)
{ {
@ -277,19 +267,19 @@ int ASEnhancer::indentLine(string &line, int indent) const
convertForceTabIndentToSpaces(line); convertForceTabIndentToSpaces(line);
// insert the space indents // insert the space indents
charsToInsert = indent * indentLength; charsToInsert = indent * indentLength;
line.insert(0U, charsToInsert, ' '); line.insert(line.begin(), charsToInsert, ' ');
// replace leading spaces with tab indents // replace leading spaces with tab indents
convertSpaceIndentToForceTab(line); convertSpaceIndentToForceTab(line);
} }
else if (useTabs) else if (useTabs)
{ {
charsToInsert = indent; charsToInsert = indent;
line.insert(0U, charsToInsert, '\t'); line.insert(line.begin(), charsToInsert, '\t');
} }
else // spaces else // spaces
{ {
charsToInsert = indent * indentLength; charsToInsert = indent * indentLength;
line.insert(0U, charsToInsert, ' '); line.insert(line.begin(), charsToInsert, ' ');
} }
return charsToInsert; return charsToInsert;
@ -303,7 +293,7 @@ int ASEnhancer::indentLine(string &line, int indent) const
* @param index the current line index. * @param index the current line index.
* @return true if a hit. * @return true if a hit.
*/ */
bool ASEnhancer::isBeginDeclareSectionSQL(string &line, size_t index) const bool ASEnhancer::isBeginDeclareSectionSQL(string& line, size_t index) const
{ {
string word; string word;
size_t hits = 0; size_t hits = 0;
@ -352,7 +342,7 @@ bool ASEnhancer::isBeginDeclareSectionSQL(string &line, size_t index) const
* @param index the current line index. * @param index the current line index.
* @return true if a hit. * @return true if a hit.
*/ */
bool ASEnhancer::isEndDeclareSectionSQL(string &line, size_t index) const bool ASEnhancer::isEndDeclareSectionSQL(string& line, size_t index) const
{ {
string word; string word;
size_t hits = 0; size_t hits = 0;
@ -401,7 +391,7 @@ bool ASEnhancer::isEndDeclareSectionSQL(string &line, size_t index) const
* @return false = one-line bracket has not been reached. * @return false = one-line bracket has not been reached.
* true = one-line bracket has been reached. * true = one-line bracket has been reached.
*/ */
bool ASEnhancer::isOneLineBlockReached(string &line, int startChar) const bool ASEnhancer::isOneLineBlockReached(string& line, int startChar) const
{ {
assert(line[startChar] == '{'); assert(line[startChar] == '{');
@ -439,7 +429,8 @@ bool ASEnhancer::isOneLineBlockReached(string &line, int startChar) const
continue; continue;
} }
if (ch == '"' || ch == '\'') if (ch == '"'
|| (ch == '\'' && !isDigitSeparator(line, i)))
{ {
isInQuote_ = true; isInQuote_ = true;
quoteChar_ = ch; quoteChar_ = ch;
@ -472,7 +463,7 @@ bool ASEnhancer::isOneLineBlockReached(string &line, int startChar) const
* parse characters in the current line to determine if an indent * parse characters in the current line to determine if an indent
* or unindent is needed. * or unindent is needed.
*/ */
void ASEnhancer::parseCurrentLine(string &line, bool isInPreprocessor, bool isInSQL) void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isInSQL)
{ {
bool isSpecialChar = false; // is a backslash escape character bool isSpecialChar = false; // is a backslash escape character
@ -502,7 +493,9 @@ void ASEnhancer::parseCurrentLine(string &line, bool isInPreprocessor, bool isIn
} }
// handle quotes (such as 'x' and "Hello Dolly") // handle quotes (such as 'x' and "Hello Dolly")
if (!isInComment && (ch == '"' || ch == '\'')) if (!isInComment
&& (ch == '"'
|| (ch == '\'' && !isDigitSeparator(line, i))))
{ {
if (!isInQuote) if (!isInQuote)
{ {
@ -665,7 +658,7 @@ void ASEnhancer::parseCurrentLine(string &line, bool isInPreprocessor, bool isIn
* @param index the current line index. * @param index the current line index.
* @return the new line index. * @return the new line index.
*/ */
size_t ASEnhancer::processSwitchBlock(string &line, size_t index) size_t ASEnhancer::processSwitchBlock(string& line, size_t index)
{ {
size_t i = index; size_t i = index;
bool isPotentialKeyword = isCharPotentialHeader(line, i); bool isPotentialKeyword = isCharPotentialHeader(line, i);
@ -754,7 +747,7 @@ size_t ASEnhancer::processSwitchBlock(string &line, size_t index)
* @param unindent the number of tabsets to erase. * @param unindent the number of tabsets to erase.
* @return the number of characters erased. * @return the number of characters erased.
*/ */
int ASEnhancer::unindentLine(string &line, int unindent) const int ASEnhancer::unindentLine(string& line, int unindent) const
{ {
size_t whitespace = line.find_first_not_of(" \t"); size_t whitespace = line.find_first_not_of(" \t");
@ -800,5 +793,4 @@ int ASEnhancer::unindentLine(string &line, int unindent) const
return charsToErase; return charsToErase;
} }
} // end namespace astyle } // end namespace astyle

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,34 @@
// ASLocalizer.cpp
// Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
// This code is licensed under the MIT License.
// License.txt describes the conditions under which this software may be distributed.
// //
// FILE ENCODING IS UTF-8 WITHOUT A BOM. // File encoding for this file is UTF-8 WITHOUT a byte order mark(BOM).
// русский 中文(简体) 日本 한국의 // русский 中文(简体) 日本語 한국의
//
// Windows:
// Add the required "Language" to the system.
// The settings do NOT need to be changed to the added language.
// Change the "Region" settings.
// Change both the "Format" and the "Current Language..." settings.
// A restart is required if the codepage has changed.
// Windows problems:
// Hindi -no available locale, language pack removed
// Japanese - language pack install error
// Ukranian - displays a ? instead of i
//
// Linux:
// Change the LANG environment variable: LANG=fr_FR.UTF-8.
// setlocale() will use the LANG environment variable on Linux.
// //
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* ASLocalizer.cpp
* *
* Copyright (C) 2014 by Jim Pattee * To add a new language to this source module:
* <http://www.gnu.org/licenses/lgpl-3.0.html>
*
* This file is a part of Artistic Style - an indentation and
* reformatting tool for C, C++, C# and Java source files.
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* To add a new language:
* *
* Add a new translation class to ASLocalizer.h. * Add a new translation class to ASLocalizer.h.
* Add the Add the English-Translation pair to the constructor in ASLocalizer.cpp. * Update the WinLangCode array in ASLocalizer.cpp.
* Update the WinLangCode array, if necessary. * Add the language code to setTranslationClass() in ASLocalizer.cpp.
* Add the language code to the function setTranslationClass(). * Add the English-Translation pair to the constructor in ASLocalizer.cpp.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -48,7 +44,6 @@
#endif #endif
#ifdef __DMC__ #ifdef __DMC__
#include <locale.h>
// digital mars doesn't have these // digital mars doesn't have these
const size_t SUBLANG_CHINESE_MACAU = 5; const size_t SUBLANG_CHINESE_MACAU = 5;
const size_t LANG_HINDI = 57; const size_t LANG_HINDI = 57;
@ -63,12 +58,12 @@
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <locale.h> // needed by some compilers
#include <stdlib.h> #include <stdlib.h>
#include <typeinfo> #include <typeinfo>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4996) // secure version deprecation warnings #pragma warning(disable: 4996) // secure version deprecation warnings
// #pragma warning(disable: 4267) // 64 bit signed/unsigned loss of data
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__
@ -80,6 +75,10 @@
#pragma warning(disable: 981) // operands are evaluated in unspecified order #pragma warning(disable: 981) // operands are evaluated in unspecified order
#endif #endif
#ifdef __clang__
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // wcstombs
#endif
namespace astyle { namespace astyle {
#ifndef ASTYLE_LIB #ifndef ASTYLE_LIB
@ -100,10 +99,6 @@ ASLocalizer::ASLocalizer()
m_translation = NULL; m_translation = NULL;
// Not all compilers support the C++ function locale::global(locale("")); // Not all compilers support the C++ function locale::global(locale(""));
// For testing on Windows change the "Region and Language" settings or use AppLocale.
// For testing on Linux change the LANG environment variable: LANG=fr_FR.UTF-8.
// setlocale() will use the LANG environment variable on Linux.
char* localeName = setlocale(LC_ALL, ""); char* localeName = setlocale(LC_ALL, "");
if (localeName == NULL) // use the english (ascii) defaults if (localeName == NULL) // use the english (ascii) defaults
{ {
@ -139,22 +134,28 @@ static WinLangCode wlc[] =
// sublanguage identifier http://msdn.microsoft.com/en-us/library/aa913256.aspx // sublanguage identifier http://msdn.microsoft.com/en-us/library/aa913256.aspx
// language ID http://msdn.microsoft.com/en-us/library/ee797784%28v=cs.20%29.aspx // language ID http://msdn.microsoft.com/en-us/library/ee797784%28v=cs.20%29.aspx
{ {
{ LANG_CHINESE, "zh" }, { LANG_BULGARIAN, "bg" }, // bg-BG 1251
{ LANG_DUTCH, "nl" }, { LANG_CHINESE, "zh" }, // zh-CHS, zh-CHT
{ LANG_ENGLISH, "en" }, { LANG_DUTCH, "nl" }, // nl-NL 1252
{ LANG_FINNISH, "fi" }, { LANG_ENGLISH, "en" }, // en-US 1252
{ LANG_FRENCH, "fr" }, { LANG_ESTONIAN, "et" }, // et-EE
{ LANG_GERMAN, "de" }, { LANG_FINNISH, "fi" }, // fi-FI 1252
{ LANG_HINDI, "hi" }, { LANG_FRENCH, "fr" }, // fr-FR 1252
{ LANG_ITALIAN, "it" }, { LANG_GERMAN, "de" }, // de-DE 1252
{ LANG_JAPANESE, "ja" }, { LANG_GREEK, "el" }, // el-GR 1253
{ LANG_KOREAN, "ko" }, { LANG_HINDI, "hi" }, // hi-IN
{ LANG_POLISH, "pl" }, { LANG_HUNGARIAN, "hu" }, // hu-HU 1250
{ LANG_PORTUGUESE, "pt" }, { LANG_ITALIAN, "it" }, // it-IT 1252
{ LANG_RUSSIAN, "ru" }, { LANG_JAPANESE, "ja" }, // ja-JP
{ LANG_SPANISH, "es" }, { LANG_KOREAN, "ko" }, // ko-KR
{ LANG_SWEDISH, "sv" }, { LANG_NORWEGIAN, "nn" }, // nn-NO 1252
{ LANG_UKRAINIAN, "uk" }, { LANG_POLISH, "pl" }, // pl-PL 1250
{ LANG_PORTUGUESE, "pt" }, // pt-PT 1252
{ LANG_ROMANIAN, "ro" }, // ro-RO 1250
{ LANG_RUSSIAN, "ru" }, // ru-RU 1251
{ LANG_SPANISH, "es" }, // es-ES 1252
{ LANG_SWEDISH, "sv" }, // sv-SE 1252
{ LANG_UKRAINIAN, "uk" }, // uk-UA 1251
}; };
void ASLocalizer::setLanguageFromLCID(size_t lcid) void ASLocalizer::setLanguageFromLCID(size_t lcid)
@ -224,16 +225,14 @@ void ASLocalizer::setLanguageFromName(const char* langID)
// de_DE.iso88591@euro // de_DE.iso88591@euro
{ {
// the constants describing the format of lang_LANG locale string // the constants describing the format of lang_LANG locale string
static const size_t LEN_LANG = 2;
m_lcid = 0; m_lcid = 0;
string langStr = langID; string langStr = langID;
m_langID = langStr.substr(0, LEN_LANG); m_langID = langStr.substr(0, 2);
// need the sublang for chinese // need the sublang for chinese
if (m_langID == "zh" && langStr[LEN_LANG] == '_') if (m_langID == "zh" && langStr[2] == '_')
{ {
string subLang = langStr.substr(LEN_LANG + 1, LEN_LANG); string subLang = langStr.substr(3, 2);
if (subLang == "CN" || subLang == "SG") if (subLang == "CN" || subLang == "SG")
m_subLangID = "CHS"; m_subLangID = "CHS";
else else
@ -262,7 +261,9 @@ void ASLocalizer::setTranslationClass()
delete m_translation; delete m_translation;
m_translation = NULL; m_translation = NULL;
} }
if (m_langID == "zh" && m_subLangID == "CHS") if (m_langID == "bg")
m_translation = new Bulgarian;
else if (m_langID == "zh" && m_subLangID == "CHS")
m_translation = new ChineseSimplified; m_translation = new ChineseSimplified;
else if (m_langID == "zh" && m_subLangID == "CHT") else if (m_langID == "zh" && m_subLangID == "CHT")
m_translation = new ChineseTraditional; m_translation = new ChineseTraditional;
@ -270,24 +271,34 @@ void ASLocalizer::setTranslationClass()
m_translation = new Dutch; m_translation = new Dutch;
else if (m_langID == "en") else if (m_langID == "en")
m_translation = new English; m_translation = new English;
else if (m_langID == "et")
m_translation = new Estonian;
else if (m_langID == "fi") else if (m_langID == "fi")
m_translation = new Finnish; m_translation = new Finnish;
else if (m_langID == "fr") else if (m_langID == "fr")
m_translation = new French; m_translation = new French;
else if (m_langID == "de") else if (m_langID == "de")
m_translation = new German; m_translation = new German;
else if (m_langID == "el")
m_translation = new Greek;
else if (m_langID == "hi") else if (m_langID == "hi")
m_translation = new Hindi; m_translation = new Hindi;
else if (m_langID == "hu")
m_translation = new Hungarian;
else if (m_langID == "it") else if (m_langID == "it")
m_translation = new Italian; m_translation = new Italian;
else if (m_langID == "ja") else if (m_langID == "ja")
m_translation = new Japanese; m_translation = new Japanese;
else if (m_langID == "ko") else if (m_langID == "ko")
m_translation = new Korean; m_translation = new Korean;
else if (m_langID == "nn")
m_translation = new Norwegian;
else if (m_langID == "pl") else if (m_langID == "pl")
m_translation = new Polish; m_translation = new Polish;
else if (m_langID == "pt") else if (m_langID == "pt")
m_translation = new Portuguese; m_translation = new Portuguese;
else if (m_langID == "ro")
m_translation = new Romanian;
else if (m_langID == "ru") else if (m_langID == "ru")
m_translation = new Russian; m_translation = new Russian;
else if (m_langID == "es") else if (m_langID == "es")
@ -304,14 +315,14 @@ void ASLocalizer::setTranslationClass()
// Translation base class methods. // Translation base class methods.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Translation::addPair(const string &english, const wstring &translated) void Translation::addPair(const string& english, const wstring& translated)
// Add a string pair to the translation vector. // Add a string pair to the translation vector.
{ {
pair<string, wstring> entry(english, translated); pair<string, wstring> entry(english, translated);
m_translation.push_back(entry); m_translation.push_back(entry);
} }
string Translation::convertToMultiByte(const wstring &wideStr) const string Translation::convertToMultiByte(const wstring& wideStr) const
// Convert wchar_t to a multibyte string using the currently assigned locale. // Convert wchar_t to a multibyte string using the currently assigned locale.
// Return an empty string if an error occurs. // Return an empty string if an error occurs.
{ {
@ -351,7 +362,7 @@ size_t Translation::getTranslationVectorSize() const
return m_translation.size(); return m_translation.size();
} }
bool Translation::getWideTranslation(const string &stringIn, wstring &wideOut) const bool Translation::getWideTranslation(const string& stringIn, wstring& wideOut) const
// Get the wide translation string. Used for testing. // Get the wide translation string. Used for testing.
{ {
for (size_t i = 0; i < m_translation.size(); i++) for (size_t i = 0; i < m_translation.size(); i++)
@ -367,25 +378,24 @@ bool Translation::getWideTranslation(const string &stringIn, wstring &wideOut) c
return false; return false;
} }
string &Translation::translate(const string &stringIn) const string& Translation::translate(const string& stringIn) const
// Translate a string. // Translate a string.
// Return a static string instead of a member variable so the method can have a "const" designation. // Return a mutable string so the method can have a "const" designation.
// This allows "settext" to be called from a "const" method. // This allows "settext" to be called from a "const" method.
{ {
static string mbTranslation; m_mbTranslation.clear();
mbTranslation.clear();
for (size_t i = 0; i < m_translation.size(); i++) for (size_t i = 0; i < m_translation.size(); i++)
{ {
if (m_translation[i].first == stringIn) if (m_translation[i].first == stringIn)
{ {
mbTranslation = convertToMultiByte(m_translation[i].second); m_mbTranslation = convertToMultiByte(m_translation[i].second);
break; break;
} }
} }
// not found, return english // not found, return english
if (mbTranslation.empty()) if (m_mbTranslation.empty())
mbTranslation = stringIn; m_mbTranslation = stringIn;
return mbTranslation; return m_mbTranslation;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -393,7 +403,39 @@ string &Translation::translate(const string &stringIn) const
// These classes have only a constructor which builds the language vector. // These classes have only a constructor which builds the language vector.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
Bulgarian::Bulgarian() // български
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Форматиран %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Непроменен %s\n"); // should align with formatted
addPair("Directory %s\n", L"директория %s\n");
addPair("Exclude %s\n", L"Изключвам %s\n");
addPair("Exclude (unmatched) %s\n", L"Изключване (несравнимо) %s\n");
addPair(" %s formatted %s unchanged ", L" %s форматиран %s hепроменен ");
addPair(" seconds ", L" секунди ");
addPair("%d min %d sec ", L"%d мин %d сек ");
addPair("%s lines\n", L"%s линии\n");
addPair("Using default options file %s\n", L"Използване на файла възможности по подразбиране %s\n");
addPair("Opening HTML documentation %s\n", L"Откриване HTML документация %s\n");
addPair("Invalid option file options:", L"Невалидни опции опция файлове:");
addPair("Invalid command line options:", L"Невалидни опции за командния ред:");
addPair("For help on options type 'astyle -h'", L"За помощ относно възможностите тип 'astyle -h'");
addPair("Cannot open options file", L"Не може да се отвори файл опции");
addPair("Cannot open directory", L"Не може да се отвори директория");
addPair("Cannot open HTML file %s\n", L"Не може да се отвори HTML файл %s\n");
addPair("Command execute failure", L"Command изпълни недостатъчност");
addPair("Command is not installed", L"Command не е инсталиран");
addPair("Missing filename in %s\n", L"Липсва името на файла в %s\n");
addPair("Recursive option with no wildcard", L"Рекурсивно опция, без маска");
addPair("Did you intend quote the filename", L"Знаете ли намерение да цитирам името на файла");
addPair("No file to process %s\n", L"Не файл за обработка %s\n");
addPair("Did you intend to use --recursive", L"Знаете ли възнамерявате да използвате --recursive");
addPair("Cannot process UTF-32 encoding", L"Не може да са UTF-32 кодиране");
addPair("\nArtistic Style has terminated", L"\nArtistic Style е прекратено");
}
ChineseSimplified::ChineseSimplified() // 中文(简体) ChineseSimplified::ChineseSimplified() // 中文(简体)
// build the translation vector in the Translation base class
{ {
addPair("Formatted %s\n", L"格式化 %s\n"); // should align with unchanged addPair("Formatted %s\n", L"格式化 %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"未改变 %s\n"); // should align with formatted addPair("Unchanged %s\n", L"未改变 %s\n"); // should align with formatted
@ -424,6 +466,7 @@ ChineseSimplified::ChineseSimplified() // 中文(简体)
} }
ChineseTraditional::ChineseTraditional() // 中文(繁體) ChineseTraditional::ChineseTraditional() // 中文(繁體)
// build the translation vector in the Translation base class
{ {
addPair("Formatted %s\n", L"格式化 %s\n"); // should align with unchanged addPair("Formatted %s\n", L"格式化 %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"未改變 %s\n"); // should align with formatted addPair("Unchanged %s\n", L"未改變 %s\n"); // should align with formatted
@ -488,6 +531,37 @@ English::English()
// this class is NOT translated // this class is NOT translated
{} {}
Estonian::Estonian() // Eesti
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Formaadis %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Muutumatu %s\n"); // should align with formatted
addPair("Directory %s\n", L"Kataloog %s\n");
addPair("Exclude %s\n", L"Välista %s\n");
addPair("Exclude (unmatched) %s\n", L"Välista (tasakaalustamata) %s\n");
addPair(" %s formatted %s unchanged ", L" %s formaadis %s muutumatu ");
addPair(" seconds ", L" sekundit ");
addPair("%d min %d sec ", L"%d min %d sek ");
addPair("%s lines\n", L"%s read\n");
addPair("Using default options file %s\n", L"Kasutades selliseid vaikimisi valikuid faili %s\n");
addPair("Opening HTML documentation %s\n", L"Avamine HTML dokumentatsioon %s\n");
addPair("Invalid option file options:", L"Vale valik faili võimalusi:");
addPair("Invalid command line options:", L"Vale käsureavõtmetega:");
addPair("For help on options type 'astyle -h'", L"Abiks võimaluste tüüp 'astyle -h'");
addPair("Cannot open options file", L"Ei saa avada võimalusi faili");
addPair("Cannot open directory", L"Ei saa avada kataloogi");
addPair("Cannot open HTML file %s\n", L"Ei saa avada HTML-faili %s\n");
addPair("Command execute failure", L"Käsk täita rike");
addPair("Command is not installed", L"Käsk ei ole paigaldatud");
addPair("Missing filename in %s\n", L"Kadunud failinimi %s\n");
addPair("Recursive option with no wildcard", L"Rekursiivne võimalus ilma metamärgi");
addPair("Did you intend quote the filename", L"Kas te kavatsete tsiteerida failinimi");
addPair("No file to process %s\n", L"No faili töötlema %s\n");
addPair("Did you intend to use --recursive", L"Kas te kavatsete kasutada --recursive");
addPair("Cannot process UTF-32 encoding", L"Ei saa töödelda UTF-32 kodeeringus");
addPair("\nArtistic Style has terminated", L"\nArtistic Style on lõpetatud");
}
Finnish::Finnish() // Suomeksi Finnish::Finnish() // Suomeksi
// build the translation vector in the Translation base class // build the translation vector in the Translation base class
{ {
@ -581,6 +655,37 @@ German::German() // Deutsch
addPair("\nArtistic Style has terminated", L"\nArtistic Style ist beendet"); addPair("\nArtistic Style has terminated", L"\nArtistic Style ist beendet");
} }
Greek::Greek() // ελληνικά
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Διαμορφωμένη %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Αμετάβλητος %s\n"); // should align with formatted
addPair("Directory %s\n", L"Κατάλογος %s\n");
addPair("Exclude %s\n", L"Αποκλείω %s\n");
addPair("Exclude (unmatched) %s\n", L"Ausschließen (unerreichte) %s\n");
addPair(" %s formatted %s unchanged ", L" %s σχηματοποιημένη %s αμετάβλητες ");
addPair(" seconds ", L" δευτερόλεπτα ");
addPair("%d min %d sec ", L"%d λεπ %d δευ ");
addPair("%s lines\n", L"%s γραμμές\n");
addPair("Using default options file %s\n", L"Χρησιμοποιώντας το αρχείο προεπιλεγμένες επιλογές %s\n");
addPair("Opening HTML documentation %s\n", L"Εγκαίνια έγγραφα HTML %s\n");
addPair("Invalid option file options:", L"Μη έγκυρες επιλογές αρχείου επιλογή:");
addPair("Invalid command line options:", L"Μη έγκυρη επιλογές γραμμής εντολών:");
addPair("For help on options type 'astyle -h'", L"Για βοήθεια σχετικά με το είδος επιλογές 'astyle -h'");
addPair("Cannot open options file", L"Δεν μπορείτε να ανοίξετε το αρχείο επιλογών");
addPair("Cannot open directory", L"Δεν μπορείτε να ανοίξετε τον κατάλογο");
addPair("Cannot open HTML file %s\n", L"Δεν μπορείτε να ανοίξετε το αρχείο HTML %s\n");
addPair("Command execute failure", L"Εντολή να εκτελέσει την αποτυχία");
addPair("Command is not installed", L"Η εντολή δεν έχει εγκατασταθεί");
addPair("Missing filename in %s\n", L"Λείπει το όνομα αρχείου σε %s\n");
addPair("Recursive option with no wildcard", L"Αναδρομικές επιλογή χωρίς μπαλαντέρ");
addPair("Did you intend quote the filename", L"Μήπως σκοπεύετε να αναφέρετε το όνομα του αρχείου");
addPair("No file to process %s\n", L"Δεν υπάρχει αρχείο για την επεξεργασία %s\n");
addPair("Did you intend to use --recursive", L"Μήπως σκοπεύετε να χρησιμοποιήσετε --recursive");
addPair("Cannot process UTF-32 encoding", L"δεν μπορεί να επεξεργαστεί UTF-32 κωδικοποίηση");
addPair("\nArtistic Style has terminated", L"\nArtistic Style έχει λήξει");
}
Hindi::Hindi() // हिन्दी Hindi::Hindi() // हिन्दी
// build the translation vector in the Translation base class // build the translation vector in the Translation base class
{ {
@ -614,6 +719,37 @@ Hindi::Hindi() // हिन्दी
addPair("\nArtistic Style has terminated", L"\nArtistic Style समाप्त किया है"); addPair("\nArtistic Style has terminated", L"\nArtistic Style समाप्त किया है");
} }
Hungarian::Hungarian() // Magyar
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Formázott %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Változatlan %s\n"); // should align with formatted
addPair("Directory %s\n", L"Címjegyzék %s\n");
addPair("Exclude %s\n", L"Kizár %s\n");
addPair("Exclude (unmatched) %s\n", L"Escludere (senza pari) %s\n");
addPair(" %s formatted %s unchanged ", L" %s formázott %s változatlan ");
addPair(" seconds ", L" másodperc ");
addPair("%d min %d sec ", L"%d jeg %d más ");
addPair("%s lines\n", L"%s vonalak\n");
addPair("Using default options file %s\n", L"Az alapértelmezett beállítások fájl %s\n");
addPair("Opening HTML documentation %s\n", L"Nyitó HTML dokumentáció %s\n");
addPair("Invalid option file options:", L"Érvénytelen opció fájlbeállítást:");
addPair("Invalid command line options:", L"Érvénytelen parancssori opciók:");
addPair("For help on options type 'astyle -h'", L"Ha segítségre van lehetőség típus 'astyle-h'");
addPair("Cannot open options file", L"Nem lehet megnyitni beállítási fájlban");
addPair("Cannot open directory", L"Nem lehet megnyitni könyvtár");
addPair("Cannot open HTML file %s\n", L"Nem lehet megnyitni a HTML fájlt %s\n");
addPair("Command execute failure", L"Command végre hiba");
addPair("Command is not installed", L"Parancs nincs telepítve");
addPair("Missing filename in %s\n", L"Hiányzó fájlnév %s\n");
addPair("Recursive option with no wildcard", L"Rekurzív kapcsolót nem wildcard");
addPair("Did you intend quote the filename", L"Esetleg kívánja idézni a fájlnév");
addPair("No file to process %s\n", L"Nincs fájl feldolgozása %s\n");
addPair("Did you intend to use --recursive", L"Esetleg a használni kívánt --recursive");
addPair("Cannot process UTF-32 encoding", L"Nem tudja feldolgozni UTF-32 kódolással");
addPair("\nArtistic Style has terminated", L"\nArtistic Style megszűnt");
}
Italian::Italian() // Italiano Italian::Italian() // Italiano
// build the translation vector in the Translation base class // build the translation vector in the Translation base class
{ {
@ -645,37 +781,39 @@ Italian::Italian() // Italiano
addPair("\nArtistic Style has terminated", L"\nArtistic Style ha terminato"); addPair("\nArtistic Style has terminated", L"\nArtistic Style ha terminato");
} }
Japanese::Japanese() // 日本 Japanese::Japanese() // 日本語
// build the translation vector in the Translation base class
{ {
addPair("Formatted %s\n", L"フォーマット %s\n"); // should align with unchanged addPair("Formatted %s\n", L"フォーマット済みの %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L" %s\n"); // should align with formatted addPair("Unchanged %s\n", L"わりません %s\n"); // should align with formatted
addPair("Directory %s\n", L"ディレクトリ %s\n"); addPair("Directory %s\n", L"ディレクトリ %s\n");
addPair("Exclude %s\n", L"除外する %s\n"); addPair("Exclude %s\n", L"除外する %s\n");
addPair("Exclude (unmatched) %s\n", L"除外(マッチせず) %s\n"); addPair("Exclude (unmatched) %s\n", L"除外する(一致しません) %s\n");
addPair(" %s formatted %s unchanged ", L" %sフォーマット %s 変更 "); addPair(" %s formatted %s unchanged ", L" %s フフォーマット済みの %s 変わりません ");
addPair(" seconds ", L""); addPair(" seconds ", L"");
addPair("%d min %d sec ", L"%d 分 %d 秒 "); addPair("%d min %d sec ", L"%d 分 %d 秒 ");
addPair("%s lines\n", L"%s の行\n"); addPair("%s lines\n", L"%s ライン\n");
addPair("Using default options file %s\n", L"デフォルトの設定ファイルを使用してください %s\n"); addPair("Using default options file %s\n", L"デフォルトのオプションファイルを使用して、 %s\n");
addPair("Opening HTML documentation %s\n", L"HTML文書を開く %s\n"); addPair("Opening HTML documentation %s\n", L"オープニングHTMLドキュメント %s\n");
addPair("Invalid option file options:", L"無効なコンフィギュレーションファイルオプション:"); addPair("Invalid option file options:", L"無効なオプションファイルのオプション:");
addPair("Invalid command line options:", L"無効なコマンドラインオプション:"); addPair("Invalid command line options:", L"無効なコマンドラインオプション:");
addPair("For help on options type 'astyle -h'", L"マンドラインについてのヘルプは'astyle- h'を入力してください"); addPair("For help on options type 'astyle -h'", L"オプションの種類のヘルプについて'astyle- h'を入力してください");
addPair("Cannot open options file", L"コンフィギュレーションファイルを開くことができません"); addPair("Cannot open options file", L"オプションファイルを開くことができません");
addPair("Cannot open directory", L"ディレクトリのオープンに失敗しました"); addPair("Cannot open directory", L"ディレクトリを開くことができません。");
addPair("Cannot open HTML file %s\n", L"HTMLファイルを開くことができません %s\n"); addPair("Cannot open HTML file %s\n", L"HTMLファイルを開くことができません %s\n");
addPair("Command execute failure", L"コマンドの失敗を実行"); addPair("Command execute failure", L"コマンドが失敗を実行します");
addPair("Command is not installed", L"コマンドがインストールされていません"); addPair("Command is not installed", L"コマンドがインストールされていません");
addPair("Missing filename in %s\n", L"%s はファイル名で欠落しています\n"); addPair("Missing filename in %s\n", L"%s で、ファイル名がありません\n");
addPair("Recursive option with no wildcard", L"再帰的なオプションではワイルドカードではない"); addPair("Recursive option with no wildcard", L"無ワイルドカードを使用して再帰的なオプション");
addPair("Did you intend quote the filename", L"あなたは、ファイル名を参照するつもり"); addPair("Did you intend quote the filename", L"あなたはファイル名を引用するつもりでした");
addPair("No file to process %s\n", L"いいえファイルは処理できません %s\n"); addPair("No file to process %s\n", L"いいえファイルは処理しないように %s\n");
addPair("Did you intend to use --recursive", L"あなたが使用する予定 --recursive"); addPair("Did you intend to use --recursive", L"あなたは--recursive使用するつもりでした");
addPair("Cannot process UTF-32 encoding", L"UTF- 32エンコーディングを処理できない"); addPair("Cannot process UTF-32 encoding", L"UTF - 32エンコーディングを処理できません");
addPair("\nArtistic Style has terminated", L"\nArtistic Style 実行が終了しました"); addPair("\nArtistic Style has terminated", L"\nArtistic Style 終了しました");
} }
Korean::Korean() // 한국의 Korean::Korean() // 한국의
// build the translation vector in the Translation base class
{ {
addPair("Formatted %s\n", L"수정됨 %s\n"); // should align with unchanged addPair("Formatted %s\n", L"수정됨 %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"변경없음 %s\n"); // should align with formatted addPair("Unchanged %s\n", L"변경없음 %s\n"); // should align with formatted
@ -705,6 +843,37 @@ Korean::Korean() // 한국의
addPair("\nArtistic Style has terminated", L"\nArtistic Style를 종료합니다"); addPair("\nArtistic Style has terminated", L"\nArtistic Style를 종료합니다");
} }
Norwegian::Norwegian() // Norsk
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Formatert %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Uendret %s\n"); // should align with formatted
addPair("Directory %s\n", L"Katalog %s\n");
addPair("Exclude %s\n", L"Ekskluder %s\n");
addPair("Exclude (unmatched) %s\n", L"Ekskluder (uovertruffen) %s\n");
addPair(" %s formatted %s unchanged ", L" %s formatert %s uendret ");
addPair(" seconds ", L" sekunder ");
addPair("%d min %d sec ", L"%d min %d sek? ");
addPair("%s lines\n", L"%s linjer\n");
addPair("Using default options file %s\n", L"Ved hjelp av standardalternativer fil %s\n");
addPair("Opening HTML documentation %s\n", L"Åpning HTML dokumentasjon %s\n");
addPair("Invalid option file options:", L"Ugyldige alternativ filalternativer:");
addPair("Invalid command line options:", L"Kommandolinjevalg Ugyldige:");
addPair("For help on options type 'astyle -h'", L"For hjelp til alternativer type 'astyle -h'");
addPair("Cannot open options file", L"Kan ikke åpne alternativer fil");
addPair("Cannot open directory", L"Kan ikke åpne katalog");
addPair("Cannot open HTML file %s\n", L"Kan ikke åpne HTML-fil %s\n");
addPair("Command execute failure", L"Command utføre svikt");
addPair("Command is not installed", L"Command er ikke installert");
addPair("Missing filename in %s\n", L"Mangler filnavn i %s\n");
addPair("Recursive option with no wildcard", L"Rekursiv alternativ uten wildcard");
addPair("Did you intend quote the filename", L"Har du tenkt sitere filnavnet");
addPair("No file to process %s\n", L"Ingen fil å behandle %s\n");
addPair("Did you intend to use --recursive", L"Har du tenkt å bruke --recursive");
addPair("Cannot process UTF-32 encoding", L"Kan ikke behandle UTF-32 koding");
addPair("\nArtistic Style has terminated", L"\nArtistic Style har avsluttet");
}
Polish::Polish() // Polski Polish::Polish() // Polski
// build the translation vector in the Translation base class // build the translation vector in the Translation base class
{ {
@ -767,6 +936,37 @@ Portuguese::Portuguese() // Português
addPair("\nArtistic Style has terminated", L"\nArtistic Style terminou"); addPair("\nArtistic Style has terminated", L"\nArtistic Style terminou");
} }
Romanian::Romanian() // Română
// build the translation vector in the Translation base class
{
addPair("Formatted %s\n", L"Formatat %s\n"); // should align with unchanged
addPair("Unchanged %s\n", L"Neschimbat %s\n"); // should align with formatted
addPair("Directory %s\n", L"Director %s\n");
addPair("Exclude %s\n", L"Excludeți %s\n");
addPair("Exclude (unmatched) %s\n", L"Excludeți (necompensată) %s\n");
addPair(" %s formatted %s unchanged ", L" %s formatat %s neschimbat ");
addPair(" seconds ", L" secunde ");
addPair("%d min %d sec ", L"%d min %d sec ");
addPair("%s lines\n", L"%s linii\n");
addPair("Using default options file %s\n", L"Fișier folosind opțiunile implicite %s\n");
addPair("Opening HTML documentation %s\n", L"Documentație HTML deschidere %s\n");
addPair("Invalid option file options:", L"Opțiuni de opțiune de fișier nevalide:");
addPair("Invalid command line options:", L"Opțiuni de linie de comandă nevalide:");
addPair("For help on options type 'astyle -h'", L"Pentru ajutor cu privire la tipul de opțiuni 'astyle -h'");
addPair("Cannot open options file", L"Nu se poate deschide fișierul de opțiuni");
addPair("Cannot open directory", L"Nu se poate deschide directorul");
addPair("Cannot open HTML file %s\n", L"Nu se poate deschide fișierul HTML %s\n");
addPair("Command execute failure", L"Comandă executa eșec");
addPair("Command is not installed", L"Comanda nu este instalat");
addPair("Missing filename in %s\n", L"Lipsă nume de fișier %s\n");
addPair("Recursive option with no wildcard", L"Opțiunea recursiv cu nici un wildcard");
addPair("Did you intend quote the filename", L"V-intentionati cita numele de fișier");
addPair("No file to process %s\n", L"Nu există un fișier pentru a procesa %s\n");
addPair("Did you intend to use --recursive", L"V-ați intenționați să utilizați --recursive");
addPair("Cannot process UTF-32 encoding", L"Nu se poate procesa codificarea UTF-32");
addPair("\nArtistic Style has terminated", L"\nArtistic Style a terminat");
}
Russian::Russian() // русский Russian::Russian() // русский
// build the translation vector in the Translation base class // build the translation vector in the Translation base class
{ {

View File

@ -1,28 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ASLocalizer.h
* ASLocalizer.h // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
* // This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
*
* This file is a part of Artistic Style - an indentation and
* reformatting tool for C, C++, C# and Java source files.
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#ifndef ASLOCALIZER_H #ifndef ASLOCALIZER_H
#define ASLOCALIZER_H #define ASLOCALIZER_H
@ -45,7 +25,7 @@ class Translation;
class ASLocalizer class ASLocalizer
{ {
public: // functions public: // functions
ASLocalizer(); ASLocalizer();
virtual ~ASLocalizer(); virtual ~ASLocalizer();
string getLanguageID() const; string getLanguageID() const;
@ -56,10 +36,10 @@ class ASLocalizer
void setLanguageFromName(const char* langID); void setLanguageFromName(const char* langID);
const char* settext(const char* textIn) const; const char* settext(const char* textIn) const;
private: // functions private: // functions
void setTranslationClass(); void setTranslationClass();
private: // variables private: // variables
Translation* m_translation; // pointer to a polymorphic Translation class Translation* m_translation; // pointer to a polymorphic Translation class
string m_langID; // language identifier from the locale string m_langID; // language identifier from the locale
string m_subLangID; // sub language identifier, if needed string m_subLangID; // sub language identifier, if needed
@ -79,18 +59,21 @@ class Translation
// NOTE: This class must have virtual methods for typeid() to work. // NOTE: This class must have virtual methods for typeid() to work.
// typeid() is used by AStyleTestI18n_Localizer.cpp. // typeid() is used by AStyleTestI18n_Localizer.cpp.
{ {
public: public:
Translation() {} Translation() {}
virtual ~Translation() {} virtual ~Translation() {}
string convertToMultiByte(const wstring &wideStr) const; string convertToMultiByte(const wstring& wideStr) const;
size_t getTranslationVectorSize() const; size_t getTranslationVectorSize() const;
bool getWideTranslation(const string &stringIn, wstring &wideOut) const; bool getWideTranslation(const string& stringIn, wstring& wideOut) const;
string &translate(const string &stringIn) const; string& translate(const string& stringIn) const;
protected: protected:
void addPair(const string &english, const wstring &translated); void addPair(const string& english, const wstring& translated);
// variables // variables
vector<pair<string, wstring> > m_translation; // translation vector vector<pair<string, wstring> > m_translation; // translation vector
private:
mutable string m_mbTranslation;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -99,107 +82,74 @@ class Translation
// These classes have only a constructor which builds the language vector. // These classes have only a constructor which builds the language vector.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class Bulgarian : public Translation
{ public: Bulgarian(); };
class ChineseSimplified : public Translation class ChineseSimplified : public Translation
{ { public: ChineseSimplified(); };
public:
ChineseSimplified();
};
class ChineseTraditional : public Translation class ChineseTraditional : public Translation
{ { public: ChineseTraditional(); };
public:
ChineseTraditional();
};
class Dutch : public Translation class Dutch : public Translation
{ { public: Dutch(); };
public:
Dutch();
};
class English : public Translation class English : public Translation
{ { public: English(); };
public:
English(); class Estonian : public Translation
}; { public: Estonian(); };
class Finnish : public Translation class Finnish : public Translation
{ { public: Finnish(); };
public:
Finnish();
};
class French : public Translation class French : public Translation
{ { public: French(); };
public:
French();
};
class German : public Translation class German : public Translation
{ { public: German(); };
public:
German(); class Greek : public Translation
}; { public: Greek(); };
class Hindi : public Translation class Hindi : public Translation
{ { public: Hindi(); };
public:
Hindi(); class Hungarian : public Translation
}; { public: Hungarian(); };
class Italian : public Translation class Italian : public Translation
{ { public: Italian(); };
public:
Italian();
};
class Japanese : public Translation class Japanese : public Translation
{ { public: Japanese(); };
public:
Japanese();
};
class Korean : public Translation class Korean : public Translation
{ { public: Korean(); };
public:
Korean(); class Norwegian : public Translation
}; { public: Norwegian(); };
class Polish : public Translation class Polish : public Translation
{ { public: Polish(); };
public:
Polish();
};
class Portuguese : public Translation class Portuguese : public Translation
{ { public: Portuguese(); };
public:
Portuguese(); class Romanian : public Translation
}; { public: Romanian(); };
class Russian : public Translation class Russian : public Translation
{ { public: Russian(); };
public:
Russian();
};
class Spanish : public Translation class Spanish : public Translation
{ { public: Spanish(); };
public:
Spanish();
};
class Swedish : public Translation class Swedish : public Translation
{ { public: Swedish(); };
public:
Swedish();
};
class Ukrainian : public Translation class Ukrainian : public Translation
{ { public: Ukrainian(); };
public:
Ukrainian();
};
#endif // ASTYLE_LIB #endif // ASTYLE_LIB

View File

@ -1,35 +1,21 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ASResource.cpp
* ASResource.cpp // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
* // This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
* //-----------------------------------------------------------------------------
* This file is a part of Artistic Style - an indentation and // headers
* reformatting tool for C, C++, C# and Java source files. //-----------------------------------------------------------------------------
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "astyle.h" #include "astyle.h"
#include <algorithm> #include <algorithm>
//-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
namespace astyle { namespace astyle {
//
const string ASResource::AS_IF = string("if"); const string ASResource::AS_IF = string("if");
const string ASResource::AS_ELSE = string("else"); const string ASResource::AS_ELSE = string("else");
const string ASResource::AS_FOR = string("for"); const string ASResource::AS_FOR = string("for");
@ -62,6 +48,7 @@ const string ASResource::AS_TRY = string("try");
const string ASResource::AS_CATCH = string("catch"); const string ASResource::AS_CATCH = string("catch");
const string ASResource::AS_THROW = string("throw"); const string ASResource::AS_THROW = string("throw");
const string ASResource::AS_FINALLY = string("finally"); 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_TRY = string("__try");
const string ASResource::_AS_FINALLY = string("__finally"); const string ASResource::_AS_FINALLY = string("__finally");
const string ASResource::_AS_EXCEPT = string("__except"); const string ASResource::_AS_EXCEPT = string("__except");
@ -277,6 +264,7 @@ void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool
headers->push_back(&AS_SET); headers->push_back(&AS_SET);
headers->push_back(&AS_ADD); headers->push_back(&AS_ADD);
headers->push_back(&AS_REMOVE); headers->push_back(&AS_REMOVE);
headers->push_back(&AS_USING);
} }
if (beautifier) if (beautifier)
@ -315,17 +303,19 @@ void ASResource::buildIndentableHeaders(vector<const string*>* indentableHeaders
*/ */
void ASResource::buildIndentableMacros(vector<const pair<const string, const string>* >* indentableMacros) void ASResource::buildIndentableMacros(vector<const pair<const string, const string>* >* indentableMacros)
{ {
// the pairs must be retained in memory typedef pair<const string, const string> macro_pair;
static const struct pair<const string, const string> macros[] =
// the pairs must be retained in memory because of pair pointers
static const macro_pair macros[] =
{ {
// wxWidgets // wxWidgets
make_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"), macro_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"),
make_pair("wxBEGIN_EVENT_TABLE", "wxEND_EVENT_TABLE"), macro_pair("wxBEGIN_EVENT_TABLE", "wxEND_EVENT_TABLE"),
// MFC // MFC
make_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"), macro_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"),
make_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"), macro_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"),
make_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"), macro_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"),
make_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"), macro_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"),
}; };
size_t elements = sizeof(macros) / sizeof(macros[0]); size_t elements = sizeof(macros) / sizeof(macros[0]);
@ -570,7 +560,7 @@ void ASResource::buildPreDefinitionHeaders(vector<const string*>* preDefinitionH
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// check if a specific line position contains a keyword. // check if a specific line position contains a keyword.
bool ASBase::findKeyword(const string &line, int i, const string &keyword) const bool ASBase::findKeyword(const string& line, int i, const string& keyword) const
{ {
assert(isCharPotentialHeader(line, i)); assert(isCharPotentialHeader(line, i));
// check the word // check the word
@ -586,7 +576,7 @@ bool ASBase::findKeyword(const string &line, int i, const string &keyword) const
if (isLegalNameChar(line[wordEnd])) if (isLegalNameChar(line[wordEnd]))
return false; return false;
// is not a keyword if part of a definition // is not a keyword if part of a definition
const char peekChar = peekNextChar(line, wordEnd - 1); const char peekChar = peekNextChar(line, (int)wordEnd - 1);
if (peekChar == ',' || peekChar == ')') if (peekChar == ',' || peekChar == ')')
return false; return false;
return true; return true;
@ -594,7 +584,7 @@ bool ASBase::findKeyword(const string &line, int i, const string &keyword) const
// get the current word on a line // get the current word on a line
// index must point to the beginning of the word // index must point to the beginning of the word
string ASBase::getCurrentWord(const string &line, size_t index) const string ASBase::getCurrentWord(const string& line, size_t index) const
{ {
assert(isCharPotentialHeader(line, index)); assert(isCharPotentialHeader(line, index));
size_t lineLength = line.length(); size_t lineLength = line.length();
@ -607,4 +597,71 @@ string ASBase::getCurrentWord(const string &line, size_t index) const
return line.substr(index, i - index); return line.substr(index, i - index);
} }
// check if a specific character can be used in a legal variable/method/class name
bool ASBase::isLegalNameChar(char ch) const
{
if (isWhiteSpace(ch)) return false;
if ((unsigned) ch > 127) return false;
return (isalnum((unsigned char) ch)
|| ch == '.' || ch == '_'
|| (isJavaStyle() && ch == '$')
|| (isSharpStyle() && ch == '@')); // may be used as a prefix
}
// check if a specific character can be part of a header
bool ASBase::isCharPotentialHeader(const string& line, size_t i) const
{
assert(!isWhiteSpace(line[i]));
char prevCh = ' ';
if (i > 0) prevCh = line[i - 1];
if (!isLegalNameChar(prevCh) && isLegalNameChar(line[i]))
return true;
return false;
}
// check if a specific character can be part of an operator
bool ASBase::isCharPotentialOperator(char ch) const
{
assert(!isWhiteSpace(ch));
if ((unsigned) ch > 127) return false;
return (ispunct((unsigned char) ch)
&& ch != '{' && ch != '}'
&& ch != '(' && ch != ')'
&& ch != '[' && ch != ']'
&& ch != ';' && ch != ','
&& ch != '#' && ch != '\\'
&& ch != '\'' && ch != '\"');
}
// check if a specific character is a digit
// NOTE: Visual C isdigit() gives assert error if char > 256
bool ASBase::isDigit(char ch) const
{
return (ch >= '0' && ch <= '9');
}
// check if a specific character is a digit separator
bool ASBase::isDigitSeparator(const string& line, int i) const
{
assert(line[i] == '\'');
// casting to (unsigned char) eliminates negative characters
// will get a "Debug Assertion Failed" if not cast
bool foundDigitSeparator = i > 0
&& isxdigit((unsigned char) line[i - 1])
&& i < (int) line.length() - 1
&& isxdigit((unsigned char) line[i + 1]);
return foundDigitSeparator;
}
// peek at the next unread character.
char ASBase::peekNextChar(const string& line, int i) const
{
char ch = ' ';
size_t peekNum = line.find_first_not_of(" \t", i + 1);
if (peekNum == string::npos)
return ch;
ch = line[peekNum];
return ch;
}
} // end namespace astyle } // end namespace astyle

View File

@ -1,32 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // astyle.h
* astyle.h // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
// This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
*
* This file is a part of Artistic Style - an indentation and
* reformatting tool for C, C++, C# and Java source files.
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#ifndef ASTYLE_H #ifndef ASTYLE_H
#define ASTYLE_H #define ASTYLE_H
//-----------------------------------------------------------------------------
// headers
//-----------------------------------------------------------------------------
#ifdef __VMS #ifdef __VMS
#define __USE_STD_IOSTREAM 1 #define __USE_STD_IOSTREAM 1
#include <assert> #include <assert>
@ -39,13 +22,16 @@
#include <string> #include <string>
#include <vector> #include <vector>
//-----------------------------------------------------------------------------
// declarations
//-----------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
#include <string.h> // need both string and string.h for GCC #include <string.h> // need both string and string.h for GCC
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4996) // secure version deprecation warnings #pragma warning(disable: 4267) // conversion from size_t to int
#pragma warning(disable: 4267) // 64 bit signed/unsigned loss of data
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__
@ -61,10 +47,18 @@
#pragma clang diagnostic ignored "-Wshorten-64-to-32" #pragma clang diagnostic ignored "-Wshorten-64-to-32"
#endif #endif
namespace astyle { //-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
namespace astyle {
//
using namespace std; using namespace std;
//----------------------------------------------------------------------------
// definitions
//----------------------------------------------------------------------------
enum FileType { C_TYPE = 0, JAVA_TYPE = 1, SHARP_TYPE = 2 }; enum FileType { C_TYPE = 0, JAVA_TYPE = 1, SHARP_TYPE = 2 };
/* The enums below are not recognized by 'vectors' in Microsoft Visual C++ /* The enums below are not recognized by 'vectors' in Microsoft Visual C++
@ -181,7 +175,7 @@ enum LineEndFormat
class ASSourceIterator class ASSourceIterator
{ {
public: public:
ASSourceIterator() {} ASSourceIterator() {}
virtual ~ASSourceIterator() {} virtual ~ASSourceIterator() {}
virtual int getStreamLength() const = 0; virtual int getStreamLength() const = 0;
@ -198,7 +192,7 @@ class ASSourceIterator
class ASResource class ASResource
{ {
public: public:
ASResource() {} ASResource() {}
virtual ~ASResource() {} virtual ~ASResource() {}
void buildAssignmentOperators(vector<const string*>* assignmentOperators); void buildAssignmentOperators(vector<const string*>* assignmentOperators);
@ -213,12 +207,12 @@ class ASResource
void buildPreCommandHeaders(vector<const string*>* preCommandHeaders, int fileType); void buildPreCommandHeaders(vector<const string*>* preCommandHeaders, int fileType);
void buildPreDefinitionHeaders(vector<const string*>* preDefinitionHeaders, int fileType); void buildPreDefinitionHeaders(vector<const string*>* preDefinitionHeaders, int fileType);
public: public:
static const string AS_IF, AS_ELSE; static const string AS_IF, AS_ELSE;
static const string AS_DO, AS_WHILE; static const string AS_DO, AS_WHILE;
static const string AS_FOR; static const string AS_FOR;
static const string AS_SWITCH, AS_CASE, AS_DEFAULT; static const string AS_SWITCH, AS_CASE, AS_DEFAULT;
static const string AS_TRY, AS_CATCH, AS_THROW, AS_THROWS, AS_FINALLY; static const string AS_TRY, AS_CATCH, AS_THROW, AS_THROWS, AS_FINALLY, AS_USING;
static const string _AS_TRY, _AS_FINALLY, _AS_EXCEPT; static const string _AS_TRY, _AS_FINALLY, _AS_EXCEPT;
static const string AS_PUBLIC, AS_PROTECTED, AS_PRIVATE; static const string AS_PUBLIC, AS_PROTECTED, AS_PRIVATE;
static const string AS_CLASS, AS_STRUCT, AS_UNION, AS_INTERFACE, AS_NAMESPACE; static const string AS_CLASS, AS_STRUCT, AS_UNION, AS_INTERFACE, AS_NAMESPACE;
@ -257,79 +251,35 @@ class ASResource
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Class ASBase // Class ASBase
// Functions definitions are at the end of ASResource.cpp.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class ASBase class ASBase
{ {
private: private:
// all variables should be set by the "init" function // all variables should be set by the "init" function
int baseFileType; // a value from enum FileType int baseFileType; // a value from enum FileType
protected: protected:
ASBase() : baseFileType(C_TYPE) { } ASBase() : baseFileType(C_TYPE) { }
virtual ~ASBase() {}
// functions definitions are at the end of ASResource.cpp protected: // inline functions
bool findKeyword(const string &line, int i, const string &keyword) const;
string getCurrentWord(const string &line, size_t index) const;
protected:
void init(int fileTypeArg) { baseFileType = fileTypeArg; } void init(int fileTypeArg) { baseFileType = fileTypeArg; }
bool isCStyle() const { return (baseFileType == C_TYPE); } bool isCStyle() const { return (baseFileType == C_TYPE); }
bool isJavaStyle() const { return (baseFileType == JAVA_TYPE); } bool isJavaStyle() const { return (baseFileType == JAVA_TYPE); }
bool isSharpStyle() const { return (baseFileType == SHARP_TYPE); } bool isSharpStyle() const { return (baseFileType == SHARP_TYPE); }
// check if a specific character is a digit
// NOTE: Visual C isdigit() gives assert error if char > 256
bool isDigit(char ch) const {
return (ch >= '0' && ch <= '9');
}
// check if a specific character can be used in a legal variable/method/class name
bool isLegalNameChar(char ch) const {
if (isWhiteSpace(ch)) return false;
if ((unsigned) ch > 127) return false;
return (isalnum((unsigned char)ch)
|| ch == '.' || ch == '_'
|| (isJavaStyle() && ch == '$')
|| (isSharpStyle() && ch == '@')); // may be used as a prefix
}
// check if a specific character can be part of a header
bool isCharPotentialHeader(const string &line, size_t i) const {
assert(!isWhiteSpace(line[i]));
char prevCh = ' ';
if (i > 0) prevCh = line[i - 1];
if (!isLegalNameChar(prevCh) && isLegalNameChar(line[i]))
return true;
return false;
}
// check if a specific character can be part of an operator
bool isCharPotentialOperator(char ch) const {
assert(!isWhiteSpace(ch));
if ((unsigned) ch > 127) return false;
return (ispunct((unsigned char)ch)
&& ch != '{' && ch != '}'
&& ch != '(' && ch != ')'
&& ch != '[' && ch != ']'
&& ch != ';' && ch != ','
&& ch != '#' && ch != '\\'
&& ch != '\'' && ch != '\"');
}
// check if a specific character is a whitespace character
bool isWhiteSpace(char ch) const { return (ch == ' ' || ch == '\t'); } bool isWhiteSpace(char ch) const { return (ch == ' ' || ch == '\t'); }
// peek at the next unread character. protected: // functions definitions are at the end of ASResource.cpp
char peekNextChar(const string &line, int i) const { bool findKeyword(const string& line, int i, const string& keyword) const;
char ch = ' '; string getCurrentWord(const string& line, size_t index) const;
size_t peekNum = line.find_first_not_of(" \t", i + 1); bool isDigit(char ch) const;
if (peekNum == string::npos) bool isLegalNameChar(char ch) const;
return ch; bool isCharPotentialHeader(const string& line, size_t i) const;
ch = line[peekNum]; bool isCharPotentialOperator(char ch) const;
return ch; bool isDigitSeparator(const string& line, int i) const;
} char peekNextChar(const string& line, int i) const;
}; // Class ASBase }; // Class ASBase
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -338,11 +288,11 @@ class ASBase
class ASBeautifier : protected ASResource, protected ASBase class ASBeautifier : protected ASResource, protected ASBase
{ {
public: public:
ASBeautifier(); ASBeautifier();
virtual ~ASBeautifier(); virtual ~ASBeautifier();
virtual void init(ASSourceIterator* iter); virtual void init(ASSourceIterator* iter);
virtual string beautify(const string &line); virtual string beautify(const string& line);
void setCaseIndent(bool state); void setCaseIndent(bool state);
void setClassIndent(bool state); void setClassIndent(bool state);
void setCStyle(); void setCStyle();
@ -369,7 +319,8 @@ class ASBeautifier : protected ASResource, protected ASBase
int getIndentLength(void) const; int getIndentLength(void) const;
int getTabLength(void) const; int getTabLength(void) const;
string getIndentString(void) const; string getIndentString(void) const;
string getNextWord(const string &line, size_t currPos) const; string getNextWord(const string& line, size_t currPos) const;
bool getAlignMethodColon(void) const;
bool getBracketIndent(void) const; bool getBracketIndent(void) const;
bool getBlockIndent(void) const; bool getBlockIndent(void) const;
bool getCaseIndent(void) const; bool getCaseIndent(void) const;
@ -382,25 +333,26 @@ class ASBeautifier : protected ASResource, protected ASBase
bool getPreprocDefineIndent(void) const; bool getPreprocDefineIndent(void) const;
bool getSwitchIndent(void) const; bool getSwitchIndent(void) const;
protected: protected:
void deleteBeautifierVectors(); void deleteBeautifierVectors();
const string* findHeader(const string &line, int i, const string* findHeader(const string& line, int i,
const vector<const string*>* possibleHeaders) const; const vector<const string*>* possibleHeaders) const;
const string* findOperator(const string &line, int i, const string* findOperator(const string& line, int i,
const vector<const string*>* possibleOperators) const; const vector<const string*>* possibleOperators) const;
int getNextProgramCharDistance(const string &line, int i) const; int getNextProgramCharDistance(const string& line, int i) const;
int indexOf(vector<const string*> &container, const string* element) const; int indexOf(vector<const string*>& container, const string* element) const;
void setBlockIndent(bool state); void setBlockIndent(bool state);
void setBracketIndent(bool state); void setBracketIndent(bool state);
void setBracketIndentVtk(bool state); void setBracketIndentVtk(bool state);
string extractPreprocessorStatement(const string &line) const; string extractPreprocessorStatement(const string& line) const;
string trim(const string &str) const; string trim(const string& str) const;
string rtrim(const string &str) const; string rtrim(const string& str) const;
// variables set by ASFormatter - must be updated in activeBeautifierStack // variables set by ASFormatter - must be updated in activeBeautifierStack
int inLineNumber; int inLineNumber;
int horstmannIndentInStatement; int horstmannIndentInStatement;
int nonInStatementBracket; int nonInStatementBracket;
int objCColonAlignSubsequent; // for subsequent lines not counting indent
bool lineCommentNoBeautify; bool lineCommentNoBeautify;
bool isElseHeaderIndent; bool isElseHeaderIndent;
bool isCaseHeaderCommentIndent; bool isCaseHeaderCommentIndent;
@ -412,42 +364,42 @@ class ASBeautifier : protected ASResource, protected ASBase
bool isInIndentableStruct; bool isInIndentableStruct;
bool isInIndentablePreproc; bool isInIndentablePreproc;
private: // functions private: // functions
ASBeautifier(const ASBeautifier &copy); ASBeautifier(const ASBeautifier& copy); // inline functions
ASBeautifier &operator=(ASBeautifier &); // not to be implemented ASBeautifier& operator=(ASBeautifier&); // not to be implemented
void adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHeaderIndent); void adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHeaderIndent);
void computePreliminaryIndentation(); void computePreliminaryIndentation();
void parseCurrentLine(const string &line); void parseCurrentLine(const string& line);
void popLastInStatementIndent(); void popLastInStatementIndent();
void processPreprocessor(const string &preproc, const string &line); void processPreprocessor(const string& preproc, const string& line);
void registerInStatementIndent(const string &line, int i, int spaceIndentCount, void registerInStatementIndent(const string& line, int i, int spaceIndentCount,
int tabIncrementIn, int minIndent, bool updateParenStack); int tabIncrementIn, int minIndent, bool updateParenStack);
void registerInStatementIndentColon(const string &line, int i, int tabIncrementIn); void registerInStatementIndentColon(const string& line, int i, int tabIncrementIn);
void initVectors(); void initVectors();
void initTempStacksContainer(vector<vector<const string*>*>* &container, void initTempStacksContainer(vector<vector<const string*>*>*& container,
vector<vector<const string*>*>* value); vector<vector<const string*>*>* value);
void clearObjCMethodDefinitionAlignment(); void clearObjCMethodDefinitionAlignment();
void deleteBeautifierContainer(vector<ASBeautifier*>* &container); void deleteBeautifierContainer(vector<ASBeautifier*>*& container);
void deleteTempStacksContainer(vector<vector<const string*>*>* &container); void deleteTempStacksContainer(vector<vector<const string*>*>*& container);
int adjustIndentCountForBreakElseIfComments() const; int adjustIndentCountForBreakElseIfComments() const;
int computeObjCColonAlignment(string &line, int colonAlignPosition) const; int computeObjCColonAlignment(string& line, int colonAlignPosition) const;
int convertTabToSpaces(int i, int tabIncrementIn) const; int convertTabToSpaces(int i, int tabIncrementIn) const;
int getInStatementIndentAssign(const string &line, size_t currPos) const; int getInStatementIndentAssign(const string& line, size_t currPos) const;
int getInStatementIndentComma(const string &line, size_t currPos) const; int getInStatementIndentComma(const string& line, size_t currPos) const;
bool isIndentedPreprocessor(const string &line, size_t currPos) const; bool isIndentedPreprocessor(const string& line, size_t currPos) const;
bool isLineEndComment(const string &line, int startPos) const; bool isLineEndComment(const string& line, int startPos) const;
bool isPreprocessorConditionalCplusplus(const string &line) const; bool isPreprocessorConditionalCplusplus(const string& line) const;
bool isInPreprocessorUnterminatedComment(const string &line); bool isInPreprocessorUnterminatedComment(const string& line);
bool statementEndsWithComma(const string &line, int index) const; bool statementEndsWithComma(const string& line, int index) const;
string &getIndentedLineReturn(string &newLine, const string &originalLine) const; string& getIndentedLineReturn(string& newLine, const string& originalLine) const;
string preLineWS(int lineIndentCount, int lineSpaceIndentCount) const; string preLineWS(int lineIndentCount, int lineSpaceIndentCount) const;
template<typename T> void deleteContainer(T &container); template<typename T> void deleteContainer(T& container);
template<typename T> void initContainer(T &container, T value); template<typename T> void initContainer(T& container, T value);
vector<vector<const string*>*>* copyTempStacks(const ASBeautifier &other) const; vector<vector<const string*>*>* copyTempStacks(const ASBeautifier& other) const;
pair<int, int> computePreprocessorIndent(); pair<int, int> computePreprocessorIndent();
private: // variables private: // variables
int beautifierFileType; int beautifierFileType;
vector<const string*>* headers; vector<const string*>* headers;
vector<const string*>* nonParenHeaders; vector<const string*>* nonParenHeaders;
@ -573,26 +525,26 @@ class ASBeautifier : protected ASResource, protected ASBase
class ASEnhancer : protected ASBase class ASEnhancer : protected ASBase
{ {
public: // functions public: // functions
ASEnhancer(); ASEnhancer();
virtual ~ASEnhancer(); virtual ~ASEnhancer();
void init(int, int, int, bool, bool, bool, bool, bool, bool, bool, void init(int, int, int, bool, bool, bool, bool, bool, bool, bool,
vector<const pair<const string, const string>* >*); vector<const pair<const string, const string>* >*);
void enhance(string &line, bool isInNamespace, bool isInPreprocessor, bool isInSQL); void enhance(string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL);
private: // functions private: // functions
void convertForceTabIndentToSpaces(string &line) const; void convertForceTabIndentToSpaces(string& line) const;
void convertSpaceIndentToForceTab(string &line) const; void convertSpaceIndentToForceTab(string& line) const;
size_t findCaseColon(string &line, size_t caseIndex) const; size_t findCaseColon(string& line, size_t caseIndex) const;
int indentLine(string &line, int indent) const; int indentLine(string& line, int indent) const;
bool isBeginDeclareSectionSQL(string &line, size_t index) const; bool isBeginDeclareSectionSQL(string& line, size_t index) const;
bool isEndDeclareSectionSQL(string &line, size_t index) const; bool isEndDeclareSectionSQL(string& line, size_t index) const;
bool isOneLineBlockReached(string &line, int startChar) const; bool isOneLineBlockReached(string& line, int startChar) const;
void parseCurrentLine(string &line, bool isInPreprocessor, bool isInSQL); void parseCurrentLine(string& line, bool isInPreprocessor, bool isInSQL);
size_t processSwitchBlock(string &line, size_t index); size_t processSwitchBlock(string& line, size_t index);
int unindentLine(string &line, int unindent) const; int unindentLine(string& line, int unindent) const;
private: private:
// options from command line or options file // options from command line or options file
int indentLength; int indentLength;
int tabLength; int tabLength;
@ -621,15 +573,15 @@ class ASEnhancer : protected ASBase
// struct used by ParseFormattedLine function // struct used by ParseFormattedLine function
// contains variables used to unindent the case blocks // contains variables used to unindent the case blocks
struct switchVariables struct SwitchVariables
{ {
int switchBracketCount; int switchBracketCount;
int unindentDepth; int unindentDepth;
bool unindentCase; bool unindentCase;
}; };
switchVariables sw; // switch variables struct SwitchVariables sw; // switch variables struct
vector<switchVariables> switchStack; // stack vector of switch variables vector<SwitchVariables> switchStack; // stack vector of switch variables
// event table variables // event table variables
bool nextLineIsEventIndent; // begin event table indent is reached bool nextLineIsEventIndent; // begin event table indent is reached
@ -648,7 +600,7 @@ class ASEnhancer : protected ASBase
class ASFormatter : public ASBeautifier class ASFormatter : public ASBeautifier
{ {
public: // functions public: // functions
ASFormatter(); ASFormatter();
virtual ~ASFormatter(); virtual ~ASFormatter();
virtual void init(ASSourceIterator* iter); virtual void init(ASSourceIterator* iter);
@ -673,7 +625,10 @@ class ASFormatter : public ASBeautifier
void setBreakOneLineBlocksMode(bool state); void setBreakOneLineBlocksMode(bool state);
void setMethodPrefixPaddingMode(bool state); void setMethodPrefixPaddingMode(bool state);
void setMethodPrefixUnPaddingMode(bool state); void setMethodPrefixUnPaddingMode(bool state);
void setReturnTypePaddingMode(bool state);
void setReturnTypeUnPaddingMode(bool state);
void setCloseTemplatesMode(bool state); void setCloseTemplatesMode(bool state);
void setCommaPaddingMode(bool state);
void setDeleteEmptyLinesMode(bool state); void setDeleteEmptyLinesMode(bool state);
void setIndentCol1CommentsMode(bool state); void setIndentCol1CommentsMode(bool state);
void setLineEndFormat(LineEndFormat fmt); void setLineEndFormat(LineEndFormat fmt);
@ -696,16 +651,16 @@ class ASFormatter : public ASBeautifier
int getChecksumDiff() const; int getChecksumDiff() const;
int getFormatterFileType() const; int getFormatterFileType() const;
private: // functions private: // functions
ASFormatter(const ASFormatter &copy); // copy constructor not to be implemented ASFormatter(const ASFormatter& copy); // not to be implemented
ASFormatter &operator=(ASFormatter &); // assignment operator not to be implemented ASFormatter& operator=(ASFormatter&); // not to be implemented
template<typename T> void deleteContainer(T &container); template<typename T> void deleteContainer(T& container);
template<typename T> void initContainer(T &container, T value); template<typename T> void initContainer(T& container, T value);
char peekNextChar() const; char peekNextChar() const;
BracketType getBracketType(); BracketType getBracketType();
bool adjustChecksumIn(int adjustment); bool adjustChecksumIn(int adjustment);
bool computeChecksumIn(const string &currentLine_); bool computeChecksumIn(const string& currentLine_);
bool computeChecksumOut(const string &beautifiedLine); bool computeChecksumOut(const string& beautifiedLine);
bool addBracketsToStatement(); bool addBracketsToStatement();
bool removeBracketsFromStatement(); bool removeBracketsFromStatement();
bool commentAndHeaderFollows(); bool commentAndHeaderFollows();
@ -721,18 +676,19 @@ class ASFormatter : public ASBeautifier
bool isClosingHeader(const string* header) const; bool isClosingHeader(const string* header) const;
bool isCurrentBracketBroken() const; bool isCurrentBracketBroken() const;
bool isDereferenceOrAddressOf() const; bool isDereferenceOrAddressOf() const;
bool isExecSQL(string &line, size_t index) const; bool isExecSQL(string& line, size_t index) const;
bool isEmptyLine(const string &line) const; bool isEmptyLine(const string& line) const;
bool isExternC() const; bool isExternC() const;
bool isNextWordSharpNonParenHeader(int startChar) const; bool isNextWordSharpNonParenHeader(int startChar) const;
bool isNonInStatementArrayBracket() const; bool isNonInStatementArrayBracket() const;
bool isOkToSplitFormattedLine(); bool isOkToSplitFormattedLine();
bool isPointerOrReference() const; bool isPointerOrReference() const;
bool isPointerOrReferenceCentered() const; bool isPointerOrReferenceCentered() const;
bool isPointerOrReferenceVariable(string &word) const; bool isPointerOrReferenceVariable(string& word) const;
bool isSharpStyleWithParen(const string* header) const; bool isSharpStyleWithParen(const string* header) const;
bool isStructAccessModified(string &firstLine, size_t index) const; bool isStructAccessModified(string& firstLine, size_t index) const;
bool isIndentablePreprocessorBlock(string &firstLine, size_t index); bool isIndentablePreprocessorBlock(string& firstLine, size_t index);
bool isNDefPreprocStatement(string& firstLine, string& preproc) const;
bool isUnaryOperator() const; bool isUnaryOperator() const;
bool isUniformInitializerBracket() const; bool isUniformInitializerBracket() const;
bool isImmediatelyPostCast() const; bool isImmediatelyPostCast() const;
@ -742,24 +698,25 @@ class ASFormatter : public ASBeautifier
bool isOkToBreakBlock(BracketType bracketType) const; bool isOkToBreakBlock(BracketType bracketType) const;
bool isOperatorPaddingDisabled() const; bool isOperatorPaddingDisabled() const;
bool pointerSymbolFollows() const; bool pointerSymbolFollows() const;
int findObjCColonAlignment() const;
int getCurrentLineCommentAdjustment(); int getCurrentLineCommentAdjustment();
int getNextLineCommentAdjustment(); int getNextLineCommentAdjustment();
int isOneLineBlockReached(string &line, int startChar) const; int isOneLineBlockReached(string& line, int startChar) const;
void adjustComments(); void adjustComments();
void appendChar(char ch, bool canBreakLine); void appendChar(char ch, bool canBreakLine);
void appendCharInsideComments(); void appendCharInsideComments();
void appendOperator(const string &sequence, bool canBreakLine = true); void appendOperator(const string& sequence, bool canBreakLine = true);
void appendSequence(const string &sequence, bool canBreakLine = true); void appendSequence(const string& sequence, bool canBreakLine = true);
void appendSpacePad(); void appendSpacePad();
void appendSpaceAfter(); void appendSpaceAfter();
void breakLine(bool isSplitLine = false); void breakLine(bool isSplitLine = false);
void buildLanguageVectors(); void buildLanguageVectors();
void updateFormattedLineSplitPoints(char appendedChar); void updateFormattedLineSplitPoints(char appendedChar);
void updateFormattedLineSplitPointsOperator(const string &sequence); void updateFormattedLineSplitPointsOperator(const string& sequence);
void checkIfTemplateOpener(); void checkIfTemplateOpener();
void clearFormattedLineSplitPoints(); void clearFormattedLineSplitPoints();
void convertTabToSpaces(); void convertTabToSpaces();
void deleteContainer(vector<BracketType>* &container); void deleteContainer(vector<BracketType>*& container);
void formatArrayRunIn(); void formatArrayRunIn();
void formatRunIn(); void formatRunIn();
void formatArrayBrackets(BracketType bracketType, bool isOpeningArrayBracket); void formatArrayBrackets(BracketType bracketType, bool isOpeningArrayBracket);
@ -780,27 +737,27 @@ class ASFormatter : public ASBeautifier
void fixOptionVariableConflicts(); void fixOptionVariableConflicts();
void goForward(int i); void goForward(int i);
void isLineBreakBeforeClosingHeader(); void isLineBreakBeforeClosingHeader();
void initContainer(vector<BracketType>* &container, vector<BracketType>* value); void initContainer(vector<BracketType>*& container, vector<BracketType>* value);
void initNewLine(); void initNewLine();
void padObjCMethodColon(); void padObjCMethodColon();
void padOperators(const string* newOperator); void padOperators(const string* newOperator);
void padParens(); void padParens();
void padParenObjC(void);
void processPreprocessor(); void processPreprocessor();
void resetEndOfStatement(); void resetEndOfStatement();
void setAttachClosingBracketMode(bool state); void setAttachClosingBracketMode(bool state);
void setBreakBlocksVariables();
void stripCommentPrefix(); void stripCommentPrefix();
void testForTimeToSplitFormattedLine(); void testForTimeToSplitFormattedLine();
void trimContinuationLine(); void trimContinuationLine();
void updateFormattedLineSplitPointsPointerOrReference(size_t index); void updateFormattedLineSplitPointsPointerOrReference(size_t index);
size_t findFormattedLineSplitPoint() const; size_t findFormattedLineSplitPoint() const;
size_t findNextChar(string &line, char searchChar, int searchStart = 0); size_t findNextChar(string& line, char searchChar, int searchStart = 0) const;
const string* checkForHeaderFollowingComment(const string &firstLine) const; const string* checkForHeaderFollowingComment(const string& firstLine) const;
const string* getFollowingOperator() const; const string* getFollowingOperator() const;
string getPreviousWord(const string &line, int currPos) 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, bool shouldReset = false) const;
private: // variables private: // variables
int formatterFileType; int formatterFileType;
vector<const string*>* headers; vector<const string*>* headers;
vector<const string*>* nonParenHeaders; vector<const string*>* nonParenHeaders;
@ -835,6 +792,7 @@ class ASFormatter : public ASBeautifier
int charNum; int charNum;
int horstmannIndentChars; int horstmannIndentChars;
int nextLineSpacePadNum; int nextLineSpacePadNum;
int objCColonAlign;
int preprocBracketTypeStackSize; int preprocBracketTypeStackSize;
int spacePadNum; int spacePadNum;
int tabIncrementIn; int tabIncrementIn;
@ -868,6 +826,7 @@ class ASFormatter : public ASBeautifier
ObjCColonPad objCColonPadMode; ObjCColonPad objCColonPadMode;
LineEndFormat lineEnd; LineEndFormat lineEnd;
bool isVirgin; bool isVirgin;
bool shouldPadCommas;
bool shouldPadOperators; bool shouldPadOperators;
bool shouldPadParensOutside; bool shouldPadParensOutside;
bool shouldPadFirstParen; bool shouldPadFirstParen;
@ -941,6 +900,7 @@ class ASFormatter : public ASBeautifier
bool isCharImmediatelyPostPointerOrReference; bool isCharImmediatelyPostPointerOrReference;
bool isInObjCMethodDefinition; bool isInObjCMethodDefinition;
bool isInObjCInterface; bool isInObjCInterface;
bool isInObjCReturnType;
bool isInObjCSelector; bool isInObjCSelector;
bool breakCurrentOneLineBlock; bool breakCurrentOneLineBlock;
bool shouldRemoveNextClosingBracket; bool shouldRemoveNextClosingBracket;
@ -959,6 +919,8 @@ class ASFormatter : public ASBeautifier
bool shouldPadMethodColon; bool shouldPadMethodColon;
bool shouldPadMethodPrefix; bool shouldPadMethodPrefix;
bool shouldUnPadMethodPrefix; bool shouldUnPadMethodPrefix;
bool shouldPadReturnType;
bool shouldUnPadReturnType;
bool shouldDeleteEmptyLines; bool shouldDeleteEmptyLines;
bool needHeaderOpeningBracket; bool needHeaderOpeningBracket;
bool shouldBreakLineAtNextChar; bool shouldBreakLineAtNextChar;
@ -970,6 +932,7 @@ class ASFormatter : public ASBeautifier
bool isImmediatelyPostComment; bool isImmediatelyPostComment;
bool isImmediatelyPostLineComment; bool isImmediatelyPostLineComment;
bool isImmediatelyPostEmptyBlock; bool isImmediatelyPostEmptyBlock;
bool isImmediatelyPostObjCMethodPrefix;
bool isImmediatelyPostPreprocessor; bool isImmediatelyPostPreprocessor;
bool isImmediatelyPostReturn; bool isImmediatelyPostReturn;
bool isImmediatelyPostThrow; bool isImmediatelyPostThrow;
@ -992,29 +955,32 @@ class ASFormatter : public ASBeautifier
bool processedFirstConditional; bool processedFirstConditional;
bool isJavaStaticConstructor; bool isJavaStaticConstructor;
private: // inline functions private: // inline functions
// append the CURRENT character (curentChar) to the current formatted line. // append the CURRENT character (curentChar) to the current formatted line.
void appendCurrentChar(bool canBreakLine = true) { 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 // check if a specific sequence exists in the current placement of the current line
bool isSequenceReached(const char* sequence) const { 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 // call ASBase::findHeader for the current character
const string* findHeader(const vector<const string*>* headers_) { const string* findHeader(const vector<const string*>* headers_)
{
return ASBeautifier::findHeader(currentLine, charNum, headers_); return ASBeautifier::findHeader(currentLine, charNum, headers_);
} }
// call ASBase::findOperator for the current character // call ASBase::findOperator for the current character
const string* findOperator(const vector<const string*>* headers_) { const string* findOperator(const vector<const string*>* headers_)
{
return ASBeautifier::findOperator(currentLine, charNum, headers_); return ASBeautifier::findOperator(currentLine, charNum, headers_);
} }
}; // Class ASFormatter }; // Class ASFormatter
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// astyle namespace global declarations // astyle namespace global declarations
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -1,52 +1,37 @@
// astyle_main.cpp
// Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
// This code is licensed under the MIT License.
// License.txt describes the conditions under which this software may be distributed.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* astyle_main.cpp * AStyle_main source file map.
* * This source file contains several classes.
* Copyright (C) 2014 by Jim Pattee * They are arranged as follows.
* <http://www.gnu.org/licenses/lgpl-3.0.html> * ---------------------------------------
* * namespace astyle {
* This file is a part of Artistic Style - an indentation and * ASStreamIterator methods
* reformatting tool for C, C++, C# and Java source files. * ASConsole methods
* <http://astyle.sourceforge.net> * // Windows specific
* * // Linux specific
* Artistic Style is free software: you can redistribute it and/or modify * ASLibrary methods
* it under the terms of the GNU Lesser General Public License as published * // Windows specific
* by the Free Software Foundation, either version 3 of the License, or * // Linux specific
* (at your option) any later version. * ASOptions methods
* * Utf8_16 methods
* Artistic Style is distributed in the hope that it will be useful, * } // end of astyle namespace
* but WITHOUT ANY WARRANTY; without even the implied warranty of * Global Area ---------------------------
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Java Native Interface functions
* GNU Lesser General Public License for more details. * AStyleMainUtf16 entry point
* * AStyleMain entry point
* You should have received a copy of the GNU Lesser General Public License * AStyleGetVersion entry point
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>. * main entry point
* * ---------------------------------------
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
/*
AStyle_main source file map. //-----------------------------------------------------------------------------
This source file contains several classes. // headers
They are arranged as follows. //-----------------------------------------------------------------------------
---------------------------------------
namespace astyle {
ASStreamIterator methods
ASConsole methods
// Windows specific
// Linux specific
ASLibrary methods
// Windows specific
// Linux specific
ASOptions methods
Utf8_16 methods
} // end of astyle namespace
Global Area ---------------------------
Java Native Interface functions
AStyleMainUtf16 entry point
AStyleMain entry point
AStyleGetVersion entry point
main entry point
---------------------------------------
*/
#include "astyle_main.h" #include "astyle_main.h"
@ -54,6 +39,7 @@
#include <cstdlib> #include <cstdlib>
#include <errno.h> #include <errno.h>
#include <fstream> #include <fstream>
#include <locale.h> // needed by some compilers
#include <sstream> #include <sstream>
// includes for recursive getFileNames() function // includes for recursive getFileNames() function
@ -74,9 +60,9 @@
#endif /* __VMS */ #endif /* __VMS */
#endif #endif
#ifdef __DMC__ //-----------------------------------------------------------------------------
#include <locale.h> // declarations
#endif //-----------------------------------------------------------------------------
// turn off MinGW automatic file globbing // turn off MinGW automatic file globbing
// this CANNOT be in the astyle namespace // this CANNOT be in the astyle namespace
@ -89,17 +75,17 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
namespace astyle { namespace astyle {
//
// console build variables // console build variables
#ifndef ASTYLE_LIB #ifndef ASTYLE_LIB
ASConsole* g_console = NULL; // class to encapsulate console variables ASConsole* g_console = NULL; // class to encapsulate console variables
ostream* _err = &cerr; // direct error messages to cerr ostream* _err = &cerr; // direct error messages to cerr
#ifdef _WIN32 #ifdef _WIN32
char g_fileSeparator = '\\'; // Windows file separator char g_fileSeparator = '\\'; // Windows file separator
bool g_isCaseSensitive = false; // Windows IS case sensitive bool g_isCaseSensitive = false; // Windows IS NOT case sensitive
#else #else
char g_fileSeparator = '/'; // Linux file separator char g_fileSeparator = '/'; // Linux file separator
bool g_isCaseSensitive = true; // Linux IS NOT case sensitive bool g_isCaseSensitive = true; // Linux IS case sensitive
#endif // _WIN32 #endif // _WIN32
#endif // ASTYLE_LIB #endif // ASTYLE_LIB
@ -110,7 +96,7 @@ namespace astyle {
jmethodID g_mid; jmethodID g_mid;
#endif #endif
const char* g_version = "2.05.1"; const char* g_version = "2.06 beta";
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// ASStreamIterator class // ASStreamIterator class
@ -125,7 +111,6 @@ ASStreamIterator<T>::ASStreamIterator(T* in)
eolWindows = 0; eolWindows = 0;
eolLinux = 0; eolLinux = 0;
eolMacOld = 0; eolMacOld = 0;
outputEOL[0] = '\0';
peekStart = 0; peekStart = 0;
prevLineDeleted = false; prevLineDeleted = false;
checkForEmptyLine = false; checkForEmptyLine = false;
@ -227,14 +212,14 @@ string ASStreamIterator<T>::nextLine(bool emptyLineWasDeleted)
if (eolWindows >= eolLinux) if (eolWindows >= eolLinux)
{ {
if (eolWindows >= eolMacOld) if (eolWindows >= eolMacOld)
strcpy(outputEOL, "\r\n"); // Windows (CR+LF) outputEOL = "\r\n"; // Windows (CR+LF)
else else
strcpy(outputEOL, "\r"); // MacOld (CR) outputEOL = "\r"; // MacOld (CR)
} }
else if (eolLinux >= eolMacOld) else if (eolLinux >= eolMacOld)
strcpy(outputEOL, "\n"); // Linux (LF) outputEOL = "\n"; // Linux (LF)
else else
strcpy(outputEOL, "\r"); // MacOld (CR) outputEOL = "\r"; // MacOld (CR)
return buffer; return buffer;
} }
@ -339,12 +324,12 @@ bool ASStreamIterator<T>::getLineEndChange(int lineEndFormat) const
#ifndef ASTYLE_LIB #ifndef ASTYLE_LIB
// rewrite a stringstream converting the line ends // rewrite a stringstream converting the line ends
void ASConsole::convertLineEnds(ostringstream &out, int lineEnd) void ASConsole::convertLineEnds(ostringstream& out, int lineEnd)
{ {
assert(lineEnd == LINEEND_WINDOWS || lineEnd == LINEEND_LINUX || lineEnd == LINEEND_MACOLD); assert(lineEnd == LINEEND_WINDOWS || lineEnd == LINEEND_LINUX || lineEnd == LINEEND_MACOLD);
const string &inStr = out.str(); // avoids strange looking syntax const string& inStr = out.str(); // avoids strange looking syntax
string outStr; // the converted output string outStr; // the converted output
int inLength = inStr.length(); int inLength = (int)inStr.length();
for (int pos = 0; pos < inLength; pos++) for (int pos = 0; pos < inLength; pos++)
{ {
if (inStr[pos] == '\r') if (inStr[pos] == '\r')
@ -422,14 +407,14 @@ void ASConsole::convertLineEnds(ostringstream &out, int lineEnd)
out.str(outStr); out.str(outStr);
} }
void ASConsole::correctMixedLineEnds(ostringstream &out) void ASConsole::correctMixedLineEnds(ostringstream& out)
{ {
LineEndFormat lineEndFormat = LINEEND_DEFAULT; LineEndFormat lineEndFormat = LINEEND_DEFAULT;
if (strcmp(outputEOL, "\r\n") == 0) if (outputEOL == "\r\n")
lineEndFormat = LINEEND_WINDOWS; lineEndFormat = LINEEND_WINDOWS;
if (strcmp(outputEOL, "\n") == 0) if (outputEOL == "\n")
lineEndFormat = LINEEND_LINUX; lineEndFormat = LINEEND_LINUX;
if (strcmp(outputEOL, "\r") == 0) if (outputEOL == "\r")
lineEndFormat = LINEEND_MACOLD; lineEndFormat = LINEEND_MACOLD;
convertLineEnds(out, lineEndFormat); convertLineEnds(out, lineEndFormat);
} }
@ -493,7 +478,11 @@ void ASConsole::formatCinToCout()
ASStreamIterator<stringstream> streamIterator(&outStream); ASStreamIterator<stringstream> streamIterator(&outStream);
// Windows pipe or redirection always outputs Windows line-ends. // Windows pipe or redirection always outputs Windows line-ends.
// Linux pipe or redirection will output any line end. // Linux pipe or redirection will output any line end.
#ifdef _WIN32
LineEndFormat lineEndFormat = LINEEND_DEFAULT;
#else
LineEndFormat lineEndFormat = formatter.getLineEndFormat(); LineEndFormat lineEndFormat = formatter.getLineEndFormat();
#endif // _WIN32
initializeOutputEOL(lineEndFormat); initializeOutputEOL(lineEndFormat);
formatter.init(&streamIterator); formatter.init(&streamIterator);
@ -524,7 +513,7 @@ void ASConsole::formatCinToCout()
* *
* @param fileName_ The path and name of the file to be processed. * @param fileName_ The path and name of the file to be processed.
*/ */
void ASConsole::formatFile(const string &fileName_) void ASConsole::formatFile(const string& fileName_)
{ {
stringstream in; stringstream in;
ostringstream out; ostringstream out;
@ -721,7 +710,7 @@ bool ASConsole::getPreserveDate() const
void ASConsole::setBypassBrowserOpen(bool state) void ASConsole::setBypassBrowserOpen(bool state)
{ bypassBrowserOpen = state; } { bypassBrowserOpen = state; }
string ASConsole::getParam(const string &arg, const char* op) string ASConsole::getParam(const string& arg, const char* op)
{ {
return arg.substr(strlen(op)); return arg.substr(strlen(op));
} }
@ -734,21 +723,21 @@ void ASConsole::initializeOutputEOL(LineEndFormat lineEndFormat)
|| lineEndFormat == LINEEND_LINUX || lineEndFormat == LINEEND_LINUX
|| lineEndFormat == LINEEND_MACOLD); || lineEndFormat == LINEEND_MACOLD);
outputEOL[0] = '\0'; // current line end outputEOL.clear(); // current line end
prevEOL[0] = '\0'; // previous line end prevEOL.clear(); // previous line end
lineEndsMixed = false; // output has mixed line ends, LINEEND_DEFAULT only lineEndsMixed = false; // output has mixed line ends, LINEEND_DEFAULT only
if (lineEndFormat == LINEEND_WINDOWS) if (lineEndFormat == LINEEND_WINDOWS)
strcpy(outputEOL, "\r\n"); outputEOL = "\r\n";
else if (lineEndFormat == LINEEND_LINUX) else if (lineEndFormat == LINEEND_LINUX)
strcpy(outputEOL, "\n"); outputEOL = "\n";
else if (lineEndFormat == LINEEND_MACOLD) else if (lineEndFormat == LINEEND_MACOLD)
strcpy(outputEOL, "\r"); outputEOL = "\r";
else else
outputEOL[0] = '\0'; outputEOL.clear();
} }
FileEncoding ASConsole::readFile(const string &fileName_, stringstream &in) const FileEncoding ASConsole::readFile(const string& fileName_, stringstream& in) const
{ {
const int blockSize = 65536; // 64 KB const int blockSize = 65536; // 64 KB
ifstream fin(fileName_.c_str(), ios::binary); ifstream fin(fileName_.c_str(), ios::binary);
@ -771,11 +760,11 @@ FileEncoding ASConsole::readFile(const string &fileName_, stringstream &in) cons
if (encoding == UTF_16LE || encoding == UTF_16BE) if (encoding == UTF_16LE || encoding == UTF_16BE)
{ {
// convert utf-16 to utf-8 // convert utf-16 to utf-8
size_t utf8Size = utf8_16.Utf8LengthFromUtf16(data, dataSize, isBigEndian); size_t utf8Size = utf8_16.utf8LengthFromUtf16(data, dataSize, isBigEndian);
char* utf8Out = new(nothrow) char[utf8Size]; char* utf8Out = new(nothrow) char[utf8Size];
if (!utf8Out) if (!utf8Out)
error("Cannot allocate memory for utf-8 conversion", fileName_.c_str()); error("Cannot allocate memory for utf-8 conversion", fileName_.c_str());
size_t utf8Len = utf8_16.Utf16ToUtf8(data, dataSize, isBigEndian, firstBlock, utf8Out); size_t utf8Len = utf8_16.utf16ToUtf8(data, dataSize, isBigEndian, firstBlock, utf8Out);
assert(utf8Len == utf8Size); assert(utf8Len == utf8Size);
in << string(utf8Out, utf8Len); in << string(utf8Out, utf8Len);
delete [] utf8Out; delete [] utf8Out;
@ -827,24 +816,24 @@ void ASConsole::setPreserveDate(bool state)
{ preserveDate = state; } { preserveDate = state; }
// set outputEOL variable // set outputEOL variable
void ASConsole::setOutputEOL(LineEndFormat lineEndFormat, const char* currentEOL) void ASConsole::setOutputEOL(LineEndFormat lineEndFormat, const string& currentEOL)
{ {
if (lineEndFormat == LINEEND_DEFAULT) if (lineEndFormat == LINEEND_DEFAULT)
{ {
strcpy(outputEOL, currentEOL); outputEOL = currentEOL;
if (strlen(prevEOL) == 0) if (prevEOL.empty())
strcpy(prevEOL, outputEOL); prevEOL = outputEOL;
if (strcmp(prevEOL, outputEOL) != 0) if (prevEOL != outputEOL)
{ {
lineEndsMixed = true; lineEndsMixed = true;
filesAreIdentical = false; filesAreIdentical = false;
strcpy(prevEOL, outputEOL); prevEOL = outputEOL;
} }
} }
else else
{ {
strcpy(prevEOL, currentEOL); prevEOL = currentEOL;
if (strcmp(prevEOL, outputEOL) != 0) if (prevEOL != outputEOL)
filesAreIdentical = false; filesAreIdentical = false;
} }
} }
@ -879,7 +868,7 @@ void ASConsole::displayLastError()
* *
* @return The path of the current directory * @return The path of the current directory
*/ */
string ASConsole::getCurrentDirectory(const string &fileName_) const string ASConsole::getCurrentDirectory(const string& fileName_) const
{ {
char currdir[MAX_PATH]; char currdir[MAX_PATH];
currdir[0] = '\0'; currdir[0] = '\0';
@ -895,7 +884,7 @@ string ASConsole::getCurrentDirectory(const string &fileName_) const
* @param directory The path of the directory to be processed. * @param directory The path of the directory to be processed.
* @param wildcard The wildcard to be processed (e.g. *.cpp). * @param wildcard The wildcard to be processed (e.g. *.cpp).
*/ */
void ASConsole::getFileNames(const string &directory, const string &wildcard) void ASConsole::getFileNames(const string& directory, const string& wildcard)
{ {
vector<string> subDirectory; // sub directories of directory vector<string> subDirectory; // sub directories of directory
WIN32_FIND_DATA findFileData; // for FindFirstFile and FindNextFile WIN32_FIND_DATA findFileData; // for FindFirstFile and FindNextFile
@ -1083,7 +1072,7 @@ void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const
* @param fileName_ The filename is used only for the error message. * @param fileName_ The filename is used only for the error message.
* @return The path of the current directory * @return The path of the current directory
*/ */
string ASConsole::getCurrentDirectory(const string &fileName_) const string ASConsole::getCurrentDirectory(const string& fileName_) const
{ {
char* currdir = getenv("PWD"); char* currdir = getenv("PWD");
if (currdir == NULL) if (currdir == NULL)
@ -1098,7 +1087,7 @@ string ASConsole::getCurrentDirectory(const string &fileName_) const
* @param directory The path of the directory to be processed. * @param directory The path of the directory to be processed.
* @param wildcard The wildcard to be processed (e.g. *.cpp). * @param wildcard The wildcard to be processed (e.g. *.cpp).
*/ */
void ASConsole::getFileNames(const string &directory, const string &wildcard) void ASConsole::getFileNames(const string& directory, const string& wildcard)
{ {
struct dirent* entry; // entry from readdir() struct dirent* entry; // entry from readdir()
struct stat statbuf; // entry from stat() struct stat statbuf; // entry from stat()
@ -1293,9 +1282,9 @@ void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const
// find xdg-open (usually in /usr/bin) // find xdg-open (usually in /usr/bin)
// Mac uses open instead // Mac uses open instead
#ifdef __APPLE__ #ifdef __APPLE__
const char* FILE_OPEN = "open"; const char* fileOpen = "open";
#else #else
const char* FILE_OPEN = "xdg-open"; const char* fileOpen = "xdg-open";
#endif #endif
string searchPath; string searchPath;
char* searchDir = strtok(paths, ":"); char* searchDir = strtok(paths, ":");
@ -1305,29 +1294,29 @@ void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const
if (searchPath.length() > 0 if (searchPath.length() > 0
&& searchPath[searchPath.length() - 1] != g_fileSeparator) && searchPath[searchPath.length() - 1] != g_fileSeparator)
searchPath.append(string(1, g_fileSeparator)); searchPath.append(string(1, g_fileSeparator));
searchPath.append(FILE_OPEN); searchPath.append(fileOpen);
if (stat(searchPath.c_str(), &statbuf) == 0 && (statbuf.st_mode & S_IFREG)) if (stat(searchPath.c_str(), &statbuf) == 0 && (statbuf.st_mode & S_IFREG))
break; break;
searchDir = strtok(NULL, ":"); searchDir = strtok(NULL, ":");
} }
delete[] paths; delete[] paths;
if (searchDir == NULL) if (searchDir == NULL)
error(_("Command is not installed"), FILE_OPEN); error(_("Command is not installed"), fileOpen);
// browser open will be bypassed in test programs // browser open will be bypassed in test programs
printf(_("Opening HTML documentation %s\n"), htmlFilePath.c_str()); printf(_("Opening HTML documentation %s\n"), htmlFilePath.c_str());
if (!bypassBrowserOpen) if (!bypassBrowserOpen)
{ {
execlp(FILE_OPEN, FILE_OPEN, htmlFilePath.c_str(), NULL); execlp(fileOpen, fileOpen, htmlFilePath.c_str(), NULL);
// execlp will NOT return if successful // execlp will NOT return if successful
error(_("Command execute failure"), FILE_OPEN); error(_("Command execute failure"), fileOpen);
} }
} }
#endif // _WIN32 #endif // _WIN32
// get individual file names from the command-line file path // get individual file names from the command-line file path
void ASConsole::getFilePaths(string &filePath) void ASConsole::getFilePaths(string& filePath)
{ {
fileName.clear(); fileName.clear();
targetDirectory = string(); targetDirectory = string();
@ -1361,7 +1350,8 @@ void ASConsole::getFilePaths(string &filePath)
hasWildcard = true; hasWildcard = true;
// clear exclude hits vector // clear exclude hits vector
for (size_t ix = 0; ix < excludeHitsVector.size(); ix++) size_t excludeHitsVectorSize = excludeHitsVector.size();
for (size_t ix = 0; ix < excludeHitsVectorSize; ix++)
excludeHitsVector[ix] = false; excludeHitsVector[ix] = false;
// If the filename is not quoted on Linux, bash will replace the // If the filename is not quoted on Linux, bash will replace the
@ -1398,7 +1388,7 @@ void ASConsole::getFilePaths(string &filePath)
bool excludeErr = false; bool excludeErr = false;
for (size_t ix = 0; ix < excludeHitsVector.size(); ix++) for (size_t ix = 0; ix < excludeHitsVector.size(); ix++)
{ {
if (excludeHitsVector[ix] == false) if (!excludeHitsVector[ix])
{ {
excludeErr = true; excludeErr = true;
if (!ignoreExcludeErrorsDisplay) if (!ignoreExcludeErrorsDisplay)
@ -1441,17 +1431,17 @@ bool ASConsole::fileNameVectorIsEmpty() const
return fileNameVector.empty(); return fileNameVector.empty();
} }
bool ASConsole::isOption(const string &arg, const char* op) bool ASConsole::isOption(const string& arg, const char* op)
{ {
return arg.compare(op) == 0; return arg.compare(op) == 0;
} }
bool ASConsole::isOption(const string &arg, const char* a, const char* b) bool ASConsole::isOption(const string& arg, const char* a, const char* b)
{ {
return (isOption(arg, a) || isOption(arg, b)); return (isOption(arg, a) || isOption(arg, b));
} }
bool ASConsole::isParamOption(const string &arg, const char* option) bool ASConsole::isParamOption(const string& arg, const char* option)
{ {
bool retVal = arg.compare(0, strlen(option), option) == 0; bool retVal = arg.compare(0, strlen(option), option) == 0;
// if comparing for short option, 2nd char of arg must be numeric // if comparing for short option, 2nd char of arg must be numeric
@ -1465,7 +1455,7 @@ bool ASConsole::isParamOption(const string &arg, const char* option)
// used for both directories and filenames // used for both directories and filenames
// updates the g_excludeHitsVector // updates the g_excludeHitsVector
// return true if a match // return true if a match
bool ASConsole::isPathExclued(const string &subPath) bool ASConsole::isPathExclued(const string& subPath)
{ {
bool retVal = false; bool retVal = false;
@ -1735,6 +1725,9 @@ void ASConsole::printHelp() const
cout << " --pad-oper OR -p\n"; cout << " --pad-oper OR -p\n";
cout << " Insert space padding around operators.\n"; cout << " Insert space padding around operators.\n";
cout << endl; cout << endl;
cout << " --pad-comma OR -xg\n";
cout << " Insert space padding around commas and semicolons.\n";
cout << endl;
cout << " --pad-paren OR -P\n"; cout << " --pad-paren OR -P\n";
cout << " Insert space padding around parenthesis on both the outside\n"; cout << " Insert space padding around parenthesis on both the outside\n";
cout << " and the inside.\n"; cout << " and the inside.\n";
@ -1836,9 +1829,6 @@ void ASConsole::printHelp() const
cout << endl; cout << endl;
cout << "Objective-C Options:\n"; cout << "Objective-C Options:\n";
cout << "--------------------\n"; cout << "--------------------\n";
cout << " --align-method-colon OR -xM\n";
cout << " Align the colons in an Objective-C method definition.\n";
cout << endl;
cout << " --pad-method-prefix OR -xQ\n"; cout << " --pad-method-prefix OR -xQ\n";
cout << " Insert space padding after the '-' or '+' Objective-C\n"; cout << " Insert space padding after the '-' or '+' Objective-C\n";
cout << " method prefix.\n"; cout << " method prefix.\n";
@ -1847,6 +1837,15 @@ void ASConsole::printHelp() const
cout << " Remove all space padding after the '-' or '+' Objective-C\n"; cout << " Remove all space padding after the '-' or '+' Objective-C\n";
cout << " method prefix.\n"; cout << " method prefix.\n";
cout << endl; cout << endl;
cout << " --pad-return-type OR -xq\n";
cout << " Insert space padding after the Objective-C return type.\n";
cout << endl;
cout << " --unpad-return-type OR -xr\n";
cout << " Remove all space padding after the Objective-C return type.\n";
cout << endl;
cout << " --align-method-colon OR -xM\n";
cout << " Align the colons in an Objective-C method definition.\n";
cout << endl;
cout << " --pad-method-colon=none OR -xP\n"; cout << " --pad-method-colon=none OR -xP\n";
cout << " --pad-method-colon=all OR -xP1\n"; cout << " --pad-method-colon=all OR -xP1\n";
cout << " --pad-method-colon=after OR -xP2\n"; cout << " --pad-method-colon=after OR -xP2\n";
@ -1960,7 +1959,7 @@ void ASConsole::processFiles()
// process options from the command line and options file // process options from the command line and options file
// build the vectors fileNameVector, excludeVector, optionsVector, and fileOptionsVector // build the vectors fileNameVector, excludeVector, optionsVector, and fileOptionsVector
void ASConsole::processOptions(vector<string> &argvOptions) void ASConsole::processOptions(vector<string>& argvOptions)
{ {
string arg; string arg;
bool ok = true; bool ok = true;
@ -1986,7 +1985,7 @@ void ASConsole::processOptions(vector<string> &argvOptions)
{ {
optionsFileName = getParam(arg, "--options="); optionsFileName = getParam(arg, "--options=");
optionsFileRequired = true; optionsFileRequired = true;
if (optionsFileName.compare("") == 0) if (optionsFileName.empty())
setOptionsFileName(" "); setOptionsFileName(" ");
} }
else if ( isOption(arg, "-h") else if ( isOption(arg, "-h")
@ -2028,31 +2027,31 @@ void ASConsole::processOptions(vector<string> &argvOptions)
// get options file path and name // get options file path and name
if (shouldParseOptionsFile) if (shouldParseOptionsFile)
{ {
if (optionsFileName.compare("") == 0) if (optionsFileName.empty())
{ {
char* env = getenv("ARTISTIC_STYLE_OPTIONS"); char* env = getenv("ARTISTIC_STYLE_OPTIONS");
if (env != NULL) if (env != NULL)
setOptionsFileName(env); setOptionsFileName(env);
} }
if (optionsFileName.compare("") == 0) if (optionsFileName.empty())
{ {
char* env = getenv("HOME"); char* env = getenv("HOME");
if (env != NULL) if (env != NULL)
setOptionsFileName(string(env) + "/.astylerc"); setOptionsFileName(string(env) + "/.astylerc");
} }
if (optionsFileName.compare("") == 0) if (optionsFileName.empty())
{ {
char* env = getenv("USERPROFILE"); char* env = getenv("USERPROFILE");
if (env != NULL) if (env != NULL)
setOptionsFileName(string(env) + "/astylerc"); setOptionsFileName(string(env) + "/astylerc");
} }
if (optionsFileName.compare("") != 0) if (!optionsFileName.empty())
standardizePath(optionsFileName); standardizePath(optionsFileName);
} }
// create the options file vector and parse the options for errors // create the options file vector and parse the options for errors
ASOptions options(formatter); ASOptions options(formatter);
if (optionsFileName.compare("") != 0) if (!optionsFileName.empty())
{ {
ifstream optionsIn(optionsFileName.c_str()); ifstream optionsIn(optionsFileName.c_str());
if (optionsIn) if (optionsIn)
@ -2126,7 +2125,7 @@ void ASConsole::renameFile(const char* oldFileName, const char* newFileName, con
// make sure file separators are correct type (Windows or Linux) // make sure file separators are correct type (Windows or Linux)
// remove ending file separator // remove ending file separator
// remove beginning file separator if requested and NOT a complete file path // remove beginning file separator if requested and NOT a complete file path
void ASConsole::standardizePath(string &path, bool removeBeginningSeparator /*false*/) const void ASConsole::standardizePath(string& path, bool removeBeginningSeparator /*false*/) const
{ {
#ifdef __VMS #ifdef __VMS
struct FAB fab; struct FAB fab;
@ -2187,7 +2186,7 @@ void ASConsole::standardizePath(string &path, bool removeBeginningSeparator /*fa
path.erase(0, 1); path.erase(0, 1);
} }
void ASConsole::printMsg(const char* msg, const string &data) const void ASConsole::printMsg(const char* msg, const string& data) const
{ {
if (isQuiet) if (isQuiet)
return; return;
@ -2208,14 +2207,19 @@ void ASConsole::printVerboseHeader() const
if (isQuiet) if (isQuiet)
return; return;
// get the date // get the date
struct tm* ptr;
time_t lt; time_t lt;
char str[20]; char str[20];
lt = time(NULL); lt = time(NULL);
ptr = localtime(&lt); struct tm* ptr = localtime(&lt);
strftime(str, 20, "%x", ptr); strftime(str, 20, "%x", ptr);
// print the header // print the header
printf("Artistic Style %s %s\n", g_version, str); // 60 is the length of the separator in printSeparatingLine()
string header = "Artistic Style " + string(g_version);
size_t numSpaces = 60 - header.length() - strlen(str);
header.append(numSpaces, ' ');
header.append(str);
header.append("\n");
printf("%s", header.c_str());
// print options file // print options file
if (!optionsFileName.empty()) if (!optionsFileName.empty())
printf(_("Using default options file %s\n"), optionsFileName.c_str()); printf(_("Using default options file %s\n"), optionsFileName.c_str());
@ -2265,7 +2269,7 @@ void ASConsole::sleep(int seconds) const
while (clock() < endwait) {} while (clock() < endwait) {}
} }
bool ASConsole::stringEndsWith(const string &str, const string &suffix) const bool ASConsole::stringEndsWith(const string& str, const string& suffix) const
{ {
int strIndex = (int) str.length() - 1; int strIndex = (int) str.length() - 1;
int suffixIndex = (int) suffix.length() - 1; int suffixIndex = (int) suffix.length() - 1;
@ -2367,7 +2371,7 @@ int ASConsole::wildcmp(const char* wild, const char* data) const
return !*wild; return !*wild;
} }
void ASConsole::writeFile(const string &fileName_, FileEncoding encoding, ostringstream &out) const void ASConsole::writeFile(const string& fileName_, FileEncoding encoding, ostringstream& out) const
{ {
// save date accessed and date modified of original file // save date accessed and date modified of original file
struct stat stBuf; struct stat stBuf;
@ -2391,9 +2395,9 @@ void ASConsole::writeFile(const string &fileName_, FileEncoding encoding, ostrin
{ {
// convert utf-8 to utf-16 // convert utf-8 to utf-16
bool isBigEndian = (encoding == UTF_16BE); bool isBigEndian = (encoding == UTF_16BE);
size_t utf16Size = utf8_16.Utf16LengthFromUtf8(out.str().c_str(), out.str().length()); size_t utf16Size = utf8_16.utf16LengthFromUtf8(out.str().c_str(), out.str().length());
char* utf16Out = new char[utf16Size]; char* utf16Out = new char[utf16Size];
size_t utf16Len = utf8_16.Utf8ToUtf16(const_cast<char*>(out.str().c_str()), size_t utf16Len = utf8_16.utf8ToUtf16(const_cast<char*>(out.str().c_str()),
out.str().length(), isBigEndian, utf16Out); out.str().length(), isBigEndian, utf16Out);
assert(utf16Len == utf16Size); assert(utf16Len == utf16Size);
fout << string(utf16Out, utf16Len); fout << string(utf16Out, utf16Len);
@ -2426,13 +2430,13 @@ void ASConsole::writeFile(const string &fileName_, FileEncoding encoding, ostrin
} }
} }
#else // ASTYLE_LIB
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// ASLibrary class // ASLibrary class
// used by shared object (DLL) calls // used by shared object (DLL) calls
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#else // ASTYLE_LIB
utf16_t* ASLibrary::formatUtf16(const utf16_t* pSourceIn, // the source to be formatted utf16_t* ASLibrary::formatUtf16(const utf16_t* pSourceIn, // the source to be formatted
const utf16_t* pOptions, // AStyle options const utf16_t* pOptions, // AStyle options
fpError fpErrorHandler, // error handler function fpError fpErrorHandler, // error handler function
@ -2498,14 +2502,14 @@ utf16_t* ASLibrary::convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc
size_t dataSize = strlen(utf8In); size_t dataSize = strlen(utf8In);
bool isBigEndian = utf8_16.getBigEndian(); bool isBigEndian = utf8_16.getBigEndian();
// return size is in number of CHARs, not utf16_t // return size is in number of CHARs, not utf16_t
size_t utf16Size = (utf8_16.Utf16LengthFromUtf8(data, dataSize) + sizeof(utf16_t)); size_t utf16Size = (utf8_16.utf16LengthFromUtf8(data, dataSize) + sizeof(utf16_t));
char* utf16Out = fpMemoryAlloc(utf16Size); char* utf16Out = fpMemoryAlloc((long)utf16Size);
if (utf16Out == NULL) if (utf16Out == NULL)
return NULL; return NULL;
#ifdef NDEBUG #ifdef NDEBUG
utf8_16.Utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out); utf8_16.utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out);
#else #else
size_t utf16Len = utf8_16.Utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out); size_t utf16Len = utf8_16.utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out);
assert(utf16Len == utf16Size); assert(utf16Len == utf16Size);
#endif #endif
assert(utf16Size == (utf8_16.utf16len(reinterpret_cast<utf16_t*>(utf16Out)) + 1) * sizeof(utf16_t)); assert(utf16Size == (utf8_16.utf16len(reinterpret_cast<utf16_t*>(utf16Out)) + 1) * sizeof(utf16_t));
@ -2525,14 +2529,14 @@ char* ASLibrary::convertUtf16ToUtf8(const utf16_t* utf16In) const
// size must be in chars // size must be in chars
size_t dataSize = utf8_16.utf16len(utf16In) * sizeof(utf16_t); size_t dataSize = utf8_16.utf16len(utf16In) * sizeof(utf16_t);
bool isBigEndian = utf8_16.getBigEndian(); bool isBigEndian = utf8_16.getBigEndian();
size_t utf8Size = utf8_16.Utf8LengthFromUtf16(data, dataSize, isBigEndian) + 1; size_t utf8Size = utf8_16.utf8LengthFromUtf16(data, dataSize, isBigEndian) + 1;
char* utf8Out = new(nothrow) char[utf8Size]; char* utf8Out = new(nothrow) char[utf8Size];
if (utf8Out == NULL) if (utf8Out == NULL)
return NULL; return NULL;
#ifdef NDEBUG #ifdef NDEBUG
utf8_16.Utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out); utf8_16.utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out);
#else #else
size_t utf8Len = utf8_16.Utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out); size_t utf8Len = utf8_16.utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out);
assert(utf8Len == utf8Size); assert(utf8Len == utf8Size);
#endif #endif
assert(utf8Size == strlen(utf8Out) + 1); assert(utf8Size == strlen(utf8Out) + 1);
@ -2552,7 +2556,7 @@ char* ASLibrary::convertUtf16ToUtf8(const utf16_t* utf16In) const
* *
* @return true if no errors, false if errors * @return true if no errors, false if errors
*/ */
bool ASOptions::parseOptions(vector<string> &optionsVector, const string &errorInfo) bool ASOptions::parseOptions(vector<string>& optionsVector, const string& errorInfo)
{ {
vector<string>::iterator option; vector<string>::iterator option;
string arg, subArg; string arg, subArg;
@ -2596,7 +2600,7 @@ bool ASOptions::parseOptions(vector<string> &optionsVector, const string &errorI
return true; return true;
} }
void ASOptions::parseOption(const string &arg, const string &errorInfo) void ASOptions::parseOption(const string& arg, const string& errorInfo)
{ {
if ( isOption(arg, "style=allman") || isOption(arg, "style=bsd") || isOption(arg, "style=break") ) if ( isOption(arg, "style=allman") || isOption(arg, "style=bsd") || isOption(arg, "style=break") )
{ {
@ -2618,7 +2622,7 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
{ {
formatter.setFormattingStyle(STYLE_WHITESMITH); formatter.setFormattingStyle(STYLE_WHITESMITH);
} }
else if (isOption(arg, "style=vtk")) else if ( isOption(arg, "style=vtk") )
{ {
formatter.setFormattingStyle(STYLE_VTK); formatter.setFormattingStyle(STYLE_VTK);
} }
@ -2876,6 +2880,10 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
{ {
formatter.setOperatorPaddingMode(true); formatter.setOperatorPaddingMode(true);
} }
else if (isOption(arg, "xg", "pad-comma"))
{
formatter.setCommaPaddingMode(true);
}
else if ( isOption(arg, "xe", "delete-empty-lines") ) else if ( isOption(arg, "xe", "delete-empty-lines") )
{ {
formatter.setDeleteEmptyLinesMode(true); formatter.setDeleteEmptyLinesMode(true);
@ -3030,10 +3038,6 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
formatter.setStripCommentPrefix(true); formatter.setStripCommentPrefix(true);
} }
// Objective-C options // Objective-C options
else if ( isOption(arg, "xM", "align-method-colon") )
{
formatter.setAlignMethodColon(true);
}
else if ( isOption(arg, "xQ", "pad-method-prefix") ) else if ( isOption(arg, "xQ", "pad-method-prefix") )
{ {
formatter.setMethodPrefixPaddingMode(true); formatter.setMethodPrefixPaddingMode(true);
@ -3042,6 +3046,18 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
{ {
formatter.setMethodPrefixUnPaddingMode(true); formatter.setMethodPrefixUnPaddingMode(true);
} }
else if (isOption(arg, "xq", "pad-return-type"))
{
formatter.setReturnTypePaddingMode(true);
}
else if (isOption(arg, "xr", "unpad-return-type"))
{
formatter.setReturnTypeUnPaddingMode(true);
}
else if (isOption(arg, "xM", "align-method-colon"))
{
formatter.setAlignMethodColon(true);
}
else if ( isOption(arg, "xP0", "pad-method-colon=none") ) else if ( isOption(arg, "xP0", "pad-method-colon=none") )
{ {
formatter.setObjCColonPaddingMode(COLON_PAD_NONE); formatter.setObjCColonPaddingMode(COLON_PAD_NONE);
@ -3182,7 +3198,7 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
} // End of parseOption function } // End of parseOption function
// Parse options from the options file. // Parse options from the options file.
void ASOptions::importOptions(istream &in, vector<string> &optionsVector) void ASOptions::importOptions(istream& in, vector<string>& optionsVector)
{ {
char ch; char ch;
bool isInQuote = false; bool isInQuote = false;
@ -3235,34 +3251,34 @@ string ASOptions::getOptionErrors() const
return optionErrors.str(); return optionErrors.str();
} }
string ASOptions::getParam(const string &arg, const char* op) string ASOptions::getParam(const string& arg, const char* op)
{ {
return arg.substr(strlen(op)); return arg.substr(strlen(op));
} }
string ASOptions::getParam(const string &arg, const char* op1, const char* op2) string ASOptions::getParam(const string& arg, const char* op1, const char* op2)
{ {
return isParamOption(arg, op1) ? getParam(arg, op1) : getParam(arg, op2); return isParamOption(arg, op1) ? getParam(arg, op1) : getParam(arg, op2);
} }
bool ASOptions::isOption(const string &arg, const char* op) bool ASOptions::isOption(const string& arg, const char* op)
{ {
return arg.compare(op) == 0; return arg.compare(op) == 0;
} }
bool ASOptions::isOption(const string &arg, const char* op1, const char* op2) bool ASOptions::isOption(const string& arg, const char* op1, const char* op2)
{ {
return (isOption(arg, op1) || isOption(arg, op2)); return (isOption(arg, op1) || isOption(arg, op2));
} }
void ASOptions::isOptionError(const string &arg, const string &errorInfo) void ASOptions::isOptionError(const string& arg, const string& errorInfo)
{ {
if (optionErrors.str().length() == 0) if (optionErrors.str().length() == 0)
optionErrors << errorInfo << endl; // need main error message optionErrors << errorInfo << endl; // need main error message
optionErrors << arg << endl; optionErrors << arg << endl;
} }
bool ASOptions::isParamOption(const string &arg, const char* option) bool ASOptions::isParamOption(const string& arg, const char* option)
{ {
bool retVal = arg.compare(0, strlen(option), option) == 0; bool retVal = arg.compare(0, strlen(option), option) == 0;
// if comparing for short option, 2nd char of arg must be numeric // if comparing for short option, 2nd char of arg must be numeric
@ -3272,7 +3288,7 @@ bool ASOptions::isParamOption(const string &arg, const char* option)
return retVal; return retVal;
} }
bool ASOptions::isParamOption(const string &arg, const char* option1, const char* option2) bool ASOptions::isParamOption(const string& arg, const char* option1, const char* option2)
{ {
return isParamOption(arg, option1) || isParamOption(arg, option2); return isParamOption(arg, option1) || isParamOption(arg, option2);
} }
@ -3310,7 +3326,7 @@ size_t Utf8_16::utf16len(const utf16* utf16In) const
// Modified for Artistic Style by Jim Pattee. // Modified for Artistic Style by Jim Pattee.
// Compute the length of an output utf-8 file given a utf-16 file. // Compute the length of an output utf-8 file given a utf-16 file.
// Input inLen is the size in BYTES (not wchar_t). // 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 Utf8_16::utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const
{ {
size_t len = 0; size_t len = 0;
size_t wcharLen = inLen / 2; size_t wcharLen = inLen / 2;
@ -3338,7 +3354,7 @@ size_t Utf8_16::Utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBi
// Copyright (C) 2002 Scott Kirkwood. // Copyright (C) 2002 Scott Kirkwood.
// Modified for Artistic Style by Jim Pattee. // Modified for Artistic Style by Jim Pattee.
// Convert a utf-8 file to utf-16. // 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 Utf8_16::utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const
{ {
int nCur = 0; int nCur = 0;
ubyte* pRead = reinterpret_cast<ubyte*>(utf8In); ubyte* pRead = reinterpret_cast<ubyte*>(utf8In);
@ -3386,6 +3402,7 @@ size_t Utf8_16::Utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char*
nCur |= (0x3F & *pRead); nCur |= (0x3F & *pRead);
state = eStart; state = eStart;
break; break;
// no default case is needed
} }
++pRead; ++pRead;
@ -3413,7 +3430,7 @@ size_t Utf8_16::Utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char*
// Modified for Artistic Style by Jim Pattee. // Modified for Artistic Style by Jim Pattee.
// Compute the length of an output utf-16 file given a utf-8 file. // Compute the length of an output utf-16 file given a utf-8 file.
// Return value is the size in BYTES (not wchar_t). // Return value is the size in BYTES (not wchar_t).
size_t Utf8_16::Utf16LengthFromUtf8(const char* utf8In, size_t len) const size_t Utf8_16::utf16LengthFromUtf8(const char* utf8In, size_t len) const
{ {
size_t ulen = 0; size_t ulen = 0;
size_t charLen; size_t charLen;
@ -3442,7 +3459,7 @@ size_t Utf8_16::Utf16LengthFromUtf8(const char* utf8In, size_t len) const
// Copyright (C) 2002 Scott Kirkwood. // Copyright (C) 2002 Scott Kirkwood.
// Modified for Artistic Style by Jim Pattee. // Modified for Artistic Style by Jim Pattee.
// Convert a utf-16 file to utf-8. // Convert a utf-16 file to utf-8.
size_t Utf8_16::Utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian, size_t Utf8_16::utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
bool firstBlock, char* utf8Out) const bool firstBlock, char* utf8Out) const
{ {
int nCur16 = 0; int nCur16 = 0;
@ -3527,6 +3544,7 @@ size_t Utf8_16::Utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
nCur = static_cast<ubyte>(0x80 | (nCur16 & 0x3F)); nCur = static_cast<ubyte>(0x80 | (nCur16 & 0x3F));
state = eStart; state = eStart;
break; break;
// no default case is needed
} }
*pCur++ = static_cast<ubyte>(nCur); *pCur++ = static_cast<ubyte>(nCur);
} }
@ -3610,14 +3628,25 @@ char* STDCALL javaMemoryAlloc(unsigned long memoryNeeded)
char* buffer = new(nothrow) char[memoryNeeded]; char* buffer = new(nothrow) char[memoryNeeded];
return buffer; return buffer;
} }
#endif // ASTYLE_JNI #endif // ASTYLE_JNI
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Entry point for AStyleMainUtf16 library builds // ASTYLE_LIB functions for library builds
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#ifdef ASTYLE_LIB #ifdef ASTYLE_LIB
//----------------------------------------------------------------------------
// ASTYLE_LIB entry point for AStyleMainUtf16 library builds
//----------------------------------------------------------------------------
/*
* IMPORTANT Visual C DLL linker for WIN32 must have the additional options:
* /EXPORT:AStyleMain=_AStyleMain@16
* /EXPORT:AStyleMainUtf16=_AStyleMainUtf16@16
* /EXPORT:AStyleGetVersion=_AStyleGetVersion@0
* No /EXPORT is required for x64
*/
extern "C" EXPORT utf16_t* STDCALL AStyleMainUtf16(const utf16_t* pSourceIn, // the source to be formatted extern "C" EXPORT utf16_t* STDCALL AStyleMainUtf16(const utf16_t* pSourceIn, // the source to be formatted
const utf16_t* pOptions, // AStyle options const utf16_t* pOptions, // AStyle options
fpError fpErrorHandler, // error handler function fpError fpErrorHandler, // error handler function
@ -3660,7 +3689,9 @@ extern "C" EXPORT utf16_t* STDCALL AStyleMainUtf16(const utf16_t* pSourceIn, //
// ASTYLE_LIB entry point for library builds // ASTYLE_LIB entry point for library builds
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/* /*
* IMPORTANT VC DLL linker for WIN32 must have the parameter /EXPORT:AStyleMain=_AStyleMain@16 * IMPORTANT Visual C DLL linker for WIN32 must have the additional options:
* /EXPORT:AStyleMain=_AStyleMain@16
* /EXPORT:AStyleMainUtf16=_AStyleMainUtf16@16
* /EXPORT:AStyleGetVersion=_AStyleGetVersion@0 * /EXPORT:AStyleGetVersion=_AStyleGetVersion@0
* No /EXPORT is required for x64 * No /EXPORT is required for x64
*/ */
@ -3721,8 +3752,8 @@ extern "C" EXPORT char* STDCALL AStyleMain(const char* pSourceIn, // the source
} }
} }
unsigned long textSizeOut = out.str().length(); size_t textSizeOut = out.str().length();
char* pTextOut = fpMemoryAlloc(textSizeOut + 1); // call memory allocation function char* pTextOut = fpMemoryAlloc((long)textSizeOut + 1); // call memory allocation function
if (pTextOut == NULL) if (pTextOut == NULL)
{ {
fpErrorHandler(120, "Allocation failure on output."); fpErrorHandler(120, "Allocation failure on output.");

View File

@ -1,28 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // astyle_main.h
* astyle_main.h // Copyright (c) 2016 by Jim Pattee <jimp03@email.com>.
* // This code is licensed under the MIT License.
* Copyright (C) 2014 by Jim Pattee // License.txt describes the conditions under which this software may be distributed.
* <http://www.gnu.org/licenses/lgpl-3.0.html>
*
* This file is a part of Artistic Style - an indentation and
* reformatting tool for C, C++, C# and Java source files.
* <http://astyle.sourceforge.net>
*
* Artistic Style is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Artistic Style is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Artistic Style. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#ifndef ASTYLE_MAIN_H #ifndef ASTYLE_MAIN_H
#define ASTYLE_MAIN_H #define ASTYLE_MAIN_H
@ -64,27 +43,38 @@
#define _(a) localizer.settext(a) #define _(a) localizer.settext(a)
#endif // ASTYLE_LIB #endif // ASTYLE_LIB
//-----------------------------------------------------------------------------
// declarations
//-----------------------------------------------------------------------------
// for G++ implementation of string.compare: // for G++ implementation of string.compare:
#if defined(__GNUC__) && __GNUC__ < 3 #if defined(__GNUC__) && __GNUC__ < 3
#error - Use GNU C compiler release 3 or higher #error - Use GNU C compiler release 3 or higher
#endif #endif
// for getenv and localtime
#if defined(_MSC_VER)
#pragma warning(disable: 4996) // secure version deprecation warnings
#endif
// for namespace problem in version 5.0 // for namespace problem in version 5.0
#if defined(_MSC_VER) && _MSC_VER < 1200 // check for V6.0 #if defined(_MSC_VER) && _MSC_VER < 1200 // check for V6.0
#error - Use Microsoft compiler version 6 or higher #error - Use Microsoft compiler version 6 or higher
#endif #endif
#ifdef __clang__
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // getenv, localtime
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
// for mingw BOM, UTF-16, and Unicode functions // for mingw BOM, UTF-16, and Unicode functions
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
#if (__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION < 16)) #if (__MINGW32_MAJOR_VERSION > 3) || \
((__MINGW32_MAJOR_VERSION == 3)&& (__MINGW32_MINOR_VERSION < 16))
#error - Use MinGW compiler version 4 or higher #error - Use MinGW compiler version 4 or higher
#endif #endif
#endif #endif
//----------------------------------------------------------------------------
// definitions
//----------------------------------------------------------------------------
#ifdef ASTYLE_LIB #ifdef ASTYLE_LIB
// define STDCALL and EXPORT for Windows // define STDCALL and EXPORT for Windows
@ -124,7 +114,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
namespace astyle { namespace astyle {
//
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// ASStreamIterator class // ASStreamIterator class
// typename will be istringstream for GUI and istream otherwise // typename will be istringstream for GUI and istream otherwise
@ -134,11 +124,11 @@ namespace astyle {
template<typename T> template<typename T>
class ASStreamIterator : public ASSourceIterator class ASStreamIterator : public ASSourceIterator
{ {
public: public:
bool checkForEmptyLine; bool checkForEmptyLine;
// function declarations // function declarations
ASStreamIterator(T* in); explicit ASStreamIterator(T* in);
virtual ~ASStreamIterator(); virtual ~ASStreamIterator();
bool getLineEndChange(int lineEndFormat) const; bool getLineEndChange(int lineEndFormat) const;
int getStreamLength() const; int getStreamLength() const;
@ -148,24 +138,24 @@ class ASStreamIterator : public ASSourceIterator
void saveLastInputLine(); void saveLastInputLine();
streamoff tellg(); streamoff tellg();
private: private:
ASStreamIterator(const ASStreamIterator &copy); // copy constructor not to be implemented ASStreamIterator(const ASStreamIterator& copy); // copy constructor not to be implemented
ASStreamIterator &operator=(ASStreamIterator &); // assignment operator not to be implemented ASStreamIterator& operator=(ASStreamIterator&); // assignment operator not to be implemented
T* inStream; // pointer to the input stream T* inStream; // pointer to the input stream
string buffer; // current input line string buffer; // current input line
string prevBuffer; // previous input line string prevBuffer; // previous input line
string outputEOL; // next output end of line char
int eolWindows; // number of Windows line endings, CRLF int eolWindows; // number of Windows line endings, CRLF
int eolLinux; // number of Linux line endings, LF int eolLinux; // number of Linux line endings, LF
int eolMacOld; // number of old Mac line endings. CR int eolMacOld; // number of old Mac line endings. CR
char outputEOL[4]; // next output end of line char
streamoff streamLength; // length of the input file stream streamoff streamLength; // length of the input file stream
streamoff peekStart; // starting position for peekNextLine streamoff peekStart; // starting position for peekNextLine
bool prevLineDeleted; // the previous input line was deleted bool prevLineDeleted; // the previous input line was deleted
public: // inline functions public: // inline functions
bool compareToInputBuffer(const string &nextLine_) const bool compareToInputBuffer(const string& nextLine_) const
{ return (nextLine_ == prevBuffer); } { return (nextLine_ == prevBuffer); }
const char* getOutputEOL() const { return outputEOL; } const string& getOutputEOL() const { return outputEOL; }
bool hasMoreLines() const { return !inStream->eof(); } bool hasMoreLines() const { return !inStream->eof(); }
}; };
@ -175,7 +165,7 @@ class ASStreamIterator : public ASSourceIterator
class Utf8_16 class Utf8_16
{ {
private: private:
typedef unsigned short utf16; // 16 bits typedef unsigned short utf16; // 16 bits
typedef unsigned char utf8; // 8 bits typedef unsigned char utf8; // 8 bits
typedef unsigned char ubyte; // 8 bits typedef unsigned char ubyte; // 8 bits
@ -186,14 +176,14 @@ class Utf8_16
enum { SURROGATE_FIRST_VALUE = 0x10000 }; enum { SURROGATE_FIRST_VALUE = 0x10000 };
enum eState { eStart, eSecondOf4Bytes, ePenultimate, eFinal }; enum eState { eStart, eSecondOf4Bytes, ePenultimate, eFinal };
public: public:
bool getBigEndian() const; bool getBigEndian() const;
int swap16bit(int value) const; int swap16bit(int value) const;
size_t utf16len(const utf16* utf16In) const; size_t utf16len(const utf16* utf16In) const;
size_t Utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const; size_t utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const;
size_t Utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const; size_t utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const;
size_t Utf16LengthFromUtf8(const char* utf8In, size_t inLen) const; size_t utf16LengthFromUtf8(const char* utf8In, size_t inLen) const;
size_t Utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian, size_t utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
bool firstBlock, char* utf8Out) const; bool firstBlock, char* utf8Out) const;
}; };
@ -204,27 +194,28 @@ class Utf8_16
class ASOptions class ASOptions
{ {
public: public:
ASOptions(ASFormatter &formatterArg) : formatter(formatterArg) {} explicit ASOptions(ASFormatter& formatterArg) : formatter(formatterArg) {}
string getOptionErrors() const; string getOptionErrors() const;
void importOptions(istream &in, vector<string> &optionsVector); void importOptions(istream& in, vector<string>& optionsVector);
bool parseOptions(vector<string> &optionsVector, const string &errorInfo); bool parseOptions(vector<string>& optionsVector, const string& errorInfo);
private: private:
// variables // variables
ASFormatter &formatter; // reference to the ASFormatter object ASFormatter& formatter; // reference to the ASFormatter object
stringstream optionErrors; // option error messages stringstream optionErrors; // option error messages
// functions // functions
ASOptions &operator=(ASOptions &); // not to be implemented ASOptions(const ASOptions&); // copy constructor not to be implemented
string getParam(const string &arg, const char* op); ASOptions& operator=(ASOptions&); // assignment operator not to be implemented
string getParam(const string &arg, const char* op1, const char* op2); string getParam(const string& arg, const char* op);
bool isOption(const string &arg, const char* op); string getParam(const string& arg, const char* op1, const char* op2);
bool isOption(const string &arg, const char* op1, const char* op2); bool isOption(const string& arg, const char* op);
void isOptionError(const string &arg, const string &errorInfo); bool isOption(const string& arg, const char* op1, const char* op2);
bool isParamOption(const string &arg, const char* option); void isOptionError(const string& arg, const string& errorInfo);
bool isParamOption(const string &arg, const char* option1, const char* option2); bool isParamOption(const string& arg, const char* option);
void parseOption(const string &arg, const string &errorInfo); bool isParamOption(const string& arg, const char* option1, const char* option2);
void parseOption(const string& arg, const string& errorInfo);
}; };
#ifndef ASTYLE_LIB #ifndef ASTYLE_LIB
@ -235,8 +226,8 @@ class ASOptions
class ASConsole class ASConsole
{ {
private: // variables private: // variables
ASFormatter &formatter; // reference to the ASFormatter object ASFormatter& formatter; // reference to the ASFormatter object
ASLocalizer localizer; // ASLocalizer object ASLocalizer localizer; // ASLocalizer object
// command line options // command line options
bool isRecursive; // recursive option bool isRecursive; // recursive option
@ -259,11 +250,11 @@ class ASConsole
int filesUnchanged; // number of files unchanged int filesUnchanged; // number of files unchanged
bool lineEndsMixed; // output has mixed line ends bool lineEndsMixed; // output has mixed line ends
int linesOut; // number of output lines int linesOut; // number of output lines
char outputEOL[4]; // current line end
char prevEOL[4]; // previous line end
Utf8_16 utf8_16; // utf8/16 conversion methods Utf8_16 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 optionsFileName; // file path and name of the options file to use
string origSuffix; // suffix= option string origSuffix; // suffix= option
string targetDirectory; // path to the directory being processed string targetDirectory; // path to the directory being processed
@ -276,8 +267,9 @@ class ASConsole
vector<string> fileOptionsVector; // options from the options file vector<string> fileOptionsVector; // options from the options file
vector<string> fileName; // files to be processed including path vector<string> fileName; // files to be processed including path
public: // variables public: // variables
ASConsole(ASFormatter &formatterArg) : formatter(formatterArg) { explicit ASConsole(ASFormatter& formatterArg) : formatter(formatterArg)
{
// command line options // command line options
isRecursive = false; isRecursive = false;
isDryRun = false; isDryRun = false;
@ -295,8 +287,6 @@ class ASConsole
hasWildcard = false; hasWildcard = false;
filesAreIdentical = true; filesAreIdentical = true;
lineEndsMixed = false; lineEndsMixed = false;
outputEOL[0] = '\0';
prevEOL[0] = '\0';
origSuffix = ".orig"; origSuffix = ".orig";
mainDirectoryLength = 0; mainDirectoryLength = 0;
filesFormatted = 0; filesFormatted = 0;
@ -304,8 +294,8 @@ class ASConsole
linesOut = 0; linesOut = 0;
} }
public: // functions public: // functions
void convertLineEnds(ostringstream &out, int lineEnd); void convertLineEnds(ostringstream& out, int lineEnd);
FileEncoding detectEncoding(const char* data, size_t dataSize) const; FileEncoding detectEncoding(const char* data, size_t dataSize) const;
void error() const; void error() const;
void error(const char* why, const char* what) const; void error(const char* why, const char* what) const;
@ -330,7 +320,7 @@ class ASConsole
string getOptionsFileName() const; string getOptionsFileName() const;
string getOrigSuffix() const; string getOrigSuffix() const;
void processFiles(); void processFiles();
void processOptions(vector<string> &argvOptions); void processOptions(vector<string>& argvOptions);
void setBypassBrowserOpen(bool state); void setBypassBrowserOpen(bool state);
void setIgnoreExcludeErrors(bool state); void setIgnoreExcludeErrors(bool state);
void setIgnoreExcludeErrorsAndDisplay(bool state); void setIgnoreExcludeErrorsAndDisplay(bool state);
@ -343,8 +333,8 @@ class ASConsole
void setOptionsFileName(string name); void setOptionsFileName(string name);
void setOrigSuffix(string suffix); void setOrigSuffix(string suffix);
void setPreserveDate(bool state); void setPreserveDate(bool state);
void standardizePath(string &path, bool removeBeginningSeparator = false) const; void standardizePath(string& path, bool removeBeginningSeparator = false) const;
bool stringEndsWith(const string &str, const string &suffix) const; bool stringEndsWith(const string& str, const string& suffix) const;
void updateExcludeVector(string suffixParam); void updateExcludeVector(string suffixParam);
vector<string> getExcludeVector() const; vector<string> getExcludeVector() const;
vector<bool> getExcludeHitsVector() const; vector<bool> getExcludeHitsVector() const;
@ -353,33 +343,33 @@ class ASConsole
vector<string> getFileOptionsVector() const; vector<string> getFileOptionsVector() const;
vector<string> getFileName() const; vector<string> getFileName() const;
private: // functions private: // functions
ASConsole &operator=(ASConsole &); // not to be implemented ASConsole& operator=(ASConsole&); // not to be implemented
void correctMixedLineEnds(ostringstream &out); void correctMixedLineEnds(ostringstream& out);
void formatFile(const string &fileName_); void formatFile(const string& fileName_);
string getCurrentDirectory(const string &fileName_) const; string getCurrentDirectory(const string& fileName_) const;
void getFileNames(const string &directory, const string &wildcard); void getFileNames(const string& directory, const string& wildcard);
void getFilePaths(string &filePath); void getFilePaths(string& filePath);
string getParam(const string &arg, const char* op); string getParam(const string& arg, const char* op);
void initializeOutputEOL(LineEndFormat lineEndFormat); void initializeOutputEOL(LineEndFormat lineEndFormat);
bool isOption(const string &arg, const char* op); bool isOption(const string& arg, const char* op);
bool isOption(const string &arg, const char* op1, const char* op2); bool isOption(const string& arg, const char* op1, const char* op2);
bool isParamOption(const string &arg, const char* option); bool isParamOption(const string& arg, const char* option);
bool isPathExclued(const string &subPath); bool isPathExclued(const string& subPath);
void launchDefaultBrowser(const char* filePathIn = NULL) const; void launchDefaultBrowser(const char* filePathIn = NULL) const;
void printHelp() const; void printHelp() const;
void printMsg(const char* msg, const string &data) const; void printMsg(const char* msg, const string& data) const;
void printSeparatingLine() const; void printSeparatingLine() const;
void printVerboseHeader() const; void printVerboseHeader() const;
void printVerboseStats(clock_t startTime) const; void printVerboseStats(clock_t startTime) const;
FileEncoding readFile(const string &fileName_, stringstream &in) const; FileEncoding readFile(const string& fileName_, stringstream& in) const;
void removeFile(const char* fileName_, const char* errMsg) const; void removeFile(const char* fileName_, const char* errMsg) const;
void renameFile(const char* oldFileName, const char* newFileName, const char* errMsg) const; void renameFile(const char* oldFileName, const char* newFileName, const char* errMsg) const;
void setOutputEOL(LineEndFormat lineEndFormat, const char* currentEOL); void setOutputEOL(LineEndFormat lineEndFormat, const string& currentEOL);
void sleep(int seconds) const; void sleep(int seconds) const;
int waitForRemove(const char* oldFileName) const; int waitForRemove(const char* oldFileName) const;
int wildcmp(const char* wild, const char* data) const; int wildcmp(const char* wild, const char* data) const;
void writeFile(const string &fileName_, FileEncoding encoding, ostringstream &out) const; void writeFile(const string& fileName_, FileEncoding encoding, ostringstream& out) const;
#ifdef _WIN32 #ifdef _WIN32
void displayLastError(); void displayLastError();
#endif #endif
@ -392,7 +382,7 @@ class ASConsole
class ASLibrary class ASLibrary
{ {
public: public:
ASLibrary() {} ASLibrary() {}
virtual ~ASLibrary() {} virtual ~ASLibrary() {}
// virtual functions are mocked in testing // virtual functions are mocked in testing
@ -400,10 +390,10 @@ class ASLibrary
virtual utf16_t* convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc) 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* pSourceIn) const;
private: private:
static char* STDCALL tempMemoryAllocation(unsigned long memoryNeeded); static char* STDCALL tempMemoryAllocation(unsigned long memoryNeeded);
private: private:
Utf8_16 utf8_16; // utf8/16 conversion methods Utf8_16 utf8_16; // utf8/16 conversion methods
}; };