Upgrade to SVN r511
This commit is contained in:
parent
c8638db9b4
commit
a80ed8000a
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal 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.
|
1232
doc/astyle.html
1232
doc/astyle.html
File diff suppressed because it is too large
Load Diff
BIN
doc/favicon.ico
Normal file
BIN
doc/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
473
doc/install.html
473
doc/install.html
@ -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>
|
||||
<title>Artistic Style - Install Information</title>
|
||||
@ -12,401 +12,335 @@
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Artistic Style Install Information
|
||||
</h1>
|
||||
<h1>Artistic Style Install Information</h1>
|
||||
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<h3 id="Contents">
|
||||
Contents
|
||||
</h3>
|
||||
<h3 id="Contents">Contents</h3>
|
||||
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Artistic_Style_Versions">Artistic Style Versions</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Artistic_Style_Versions">Artistic Style Versions</a></p>
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Linux_Version">Linux Version</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Linux_Version">Linux Version</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_GCC_Compiler">GCC Compiler</a>
|
||||
</p>
|
||||
<a class="contents" href="#_GCC_Compiler">GCC Compiler</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Other_Makefile_Options">Other Makefile Options</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Clang_Compiler">Clang Compiler</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Clang_Compiler">Clang Compiler</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Intel_Compiler">Intel Compiler</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Intel_Compiler">Intel Compiler</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Other_Makefile_Targets">Other Makefile Targets</a></p>
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Mac_OS_X_Version">Mac OS X Version</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Mac_OS_Version">Mac OS Version</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Xcode">Xcode</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Xcode">Xcode</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Makefile">Makefile</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Makefile">Makefile</a></p>
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Windows_Version">Windows Version</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Windows_Version">Windows Version</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Precompiled_Executable">Precompiled Executable</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Precompiled_Executable">Precompiled Executable</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Visual_C++_Compiler">Visual C++ Compiler</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Visual_C++_Compiler">Visual C++ Compiler</a></p>
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_Other_Compilers">Other Compilers</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Other_Compilers">Other Compilers</a></p>
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Compiler_Options">Compiler Options</a>
|
||||
</p>
|
||||
<a class="contents" href="#_Compiler_Options">Compiler Options</a></p>
|
||||
|
||||
<h3 id="_Artistic_Style_Versions">
|
||||
Artistic Style Versions
|
||||
</h3>
|
||||
<h3 id="_Artistic_Style_Versions">Artistic Style Versions</h3>
|
||||
|
||||
<p>
|
||||
astyle_x.x_linux.tar.gz is the <b>Linux </b>version of Artistic Style. It contains the source code, documentation,
|
||||
and makefiles. The Linux Version compile instructions below give information for compiling the source code.
|
||||
</p>
|
||||
astyle_x.x_linux.tar.gz is the <strong>Linux </strong>version of Artistic Style. It contains the source code,
|
||||
documentation, and makefiles. The Linux Version compile instructions below give information for compiling the
|
||||
source code.</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,
|
||||
Xcode project files, and a makefile. The Mac OS X Version compile instructions below give information for compiling
|
||||
the source code.
|
||||
</p>
|
||||
astyle_x.x_macos.tar.gz is the <strong>Mac OS </strong>version of Artistic Style. It contains the source code,
|
||||
documentation, Xcode project files, and a makefile. The Mac OS Version compile instructions below give information
|
||||
for compiling the source code.</p>
|
||||
<p>
|
||||
astyle_x.x_windows.zip is the <b>Windows </b>version of Artistic Style. It contains the source code, documentation,
|
||||
Visual C project files, and an executable. The Windows Version compile instructions below give information for
|
||||
compiling the source code.
|
||||
</p>
|
||||
astyle_x.x_windows.zip is the <strong>Windows </strong>version of Artistic Style. It contains the source code,
|
||||
documentation, Visual C project files, and an executable. The Windows Version compile instructions below give
|
||||
information for compiling the source code.</p>
|
||||
<p>
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
code and documentation are the same for all distributions.</p>
|
||||
|
||||
<h3 id="_Linux_Version">
|
||||
Linux Version
|
||||
</h3>
|
||||
<h3 id="_Linux_Version">Linux Version</h3>
|
||||
|
||||
<h4 id="_GCC_Compiler">
|
||||
GCC Compiler
|
||||
</h4>
|
||||
<h4 id="_GCC_Compiler">GCC Compiler</h4>
|
||||
|
||||
<p>
|
||||
To compile using the GCC compiler you must have GCC (3.1 or better) installed.
|
||||
</p>
|
||||
To compile using the GCC compiler you must have GCC (3.1 or better) installed.</p>
|
||||
<p>
|
||||
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
|
||||
line configuration enter the following:
|
||||
</p>
|
||||
line configuration enter the following:</p>
|
||||
<pre>cd astyle/build/gcc<br />make
|
||||
</pre>
|
||||
<p>
|
||||
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
|
||||
parens) of the various configurations:
|
||||
</p>
|
||||
parens) of the various configurations:</p>
|
||||
<ul>
|
||||
<li><b>release </b>builds the Artistic Style command line program (astyle). This is the default option.</li>
|
||||
<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><strong>release </strong>builds the Artistic Style command line program (astyle). This is the default option.
|
||||
</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><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>
|
||||
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.
|
||||
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.
|
||||
</p>
|
||||
6. If the compile cannot find the file jni.h, either set the variable or change the value in the
|
||||
makefile.</p>
|
||||
</li>
|
||||
<li><b>java </b>builds the Artistic Style program as a shared library which includes the JNI (libastylej.so).</li>
|
||||
<li><b>javadebug </b>builds the Artistic Style program as a shared library which includes the JNI and debugging information
|
||||
<li><strong>java </strong>builds the Artistic Style program as a shared library which includes the JNI (libastylej.so).
|
||||
</li>
|
||||
<li><strong>javadebug </strong>builds the Artistic Style program as a shared library which includes the JNI and debugging
|
||||
information
|
||||
(libastylejd.so).</li>
|
||||
<li><span style="font-weight: bold;">javaall </span>builds all the above java configurations.</li>
|
||||
</ul>
|
||||
<p>
|
||||
More than one configuration can be built at the same time. For example, to build all the release configurations
|
||||
enter:
|
||||
</p>
|
||||
enter:</p>
|
||||
<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">
|
||||
Other Makefile Options
|
||||
</h4>
|
||||
<h4 id="_Clang_Compiler">Clang Compiler</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>
|
||||
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
|
||||
the analysis on Artistic Style.
|
||||
</p>
|
||||
the analysis on Artistic Style.</p>
|
||||
<p>
|
||||
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
|
||||
line configuration enter the following:
|
||||
</p>
|
||||
line configuration enter the following:</p>
|
||||
<pre>cd astyle/build/clang<br />make
|
||||
</pre>
|
||||
<p>
|
||||
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
|
||||
built at the same time. For example, to build all the release configurations enter:
|
||||
</p>
|
||||
built at the same time. For example, to build all the release configurations enter:</p>
|
||||
<pre>cd astyle/build/clang<br />make release shared static
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the GCC compiler.
|
||||
</p>
|
||||
The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
|
||||
options.</p>
|
||||
|
||||
<h4 id="_Intel_Compiler">
|
||||
Intel Compiler
|
||||
</h4>
|
||||
<h4 id="_Intel_Compiler">Intel Compiler</h4>
|
||||
|
||||
<p>
|
||||
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".
|
||||
</p>
|
||||
Instructions for your compiler are in the compiler documentation file "get_started_lc.htm".</p>
|
||||
<p>
|
||||
To compile the source there are environment variables that must be set by running the compiler environment script
|
||||
compilervars.sh (or compilervars.csh) with an argument that specifies the target architecture. If this has not
|
||||
been done already enter: "<strong>source <install-dir>/bin/compilervars.sh <arg></strong>",
|
||||
where <install-dir> is the directory where the compiler is installed and <arg> is <strong>ia32 </strong>
|
||||
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
|
||||
</p>
|
||||
variables are not set." On an Intel x64 platform installed in the default directory the instruction would
|
||||
be</p>
|
||||
<pre>source /opt/intel/bin/compilervars.sh intel64</pre>
|
||||
<p>
|
||||
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
|
||||
the command line configuration enter the following:
|
||||
</p>
|
||||
the command line configuration enter the following:</p>
|
||||
<pre>cd astyle/build/intel<br />make</pre>
|
||||
<p>
|
||||
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
|
||||
built at the same time. For example, to build the entire debug configurations enter:
|
||||
</p>
|
||||
built at the same time. For example, to build the entire debug configurations enter:</p>
|
||||
<pre>cd astyle/build/intel<br />make debug shareddebug staticdebug</pre>
|
||||
<p>
|
||||
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the GCC compiler.
|
||||
</p>
|
||||
The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
|
||||
options.</p>
|
||||
|
||||
<h3 id="_Mac_OS_X_Version">
|
||||
Mac OS X Version
|
||||
</h3>
|
||||
<h4 id="_Other_Makefile_Targets">Other Makefile Targets</h4>
|
||||
|
||||
<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>
|
||||
|
||||
<p>
|
||||
Artistic Style workspace and project files for the Xcode development environment are available in the "build/xcode"
|
||||
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.
|
||||
</p>
|
||||
and Release configurations. The following projects are available.</p>
|
||||
<ul>
|
||||
<li><b>AStyle</b> 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>AStyle</strong> builds the Artistic Style command line program (astyle). </li>
|
||||
<li><strong>AStyleA</strong> builds the Artistic Style program as a Static Library (libastyle.a). This can be statically
|
||||
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
|
||||
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
|
||||
from a Java program. The Java Development (JDK) is required for the project to compile. The Project Properties
|
||||
must have an include path to the JDK include directory. The output dylib can also be called from a C++ or C#
|
||||
program.</li>
|
||||
<li><strong>AStyleDylib</strong> builds the Artistic Style program as a Dynamic Library (libastyle.dylib). It can
|
||||
be used with C/C++, Objective C, C#, and Python programs.</li>
|
||||
<li><strong>AStyleJava</strong> builds the Artistic Style program as a Dynamic Library (libastylej.dylib) that can
|
||||
be called from a Java program. The Java Development (JDK) is required for the project to compile. The Project
|
||||
Properties must have an include path to the JDK include directory. The output dylib can also be called from a
|
||||
C++ or C# program.</li>
|
||||
</ul>
|
||||
|
||||
<h5>install</h5>
|
||||
|
||||
<p>
|
||||
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
|
||||
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.
|
||||
If sudo is not used for the install an error will occur during the build.
|
||||
</p>
|
||||
If sudo is not used for the install an error will occur during the build.</p>
|
||||
<p>
|
||||
To install the astyle executable to the default directory:
|
||||
</p>
|
||||
To install the astyle executable to the default directory:</p>
|
||||
<pre>cd astyle/build/xcode
|
||||
sudo xcodebuild install -project AStyle.xcodeproj
|
||||
</pre>
|
||||
<p>
|
||||
A script is used to install the documentation
|
||||
from the same directory.
|
||||
</p>
|
||||
from the same directory.</p>
|
||||
<pre>sudo bash install.sh
|
||||
</pre>
|
||||
<h5>uninstall
|
||||
</h5>
|
||||
|
||||
<h5>uninstall</h5>
|
||||
|
||||
<p>
|
||||
Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.
|
||||
</p>
|
||||
Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.</p>
|
||||
<p>
|
||||
A script is used to uninstall astyle and the documentation:
|
||||
</p>
|
||||
A script is used to uninstall astyle and the documentation:</p>
|
||||
<pre>sudo bash uninstall.sh
|
||||
</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>
|
||||
be removed individually for each user.</p>
|
||||
|
||||
<h4 id="_Makefile">Makefile</h4>
|
||||
|
||||
<p>
|
||||
The Artistic Style makefile compile uses the OS X "Command Line Tools". If you have Xcode 4.3 or newer
|
||||
The Artistic Style makefile compile uses the Mac OS "Command Line Tools". If you have Xcode 4.3 or newer
|
||||
the command line tools, such as "make", are NOT installed by default. They must be downloaded and installed
|
||||
separately. Once everything is successfully installed you should see "make" and other command line developer
|
||||
tools in /usr/bin.
|
||||
</p>
|
||||
tools in /usr/bin.</p>
|
||||
<p>
|
||||
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
|
||||
line configuration enter the following:
|
||||
</p>
|
||||
line configuration enter the following:</p>
|
||||
<pre>cd astyle/build/mac<br />make
|
||||
</pre>
|
||||
<p>
|
||||
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
|
||||
built at the same time. For example, to build all the release configurations enter:
|
||||
</p>
|
||||
built at the same time. For example, to build all the release configurations enter:</p>
|
||||
<pre>cd astyle/build/mac<br />make release shared static
|
||||
</pre>
|
||||
<p>
|
||||
The <a href="#_Other_Makefile_Options">Other Makefile Options</a> are the same as for the Linux GCC compiler.
|
||||
</p>
|
||||
The <a href="#_Other_Makefile_Targets">Other Makefile Targets</a> section contains additional target
|
||||
options.</p>
|
||||
|
||||
<h3 id="_Windows_Version">
|
||||
Windows Version
|
||||
</h3>
|
||||
<h3 id="_Windows_Version">Windows Version</h3>
|
||||
|
||||
<h4 id="_Precompiled_Executable">
|
||||
Precompiled Executable
|
||||
</h4>
|
||||
<h4 id="_Precompiled_Executable">Precompiled Executable</h4>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
(AStyle.exe). If you prefer to compile the executable yourself follow the following instructions.</p>
|
||||
|
||||
<h4 id="_Visual_C++_Compiler">
|
||||
Visual C++ Compiler
|
||||
</h4>
|
||||
<h4 id="_Visual_C++_Compiler">Visual C++ Compiler</h4>
|
||||
|
||||
<p>
|
||||
There are configuration and project files for
|
||||
several versions of the Visual C compiler. Open the AStyle configuration
|
||||
file in the appropriate "build" directory. All project files have Debug, Release and Static configurations.
|
||||
There are
|
||||
solution and project files for
|
||||
several versions of the Visual C compiler. Open an Artistic Style solution
|
||||
file in the appropriate "build" directory. All projects have Debug, Release and Static configurations.
|
||||
Debug file output will be in the "debug" directory. Release file output will be in the "bin"
|
||||
directory. Static file output will be in the "binstatic" directory. The following solution files are available.
|
||||
</p>
|
||||
directory. Static file output will be in the "binstatic" directory. The following solution files are
|
||||
available.</p>
|
||||
<ul>
|
||||
<li><b>All AStyle </b>builds the release and the debug configurations for all the following.</li>
|
||||
<li><b>AStyle </b>builds the Artistic Style command line program (AStyle.exe). This project has an extra "Static"
|
||||
option. It is the same as the "Release" build except that it is linked with a static runtime library. This is
|
||||
needed if the executable is to be run on a system without Visual Studio installed. The builds for this configuration
|
||||
are placed in a separate "binstatic" directory. </li>
|
||||
<li><b>AStyleDll </b>builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will also build
|
||||
an exports library and a static library for linking the dll. </li>
|
||||
<li><b>AStyleJava </b>builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can be called
|
||||
from a Java program. The Java Development (JDK) is required for the project to compile. The Project Properties
|
||||
must have an include path to the JDK include and include/win32 directories. This is set in "Project >
|
||||
Properties > C/C++ > General > Additional Include Directories". The default setting is
|
||||
for the JDK to be installed in the default directory, but it may not be the most current release. The output DLL
|
||||
can also be called from a C++ or C# program.</li>
|
||||
<li><b>AStyleLib </b>builds the Artistic Style program as a Static Library (libAStyle.lib). This can be statically
|
||||
linked to a calling program.</li>
|
||||
<li><strong>All AStyle ll AStyle </strong>builds the release and the debug configurations for all the following.
|
||||
</li>
|
||||
<li><strong>AStyle </strong>builds the Artistic Style command line program (AStyle.exe). This project has an extra
|
||||
"Static" option. It is the same as the "Release" build except that it is linked with a static runtime library.
|
||||
This is needed if the executable is to be run on a system without Visual Studio installed. The builds for this
|
||||
configuration are placed in a separate "binstatic" directory. </li>
|
||||
<li><strong>AStyleDll </strong>builds the Artistic Style program as a Dynamic Link Library (AStyle.dll). This will
|
||||
also build an exports library and a static library for linking the dll. </li>
|
||||
<li><strong>AStyleJava </strong>builds the Artistic Style program as a Dynamic Link Library (AStylej.dll) that can
|
||||
be called from a Java program. The Java Development (JDK) is required for the project to compile. The Project
|
||||
Properties must have an include path to the JDK include and include/win32 directories. This is set in "Project
|
||||
> Properties > C/C++ > General > Additional Include Directories". The default setting
|
||||
is for the JDK to be installed in the default directory, but it may not be the most current release. The output
|
||||
DLL can also be called from a C++ or C# program.</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>
|
||||
|
||||
<h4 id="_Other_Compilers">
|
||||
Other Compilers
|
||||
</h4>
|
||||
<h4 id="_Other_Compilers">Other Compilers</h4>
|
||||
|
||||
<p>
|
||||
To use other compilers a project file must be built using a development environment.
|
||||
</p>
|
||||
To use other compilers a project file must be built using a development environment.</p>
|
||||
<ul>
|
||||
<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>
|
||||
@ -414,61 +348,32 @@ sudo xcodebuild install -project AStyle.xcodeproj
|
||||
<li>Compile.</li>
|
||||
</ul>
|
||||
|
||||
<h3 id="_Compiler_Options">
|
||||
Compiler Options
|
||||
</h3>
|
||||
<h3 id="_Compiler_Options">Compiler Options</h3>
|
||||
|
||||
<p>
|
||||
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
|
||||
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
|
||||
options to compile the debug versions.
|
||||
</p>
|
||||
options to compile the debug versions.</p>
|
||||
<p>
|
||||
Artistic Style is a small program and it is best to optimize for speed. The debug configurations are not usually
|
||||
optimized. To optimize for speed in the release configurations use the macro NDEBUG to remove asserts. If
|
||||
necessary, use an option to activate the C++11 standards (--std=c++0x on GCC and MinGW). Use an
|
||||
option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed. Exceptions are not
|
||||
option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed. Exceptions are
|
||||
NOT
|
||||
used. Use whole program optimization if your compiler supports it. There may be other options you can use depending
|
||||
on the compiler.
|
||||
</p>
|
||||
on the compiler.</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<center style="margin-left: -0.4in;">
|
||||
<p style="margin-left: -0.4in; text-align: center;">
|
||||
<a href="http://sourceforge.net/projects/astyle">
|
||||
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" />
|
||||
</a>
|
||||
</center>
|
||||
</a></p>
|
||||
|
||||
<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 -->
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
||||
|
431
doc/news.html
431
doc/news.html
@ -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>
|
||||
<title>Artistic Style - News</title>
|
||||
@ -15,167 +15,332 @@
|
||||
<h1>Artistic Style News</h1>
|
||||
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<h3>Artistic Style 2.06 (Pending)</h3>
|
||||
|
||||
<p>
|
||||
A new option, "pad-comma", will add a space following a comma. The option "pad-oper"
|
||||
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 "disable formatting" comment tags if there are arrays
|
||||
with vertical alignment where this is not wanted.</p>
|
||||
<p>
|
||||
New Objective-C options "pad-return-type" and "unpad-return-type" 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 "Internationalization" in the "General Information" 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 "Any CPU" can load
|
||||
either a 32-bit or 64-bit shared library.</p>
|
||||
<p>
|
||||
</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). 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 ".exe" 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 "auto detect..." option in Tools > Options... > Text Editor > General, an
|
||||
additional compiler option is required. The option "/source‑charset:utf‑8" must be added
|
||||
to the project properties at C++ > Command Line, Additional Options. Since the non‑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 "/validate‑charset" 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 > "Advanced Save Options...". Change the encoding
|
||||
to "Unicode (UTF-8 with signature) - Codepage 65001". </p>
|
||||
<p>
|
||||
In the above "Visual C++ Team Blog" 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 "Align Assignments" that will align assignment operators
|
||||
across multiple lines. There is also an extension named "Code alignment" that will align the code on
|
||||
other items as well. 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 "Clang
|
||||
with Microsoft CodeGen" option. If Visual Studio 2015 Update 2 or 3 is already installed, Clang can be installed
|
||||
by selecting File > New > Project > Visual C++ > Cross Platform, select "Install Clang with Microsoft
|
||||
CodeGen".</p>
|
||||
<p>
|
||||
To use Clang open a Visual Studio 2015 AStyle Solution. Make the following change to all configurations: </p>
|
||||
<ul>
|
||||
<li>General > Platform Toolset, select "Clang with Microsoft CodeGen".</li>
|
||||
</ul>
|
||||
<p>
|
||||
Make sure to hit "Apply" 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++ > General > Debug Information Format, select "Full Debug Information (DWARF2)" for Debug
|
||||
or "None" for Release.</li>
|
||||
<li>C/C++ > General > Warning Level, select "Enable All Warnings".</li>
|
||||
<li>C/C++ > Optimization > Optimization, select an appropriate valid value for each configuration.</li>
|
||||
<li>C/C++ > Code Generation > Enable C++ Exceptions, select "Yes" for Debug or "No" for
|
||||
Release.</li>
|
||||
<li>C/C++ > Precompiled Headers > Precompiled Header, select "Not Using Precompiled Headers".</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 "-" instead of "/".
|
||||
The new opton "/source-charset:utf-8" can NOT be used with Clang. If necessary, remove it from C/C++
|
||||
> Command Line > Additional Options.</p>
|
||||
<ul>
|
||||
<li>C/C++ > Preprocessor > Preprocessor Definitions, add " __STDC__=0".
|
||||
</li>
|
||||
<li>C/C++ > Command Line > Additional Options, enter "-Wno-macro-redefined".
|
||||
</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>"Windows XP Support for C++" 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 > Platform Toolset, to "Windows XP" for your Visual
|
||||
Studio version.</li>
|
||||
<li>In the Artistic Style Properties, change C/C++ > Preprocessor > 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 "Universal CRT" 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 (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>
|
||||
|
||||
<p>
|
||||
A new bracket style option, "style=vtk", 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
|
||||
style is available at the "Visualization Toolkit" website (http://www.vtk.org/).
|
||||
</p>
|
||||
style is available at the "Visualization Toolkit" website (http://www.vtk.org/).</p>
|
||||
<p>
|
||||
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
|
||||
indented.
|
||||
The option is described in the "Indentation Options" section of the documentation.
|
||||
</p>
|
||||
The option is described in the "Indentation Options" section of the documentation.</p>
|
||||
<p>
|
||||
A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as usual.
|
||||
</p>
|
||||
A new option, "dry-run", will run Artistic Style without updating the files. The report will be output as
|
||||
usual.</p>
|
||||
<p>
|
||||
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 "Disable Formatting" 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
|
||||
of a single line. This should allow any custom formatting to be retained.
|
||||
</p>
|
||||
of a single line. This should allow any custom formatting to be retained.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
versions of a shared library on the same system without conflicts.</p>
|
||||
<p>
|
||||
An attribute '__attribute__ ((visibility ("default")))' has been added to exported functions
|
||||
on Linux shared libraries. This allows the option "-fvisibility=hidden" to be used on dynamic library
|
||||
compiles. According to the GNU documentation, "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
|
||||
symbol clashes. It is strongly recommended that you use this in any shared objects you distribute."
|
||||
</p>
|
||||
symbol clashes. It is strongly recommended that you use this in any shared objects you distribute."</p>
|
||||
<p>
|
||||
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
|
||||
final line unless it is broken initially. And the known problems with uniform initializers in class constructors
|
||||
have been fixed.
|
||||
</p>
|
||||
have been fixed.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
It is sometimes needed for static libraries on other compilers to prevent error and warning messages.</p>
|
||||
<p>
|
||||
Qt and Boost macros foreach, forever, Q_FOREACH, and Q_FOREVER will now be recognized as headers.
|
||||
</p>
|
||||
Qt and Boost macros foreach, forever, Q_FOREACH, and Q_FOREVER will now be recognized as headers.</p>
|
||||
<p>
|
||||
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
|
||||
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
|
||||
documentation. The option is available only from the command line.
|
||||
</p>
|
||||
documentation. The option is available only from the command line.</p>
|
||||
<p>
|
||||
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
|
||||
the variation "html=<actual_install_path>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.
|
||||
</p>
|
||||
More information is in the "Command Line Only" section of the documentation.</p>
|
||||
<p>
|
||||
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. 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.
|
||||
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.
|
||||
</p>
|
||||
documentation takes quite a bit of effort to maintain and I would like to make it easily available.</p>
|
||||
<p>
|
||||
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 | less", which
|
||||
will page the display. The "version" option has also been changed to stdout.
|
||||
</p>
|
||||
will page the display. The "version" option has also been changed to stdout.</p>
|
||||
<p>
|
||||
A shared library error handler argument has been changed from "char*" to "const char*". In
|
||||
some cases this may cause compile errors in a user program until the references have been changed.
|
||||
</p>
|
||||
some cases this may cause compile errors in a user program until the references have been changed.</p>
|
||||
<p>
|
||||
The "Indent Style" topic on Wikipedia states that the "ANSI" style refers to K&R style brackets
|
||||
and not Allman style as used by Artistic Style. The option "style=ansi" is therefore being depreciated and will
|
||||
be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or style=break).
|
||||
</p>
|
||||
be removed in a future release. Use one of the other long options instead (style=allman, style=bsd, or
|
||||
style=break).</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
install and run Artistic Style. The included files can be used without an Internet connection.</p>
|
||||
<p>
|
||||
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
|
||||
change to the makefile debug locations to make them similar to Xcode. The "Install Instructions" have
|
||||
been updated for both.
|
||||
</p>
|
||||
been updated for both.</p>
|
||||
<p>
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
(beginning with release 2.1). Node.js can also be installed in Visual Studio Express.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
work on XP. If you are using XP, Artistic Style will need to be recompiled on the XP machine.</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
|
||||
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
|
||||
used from within Visual Studio. To install it search the "Extensions and Updates", "Online"
|
||||
entry for "astyle".
|
||||
</p>
|
||||
entry for "astyle".</p>
|
||||
<p>
|
||||
Thanks to Peter A. Bigot, HyungKi Jeong, David Faure, and Carl Moore for their contributions.
|
||||
</p>
|
||||
Thanks to Peter A. Bigot, HyungKi Jeong, David Faure, and Carl Moore for their contributions.</p>
|
||||
|
||||
<h3>Artistic Style 2.04 (November 2013)</h3>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
Style. You may want to format your source before making program changes in order to bring it up to date.</p>
|
||||
<p>
|
||||
A new programming language, Objective‑C, has been added to Artistic Style. Four new options, "align‑method‑colon",
|
||||
"pad‑method‑colon=", "pad‑method‑prefix", and "unpad‑method‑prefix" have been
|
||||
added to format the methods. The options are described in a new "Objective‑C" section in the documentation.
|
||||
These new options affect only Objective‑C source code. They have no effect on the other programming languages.
|
||||
</p>
|
||||
These new options affect only Objective‑C source code. They have no effect on the other programming
|
||||
languages.</p>
|
||||
<p>
|
||||
Because of the longer continuation indents sometimes needed for Objective‑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
|
||||
this value. The default minimum is 40 and the maximum is 120.
|
||||
</p>
|
||||
this value. The default minimum is 40 and the maximum is 120.</p>
|
||||
<p>
|
||||
A new bracket style option, "style=google", has been added. It uses attached brackets and indents the class access
|
||||
modifiers one-half indent. A complete description of the Google style is available at the google‑styleguide
|
||||
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.
|
||||
</p>
|
||||
along with a python program to verify the style and an emacs script for using the style.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
indent. The rest of the class is not indented. It is described in the "Indentation Options" section of the
|
||||
documentation.</p>
|
||||
<p>
|
||||
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
|
||||
of the documentation.
|
||||
</p>
|
||||
of the documentation.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
statement on a single line. It is described in the "Formatting Options" section of the documentation.</p>
|
||||
<p>
|
||||
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
|
||||
been deprecated and will be removed in a future release. Use "indent-preproc-define" instead. The processing of
|
||||
preprocessor #define statements has not changed.
|
||||
</p>
|
||||
preprocessor #define statements has not changed.</p>
|
||||
<p>
|
||||
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 '*'
|
||||
@ -183,125 +348,102 @@
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
the indentation of any commented-out code.</p>
|
||||
<p>
|
||||
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
|
||||
to "pad-first-paren-out". This needs to be done only once.
|
||||
</p>
|
||||
to "pad-first-paren-out". This needs to be done only once.</p>
|
||||
<p>
|
||||
Processing of C++11 raw string literals has been added.
|
||||
</p>
|
||||
Processing of C++11 raw string literals has been added.</p>
|
||||
<p>
|
||||
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.
|
||||
It removes the "__declspec(dllexport)"
|
||||
definition from exported functions. Linux compilers do not use this.
|
||||
</p>
|
||||
definition from exported functions. Linux compilers do not use this.</p>
|
||||
<p>
|
||||
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,
|
||||
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
|
||||
previous release are marked in the example.
|
||||
</p>
|
||||
previous release are marked in the example.</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
|
||||
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
|
||||
use UTF-16.
|
||||
</p>
|
||||
use UTF-16.</p>
|
||||
<p>
|
||||
The "Links" page has two new sections for links mentioned in previous versions of Artistic Style. It links to
|
||||
free software and other information.
|
||||
</p>
|
||||
free software and other information.</p>
|
||||
<p>
|
||||
The "Developer Information" section has a new example and download for calling Artistic Style from an Objective‑C
|
||||
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
|
||||
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‑C on Windows and
|
||||
Linux" which has information on compiling and running the example on those systems.
|
||||
</p>
|
||||
Linux" which has information on compiling and running the example on those systems.</p>
|
||||
<p>
|
||||
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
|
||||
Windows 8. This means that applications built with a Visual Studio 2012 C++ compiler would fail to load and execute
|
||||
on Windows XP.
|
||||
</p>
|
||||
on Windows XP.</p>
|
||||
<p>
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
move semantics will probably result in faster execution.</p>
|
||||
<p>
|
||||
Thanks to Evmenov Georgiy, Matthew Woehlke, Jiang, Ruzzz, and beta100100 for their contributions.
|
||||
</p>
|
||||
Thanks to Evmenov Georgiy, Matthew Woehlke, Jiang, Ruzzz, and beta100100 for their contributions.</p>
|
||||
|
||||
<h3>Artistic Style 2.03 (April 2013)</h3>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
Style. You may want to format your source before making program changes in order to bring it up to date.</p>
|
||||
<p>
|
||||
A new option, "max-code-length=#" or "xC#", will limit the length of code on a line. A new option "break‑after‑logical",
|
||||
or "xL", will modify a line break for conditionals. See the documentation for details.
|
||||
</p>
|
||||
or "xL", will modify a line break for conditionals. See the documentation for details.</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
|
||||
documentation for details.
|
||||
</p>
|
||||
documentation for details.</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
than the indent length. See the documentation for details.</p>
|
||||
<p>
|
||||
The short option for delete-empty-lines has changed from "xd" to "xe".
|
||||
</p>
|
||||
The short option for delete-empty-lines has changed from "xd" to "xe".</p>
|
||||
<p>
|
||||
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 "align-pointer" and "align-reference"
|
||||
options.
|
||||
</p>
|
||||
options.</p>
|
||||
<p>
|
||||
Closing the ending angle brackets of templates is now allowed by the C++11 standard. A new option, "close-templates"
|
||||
or "xy", will close the whitespace in the angle brackets of template definitions. Be sure your compiler supports
|
||||
this before making the changes.
|
||||
</p>
|
||||
this before making the changes.</p>
|
||||
<p>
|
||||
The C/C++ keyword 'extern "C"' in a preprocessor no longer causes an extra indent.
|
||||
</p>
|
||||
The C/C++ keyword 'extern "C"' in a preprocessor no longer causes an extra indent.</p>
|
||||
<p>
|
||||
Formatting of C++/CLI managed pointers (the '^' character) has been added to the "align-pointer"
|
||||
option.
|
||||
</p>
|
||||
option.</p>
|
||||
<p>
|
||||
The breaking of switch "default" statements has been fixed. The "default" statements
|
||||
that have been incorrectly broken will be fixed in this release.
|
||||
</p>
|
||||
that have been incorrectly broken will be fixed in this release.</p>
|
||||
<p>
|
||||
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
|
||||
needs to be set. With others. such as CodeBlocks, identification is automatic. On Linux, UTF-8 is the default
|
||||
encoding.
|
||||
</p>
|
||||
encoding.</p>
|
||||
<p>
|
||||
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
|
||||
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 "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.
|
||||
</p>
|
||||
the addition as a bug report and it will be included in the next release.</p>
|
||||
<p>
|
||||
There is a new Linux makefile for the Clang Compiler. Clang is a free compiler can be installed as a package on
|
||||
many Linux distributions. Some of its features are fast compiles, low memory use, expressive diagnostic messages,
|
||||
and GCC compatibility. It includes a static analyzer tool that finds potential bugs in your source code. An experimental
|
||||
version can be installed on a Windows platform. There is more information in the Install Information documentation.
|
||||
</p>
|
||||
version can be installed on a Windows platform. There is more information in the Install Information
|
||||
documentation.</p>
|
||||
<p>
|
||||
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
|
||||
@ -310,32 +452,28 @@
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
option to create the import library and export files.</p>
|
||||
<p>
|
||||
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
|
||||
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
|
||||
on computers using Windows XP.
|
||||
</p>
|
||||
on computers using Windows XP.</p>
|
||||
<p>
|
||||
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
|
||||
files available.
|
||||
</p>
|
||||
files available.</p>
|
||||
<p>
|
||||
If you use a compiler other than Visual Studio, you can probably get better execution by compiling using the C++11
|
||||
standards. Artistic Style uses a lot of string vectors and the new move semantics will probably result in faster
|
||||
execution. (To use C++11 on GCC and MinGW use the option --std=c++0x). This may change on future compiler releases.).
|
||||
</p>
|
||||
execution. (To use C++11 on GCC and MinGW use the option --std=c++0x). This may change on future compiler
|
||||
releases.</p>
|
||||
<p>
|
||||
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
|
||||
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
|
||||
memory in Python.
|
||||
</p>
|
||||
memory in Python.</p>
|
||||
<p>
|
||||
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
|
||||
@ -343,52 +481,23 @@
|
||||
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,
|
||||
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.
|
||||
</p>
|
||||
single page scripts. And there are some minor bugs. But overall it works quite well.</p>
|
||||
<p>
|
||||
Thanks to Christopher Sean Morrison, Keith OHara, louis6g, and J for their contributions.
|
||||
</p>
|
||||
Thanks to Christopher Sean Morrison, Keith OHara, louis6g, and J for their contributions.</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Previous releases are available in the <a href="http://astyle.sourceforge.net/newsArchives.html">News Archives</a>.</strong>
|
||||
</p>
|
||||
<strong>Previous releases are available in the
|
||||
<a href="http://astyle.sourceforge.net/newsArchives.html">News Archives</a>.</strong></p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<center style="margin-left: -0.4in;">
|
||||
<p style="margin-left: -0.4in; text-align: center;">
|
||||
<a href="http://sourceforge.net/projects/astyle">
|
||||
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a>
|
||||
</center>
|
||||
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a></p>
|
||||
|
||||
<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 -->
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
||||
|
@ -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>
|
||||
<title>Artistic Style - Release Notes</title>
|
||||
@ -15,8 +15,40 @@
|
||||
<h1>Artistic Style Release Notes</h1>
|
||||
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<h3>Artistic Style 2.06 (Pending)</h3>
|
||||
|
||||
<ul>
|
||||
<li>Add new Objective‑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‑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 "if" 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 "using" as a header.</li>
|
||||
<li>Fix C# to always recognize "forever" as a header.</li>
|
||||
<li>Fix end of line comments for "pad-method-prefix" and "unpad-method-prefix".</li>
|
||||
<li>Fix end of line comments for "pad-method-colon".</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 (December 2014)</h3>
|
||||
|
||||
@ -79,7 +111,7 @@
|
||||
<li>Fix indentation of C# "let" statements.</li>
|
||||
<li>Fix a few omissions with "fill-empty-lines".</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>
|
||||
<li>Extract class Utf8_16 from ASConsole. </li>
|
||||
<li>Replace Linux dependency on iconv with a Utf8_16 class for ASLibrary.</li>
|
||||
@ -234,47 +266,19 @@
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Previous releases are available in the <a href="http://astyle.sourceforge.net/notesArchives.html">Release
|
||||
Notes Archives</a>.</strong>
|
||||
</p>
|
||||
Notes Archives</a>.</strong></p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<center style="margin-left: -0.4in;">
|
||||
<p style="margin-left: -0.4in; text-align: center;">
|
||||
<a href="http://sourceforge.net/projects/astyle">
|
||||
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a>
|
||||
</center>
|
||||
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=2319&type=16" alt="" /></a></p>
|
||||
|
||||
<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 -->
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
* p.contents entries are for the table of contents
|
||||
* a.contents are table of contents links (not underlined)
|
||||
* a.links are links (underlined)
|
||||
* .footer is the image table at the bottom of the page
|
||||
* img does not have a border
|
||||
* 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 { color: #0000A0; text-align: center; font-size: larger; margin-top: 0.4in; margin-left: -0.5in; }
|
||||
h3 { color: #0000A0; margin-top: 0.4in; margin-left: -0.4in; }
|
||||
h4 { color: #0000A0; }
|
||||
h4 { color: #0000A0; margin-top: 0.3in; }
|
||||
|
||||
p.noindent { margin-left: -0.4in; }
|
||||
p.contents1 { font-size: 105%; margin-top: 0in; margin-left: 0in; margin-bottom: 0in; margin-right: 0in; }
|
||||
@ -31,9 +30,6 @@ a.contents:hover { color: #F00000; text-decoration: none; }
|
||||
a:link, a:visited { color: #0000A0; 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; }
|
||||
|
||||
pre { margin-left: 0.3in; color: navy; font-weight: bold; }
|
||||
|
@ -1,7 +1,6 @@
|
||||
# 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 \
|
||||
ASBeautifier.cpp \
|
||||
ASFormatter.cpp \
|
||||
@ -9,6 +8,13 @@ SRC = astyle_main.cpp \
|
||||
ASLocalizer.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
|
||||
vpath %.cpp ../../src
|
||||
vpath %.h ../../src
|
||||
@ -24,15 +30,12 @@ ifndef prefix
|
||||
prefix=/usr
|
||||
endif
|
||||
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
|
||||
bindir = bin
|
||||
objdir = obj
|
||||
ipath=$(prefix)/bin
|
||||
CBASEFLAGS = -W -Wall -fno-rtti -fno-exceptions
|
||||
CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions
|
||||
JAVAINCS = -I$(JAVA_HOME)/include
|
||||
CXX = clang++
|
||||
INSTALL=install -o $(USER) -g $(USER)
|
||||
@ -67,54 +70,54 @@ endif
|
||||
# a suffix is added for each build
|
||||
OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC))
|
||||
OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC))
|
||||
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRC))
|
||||
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRC))
|
||||
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRC))
|
||||
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRC))
|
||||
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRC))
|
||||
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRC))
|
||||
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRCx))
|
||||
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRCx))
|
||||
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRCx))
|
||||
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRCx))
|
||||
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRCx))
|
||||
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRCx))
|
||||
|
||||
# define object file rule (with the suffix) for each build
|
||||
|
||||
# OBJ
|
||||
$(objdir)/%.o: %.cpp astyle.h astyle_main.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSr) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSr) -c $< -o $@
|
||||
|
||||
# OBJd
|
||||
$(objdir)/%_d.o: %.cpp astyle.h astyle_main.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSd) -c $< -o $@
|
||||
|
||||
# OBJs
|
||||
$(objdir)/%_s.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSs) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSs) -c $< -o $@
|
||||
|
||||
# OBJsd
|
||||
$(objdir)/%_sd.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsd) -c $< -o $@
|
||||
|
||||
# OBJa
|
||||
$(objdir)/%_a.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSa) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSa) -c $< -o $@
|
||||
|
||||
# OBJad
|
||||
$(objdir)/%_ad.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSad) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSad) -c $< -o $@
|
||||
|
||||
# OBJsj
|
||||
$(objdir)/%_sj.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsj) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsj) -c $< -o $@
|
||||
|
||||
# OBJsjd
|
||||
$(objdir)/%_sjd.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsjd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsjd) -c $< -o $@
|
||||
|
||||
##################################################
|
||||
# define build dependencies for each command
|
||||
@ -131,16 +134,16 @@ astyled: $(OBJd)
|
||||
$(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
@ echo
|
||||
|
||||
shared: libastyle-2.05.1.so
|
||||
libastyle-2.05.1.so: $(OBJs)
|
||||
shared: libastyle.so
|
||||
libastyle.so: $(OBJs)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^
|
||||
@ echo
|
||||
|
||||
shareddebug: libastyle-2.05.1d.so
|
||||
libastyle-2.05.1d.so: $(OBJsd)
|
||||
shareddebug: libastyled.so
|
||||
libastyled.so: $(OBJsd)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^
|
||||
@ echo
|
||||
|
||||
static: libastyle.a
|
||||
@ -155,16 +158,16 @@ libastyled.a: $(OBJad)
|
||||
ar crs $(bindir)/$@ $^
|
||||
@ echo
|
||||
|
||||
java: libastyle-2.05.1j.so
|
||||
libastyle-2.05.1j.so: $(OBJsj)
|
||||
java: libastylej.so
|
||||
libastylej.so: $(OBJsj)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^
|
||||
@ echo
|
||||
|
||||
javadebug: libastyle-2.05.1jd.so
|
||||
libastyle-2.05.1jd.so: $(OBJsjd)
|
||||
javadebug: libastylejd.so
|
||||
libastylejd.so: $(OBJsjd)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^
|
||||
@ echo
|
||||
|
||||
all: release debug shared shareddebug static staticdebug
|
||||
@ -181,19 +184,17 @@ install:
|
||||
$(INSTALL) -m 755 -d $(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)
|
||||
@mkdir -p $(SYSCONF_PATH)/html;
|
||||
@for files in ../../doc/*.html ../../doc/*.css; \
|
||||
do \
|
||||
$(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \
|
||||
done
|
||||
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
|
||||
rm -rf $(SYSCONF_PATH_OLD); \
|
||||
fi
|
||||
|
||||
uninstall:
|
||||
rm -f $(ipath)/astyle
|
||||
rm -rf $(SYSCONF_PATH)
|
||||
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
|
||||
rm -rf $(SYSCONF_PATH_OLD); \
|
||||
fi
|
||||
|
@ -1,7 +1,6 @@
|
||||
# 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 \
|
||||
ASBeautifier.cpp \
|
||||
ASFormatter.cpp \
|
||||
@ -9,6 +8,13 @@ SRC = astyle_main.cpp \
|
||||
ASLocalizer.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
|
||||
vpath %.cpp ../../src
|
||||
vpath %.h ../../src
|
||||
@ -24,15 +30,12 @@ ifndef prefix
|
||||
prefix=/usr
|
||||
endif
|
||||
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
|
||||
bindir = bin
|
||||
objdir = obj
|
||||
ipath=$(prefix)/bin
|
||||
CBASEFLAGS = -W -Wall -fno-rtti -fno-exceptions
|
||||
CBASEFLAGS = -Wall -Wextra -fno-rtti -fno-exceptions
|
||||
JAVAINCS = -I$(JAVA_HOME)/include
|
||||
CXX = g++
|
||||
INSTALL=install -o $(USER) -g $(USER)
|
||||
@ -67,54 +70,54 @@ endif
|
||||
# a suffix is added for each build
|
||||
OBJ = $(patsubst %.cpp,$(objdir)/%.o,$(SRC))
|
||||
OBJd = $(patsubst %.cpp,$(objdir)/%_d.o,$(SRC))
|
||||
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRC))
|
||||
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRC))
|
||||
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRC))
|
||||
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRC))
|
||||
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRC))
|
||||
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRC))
|
||||
OBJs = $(patsubst %.cpp,$(objdir)/%_s.o,$(SRCx))
|
||||
OBJsd = $(patsubst %.cpp,$(objdir)/%_sd.o,$(SRCx))
|
||||
OBJa = $(patsubst %.cpp,$(objdir)/%_a.o,$(SRCx))
|
||||
OBJad = $(patsubst %.cpp,$(objdir)/%_ad.o,$(SRCx))
|
||||
OBJsj = $(patsubst %.cpp,$(objdir)/%_sj.o,$(SRCx))
|
||||
OBJsjd = $(patsubst %.cpp,$(objdir)/%_sjd.o,$(SRCx))
|
||||
|
||||
# define object file rule (with the suffix) for each build
|
||||
|
||||
# OBJ
|
||||
$(objdir)/%.o: %.cpp astyle.h astyle_main.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSr) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSr) -c $< -o $@
|
||||
|
||||
# OBJd
|
||||
$(objdir)/%_d.o: %.cpp astyle.h astyle_main.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSd) -c $< -o $@
|
||||
|
||||
# OBJs
|
||||
$(objdir)/%_s.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSs) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSs) -c $< -o $@
|
||||
|
||||
# OBJsd
|
||||
$(objdir)/%_sd.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsd) -c $< -o $@
|
||||
|
||||
# OBJa
|
||||
$(objdir)/%_a.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSa) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSa) -c $< -o $@
|
||||
|
||||
# OBJad
|
||||
$(objdir)/%_ad.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSad) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSad) -c $< -o $@
|
||||
|
||||
# OBJsj
|
||||
$(objdir)/%_sj.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsj) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsj) -c $< -o $@
|
||||
|
||||
# OBJsjd
|
||||
$(objdir)/%_sjd.o: %.cpp astyle.h
|
||||
@ mkdir -p $(objdir)
|
||||
$(CXX) $(CFLAGSsjd) -c -o $@ $<
|
||||
$(CXX) $(CFLAGSsjd) -c $< -o $@
|
||||
|
||||
##################################################
|
||||
# define build dependencies for each command
|
||||
@ -131,16 +134,16 @@ astyled: $(OBJd)
|
||||
$(CXX) $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
@ echo
|
||||
|
||||
shared: libastyle-2.05.1.so
|
||||
libastyle-2.05.1.so: $(OBJs)
|
||||
shared: libastyle.so
|
||||
libastyle.so: $(OBJs)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06.so $^
|
||||
@ echo
|
||||
|
||||
shareddebug: libastyle-2.05.1d.so
|
||||
libastyle-2.05.1d.so: $(OBJsd)
|
||||
shareddebug: libastyled.so
|
||||
libastyled.so: $(OBJsd)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06d.so $^
|
||||
@ echo
|
||||
|
||||
static: libastyle.a
|
||||
@ -155,16 +158,16 @@ libastyled.a: $(OBJad)
|
||||
ar crs $(bindir)/$@ $^
|
||||
@ echo
|
||||
|
||||
java: libastyle-2.05.1j.so
|
||||
libastyle-2.05.1j.so: $(OBJsj)
|
||||
java: libastylej.so
|
||||
libastylej.so: $(OBJsj)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSr) -o $(bindir)/libastyle-2.06j.so $^
|
||||
@ echo
|
||||
|
||||
javadebug: libastyle-2.05.1jd.so
|
||||
libastyle-2.05.1jd.so: $(OBJsjd)
|
||||
javadebug: libastylejd.so
|
||||
libastylejd.so: $(OBJsjd)
|
||||
@ mkdir -p $(bindir)
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/$@ $^
|
||||
$(CXX) -shared $(LDFLAGSd) -o $(bindir)/libastyle-2.06jd.so $^
|
||||
@ echo
|
||||
|
||||
all: release debug shared shareddebug static staticdebug
|
||||
@ -181,19 +184,17 @@ install:
|
||||
$(INSTALL) -m 755 -d $(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)
|
||||
@mkdir -p $(SYSCONF_PATH)/html;
|
||||
@for files in ../../doc/*.html ../../doc/*.css; \
|
||||
do \
|
||||
$(INSTALL) -m 644 $$files $(SYSCONF_PATH)/html; \
|
||||
done
|
||||
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
|
||||
rm -rf $(SYSCONF_PATH_OLD); \
|
||||
fi
|
||||
|
||||
uninstall:
|
||||
rm -f $(ipath)/astyle
|
||||
rm -rf $(SYSCONF_PATH)
|
||||
@if [ -d $(SYSCONF_PATH_OLD) ]; then \
|
||||
rm -rf $(SYSCONF_PATH_OLD); \
|
||||
fi
|
||||
|
@ -1,39 +1,29 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ASBeautifier.cpp
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// ASBeautifier.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.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "astyle.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
|
||||
//
|
||||
// this must be global
|
||||
static int g_preprocessorCppExternCBracket;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASBeautifier class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ASBeautifier's constructor
|
||||
* This constructor is called only once for each source file.
|
||||
@ -41,8 +31,6 @@ static int g_preprocessorCppExternCBracket;
|
||||
*/
|
||||
ASBeautifier::ASBeautifier()
|
||||
{
|
||||
g_preprocessorCppExternCBracket = 0;
|
||||
|
||||
waitingBeautifierStack = NULL;
|
||||
activeBeautifierStack = NULL;
|
||||
waitingBeautifierStackLengthStack = NULL;
|
||||
@ -158,6 +146,7 @@ ASBeautifier::ASBeautifier(const ASBeautifier &other) : ASBase(other)
|
||||
inLineNumber = other.inLineNumber;
|
||||
horstmannIndentInStatement = other.horstmannIndentInStatement;
|
||||
nonInStatementBracket = other.nonInStatementBracket;
|
||||
objCColonAlignSubsequent = other.objCColonAlignSubsequent;
|
||||
lineCommentNoBeautify = other.lineCommentNoBeautify;
|
||||
isElseHeaderIndent = other.isElseHeaderIndent;
|
||||
isCaseHeaderCommentIndent = other.isCaseHeaderCommentIndent;
|
||||
@ -302,6 +291,7 @@ void ASBeautifier::init(ASSourceIterator* iter)
|
||||
sourceIterator = iter;
|
||||
initVectors();
|
||||
ASBase::init(getFileType());
|
||||
g_preprocessorCppExternCBracket = 0;
|
||||
|
||||
initContainer(waitingBeautifierStack, new vector<ASBeautifier*>);
|
||||
initContainer(activeBeautifierStack, new vector<ASBeautifier*>);
|
||||
@ -409,6 +399,7 @@ void ASBeautifier::init(ASSourceIterator* iter)
|
||||
inLineNumber = 0;
|
||||
horstmannIndentInStatement = 0;
|
||||
nonInStatementBracket = 0;
|
||||
objCColonAlignSubsequent = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -736,6 +727,16 @@ bool ASBeautifier::getForceTabIndentation(void) const
|
||||
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.
|
||||
*
|
||||
@ -857,7 +858,7 @@ int ASBeautifier::getTabLength(void) const
|
||||
string ASBeautifier::beautify(const string& originalLine)
|
||||
{
|
||||
string line;
|
||||
bool isInQuoteContinuation = isInVerbatimQuote | haveLineContinuationChar;
|
||||
bool isInQuoteContinuation = isInVerbatimQuote || haveLineContinuationChar;
|
||||
|
||||
currentHeader = NULL;
|
||||
lastLineHeader = NULL;
|
||||
@ -965,7 +966,7 @@ string ASBeautifier::beautify(const string &originalLine)
|
||||
{
|
||||
if (isInIndentablePreprocBlock)
|
||||
return preLineWS(preprocBlockIndent, 0);
|
||||
else if (!headerStack->empty() || isInEnum)
|
||||
if (!headerStack->empty() || isInEnum)
|
||||
return preLineWS(prevFinalLineIndentCount, prevFinalLineSpaceIndentCount);
|
||||
// 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.
|
||||
if (!backslashEndsPrevLine && isInDefineDefinition && !isInDefine)
|
||||
{
|
||||
ASBeautifier* defineBeautifier;
|
||||
|
||||
isInDefineDefinition = false;
|
||||
defineBeautifier = activeBeautifierStack->back();
|
||||
ASBeautifier* defineBeautifier = activeBeautifierStack->back();
|
||||
activeBeautifierStack->pop_back();
|
||||
|
||||
string indentedLine = defineBeautifier->beautify(line);
|
||||
@ -1099,6 +1098,7 @@ string ASBeautifier::beautify(const string &originalLine)
|
||||
activeBeautifierStack->back()->inLineNumber = inLineNumber;
|
||||
activeBeautifierStack->back()->horstmannIndentInStatement = horstmannIndentInStatement;
|
||||
activeBeautifierStack->back()->nonInStatementBracket = nonInStatementBracket;
|
||||
activeBeautifierStack->back()->objCColonAlignSubsequent = objCColonAlignSubsequent;
|
||||
activeBeautifierStack->back()->lineCommentNoBeautify = lineCommentNoBeautify;
|
||||
activeBeautifierStack->back()->isElseHeaderIndent = isElseHeaderIndent;
|
||||
activeBeautifierStack->back()->isCaseHeaderCommentIndent = isCaseHeaderCommentIndent;
|
||||
@ -1143,6 +1143,9 @@ string ASBeautifier::beautify(const string &originalLine)
|
||||
if (shouldAlignMethodColon)
|
||||
{
|
||||
colonIndentObjCMethodDefinition = line.find(':');
|
||||
int objCColonAlignSubsequentIndent = objCColonAlignSubsequent + indentLength;
|
||||
if (objCColonAlignSubsequentIndent > colonIndentObjCMethodDefinition)
|
||||
colonIndentObjCMethodDefinition = objCColonAlignSubsequentIndent;
|
||||
}
|
||||
else if (inStatementIndentStack->empty()
|
||||
|| inStatementIndentStack->back() == 0)
|
||||
@ -1249,7 +1252,6 @@ string ASBeautifier::preLineWS(int lineIndentCount, int lineSpaceIndentCount) co
|
||||
void ASBeautifier::registerInStatementIndent(const string& line, int i, int spaceTabCount_,
|
||||
int tabIncrementIn, int minIndent, bool updateParenStack)
|
||||
{
|
||||
int inStatementIndent;
|
||||
int remainingCharNum = line.length() - i;
|
||||
int nextNonWSChar = getNextProgramCharDistance(line, i);
|
||||
|
||||
@ -1281,7 +1283,7 @@ void ASBeautifier::registerInStatementIndent(const string &line, int i, int spac
|
||||
tabIncrement += convertTabToSpaces(j, tabIncrement);
|
||||
}
|
||||
|
||||
inStatementIndent = i + nextNonWSChar + spaceTabCount_ + tabIncrement;
|
||||
int inStatementIndent = i + nextNonWSChar + spaceTabCount_ + tabIncrement;
|
||||
|
||||
// check for run-in statement
|
||||
if (i > 0 && line[0] == '{')
|
||||
@ -1376,7 +1378,7 @@ int ASBeautifier::getNextProgramCharDistance(const string &line, int i) const
|
||||
{
|
||||
if (line.compare(i + charDistance, 2, "//") == 0)
|
||||
return remainingCharNum;
|
||||
else if (line.compare(i + charDistance, 2, "/*") == 0)
|
||||
if (line.compare(i + charDistance, 2, "/*") == 0)
|
||||
{
|
||||
charDistance++;
|
||||
inComment = true;
|
||||
@ -1461,7 +1463,6 @@ int ASBeautifier::indexOf(vector<const string*> &container, const string* elemen
|
||||
where = find(container.begin(), container.end(), element);
|
||||
if (where == container.end())
|
||||
return -1;
|
||||
else
|
||||
return (int) (where - container.begin());
|
||||
}
|
||||
|
||||
@ -1485,7 +1486,6 @@ int ASBeautifier::convertTabToSpaces(int i, int tabIncrementIn) const
|
||||
*/
|
||||
string ASBeautifier::trim(const string& str) const
|
||||
{
|
||||
|
||||
int start = 0;
|
||||
int end = str.length() - 1;
|
||||
|
||||
@ -1685,7 +1685,8 @@ bool ASBeautifier::statementEndsWithComma(const string &line, int index) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '"' || ch == '\'')
|
||||
if (ch == '"'
|
||||
|| (ch == '\'' && !isDigitSeparator(line, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = ch;
|
||||
@ -1965,14 +1966,12 @@ void ASBeautifier::processPreprocessor(const string &preproc, const string &line
|
||||
{
|
||||
if (!isInDefineDefinition)
|
||||
{
|
||||
ASBeautifier* defineBeautifier;
|
||||
|
||||
// this is the original beautifier
|
||||
isInDefineDefinition = true;
|
||||
|
||||
// push a new beautifier into the active stack
|
||||
// this beautifier will be used for the indentation of this define
|
||||
defineBeautifier = new ASBeautifier(*this);
|
||||
ASBeautifier* defineBeautifier = new ASBeautifier(*this);
|
||||
activeBeautifierStack->push_back(defineBeautifier);
|
||||
}
|
||||
else
|
||||
@ -2012,8 +2011,8 @@ void ASBeautifier::processPreprocessor(const string &preproc, const string &line
|
||||
}
|
||||
else if (preproc == "endif")
|
||||
{
|
||||
int stackLength;
|
||||
ASBeautifier* beautifier;
|
||||
int stackLength = 0;
|
||||
ASBeautifier* beautifier = NULL;
|
||||
|
||||
if (waitingBeautifierStackLengthStack != NULL && !waitingBeautifierStackLengthStack->empty())
|
||||
{
|
||||
@ -2145,7 +2144,7 @@ void ASBeautifier::computePreliminaryIndentation()
|
||||
&& (*headerStack)[headerStack->size() - 2] == &AS_CLASS
|
||||
&& (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACKET
|
||||
&& lineBeginsWithCloseBracket
|
||||
&& bracketBlockStateStack->back() == true)
|
||||
&& bracketBlockStateStack->back())
|
||||
--indentCount;
|
||||
|
||||
// unindent an indented switch closing bracket...
|
||||
@ -2305,6 +2304,7 @@ void ASBeautifier::clearObjCMethodDefinitionAlignment()
|
||||
spaceIndentCount = 0;
|
||||
spaceIndentObjCMethodDefinition = 0;
|
||||
colonIndentObjCMethodDefinition = 0;
|
||||
objCColonAlignSubsequent = 0;
|
||||
isInObjCMethodDefinition = false;
|
||||
isImmediatelyPostObjCMethodDefinition = false;
|
||||
if (!inStatementIndentStack->empty())
|
||||
@ -2347,15 +2347,7 @@ void ASBeautifier::parseCurrentLine(const string &line)
|
||||
if (isInBeautifySQL)
|
||||
continue;
|
||||
|
||||
if (isWhiteSpace(ch))
|
||||
{
|
||||
if (ch == '\t')
|
||||
tabIncrementIn += convertTabToSpaces(i, tabIncrementIn);
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle special characters (i.e. backslash+character such as \n, \t, ...)
|
||||
|
||||
if (isInQuote && !isInVerbatimQuote)
|
||||
{
|
||||
if (isSpecialChar)
|
||||
@ -2380,8 +2372,18 @@ void ASBeautifier::parseCurrentLine(const string &line)
|
||||
else if (isInDefine && ch == '\\')
|
||||
continue;
|
||||
|
||||
// bypass whitespace here
|
||||
if (isWhiteSpace(ch))
|
||||
{
|
||||
if (ch == '\t')
|
||||
tabIncrementIn += convertTabToSpaces(i, tabIncrementIn);
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle quotes (such as 'x' and "Hello Dolly")
|
||||
if (!(isInComment || isInLineComment) && (ch == '"' || ch == '\''))
|
||||
if (!(isInComment || isInLineComment)
|
||||
&& (ch == '"'
|
||||
|| (ch == '\'' && !isDigitSeparator(line, i))))
|
||||
{
|
||||
if (!isInQuote)
|
||||
{
|
||||
@ -2807,11 +2809,15 @@ void ASBeautifier::parseCurrentLine(const string &line)
|
||||
const string* newHeader = findHeader(line, i, headers);
|
||||
|
||||
// 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)
|
||||
newHeader = NULL;
|
||||
}
|
||||
else if (newHeader == &AS_USING
|
||||
&& ASBeautifier::peekNextChar(line, i + (*newHeader).length() - 1) != '(')
|
||||
newHeader = NULL;
|
||||
|
||||
if (newHeader != NULL)
|
||||
{
|
||||
@ -2820,10 +2826,8 @@ void ASBeautifier::parseCurrentLine(const string &line)
|
||||
|
||||
isInHeader = true;
|
||||
|
||||
vector<const string*>* lastTempStack;
|
||||
if (tempStacks->empty())
|
||||
lastTempStack = NULL;
|
||||
else
|
||||
vector<const string*>* lastTempStack = NULL;;
|
||||
if (!tempStacks->empty())
|
||||
lastTempStack = tempStacks->back();
|
||||
|
||||
// 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)))
|
||||
{
|
||||
// found a bit field
|
||||
// so do nothing special
|
||||
// found a bit field - do nothing special
|
||||
}
|
||||
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 namespace astyle
|
||||
|
@ -1,33 +1,23 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ASEnhancer.cpp
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// ASEnhancer.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.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "astyle.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASEnhancer class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ASEnhancer constructor
|
||||
@ -202,8 +192,7 @@ void ASEnhancer::convertSpaceIndentToForceTab(string &line) const
|
||||
// replace leading spaces with tab indents
|
||||
size_t newSpaceIndentLength = line.find_first_not_of(" \t");
|
||||
size_t tabCount = newSpaceIndentLength / tabLength; // truncate extra spaces
|
||||
line.erase(0U, tabCount * tabLength);
|
||||
line.insert(0U, tabCount, '\t');
|
||||
line.replace(0U, tabCount * tabLength, tabCount, '\t');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,7 +227,8 @@ size_t ASEnhancer::findCaseColon(string &line, size_t caseIndex) const
|
||||
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;
|
||||
quoteChar_ = line[i];
|
||||
@ -269,7 +259,7 @@ int ASEnhancer::indentLine(string &line, int indent) const
|
||||
&& !emptyLineFill)
|
||||
return 0;
|
||||
|
||||
size_t charsToInsert;
|
||||
size_t charsToInsert = 0;
|
||||
|
||||
if (forceTab && indentLength != tabLength)
|
||||
{
|
||||
@ -277,19 +267,19 @@ int ASEnhancer::indentLine(string &line, int indent) const
|
||||
convertForceTabIndentToSpaces(line);
|
||||
// insert the space indents
|
||||
charsToInsert = indent * indentLength;
|
||||
line.insert(0U, charsToInsert, ' ');
|
||||
line.insert(line.begin(), charsToInsert, ' ');
|
||||
// replace leading spaces with tab indents
|
||||
convertSpaceIndentToForceTab(line);
|
||||
}
|
||||
else if (useTabs)
|
||||
{
|
||||
charsToInsert = indent;
|
||||
line.insert(0U, charsToInsert, '\t');
|
||||
line.insert(line.begin(), charsToInsert, '\t');
|
||||
}
|
||||
else // spaces
|
||||
{
|
||||
charsToInsert = indent * indentLength;
|
||||
line.insert(0U, charsToInsert, ' ');
|
||||
line.insert(line.begin(), charsToInsert, ' ');
|
||||
}
|
||||
|
||||
return charsToInsert;
|
||||
@ -439,7 +429,8 @@ bool ASEnhancer::isOneLineBlockReached(string &line, int startChar) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '"' || ch == '\'')
|
||||
if (ch == '"'
|
||||
|| (ch == '\'' && !isDigitSeparator(line, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = ch;
|
||||
@ -502,7 +493,9 @@ void ASEnhancer::parseCurrentLine(string &line, bool isInPreprocessor, bool isIn
|
||||
}
|
||||
|
||||
// handle quotes (such as 'x' and "Hello Dolly")
|
||||
if (!isInComment && (ch == '"' || ch == '\''))
|
||||
if (!isInComment
|
||||
&& (ch == '"'
|
||||
|| (ch == '\'' && !isDigitSeparator(line, i))))
|
||||
{
|
||||
if (!isInQuote)
|
||||
{
|
||||
@ -800,5 +793,4 @@ int ASEnhancer::unindentLine(string &line, int unindent) const
|
||||
return charsToErase;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace astyle
|
||||
|
@ -1,36 +1,27 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ASFormatter.cpp
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// ASFormatter.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.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "astyle.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASFormatter class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor of ASFormatter
|
||||
*/
|
||||
@ -51,6 +42,7 @@ ASFormatter::ASFormatter()
|
||||
objCColonPadMode = COLON_PAD_NO_CHANGE;
|
||||
lineEnd = LINEEND_DEFAULT;
|
||||
maxCodeLength = string::npos;
|
||||
shouldPadCommas = false;
|
||||
shouldPadOperators = false;
|
||||
shouldPadParensOutside = false;
|
||||
shouldPadFirstParen = false;
|
||||
@ -81,6 +73,8 @@ ASFormatter::ASFormatter()
|
||||
shouldPadMethodColon = false;
|
||||
shouldPadMethodPrefix = false;
|
||||
shouldUnPadMethodPrefix = false;
|
||||
shouldPadReturnType = false;
|
||||
shouldUnPadReturnType = false;
|
||||
|
||||
// initialize ASFormatter member vectors
|
||||
formatterFileType = 9; // reset to an invalid type
|
||||
@ -148,7 +142,7 @@ void ASFormatter::init(ASSourceIterator* si)
|
||||
enhancer->init(getFileType(),
|
||||
getIndentLength(),
|
||||
getTabLength(),
|
||||
getIndentString() == "\t" ? true : false,
|
||||
getIndentString() == "\t",
|
||||
getForceTabIndentation(),
|
||||
getNamespaceIndent(),
|
||||
getCaseIndent(),
|
||||
@ -187,6 +181,7 @@ void ASFormatter::init(ASSourceIterator* si)
|
||||
preprocBracketTypeStackSize = 0;
|
||||
spacePadNum = 0;
|
||||
nextLineSpacePadNum = 0;
|
||||
objCColonAlign = 0;
|
||||
templateDepth = 0;
|
||||
squareBracketCount = 0;
|
||||
horstmannIndentChars = 0;
|
||||
@ -251,6 +246,7 @@ void ASFormatter::init(ASSourceIterator* si)
|
||||
isImmediatelyPostComment = false;
|
||||
isImmediatelyPostLineComment = false;
|
||||
isImmediatelyPostEmptyBlock = false;
|
||||
isImmediatelyPostObjCMethodPrefix = false;
|
||||
isImmediatelyPostPreprocessor = false;
|
||||
isImmediatelyPostReturn = false;
|
||||
isImmediatelyPostThrow = false;
|
||||
@ -267,8 +263,9 @@ void ASFormatter::init(ASSourceIterator* si)
|
||||
isCharImmediatelyPostCloseBlock = false;
|
||||
isCharImmediatelyPostTemplate = false;
|
||||
isCharImmediatelyPostPointerOrReference = false;
|
||||
isInObjCMethodDefinition = false;
|
||||
isInObjCInterface = false;
|
||||
isInObjCMethodDefinition = false;
|
||||
isInObjCReturnType = false;
|
||||
isInObjCSelector = false;
|
||||
breakCurrentOneLineBlock = false;
|
||||
shouldRemoveNextClosingBracket = false;
|
||||
@ -438,7 +435,7 @@ void ASFormatter::fixOptionVariableConflicts()
|
||||
*/
|
||||
string ASFormatter::nextLine()
|
||||
{
|
||||
const string* newHeader;
|
||||
const string* newHeader = NULL;
|
||||
bool isInVirginLine = isVirgin;
|
||||
isCharImmediatelyPostComment = false;
|
||||
isPreviousCharPostComment = false;
|
||||
@ -556,7 +553,8 @@ string ASFormatter::nextLine()
|
||||
testForTimeToSplitFormattedLine();
|
||||
continue;
|
||||
}
|
||||
else if (currentChar == '"' || currentChar == '\'')
|
||||
else if (currentChar == '"'
|
||||
|| (currentChar == '\'' && !isDigitSeparator(currentLine, charNum)))
|
||||
{
|
||||
formatQuoteOpener();
|
||||
testForTimeToSplitFormattedLine();
|
||||
@ -609,8 +607,7 @@ string ASFormatter::nextLine()
|
||||
currentLine[charNum] = currentChar = ' ';
|
||||
shouldRemoveNextClosingBracket = false;
|
||||
assert(adjustChecksumIn(-'}'));
|
||||
// if the line is empty, delete it
|
||||
if (currentLine.find_first_not_of(" \t"))
|
||||
if (isEmptyLine(currentLine))
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -893,6 +890,7 @@ string ASFormatter::nextLine()
|
||||
isCharImmediatelyPostNonInStmt = false;
|
||||
needHeaderOpeningBracket = false;
|
||||
shouldKeepLineUnbroken = false;
|
||||
objCColonAlign = 0;
|
||||
|
||||
isPreviousBracketBlockRelated = !isBracketType(newBracketType, ARRAY_TYPE);
|
||||
bracketTypeStack->push_back(newBracketType);
|
||||
@ -1038,16 +1036,19 @@ string ASFormatter::nextLine()
|
||||
newHeader = findHeader(headers);
|
||||
|
||||
// Qt headers may be variables in C++
|
||||
if (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH)
|
||||
if (isCStyle()
|
||||
&& (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH))
|
||||
{
|
||||
if (currentLine.find_first_of("=;", charNum) != string::npos)
|
||||
newHeader = NULL;
|
||||
}
|
||||
else if (newHeader == &AS_USING
|
||||
&& ASBeautifier::peekNextChar(currentLine,
|
||||
charNum + (*newHeader).length() - 1) != '(')
|
||||
newHeader = NULL;
|
||||
|
||||
if (newHeader != NULL)
|
||||
{
|
||||
const string* previousHeader;
|
||||
|
||||
// recognize closing headers of do..while, if..else, try..catch..finally
|
||||
if ((newHeader == &AS_ELSE && currentHeader == &AS_IF)
|
||||
|| (newHeader == &AS_WHILE && currentHeader == &AS_DO)
|
||||
@ -1061,7 +1062,7 @@ string ASFormatter::nextLine()
|
||||
|| (newHeader == &AS_REMOVE && currentHeader == &AS_ADD))
|
||||
foundClosingHeader = true;
|
||||
|
||||
previousHeader = currentHeader;
|
||||
const string* previousHeader = currentHeader;
|
||||
currentHeader = newHeader;
|
||||
needHeaderOpeningBracket = true;
|
||||
|
||||
@ -1095,8 +1096,12 @@ string ASFormatter::nextLine()
|
||||
isNonParenHeader = findHeader(nonParenHeaders) != NULL;
|
||||
|
||||
// join 'else if' statements
|
||||
if (currentHeader == &AS_IF && previousHeader == &AS_ELSE && isInLineBreak
|
||||
&& !shouldBreakElseIfs && !isCharImmediatelyPostLineComment)
|
||||
if (currentHeader == &AS_IF
|
||||
&& previousHeader == &AS_ELSE
|
||||
&& isInLineBreak
|
||||
&& !shouldBreakElseIfs
|
||||
&& !isCharImmediatelyPostLineComment
|
||||
&& !isImmediatelyPostPreprocessor)
|
||||
{
|
||||
// 'else' must be last thing on the line
|
||||
size_t start = formattedLine.length() >= 6 ? formattedLine.length() - 6 : 0;
|
||||
@ -1192,9 +1197,7 @@ string ASFormatter::nextLine()
|
||||
else if ((newHeader = findHeader(preCommandHeaders)) != NULL)
|
||||
{
|
||||
// a 'const' variable is not a preCommandHeader
|
||||
if (previousNonWSChar != ';'
|
||||
&& previousNonWSChar != '{'
|
||||
&& getPreviousWord(currentLine, charNum) != AS_STATIC)
|
||||
if (previousNonWSChar == ')')
|
||||
foundPreCommandHeader = true;
|
||||
}
|
||||
else if ((newHeader = findHeader(castOperators)) != NULL)
|
||||
@ -1430,21 +1433,17 @@ string ASFormatter::nextLine()
|
||||
continue;
|
||||
}
|
||||
else if ((currentChar == '-' || currentChar == '+')
|
||||
&& charNum == 0
|
||||
&& peekNextChar() == '('
|
||||
&& isBracketType(bracketTypeStack->back(), NULL_TYPE)
|
||||
&& !isInPotentialCalculation)
|
||||
{
|
||||
isInObjCMethodDefinition = true;
|
||||
isImmediatelyPostObjCMethodPrefix = true;
|
||||
isInObjCInterface = false;
|
||||
if (getAlignMethodColon())
|
||||
objCColonAlign = findObjCColonAlignment();
|
||||
appendCurrentChar();
|
||||
if (shouldPadMethodPrefix || shouldUnPadMethodPrefix)
|
||||
{
|
||||
size_t i = currentLine.find_first_not_of(" \t", charNum + 1);
|
||||
if (i != string::npos)
|
||||
goForward(i - charNum - 1);
|
||||
if (shouldPadMethodPrefix)
|
||||
appendSpaceAfter();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1513,9 +1512,22 @@ string ASFormatter::nextLine()
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove spaces before commas
|
||||
if (currentChar == ',')
|
||||
{
|
||||
const size_t len = formattedLine.length();
|
||||
size_t lastText = formattedLine.find_last_not_of(' ');
|
||||
if (lastText != string::npos && lastText < len - 1)
|
||||
{
|
||||
formattedLine.resize(lastText + 1);
|
||||
int size_diff = len - (lastText + 1);
|
||||
spacePadNum -= size_diff;
|
||||
}
|
||||
}
|
||||
|
||||
// pad commas and semi-colons
|
||||
if (currentChar == ';'
|
||||
|| (currentChar == ',' && shouldPadOperators))
|
||||
|| (currentChar == ',' && (shouldPadOperators || shouldPadCommas)))
|
||||
{
|
||||
char nextChar = ' ';
|
||||
if (charNum + 1 < (int) currentLine.length())
|
||||
@ -1536,16 +1548,38 @@ string ASFormatter::nextLine()
|
||||
}
|
||||
}
|
||||
|
||||
// do NOT use 'continue' after this, it must do padParens if necessary
|
||||
if (currentChar == '('
|
||||
&& shouldPadHeader
|
||||
// pad parens
|
||||
if (currentChar == '(' || currentChar == ')')
|
||||
{
|
||||
if (currentChar == '(')
|
||||
{
|
||||
if (shouldPadHeader
|
||||
&& (isCharImmediatelyPostReturn || isCharImmediatelyPostThrow))
|
||||
appendSpacePad();
|
||||
}
|
||||
|
||||
if ((currentChar == '(' || currentChar == ')')
|
||||
&& (shouldPadParensOutside || shouldPadParensInside || shouldUnPadParens || shouldPadFirstParen))
|
||||
{
|
||||
if (shouldPadParensOutside || shouldPadParensInside || shouldUnPadParens || shouldPadFirstParen)
|
||||
padParens();
|
||||
else
|
||||
appendCurrentChar();
|
||||
|
||||
if (currentChar == '('
|
||||
&& isImmediatelyPostObjCMethodPrefix
|
||||
&& (shouldPadMethodPrefix || shouldUnPadMethodPrefix))
|
||||
padParenObjC();
|
||||
if (currentChar == ')'
|
||||
&& isInObjCReturnType
|
||||
&& (shouldPadReturnType || shouldUnPadReturnType))
|
||||
padParenObjC();
|
||||
|
||||
if (currentChar == '(' && isImmediatelyPostObjCMethodPrefix)
|
||||
{
|
||||
isImmediatelyPostObjCMethodPrefix = false;
|
||||
isInObjCReturnType = true;
|
||||
}
|
||||
else if (currentChar == ')' && isInObjCReturnType)
|
||||
isInObjCReturnType = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1593,6 +1627,7 @@ string ASFormatter::nextLine()
|
||||
isIndentableProprocessor = false;
|
||||
isElseHeaderIndent = elseHeaderFollowsComments;
|
||||
isCaseHeaderCommentIndent = caseHeaderFollowsComments;
|
||||
objCColonAlignSubsequent = objCColonAlign;
|
||||
if (isCharImmediatelyPostNonInStmt)
|
||||
{
|
||||
isNonInStatementArray = false;
|
||||
@ -1725,6 +1760,19 @@ void ASFormatter::setBreakElseIfsMode(bool state)
|
||||
shouldBreakElseIfs = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* set comma padding mode.
|
||||
* options:
|
||||
* true statement commas and semicolons will be padded with spaces around them.
|
||||
* false statement commas and semicolons will not be padded.
|
||||
*
|
||||
* @param state the padding mode.
|
||||
*/
|
||||
void ASFormatter::setCommaPaddingMode(bool state)
|
||||
{
|
||||
shouldPadCommas = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* set maximum code length
|
||||
*
|
||||
@ -1863,6 +1911,18 @@ void ASFormatter::setMethodPrefixUnPaddingMode(bool state)
|
||||
shouldUnPadMethodPrefix = state;
|
||||
}
|
||||
|
||||
// set objective-c '-' or '+' return type padding mode.
|
||||
void ASFormatter::setReturnTypePaddingMode(bool state)
|
||||
{
|
||||
shouldPadReturnType = state;
|
||||
}
|
||||
|
||||
// set objective-c '-' or '+' return type unpadding mode.
|
||||
void ASFormatter::setReturnTypeUnPaddingMode(bool state)
|
||||
{
|
||||
shouldUnPadReturnType = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* set objective-c method colon padding mode.
|
||||
*
|
||||
@ -2194,8 +2254,11 @@ bool ASFormatter::getNextChar()
|
||||
*/
|
||||
bool ASFormatter::getNextLine(bool emptyLineWasDeleted /*false*/)
|
||||
{
|
||||
if (sourceIterator->hasMoreLines())
|
||||
if (!sourceIterator->hasMoreLines())
|
||||
{
|
||||
endOfCodeReached = true;
|
||||
return false;
|
||||
}
|
||||
if (appendOpeningBracket)
|
||||
currentLine = "{"; // append bracket that was removed from the previous line
|
||||
else
|
||||
@ -2212,7 +2275,7 @@ bool ASFormatter::getNextLine(bool emptyLineWasDeleted /*false*/)
|
||||
isInCase = false;
|
||||
isInAsmOneLine = false;
|
||||
isHeaderInMultiStatementLine = false;
|
||||
isInQuoteContinuation = isInVerbatimQuote | haveLineContinuationChar;
|
||||
isInQuoteContinuation = isInVerbatimQuote || haveLineContinuationChar;
|
||||
haveLineContinuationChar = false;
|
||||
isImmediatelyPostEmptyLine = lineIsEmpty;
|
||||
previousChar = ' ';
|
||||
@ -2268,12 +2331,6 @@ bool ASFormatter::getNextLine(bool emptyLineWasDeleted /*false*/)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
endOfCodeReached = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* jump over the leading white space in the current line,
|
||||
@ -2546,7 +2603,7 @@ BracketType ASFormatter::getBracketType()
|
||||
{
|
||||
assert(currentChar == '{');
|
||||
|
||||
BracketType returnVal;
|
||||
BracketType returnVal = NULL_TYPE;
|
||||
|
||||
if ((previousNonWSChar == '='
|
||||
|| isBracketType(bracketTypeStack->back(), ARRAY_TYPE))
|
||||
@ -2630,7 +2687,7 @@ BracketType ASFormatter::getBracketType()
|
||||
*/
|
||||
bool ASFormatter::isClassInitializer() const
|
||||
{
|
||||
assert(currentLine[charNum] == ':');
|
||||
assert(currentChar == ':');
|
||||
assert(previousChar != ':' && peekNextChar() != ':'); // not part of '::'
|
||||
|
||||
// this should be similar to ASBeautifier::parseCurrentLine()
|
||||
@ -2746,6 +2803,8 @@ bool ASFormatter::isPointerOrReference() const
|
||||
//check for rvalue reference
|
||||
if (currentChar == '&' && nextChar == '&')
|
||||
{
|
||||
if (previousNonWSChar == '>')
|
||||
return true;
|
||||
string followingText = peekNextText(currentLine.substr(charNum + 2));
|
||||
if (followingText.length() > 0 && followingText[0] == ')')
|
||||
return true;
|
||||
@ -2790,14 +2849,12 @@ bool ASFormatter::isPointerOrReference() const
|
||||
{
|
||||
if (followingOperator == &AS_ASSIGN || followingOperator == &AS_COLON)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBracketType(bracketTypeStack->back(), COMMAND_TYPE)
|
||||
|| squareBracketCount > 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2934,7 +2991,7 @@ bool ASFormatter::isDereferenceOrAddressOf() const
|
||||
*/
|
||||
bool ASFormatter::isPointerOrReferenceCentered() const
|
||||
{
|
||||
assert(currentLine[charNum] == '*' || currentLine[charNum] == '&' || currentLine[charNum] == '^');
|
||||
assert(currentChar == '*' || currentChar == '&' || currentChar == '^');
|
||||
|
||||
int prNum = charNum;
|
||||
int lineLength = (int) currentLine.length();
|
||||
@ -2978,15 +3035,13 @@ bool ASFormatter::isPointerOrReferenceCentered() const
|
||||
*/
|
||||
bool ASFormatter::isPointerOrReferenceVariable(string& word) const
|
||||
{
|
||||
if (word == "char"
|
||||
return (word == "char"
|
||||
|| word == "int"
|
||||
|| word == "void"
|
||||
|| (word.length() >= 6 // check end of word for _t
|
||||
&& word.compare(word.length() - 2, 2, "_t") == 0)
|
||||
|| word == "INT"
|
||||
|| word == "VOID")
|
||||
return true;
|
||||
return false;
|
||||
|| word == "VOID");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3042,7 +3097,6 @@ bool ASFormatter::isInExponent() const
|
||||
return ((prevFormattedChar == 'e' || prevFormattedChar == 'E')
|
||||
&& (prevPrevFormattedChar == '.' || isDigit(prevPrevFormattedChar)));
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3121,7 +3175,8 @@ int ASFormatter::isOneLineBlockReached(string &line, int startChar) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '"' || ch == '\'')
|
||||
if (ch == '"'
|
||||
|| (ch == '\'' && !isDigitSeparator(line, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = ch;
|
||||
@ -3881,16 +3936,6 @@ void ASFormatter::formatPointerOrReferenceCast(void)
|
||||
}
|
||||
else
|
||||
appendSequence(sequenceToInsert, false);
|
||||
// remove trailing whitespace if comma follows
|
||||
char nextChar = peekNextChar();
|
||||
if (nextChar == ',')
|
||||
{
|
||||
while (isWhiteSpace(currentLine[charNum + 1]))
|
||||
{
|
||||
goForward(1);
|
||||
spacePadNum--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3901,8 +3946,8 @@ void ASFormatter::formatPointerOrReferenceCast(void)
|
||||
*/
|
||||
void ASFormatter::padParens(void)
|
||||
{
|
||||
assert(shouldPadParensOutside || shouldPadParensInside || shouldUnPadParens || shouldPadFirstParen);
|
||||
assert(currentChar == '(' || currentChar == ')');
|
||||
assert(shouldPadParensOutside || shouldPadParensInside || shouldUnPadParens || shouldPadFirstParen);
|
||||
|
||||
int spacesOutsideToDelete = 0;
|
||||
int spacesInsideToDelete = 0;
|
||||
@ -4096,6 +4141,98 @@ void ASFormatter::padParens(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* add or remove space padding to objective-c parens
|
||||
* these options have precedence over the padParens methods
|
||||
* the padParens method has already been called, this method adjusts
|
||||
*/
|
||||
void ASFormatter::padParenObjC(void)
|
||||
{
|
||||
// the paren was previously been written to formattedLine
|
||||
assert(formattedLine[0] == '+' || formattedLine[0] == '-');
|
||||
assert(formattedLine.find('(') != string::npos
|
||||
|| formattedLine.find(')') != string::npos);
|
||||
assert(isImmediatelyPostObjCMethodPrefix || isInObjCReturnType);
|
||||
assert(shouldPadMethodPrefix || shouldUnPadMethodPrefix
|
||||
|| shouldPadReturnType || shouldUnPadReturnType);
|
||||
|
||||
if (isImmediatelyPostObjCMethodPrefix)
|
||||
{
|
||||
size_t prefix = formattedLine.find_first_of("+-");
|
||||
if (prefix == string::npos)
|
||||
return;
|
||||
size_t paren = formattedLine.find_first_of("(");
|
||||
if (paren == string::npos)
|
||||
return;
|
||||
int spaces = paren - prefix - 1;
|
||||
if (shouldPadMethodPrefix)
|
||||
{
|
||||
if (spaces == 0)
|
||||
{
|
||||
formattedLine.insert(prefix + 1, 1, ' ');
|
||||
spacePadNum += 1;
|
||||
}
|
||||
else if (spaces > 1)
|
||||
{
|
||||
formattedLine.erase(prefix + 1, spaces - 1);
|
||||
spacePadNum -= spaces - 1;
|
||||
}
|
||||
}
|
||||
// this option will be ignored if used with pad-method-prefix
|
||||
else if (shouldUnPadMethodPrefix)
|
||||
{
|
||||
if (spaces > 0)
|
||||
{
|
||||
formattedLine.erase(prefix + 1, spaces);
|
||||
spacePadNum -= spaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isInObjCReturnType)
|
||||
{
|
||||
size_t nextText = currentLine.find_first_not_of(" \t", charNum + 1);
|
||||
if (nextText == string::npos)
|
||||
return;
|
||||
int spaces = nextText - charNum - 1;
|
||||
if (shouldPadReturnType)
|
||||
{
|
||||
if (spaces == 0)
|
||||
{
|
||||
// this will already be padded if pad-paren is used
|
||||
if (formattedLine[formattedLine.length() - 1] != ' ')
|
||||
{
|
||||
formattedLine.append(" ");
|
||||
spacePadNum += 1;
|
||||
}
|
||||
}
|
||||
else if (spaces > 1)
|
||||
{
|
||||
// do not use goForward here
|
||||
currentLine.erase(charNum + 1, spaces - 1);
|
||||
spacePadNum -= spaces - 1;
|
||||
}
|
||||
}
|
||||
// this option will be ignored if used with pad-return-type
|
||||
else if (shouldUnPadReturnType)
|
||||
{
|
||||
// this will already be padded if pad-paren is used
|
||||
if (formattedLine[formattedLine.length() - 1] == ' ')
|
||||
{
|
||||
spacePadNum -= formattedLine.length() - 1 - nextText;
|
||||
int lastText = formattedLine.find_last_not_of(" \t");
|
||||
formattedLine.resize(lastText + 1);
|
||||
}
|
||||
if (spaces > 0)
|
||||
{
|
||||
// do not use goForward here
|
||||
currentLine.erase(charNum + 1, spaces);
|
||||
spacePadNum -= spaces;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* format opening bracket as attached or broken
|
||||
* currentChar contains the bracket
|
||||
@ -4588,8 +4725,7 @@ void ASFormatter::formatRunIn()
|
||||
indent.append(indentLength_, ' ');
|
||||
// replace spaces indents with tab indents
|
||||
size_t tabCount = indent.length() / tabLength_; // truncate extra spaces
|
||||
indent.erase(0U, tabCount * tabLength_);
|
||||
indent.insert(0U, tabCount, '\t');
|
||||
indent.replace(0U, tabCount * tabLength_, tabCount, '\t');
|
||||
horstmannIndentChars = indentLength_;
|
||||
if (indent[0] == ' ') // allow for bracket
|
||||
indent.erase(0, 1);
|
||||
@ -4720,7 +4856,7 @@ void ASFormatter::initContainer(T &container, T value)
|
||||
*/
|
||||
void ASFormatter::convertTabToSpaces()
|
||||
{
|
||||
assert(currentLine[charNum] == '\t');
|
||||
assert(currentChar == '\t');
|
||||
|
||||
// do NOT replace if in quotes
|
||||
if (isInQuote || isInQuoteContinuation)
|
||||
@ -4755,11 +4891,9 @@ bool ASFormatter::isOkToBreakBlock(BracketType bracketType) const
|
||||
*/
|
||||
bool ASFormatter::isSharpStyleWithParen(const string* header) const
|
||||
{
|
||||
if (isSharpStyle() && peekNextChar() == '('
|
||||
return (isSharpStyle() && peekNextChar() == '('
|
||||
&& (header == &AS_CATCH
|
||||
|| header == &AS_DELEGATE))
|
||||
return true;
|
||||
return false;
|
||||
|| header == &AS_DELEGATE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4882,13 +5016,13 @@ bool ASFormatter::isCurrentBracketBroken() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (shouldAttachClass
|
||||
if (shouldAttachClass
|
||||
&& (isBracketType((*bracketTypeStack)[stackEnd], CLASS_TYPE)
|
||||
|| isBracketType((*bracketTypeStack)[stackEnd], INTERFACE_TYPE)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (shouldAttachInline
|
||||
if (shouldAttachInline
|
||||
&& isCStyle() // for C++ only
|
||||
&& bracketFormatMode != RUN_IN_MODE
|
||||
&& isBracketType((*bracketTypeStack)[stackEnd], COMMAND_TYPE))
|
||||
@ -5167,7 +5301,7 @@ void ASFormatter::formatLineCommentOpener()
|
||||
lineCommentNoIndent = true;
|
||||
}
|
||||
// move comment if spaces were added or deleted
|
||||
if (lineCommentNoIndent == false && spacePadNum != 0 && !isInLineBreak)
|
||||
if (!lineCommentNoIndent && spacePadNum != 0 && !isInLineBreak)
|
||||
adjustComments();
|
||||
formattedLineCommentNum = formattedLine.length();
|
||||
|
||||
@ -5293,13 +5427,10 @@ void ASFormatter::formatQuoteBody()
|
||||
goForward(1);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
isInQuote = false;
|
||||
isInVerbatimQuote = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (quoteChar == currentChar)
|
||||
{
|
||||
isInQuote = false;
|
||||
@ -5328,7 +5459,8 @@ void ASFormatter::formatQuoteBody()
|
||||
*/
|
||||
void ASFormatter::formatQuoteOpener()
|
||||
{
|
||||
assert(currentChar == '"' || currentChar == '\'');
|
||||
assert(currentChar == '"'
|
||||
|| (currentChar == '\'' && !isDigitSeparator(currentLine, charNum)));
|
||||
|
||||
isInQuote = true;
|
||||
quoteChar = currentChar;
|
||||
@ -5672,7 +5804,7 @@ bool ASFormatter::removeBracketsFromStatement()
|
||||
* @param searchStart the start position on the line (default is 0).
|
||||
* @return the position on the line or string::npos if not found.
|
||||
*/
|
||||
size_t ASFormatter::findNextChar(string &line, char searchChar, int searchStart /*0*/)
|
||||
size_t ASFormatter::findNextChar(string& line, char searchChar, int searchStart /*0*/) const
|
||||
{
|
||||
// find the next searchChar
|
||||
size_t i;
|
||||
@ -5689,7 +5821,8 @@ size_t ASFormatter::findNextChar(string &line, char searchChar, int searchStart
|
||||
if (i >= line.length())
|
||||
return string::npos;
|
||||
}
|
||||
if (line[i] == '\'' || line[i] == '\"')
|
||||
if (line[i] == '"'
|
||||
|| (line[i] == '\'' && !isDigitSeparator(line, i)))
|
||||
{
|
||||
char quote = line[i];
|
||||
while (i < line.length())
|
||||
@ -5778,7 +5911,8 @@ bool ASFormatter::isStructAccessModified(string &firstLine, size_t index) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nextLine_[i] == '"' || nextLine_[i] == '\'')
|
||||
if (nextLine_[i] == '"'
|
||||
|| (nextLine_[i] == '\'' && !isDigitSeparator(nextLine_, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = nextLine_[i];
|
||||
@ -5839,6 +5973,8 @@ bool ASFormatter::isIndentablePreprocessorBlock(string &firstLine, size_t index)
|
||||
bool blockContainsBrackets = false;
|
||||
bool blockContainsDefineContinuation = false;
|
||||
bool isInClassConstructor = false;
|
||||
bool isPotentialHeaderGuard = false; // ifndef is first preproc statement
|
||||
bool isPotentialHeaderGuard2 = false; // define is within the first proproc
|
||||
int numBlockIndents = 0;
|
||||
int lineParenCount = 0;
|
||||
string nextLine_ = firstLine.substr(index);
|
||||
@ -5884,7 +6020,8 @@ bool ASFormatter::isIndentablePreprocessorBlock(string &firstLine, size_t index)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nextLine_[i] == '"' || nextLine_[i] == '\'')
|
||||
if (nextLine_[i] == '"'
|
||||
|| (nextLine_[i] == '\'' && !isDigitSeparator(nextLine_, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = nextLine_[i];
|
||||
@ -5908,6 +6045,8 @@ bool ASFormatter::isIndentablePreprocessorBlock(string &firstLine, size_t index)
|
||||
{
|
||||
processedFirstConditional = true;
|
||||
isFirstPreprocConditional = true;
|
||||
if (isNDefPreprocStatement(nextLine_, preproc))
|
||||
isPotentialHeaderGuard = true;
|
||||
}
|
||||
}
|
||||
else if (preproc == "endif")
|
||||
@ -5918,9 +6057,13 @@ bool ASFormatter::isIndentablePreprocessorBlock(string &firstLine, size_t index)
|
||||
if (numBlockIndents == 0)
|
||||
goto EndOfWhileLoop;
|
||||
}
|
||||
else if (preproc == "define" && nextLine_[nextLine_.length() - 1] == '\\')
|
||||
else if (preproc == "define")
|
||||
{
|
||||
if (nextLine_[nextLine_.length() - 1] == '\\')
|
||||
blockContainsDefineContinuation = true;
|
||||
// check for potential header include guards
|
||||
else if (isPotentialHeaderGuard && numBlockIndents == 1)
|
||||
isPotentialHeaderGuard2 = true;
|
||||
}
|
||||
i = nextLine_.length();
|
||||
continue;
|
||||
@ -5960,11 +6103,11 @@ EndOfWhileLoop:
|
||||
// find next executable instruction
|
||||
// this WILL RESET the get pointer
|
||||
string nextText = peekNextText("", false, needReset);
|
||||
// bypass header include guards, with an exception for small test files
|
||||
// bypass header include guards
|
||||
if (isFirstPreprocConditional)
|
||||
{
|
||||
isFirstPreprocConditional = false;
|
||||
if (nextText.empty() && sourceIterator->getStreamLength() > 250)
|
||||
if (nextText.empty() && isPotentialHeaderGuard2)
|
||||
{
|
||||
isInIndentableBlock = false;
|
||||
preprocBlockEnd = 0;
|
||||
@ -5977,6 +6120,23 @@ EndOfWhileLoop:
|
||||
return isInIndentableBlock;
|
||||
}
|
||||
|
||||
bool ASFormatter::isNDefPreprocStatement(string& nextLine_, string& preproc) const
|
||||
{
|
||||
if (preproc == "ifndef")
|
||||
return true;
|
||||
// check for '!defined'
|
||||
if (preproc == "if")
|
||||
{
|
||||
size_t i = nextLine_.find("!");
|
||||
if (i == string::npos)
|
||||
return false;
|
||||
i = nextLine_.find_first_not_of(" \t", ++i);
|
||||
if (i != string::npos && nextLine_.compare(i, 7, "defined") == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if this is an EXEC SQL statement.
|
||||
*
|
||||
@ -6174,7 +6334,8 @@ void ASFormatter::checkIfTemplateOpener()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentChar_ == '"' || currentChar_ == '\'')
|
||||
if (currentChar_ == '"'
|
||||
|| (currentChar_ == '\'' && !isDigitSeparator(nextLine_, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = currentChar_;
|
||||
@ -6498,7 +6659,7 @@ bool ASFormatter::isOkToSplitFormattedLine()
|
||||
clearFormattedLineSplitPoints();
|
||||
return false;
|
||||
}
|
||||
else if (isBracketType(bracketTypeStack->back(), ARRAY_TYPE))
|
||||
if (isBracketType(bracketTypeStack->back(), ARRAY_TYPE))
|
||||
{
|
||||
shouldKeepLineUnbroken = true;
|
||||
if (!isBracketType(bracketTypeStack->back(), ARRAY_NIS_TYPE))
|
||||
@ -6845,10 +7006,114 @@ void ASFormatter::resetEndOfStatement()
|
||||
questionMarkStack->pop_back();
|
||||
}
|
||||
|
||||
// Find the colon alignment for an Objective-C method definition.
|
||||
int ASFormatter::findObjCColonAlignment() const
|
||||
{
|
||||
assert(currentChar == '+' || currentChar == '-');
|
||||
assert(getAlignMethodColon());
|
||||
|
||||
bool isFirstLine = true;
|
||||
bool haveFirstColon = false;
|
||||
bool needReset = false;
|
||||
bool isInComment_ = false;
|
||||
bool isInQuote_ = false;
|
||||
char quoteChar_ = ' ';
|
||||
int colonAdjust = 0;
|
||||
int colonAlign = 0;
|
||||
string nextLine_ = currentLine;
|
||||
|
||||
// peek next line
|
||||
while (sourceIterator->hasMoreLines() || isFirstLine)
|
||||
{
|
||||
if (!isFirstLine)
|
||||
{
|
||||
nextLine_ = sourceIterator->peekNextLine();
|
||||
needReset = true;
|
||||
}
|
||||
// parse the line
|
||||
haveFirstColon = false;
|
||||
nextLine_ = ASBeautifier::trim(nextLine_);
|
||||
for (size_t i = 0; i < nextLine_.length(); i++)
|
||||
{
|
||||
if (isWhiteSpace(nextLine_[i]))
|
||||
continue;
|
||||
if (nextLine_.compare(i, 2, "/*") == 0)
|
||||
isInComment_ = true;
|
||||
if (isInComment_)
|
||||
{
|
||||
if (nextLine_.compare(i, 2, "*/") == 0)
|
||||
{
|
||||
isInComment_ = false;
|
||||
++i;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (nextLine_[i] == '\\')
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if (isInQuote_)
|
||||
{
|
||||
if (nextLine_[i] == quoteChar_)
|
||||
isInQuote_ = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nextLine_[i] == '"'
|
||||
|| (nextLine_[i] == '\'' && !isDigitSeparator(nextLine_, i)))
|
||||
{
|
||||
isInQuote_ = true;
|
||||
quoteChar_ = nextLine_[i];
|
||||
continue;
|
||||
}
|
||||
if (nextLine_.compare(i, 2, "//") == 0)
|
||||
{
|
||||
i = nextLine_.length();
|
||||
continue;
|
||||
}
|
||||
// process the current char
|
||||
if (nextLine_[i] == '{' || nextLine_[i] == ';')
|
||||
goto EndOfWhileLoop;
|
||||
if (isFirstLine) // colon align does not include the first line
|
||||
continue;
|
||||
if (haveFirstColon)
|
||||
continue;
|
||||
// compute colon adjustment
|
||||
if (nextLine_[i] == ':')
|
||||
{
|
||||
haveFirstColon = true;
|
||||
if (shouldPadMethodColon)
|
||||
{
|
||||
int spacesStart;
|
||||
for (spacesStart = i; spacesStart > 0; spacesStart--)
|
||||
if (!isWhiteSpace(nextLine_[spacesStart - 1]))
|
||||
break;
|
||||
int spaces = i - spacesStart;
|
||||
if (objCColonPadMode == COLON_PAD_ALL || objCColonPadMode == COLON_PAD_BEFORE)
|
||||
colonAdjust = 1 - spaces;
|
||||
else if (objCColonPadMode == COLON_PAD_NONE || objCColonPadMode == COLON_PAD_AFTER)
|
||||
colonAdjust = 0 - spaces;
|
||||
}
|
||||
// compute alignment
|
||||
int colonPosition = i + colonAdjust;
|
||||
if (colonPosition > colonAlign)
|
||||
colonAlign = colonPosition;
|
||||
}
|
||||
} // end of for loop
|
||||
isFirstLine = false;
|
||||
} // end of while loop
|
||||
EndOfWhileLoop:
|
||||
if (needReset)
|
||||
sourceIterator->peekReset();
|
||||
return colonAlign;
|
||||
}
|
||||
|
||||
// pad an Objective-C method colon
|
||||
void ASFormatter::padObjCMethodColon()
|
||||
{
|
||||
assert(currentChar == ':');
|
||||
int commentAdjust = 0;
|
||||
char nextChar = peekNextChar();
|
||||
if (objCColonPadMode == COLON_PAD_NONE
|
||||
|| objCColonPadMode == COLON_PAD_AFTER
|
||||
@ -6856,14 +7121,20 @@ void ASFormatter::padObjCMethodColon()
|
||||
{
|
||||
// remove spaces before
|
||||
for (int i = formattedLine.length() - 1; (i > -1) && isWhiteSpace(formattedLine[i]); i--)
|
||||
{
|
||||
formattedLine.erase(i);
|
||||
--commentAdjust;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// pad space before
|
||||
for (int i = formattedLine.length() - 1; (i > 0) && isWhiteSpace(formattedLine[i]); i--)
|
||||
if (isWhiteSpace(formattedLine[i - 1]))
|
||||
{
|
||||
formattedLine.erase(i);
|
||||
--commentAdjust;
|
||||
}
|
||||
appendSpacePad();
|
||||
}
|
||||
if (objCColonPadMode == COLON_PAD_NONE
|
||||
@ -6871,21 +7142,37 @@ void ASFormatter::padObjCMethodColon()
|
||||
|| nextChar == ')')
|
||||
{
|
||||
// remove spaces after
|
||||
// do not need to bump i since a char is erased
|
||||
size_t i = charNum + 1;
|
||||
while ((i < currentLine.length()) && isWhiteSpace(currentLine[i]))
|
||||
currentLine.erase(i, 1);
|
||||
int nextText = currentLine.find_first_not_of(" \t", charNum + 1);
|
||||
if (nextText == (int)string::npos)
|
||||
nextText = currentLine.length();
|
||||
int spaces = nextText - charNum - 1;
|
||||
if (spaces > 0)
|
||||
{
|
||||
// do not use goForward here
|
||||
currentLine.erase(charNum + 1, spaces);
|
||||
spacePadNum -= spaces;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// pad space after
|
||||
// do not need to bump i since a char is erased
|
||||
size_t i = charNum + 1;
|
||||
while ((i + 1 < currentLine.length()) && isWhiteSpace(currentLine[i]))
|
||||
currentLine.erase(i, 1);
|
||||
if (((int) currentLine.length() > charNum + 1) && !isWhiteSpace(currentLine[charNum + 1]))
|
||||
currentLine.insert(charNum + 1, " ");
|
||||
int nextText = currentLine.find_first_not_of(" \t", charNum + 1);
|
||||
if (nextText == (int)string::npos)
|
||||
nextText = currentLine.length();
|
||||
int spaces = nextText - charNum - 1;
|
||||
if (spaces == 0)
|
||||
{
|
||||
currentLine.insert(charNum + 1, 1, ' ');
|
||||
spacePadNum += 1;
|
||||
}
|
||||
else if (spaces > 1)
|
||||
{
|
||||
// do not use goForward here
|
||||
currentLine.erase(charNum + 1, spaces - 1);
|
||||
spacePadNum -= spaces - 1;
|
||||
}
|
||||
}
|
||||
spacePadNum += commentAdjust;
|
||||
}
|
||||
|
||||
// Remove the leading '*' from a comment line and indent to the next tab.
|
||||
|
@ -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
|
||||
* <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:
|
||||
* To add a new language to this source module:
|
||||
*
|
||||
* 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, if necessary.
|
||||
* Add the language code to the function setTranslationClass().
|
||||
* Update the WinLangCode array in ASLocalizer.cpp.
|
||||
* Add the language code to setTranslationClass() in ASLocalizer.cpp.
|
||||
* Add the English-Translation pair to the constructor in ASLocalizer.cpp.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
@ -48,7 +44,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef __DMC__
|
||||
#include <locale.h>
|
||||
// digital mars doesn't have these
|
||||
const size_t SUBLANG_CHINESE_MACAU = 5;
|
||||
const size_t LANG_HINDI = 57;
|
||||
@ -63,12 +58,12 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <locale.h> // needed by some compilers
|
||||
#include <stdlib.h>
|
||||
#include <typeinfo>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4996) // secure version deprecation warnings
|
||||
// #pragma warning(disable: 4267) // 64 bit signed/unsigned loss of data
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -80,6 +75,10 @@
|
||||
#pragma warning(disable: 981) // operands are evaluated in unspecified order
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // wcstombs
|
||||
#endif
|
||||
|
||||
namespace astyle {
|
||||
|
||||
#ifndef ASTYLE_LIB
|
||||
@ -100,10 +99,6 @@ ASLocalizer::ASLocalizer()
|
||||
m_translation = NULL;
|
||||
|
||||
// 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, "");
|
||||
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
|
||||
// language ID http://msdn.microsoft.com/en-us/library/ee797784%28v=cs.20%29.aspx
|
||||
{
|
||||
{ LANG_CHINESE, "zh" },
|
||||
{ LANG_DUTCH, "nl" },
|
||||
{ LANG_ENGLISH, "en" },
|
||||
{ LANG_FINNISH, "fi" },
|
||||
{ LANG_FRENCH, "fr" },
|
||||
{ LANG_GERMAN, "de" },
|
||||
{ LANG_HINDI, "hi" },
|
||||
{ LANG_ITALIAN, "it" },
|
||||
{ LANG_JAPANESE, "ja" },
|
||||
{ LANG_KOREAN, "ko" },
|
||||
{ LANG_POLISH, "pl" },
|
||||
{ LANG_PORTUGUESE, "pt" },
|
||||
{ LANG_RUSSIAN, "ru" },
|
||||
{ LANG_SPANISH, "es" },
|
||||
{ LANG_SWEDISH, "sv" },
|
||||
{ LANG_UKRAINIAN, "uk" },
|
||||
{ LANG_BULGARIAN, "bg" }, // bg-BG 1251
|
||||
{ LANG_CHINESE, "zh" }, // zh-CHS, zh-CHT
|
||||
{ LANG_DUTCH, "nl" }, // nl-NL 1252
|
||||
{ LANG_ENGLISH, "en" }, // en-US 1252
|
||||
{ LANG_ESTONIAN, "et" }, // et-EE
|
||||
{ LANG_FINNISH, "fi" }, // fi-FI 1252
|
||||
{ LANG_FRENCH, "fr" }, // fr-FR 1252
|
||||
{ LANG_GERMAN, "de" }, // de-DE 1252
|
||||
{ LANG_GREEK, "el" }, // el-GR 1253
|
||||
{ LANG_HINDI, "hi" }, // hi-IN
|
||||
{ LANG_HUNGARIAN, "hu" }, // hu-HU 1250
|
||||
{ LANG_ITALIAN, "it" }, // it-IT 1252
|
||||
{ LANG_JAPANESE, "ja" }, // ja-JP
|
||||
{ LANG_KOREAN, "ko" }, // ko-KR
|
||||
{ LANG_NORWEGIAN, "nn" }, // nn-NO 1252
|
||||
{ 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)
|
||||
@ -224,16 +225,14 @@ void ASLocalizer::setLanguageFromName(const char* langID)
|
||||
// de_DE.iso88591@euro
|
||||
{
|
||||
// the constants describing the format of lang_LANG locale string
|
||||
static const size_t LEN_LANG = 2;
|
||||
|
||||
m_lcid = 0;
|
||||
string langStr = langID;
|
||||
m_langID = langStr.substr(0, LEN_LANG);
|
||||
m_langID = langStr.substr(0, 2);
|
||||
|
||||
// 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")
|
||||
m_subLangID = "CHS";
|
||||
else
|
||||
@ -262,7 +261,9 @@ void ASLocalizer::setTranslationClass()
|
||||
delete m_translation;
|
||||
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;
|
||||
else if (m_langID == "zh" && m_subLangID == "CHT")
|
||||
m_translation = new ChineseTraditional;
|
||||
@ -270,24 +271,34 @@ void ASLocalizer::setTranslationClass()
|
||||
m_translation = new Dutch;
|
||||
else if (m_langID == "en")
|
||||
m_translation = new English;
|
||||
else if (m_langID == "et")
|
||||
m_translation = new Estonian;
|
||||
else if (m_langID == "fi")
|
||||
m_translation = new Finnish;
|
||||
else if (m_langID == "fr")
|
||||
m_translation = new French;
|
||||
else if (m_langID == "de")
|
||||
m_translation = new German;
|
||||
else if (m_langID == "el")
|
||||
m_translation = new Greek;
|
||||
else if (m_langID == "hi")
|
||||
m_translation = new Hindi;
|
||||
else if (m_langID == "hu")
|
||||
m_translation = new Hungarian;
|
||||
else if (m_langID == "it")
|
||||
m_translation = new Italian;
|
||||
else if (m_langID == "ja")
|
||||
m_translation = new Japanese;
|
||||
else if (m_langID == "ko")
|
||||
m_translation = new Korean;
|
||||
else if (m_langID == "nn")
|
||||
m_translation = new Norwegian;
|
||||
else if (m_langID == "pl")
|
||||
m_translation = new Polish;
|
||||
else if (m_langID == "pt")
|
||||
m_translation = new Portuguese;
|
||||
else if (m_langID == "ro")
|
||||
m_translation = new Romanian;
|
||||
else if (m_langID == "ru")
|
||||
m_translation = new Russian;
|
||||
else if (m_langID == "es")
|
||||
@ -369,23 +380,22 @@ bool Translation::getWideTranslation(const string &stringIn, wstring &wideOut) c
|
||||
|
||||
string& Translation::translate(const string& stringIn) const
|
||||
// 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.
|
||||
{
|
||||
static string mbTranslation;
|
||||
mbTranslation.clear();
|
||||
m_mbTranslation.clear();
|
||||
for (size_t i = 0; i < m_translation.size(); i++)
|
||||
{
|
||||
if (m_translation[i].first == stringIn)
|
||||
{
|
||||
mbTranslation = convertToMultiByte(m_translation[i].second);
|
||||
m_mbTranslation = convertToMultiByte(m_translation[i].second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// not found, return english
|
||||
if (mbTranslation.empty())
|
||||
mbTranslation = stringIn;
|
||||
return mbTranslation;
|
||||
if (m_mbTranslation.empty())
|
||||
m_mbTranslation = stringIn;
|
||||
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.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
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() // 中文(简体)
|
||||
// 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
|
||||
@ -424,6 +466,7 @@ ChineseSimplified::ChineseSimplified() // 中文(简体)
|
||||
}
|
||||
|
||||
ChineseTraditional::ChineseTraditional() // 中文(繁體)
|
||||
// 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
|
||||
@ -488,6 +531,37 @@ English::English()
|
||||
// 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
|
||||
// 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");
|
||||
}
|
||||
|
||||
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() // हिन्दी
|
||||
// build the translation vector in the Translation base class
|
||||
{
|
||||
@ -614,6 +719,37 @@ Hindi::Hindi() // हिन्दी
|
||||
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
|
||||
// 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");
|
||||
}
|
||||
|
||||
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("Unchanged %s\n", L"変更 %s\n"); // should align with formatted
|
||||
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 変更 ");
|
||||
addPair("Exclude (unmatched) %s\n", L"除外する(一致しません) %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("%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("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 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 実行が終了しました");
|
||||
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 終了しました");
|
||||
}
|
||||
|
||||
Korean::Korean() // 한국의
|
||||
// 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
|
||||
@ -705,6 +843,37 @@ Korean::Korean() // 한국의
|
||||
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
|
||||
// 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");
|
||||
}
|
||||
|
||||
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() // русский
|
||||
// build the translation vector in the Translation base class
|
||||
{
|
||||
|
@ -1,28 +1,8 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ASLocalizer.h
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// ASLocalizer.h
|
||||
// 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.
|
||||
|
||||
|
||||
#ifndef ASLOCALIZER_H
|
||||
#define ASLOCALIZER_H
|
||||
@ -91,6 +71,9 @@ class Translation
|
||||
void addPair(const string& english, const wstring& translated);
|
||||
// variables
|
||||
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.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class Bulgarian : public Translation
|
||||
{ public: Bulgarian(); };
|
||||
|
||||
class ChineseSimplified : public Translation
|
||||
{
|
||||
public:
|
||||
ChineseSimplified();
|
||||
};
|
||||
{ public: ChineseSimplified(); };
|
||||
|
||||
class ChineseTraditional : public Translation
|
||||
{
|
||||
public:
|
||||
ChineseTraditional();
|
||||
};
|
||||
{ public: ChineseTraditional(); };
|
||||
|
||||
class Dutch : public Translation
|
||||
{
|
||||
public:
|
||||
Dutch();
|
||||
};
|
||||
{ public: Dutch(); };
|
||||
|
||||
class English : public Translation
|
||||
{
|
||||
public:
|
||||
English();
|
||||
};
|
||||
{ public: English(); };
|
||||
|
||||
class Estonian : public Translation
|
||||
{ public: Estonian(); };
|
||||
|
||||
class Finnish : public Translation
|
||||
{
|
||||
public:
|
||||
Finnish();
|
||||
};
|
||||
{ public: Finnish(); };
|
||||
|
||||
class French : public Translation
|
||||
{
|
||||
public:
|
||||
French();
|
||||
};
|
||||
{ public: French(); };
|
||||
|
||||
class German : public Translation
|
||||
{
|
||||
public:
|
||||
German();
|
||||
};
|
||||
{ public: German(); };
|
||||
|
||||
class Greek : public Translation
|
||||
{ public: Greek(); };
|
||||
|
||||
class Hindi : public Translation
|
||||
{
|
||||
public:
|
||||
Hindi();
|
||||
};
|
||||
{ public: Hindi(); };
|
||||
|
||||
class Hungarian : public Translation
|
||||
{ public: Hungarian(); };
|
||||
|
||||
class Italian : public Translation
|
||||
{
|
||||
public:
|
||||
Italian();
|
||||
};
|
||||
{ public: Italian(); };
|
||||
|
||||
class Japanese : public Translation
|
||||
{
|
||||
public:
|
||||
Japanese();
|
||||
};
|
||||
{ public: Japanese(); };
|
||||
|
||||
class Korean : public Translation
|
||||
{
|
||||
public:
|
||||
Korean();
|
||||
};
|
||||
{ public: Korean(); };
|
||||
|
||||
class Norwegian : public Translation
|
||||
{ public: Norwegian(); };
|
||||
|
||||
class Polish : public Translation
|
||||
{
|
||||
public:
|
||||
Polish();
|
||||
};
|
||||
{ public: Polish(); };
|
||||
|
||||
class Portuguese : public Translation
|
||||
{
|
||||
public:
|
||||
Portuguese();
|
||||
};
|
||||
{ public: Portuguese(); };
|
||||
|
||||
class Romanian : public Translation
|
||||
{ public: Romanian(); };
|
||||
|
||||
class Russian : public Translation
|
||||
{
|
||||
public:
|
||||
Russian();
|
||||
};
|
||||
{ public: Russian(); };
|
||||
|
||||
class Spanish : public Translation
|
||||
{
|
||||
public:
|
||||
Spanish();
|
||||
};
|
||||
{ public: Spanish(); };
|
||||
|
||||
class Swedish : public Translation
|
||||
{
|
||||
public:
|
||||
Swedish();
|
||||
};
|
||||
{ public: Swedish(); };
|
||||
|
||||
class Ukrainian : public Translation
|
||||
{
|
||||
public:
|
||||
Ukrainian();
|
||||
};
|
||||
{ public: Ukrainian(); };
|
||||
|
||||
|
||||
#endif // ASTYLE_LIB
|
||||
|
@ -1,35 +1,21 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ASResource.cpp
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// ASResource.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.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "astyle.h"
|
||||
#include <algorithm>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
|
||||
//
|
||||
const string ASResource::AS_IF = string("if");
|
||||
const string ASResource::AS_ELSE = string("else");
|
||||
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_THROW = string("throw");
|
||||
const string ASResource::AS_FINALLY = string("finally");
|
||||
const string ASResource::AS_USING = string("using");
|
||||
const string ASResource::_AS_TRY = string("__try");
|
||||
const string ASResource::_AS_FINALLY = string("__finally");
|
||||
const string ASResource::_AS_EXCEPT = string("__except");
|
||||
@ -277,6 +264,7 @@ void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool
|
||||
headers->push_back(&AS_SET);
|
||||
headers->push_back(&AS_ADD);
|
||||
headers->push_back(&AS_REMOVE);
|
||||
headers->push_back(&AS_USING);
|
||||
}
|
||||
|
||||
if (beautifier)
|
||||
@ -315,17 +303,19 @@ void ASResource::buildIndentableHeaders(vector<const string*>* indentableHeaders
|
||||
*/
|
||||
void ASResource::buildIndentableMacros(vector<const pair<const string, const string>* >* indentableMacros)
|
||||
{
|
||||
// the pairs must be retained in memory
|
||||
static const struct pair<const string, const string> macros[] =
|
||||
typedef pair<const string, const string> macro_pair;
|
||||
|
||||
// the pairs must be retained in memory because of pair pointers
|
||||
static const macro_pair macros[] =
|
||||
{
|
||||
// wxWidgets
|
||||
make_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"),
|
||||
make_pair("wxBEGIN_EVENT_TABLE", "wxEND_EVENT_TABLE"),
|
||||
macro_pair("BEGIN_EVENT_TABLE", "END_EVENT_TABLE"),
|
||||
macro_pair("wxBEGIN_EVENT_TABLE", "wxEND_EVENT_TABLE"),
|
||||
// MFC
|
||||
make_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"),
|
||||
make_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"),
|
||||
make_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"),
|
||||
make_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"),
|
||||
macro_pair("BEGIN_DISPATCH_MAP", "END_DISPATCH_MAP"),
|
||||
macro_pair("BEGIN_EVENT_MAP", "END_EVENT_MAP"),
|
||||
macro_pair("BEGIN_MESSAGE_MAP", "END_MESSAGE_MAP"),
|
||||
macro_pair("BEGIN_PROPPAGEIDS", "END_PROPPAGEIDS"),
|
||||
};
|
||||
|
||||
size_t elements = sizeof(macros) / sizeof(macros[0]);
|
||||
@ -586,7 +576,7 @@ bool ASBase::findKeyword(const string &line, int i, const string &keyword) const
|
||||
if (isLegalNameChar(line[wordEnd]))
|
||||
return false;
|
||||
// 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 == ')')
|
||||
return false;
|
||||
return true;
|
||||
@ -607,4 +597,71 @@ string ASBase::getCurrentWord(const string &line, size_t index) const
|
||||
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
|
||||
|
162
src/astyle.h
162
src/astyle.h
@ -1,32 +1,15 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* astyle.h
|
||||
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// astyle.h
|
||||
// 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.
|
||||
|
||||
#ifndef ASTYLE_H
|
||||
#define ASTYLE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __VMS
|
||||
#define __USE_STD_IOSTREAM 1
|
||||
#include <assert>
|
||||
@ -39,13 +22,16 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <string.h> // need both string and string.h for GCC
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4996) // secure version deprecation warnings
|
||||
#pragma warning(disable: 4267) // 64 bit signed/unsigned loss of data
|
||||
#pragma warning(disable: 4267) // conversion from size_t to int
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -61,10 +47,18 @@
|
||||
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
|
||||
#endif
|
||||
|
||||
namespace astyle {
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
//
|
||||
using namespace std;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// definitions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
enum FileType { C_TYPE = 0, JAVA_TYPE = 1, SHARP_TYPE = 2 };
|
||||
|
||||
/* The enums below are not recognized by 'vectors' in Microsoft Visual C++
|
||||
@ -218,7 +212,7 @@ class ASResource
|
||||
static const string AS_DO, AS_WHILE;
|
||||
static const string AS_FOR;
|
||||
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_PUBLIC, AS_PROTECTED, AS_PRIVATE;
|
||||
static const string AS_CLASS, AS_STRUCT, AS_UNION, AS_INTERFACE, AS_NAMESPACE;
|
||||
@ -257,6 +251,7 @@ class ASResource
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class ASBase
|
||||
// Functions definitions are at the end of ASResource.cpp.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class ASBase
|
||||
@ -267,69 +262,24 @@ class ASBase
|
||||
|
||||
protected:
|
||||
ASBase() : baseFileType(C_TYPE) { }
|
||||
virtual ~ASBase() {}
|
||||
|
||||
// functions definitions are at the end of ASResource.cpp
|
||||
bool findKeyword(const string &line, int i, const string &keyword) const;
|
||||
string getCurrentWord(const string &line, size_t index) const;
|
||||
|
||||
protected:
|
||||
protected: // inline functions
|
||||
void init(int fileTypeArg) { baseFileType = fileTypeArg; }
|
||||
bool isCStyle() const { return (baseFileType == C_TYPE); }
|
||||
bool isJavaStyle() const { return (baseFileType == JAVA_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'); }
|
||||
|
||||
// peek at the next unread character.
|
||||
char 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;
|
||||
}
|
||||
protected: // functions definitions are at the end of ASResource.cpp
|
||||
bool findKeyword(const string& line, int i, const string& keyword) const;
|
||||
string getCurrentWord(const string& line, size_t index) const;
|
||||
bool isDigit(char ch) const;
|
||||
bool isLegalNameChar(char ch) const;
|
||||
bool isCharPotentialHeader(const string& line, size_t i) const;
|
||||
bool isCharPotentialOperator(char ch) const;
|
||||
bool isDigitSeparator(const string& line, int i) const;
|
||||
char peekNextChar(const string& line, int i) const;
|
||||
|
||||
}; // Class ASBase
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -370,6 +320,7 @@ class ASBeautifier : protected ASResource, protected ASBase
|
||||
int getTabLength(void) const;
|
||||
string getIndentString(void) const;
|
||||
string getNextWord(const string& line, size_t currPos) const;
|
||||
bool getAlignMethodColon(void) const;
|
||||
bool getBracketIndent(void) const;
|
||||
bool getBlockIndent(void) const;
|
||||
bool getCaseIndent(void) const;
|
||||
@ -401,6 +352,7 @@ class ASBeautifier : protected ASResource, protected ASBase
|
||||
int inLineNumber;
|
||||
int horstmannIndentInStatement;
|
||||
int nonInStatementBracket;
|
||||
int objCColonAlignSubsequent; // for subsequent lines not counting indent
|
||||
bool lineCommentNoBeautify;
|
||||
bool isElseHeaderIndent;
|
||||
bool isCaseHeaderCommentIndent;
|
||||
@ -413,7 +365,7 @@ class ASBeautifier : protected ASResource, protected ASBase
|
||||
bool isInIndentablePreproc;
|
||||
|
||||
private: // functions
|
||||
ASBeautifier(const ASBeautifier ©);
|
||||
ASBeautifier(const ASBeautifier& copy); // inline functions
|
||||
ASBeautifier& operator=(ASBeautifier&); // not to be implemented
|
||||
|
||||
void adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHeaderIndent);
|
||||
@ -621,15 +573,15 @@ class ASEnhancer : protected ASBase
|
||||
|
||||
// struct used by ParseFormattedLine function
|
||||
// contains variables used to unindent the case blocks
|
||||
struct switchVariables
|
||||
struct SwitchVariables
|
||||
{
|
||||
int switchBracketCount;
|
||||
int unindentDepth;
|
||||
bool unindentCase;
|
||||
};
|
||||
|
||||
switchVariables sw; // switch variables struct
|
||||
vector<switchVariables> switchStack; // stack vector of switch variables
|
||||
SwitchVariables sw; // switch variables struct
|
||||
vector<SwitchVariables> switchStack; // stack vector of switch variables
|
||||
|
||||
// event table variables
|
||||
bool nextLineIsEventIndent; // begin event table indent is reached
|
||||
@ -673,7 +625,10 @@ class ASFormatter : public ASBeautifier
|
||||
void setBreakOneLineBlocksMode(bool state);
|
||||
void setMethodPrefixPaddingMode(bool state);
|
||||
void setMethodPrefixUnPaddingMode(bool state);
|
||||
void setReturnTypePaddingMode(bool state);
|
||||
void setReturnTypeUnPaddingMode(bool state);
|
||||
void setCloseTemplatesMode(bool state);
|
||||
void setCommaPaddingMode(bool state);
|
||||
void setDeleteEmptyLinesMode(bool state);
|
||||
void setIndentCol1CommentsMode(bool state);
|
||||
void setLineEndFormat(LineEndFormat fmt);
|
||||
@ -697,8 +652,8 @@ class ASFormatter : public ASBeautifier
|
||||
int getFormatterFileType() const;
|
||||
|
||||
private: // functions
|
||||
ASFormatter(const ASFormatter ©); // copy constructor not to be implemented
|
||||
ASFormatter &operator=(ASFormatter &); // assignment operator not to be implemented
|
||||
ASFormatter(const ASFormatter& copy); // not to be implemented
|
||||
ASFormatter& operator=(ASFormatter&); // not to be implemented
|
||||
template<typename T> void deleteContainer(T& container);
|
||||
template<typename T> void initContainer(T& container, T value);
|
||||
char peekNextChar() const;
|
||||
@ -733,6 +688,7 @@ class ASFormatter : public ASBeautifier
|
||||
bool isSharpStyleWithParen(const string* header) const;
|
||||
bool isStructAccessModified(string& firstLine, size_t index) const;
|
||||
bool isIndentablePreprocessorBlock(string& firstLine, size_t index);
|
||||
bool isNDefPreprocStatement(string& firstLine, string& preproc) const;
|
||||
bool isUnaryOperator() const;
|
||||
bool isUniformInitializerBracket() const;
|
||||
bool isImmediatelyPostCast() const;
|
||||
@ -742,6 +698,7 @@ class ASFormatter : public ASBeautifier
|
||||
bool isOkToBreakBlock(BracketType bracketType) const;
|
||||
bool isOperatorPaddingDisabled() const;
|
||||
bool pointerSymbolFollows() const;
|
||||
int findObjCColonAlignment() const;
|
||||
int getCurrentLineCommentAdjustment();
|
||||
int getNextLineCommentAdjustment();
|
||||
int isOneLineBlockReached(string& line, int startChar) const;
|
||||
@ -785,16 +742,16 @@ class ASFormatter : public ASBeautifier
|
||||
void padObjCMethodColon();
|
||||
void padOperators(const string* newOperator);
|
||||
void padParens();
|
||||
void padParenObjC(void);
|
||||
void processPreprocessor();
|
||||
void resetEndOfStatement();
|
||||
void setAttachClosingBracketMode(bool state);
|
||||
void setBreakBlocksVariables();
|
||||
void stripCommentPrefix();
|
||||
void testForTimeToSplitFormattedLine();
|
||||
void trimContinuationLine();
|
||||
void updateFormattedLineSplitPointsPointerOrReference(size_t index);
|
||||
size_t findFormattedLineSplitPoint() const;
|
||||
size_t findNextChar(string &line, char searchChar, int searchStart = 0);
|
||||
size_t findNextChar(string& line, char searchChar, int searchStart = 0) const;
|
||||
const string* checkForHeaderFollowingComment(const string& firstLine) const;
|
||||
const string* getFollowingOperator() const;
|
||||
string getPreviousWord(const string& line, int currPos) const;
|
||||
@ -835,6 +792,7 @@ class ASFormatter : public ASBeautifier
|
||||
int charNum;
|
||||
int horstmannIndentChars;
|
||||
int nextLineSpacePadNum;
|
||||
int objCColonAlign;
|
||||
int preprocBracketTypeStackSize;
|
||||
int spacePadNum;
|
||||
int tabIncrementIn;
|
||||
@ -868,6 +826,7 @@ class ASFormatter : public ASBeautifier
|
||||
ObjCColonPad objCColonPadMode;
|
||||
LineEndFormat lineEnd;
|
||||
bool isVirgin;
|
||||
bool shouldPadCommas;
|
||||
bool shouldPadOperators;
|
||||
bool shouldPadParensOutside;
|
||||
bool shouldPadFirstParen;
|
||||
@ -941,6 +900,7 @@ class ASFormatter : public ASBeautifier
|
||||
bool isCharImmediatelyPostPointerOrReference;
|
||||
bool isInObjCMethodDefinition;
|
||||
bool isInObjCInterface;
|
||||
bool isInObjCReturnType;
|
||||
bool isInObjCSelector;
|
||||
bool breakCurrentOneLineBlock;
|
||||
bool shouldRemoveNextClosingBracket;
|
||||
@ -959,6 +919,8 @@ class ASFormatter : public ASBeautifier
|
||||
bool shouldPadMethodColon;
|
||||
bool shouldPadMethodPrefix;
|
||||
bool shouldUnPadMethodPrefix;
|
||||
bool shouldPadReturnType;
|
||||
bool shouldUnPadReturnType;
|
||||
bool shouldDeleteEmptyLines;
|
||||
bool needHeaderOpeningBracket;
|
||||
bool shouldBreakLineAtNextChar;
|
||||
@ -970,6 +932,7 @@ class ASFormatter : public ASBeautifier
|
||||
bool isImmediatelyPostComment;
|
||||
bool isImmediatelyPostLineComment;
|
||||
bool isImmediatelyPostEmptyBlock;
|
||||
bool isImmediatelyPostObjCMethodPrefix;
|
||||
bool isImmediatelyPostPreprocessor;
|
||||
bool isImmediatelyPostReturn;
|
||||
bool isImmediatelyPostThrow;
|
||||
@ -994,27 +957,30 @@ class ASFormatter : public ASBeautifier
|
||||
|
||||
private: // inline functions
|
||||
// append the CURRENT character (curentChar) to the current formatted line.
|
||||
void appendCurrentChar(bool canBreakLine = true) {
|
||||
void appendCurrentChar(bool canBreakLine = true)
|
||||
{
|
||||
appendChar(currentChar, canBreakLine);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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_);
|
||||
}
|
||||
|
||||
// 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_);
|
||||
}
|
||||
}; // Class ASFormatter
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// astyle namespace global declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1,59 +1,45 @@
|
||||
// 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
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
/*
|
||||
AStyle_main source file map.
|
||||
This source file contains several classes.
|
||||
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
|
||||
---------------------------------------
|
||||
* AStyle_main source file map.
|
||||
* This source file contains several classes.
|
||||
* 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
|
||||
* ---------------------------------------
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// headers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "astyle_main.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <errno.h>
|
||||
#include <fstream>
|
||||
#include <locale.h> // needed by some compilers
|
||||
#include <sstream>
|
||||
|
||||
// includes for recursive getFileNames() function
|
||||
@ -74,9 +60,9 @@
|
||||
#endif /* __VMS */
|
||||
#endif
|
||||
|
||||
#ifdef __DMC__
|
||||
#include <locale.h>
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// turn off MinGW automatic file globbing
|
||||
// this CANNOT be in the astyle namespace
|
||||
@ -89,17 +75,17 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
|
||||
//
|
||||
// console build variables
|
||||
#ifndef ASTYLE_LIB
|
||||
ASConsole* g_console = NULL; // class to encapsulate console variables
|
||||
ostream* _err = &cerr; // direct error messages to cerr
|
||||
#ifdef _WIN32
|
||||
char g_fileSeparator = '\\'; // Windows file separator
|
||||
bool g_isCaseSensitive = false; // Windows IS case sensitive
|
||||
bool g_isCaseSensitive = false; // Windows IS NOT case sensitive
|
||||
#else
|
||||
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 // ASTYLE_LIB
|
||||
|
||||
@ -110,7 +96,7 @@ namespace astyle {
|
||||
jmethodID g_mid;
|
||||
#endif
|
||||
|
||||
const char* g_version = "2.05.1";
|
||||
const char* g_version = "2.06 beta";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASStreamIterator class
|
||||
@ -125,7 +111,6 @@ ASStreamIterator<T>::ASStreamIterator(T* in)
|
||||
eolWindows = 0;
|
||||
eolLinux = 0;
|
||||
eolMacOld = 0;
|
||||
outputEOL[0] = '\0';
|
||||
peekStart = 0;
|
||||
prevLineDeleted = false;
|
||||
checkForEmptyLine = false;
|
||||
@ -227,14 +212,14 @@ string ASStreamIterator<T>::nextLine(bool emptyLineWasDeleted)
|
||||
if (eolWindows >= eolLinux)
|
||||
{
|
||||
if (eolWindows >= eolMacOld)
|
||||
strcpy(outputEOL, "\r\n"); // Windows (CR+LF)
|
||||
outputEOL = "\r\n"; // Windows (CR+LF)
|
||||
else
|
||||
strcpy(outputEOL, "\r"); // MacOld (CR)
|
||||
outputEOL = "\r"; // MacOld (CR)
|
||||
}
|
||||
else if (eolLinux >= eolMacOld)
|
||||
strcpy(outputEOL, "\n"); // Linux (LF)
|
||||
outputEOL = "\n"; // Linux (LF)
|
||||
else
|
||||
strcpy(outputEOL, "\r"); // MacOld (CR)
|
||||
outputEOL = "\r"; // MacOld (CR)
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@ -344,7 +329,7 @@ void ASConsole::convertLineEnds(ostringstream &out, int lineEnd)
|
||||
assert(lineEnd == LINEEND_WINDOWS || lineEnd == LINEEND_LINUX || lineEnd == LINEEND_MACOLD);
|
||||
const string& inStr = out.str(); // avoids strange looking syntax
|
||||
string outStr; // the converted output
|
||||
int inLength = inStr.length();
|
||||
int inLength = (int)inStr.length();
|
||||
for (int pos = 0; pos < inLength; pos++)
|
||||
{
|
||||
if (inStr[pos] == '\r')
|
||||
@ -425,11 +410,11 @@ void ASConsole::convertLineEnds(ostringstream &out, int lineEnd)
|
||||
void ASConsole::correctMixedLineEnds(ostringstream& out)
|
||||
{
|
||||
LineEndFormat lineEndFormat = LINEEND_DEFAULT;
|
||||
if (strcmp(outputEOL, "\r\n") == 0)
|
||||
if (outputEOL == "\r\n")
|
||||
lineEndFormat = LINEEND_WINDOWS;
|
||||
if (strcmp(outputEOL, "\n") == 0)
|
||||
if (outputEOL == "\n")
|
||||
lineEndFormat = LINEEND_LINUX;
|
||||
if (strcmp(outputEOL, "\r") == 0)
|
||||
if (outputEOL == "\r")
|
||||
lineEndFormat = LINEEND_MACOLD;
|
||||
convertLineEnds(out, lineEndFormat);
|
||||
}
|
||||
@ -493,7 +478,11 @@ void ASConsole::formatCinToCout()
|
||||
ASStreamIterator<stringstream> streamIterator(&outStream);
|
||||
// Windows pipe or redirection always outputs Windows line-ends.
|
||||
// Linux pipe or redirection will output any line end.
|
||||
#ifdef _WIN32
|
||||
LineEndFormat lineEndFormat = LINEEND_DEFAULT;
|
||||
#else
|
||||
LineEndFormat lineEndFormat = formatter.getLineEndFormat();
|
||||
#endif // _WIN32
|
||||
initializeOutputEOL(lineEndFormat);
|
||||
formatter.init(&streamIterator);
|
||||
|
||||
@ -734,18 +723,18 @@ void ASConsole::initializeOutputEOL(LineEndFormat lineEndFormat)
|
||||
|| lineEndFormat == LINEEND_LINUX
|
||||
|| lineEndFormat == LINEEND_MACOLD);
|
||||
|
||||
outputEOL[0] = '\0'; // current line end
|
||||
prevEOL[0] = '\0'; // previous line end
|
||||
outputEOL.clear(); // current line end
|
||||
prevEOL.clear(); // previous line end
|
||||
lineEndsMixed = false; // output has mixed line ends, LINEEND_DEFAULT only
|
||||
|
||||
if (lineEndFormat == LINEEND_WINDOWS)
|
||||
strcpy(outputEOL, "\r\n");
|
||||
outputEOL = "\r\n";
|
||||
else if (lineEndFormat == LINEEND_LINUX)
|
||||
strcpy(outputEOL, "\n");
|
||||
outputEOL = "\n";
|
||||
else if (lineEndFormat == LINEEND_MACOLD)
|
||||
strcpy(outputEOL, "\r");
|
||||
outputEOL = "\r";
|
||||
else
|
||||
outputEOL[0] = '\0';
|
||||
outputEOL.clear();
|
||||
}
|
||||
|
||||
FileEncoding ASConsole::readFile(const string& fileName_, stringstream& in) const
|
||||
@ -771,11 +760,11 @@ FileEncoding ASConsole::readFile(const string &fileName_, stringstream &in) cons
|
||||
if (encoding == UTF_16LE || encoding == UTF_16BE)
|
||||
{
|
||||
// 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];
|
||||
if (!utf8Out)
|
||||
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);
|
||||
in << string(utf8Out, utf8Len);
|
||||
delete [] utf8Out;
|
||||
@ -827,24 +816,24 @@ void ASConsole::setPreserveDate(bool state)
|
||||
{ preserveDate = state; }
|
||||
|
||||
// set outputEOL variable
|
||||
void ASConsole::setOutputEOL(LineEndFormat lineEndFormat, const char* currentEOL)
|
||||
void ASConsole::setOutputEOL(LineEndFormat lineEndFormat, const string& currentEOL)
|
||||
{
|
||||
if (lineEndFormat == LINEEND_DEFAULT)
|
||||
{
|
||||
strcpy(outputEOL, currentEOL);
|
||||
if (strlen(prevEOL) == 0)
|
||||
strcpy(prevEOL, outputEOL);
|
||||
if (strcmp(prevEOL, outputEOL) != 0)
|
||||
outputEOL = currentEOL;
|
||||
if (prevEOL.empty())
|
||||
prevEOL = outputEOL;
|
||||
if (prevEOL != outputEOL)
|
||||
{
|
||||
lineEndsMixed = true;
|
||||
filesAreIdentical = false;
|
||||
strcpy(prevEOL, outputEOL);
|
||||
prevEOL = outputEOL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(prevEOL, currentEOL);
|
||||
if (strcmp(prevEOL, outputEOL) != 0)
|
||||
prevEOL = currentEOL;
|
||||
if (prevEOL != outputEOL)
|
||||
filesAreIdentical = false;
|
||||
}
|
||||
}
|
||||
@ -1293,9 +1282,9 @@ void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const
|
||||
// find xdg-open (usually in /usr/bin)
|
||||
// Mac uses open instead
|
||||
#ifdef __APPLE__
|
||||
const char* FILE_OPEN = "open";
|
||||
const char* fileOpen = "open";
|
||||
#else
|
||||
const char* FILE_OPEN = "xdg-open";
|
||||
const char* fileOpen = "xdg-open";
|
||||
#endif
|
||||
string searchPath;
|
||||
char* searchDir = strtok(paths, ":");
|
||||
@ -1305,22 +1294,22 @@ void ASConsole::launchDefaultBrowser(const char* filePathIn /*NULL*/) const
|
||||
if (searchPath.length() > 0
|
||||
&& searchPath[searchPath.length() - 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))
|
||||
break;
|
||||
searchDir = strtok(NULL, ":");
|
||||
}
|
||||
delete[] paths;
|
||||
if (searchDir == NULL)
|
||||
error(_("Command is not installed"), FILE_OPEN);
|
||||
error(_("Command is not installed"), fileOpen);
|
||||
|
||||
// browser open will be bypassed in test programs
|
||||
printf(_("Opening HTML documentation %s\n"), htmlFilePath.c_str());
|
||||
if (!bypassBrowserOpen)
|
||||
{
|
||||
execlp(FILE_OPEN, FILE_OPEN, htmlFilePath.c_str(), NULL);
|
||||
execlp(fileOpen, fileOpen, htmlFilePath.c_str(), NULL);
|
||||
// execlp will NOT return if successful
|
||||
error(_("Command execute failure"), FILE_OPEN);
|
||||
error(_("Command execute failure"), fileOpen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1361,7 +1350,8 @@ void ASConsole::getFilePaths(string &filePath)
|
||||
hasWildcard = true;
|
||||
|
||||
// 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;
|
||||
|
||||
// If the filename is not quoted on Linux, bash will replace the
|
||||
@ -1398,7 +1388,7 @@ void ASConsole::getFilePaths(string &filePath)
|
||||
bool excludeErr = false;
|
||||
for (size_t ix = 0; ix < excludeHitsVector.size(); ix++)
|
||||
{
|
||||
if (excludeHitsVector[ix] == false)
|
||||
if (!excludeHitsVector[ix])
|
||||
{
|
||||
excludeErr = true;
|
||||
if (!ignoreExcludeErrorsDisplay)
|
||||
@ -1735,6 +1725,9 @@ void ASConsole::printHelp() const
|
||||
cout << " --pad-oper OR -p\n";
|
||||
cout << " Insert space padding around operators.\n";
|
||||
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 << " Insert space padding around parenthesis on both the outside\n";
|
||||
cout << " and the inside.\n";
|
||||
@ -1836,9 +1829,6 @@ void ASConsole::printHelp() const
|
||||
cout << endl;
|
||||
cout << "Objective-C Options:\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 << " Insert space padding after the '-' or '+' Objective-C\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 << " method prefix.\n";
|
||||
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=all OR -xP1\n";
|
||||
cout << " --pad-method-colon=after OR -xP2\n";
|
||||
@ -1986,7 +1985,7 @@ void ASConsole::processOptions(vector<string> &argvOptions)
|
||||
{
|
||||
optionsFileName = getParam(arg, "--options=");
|
||||
optionsFileRequired = true;
|
||||
if (optionsFileName.compare("") == 0)
|
||||
if (optionsFileName.empty())
|
||||
setOptionsFileName(" ");
|
||||
}
|
||||
else if ( isOption(arg, "-h")
|
||||
@ -2028,31 +2027,31 @@ void ASConsole::processOptions(vector<string> &argvOptions)
|
||||
// get options file path and name
|
||||
if (shouldParseOptionsFile)
|
||||
{
|
||||
if (optionsFileName.compare("") == 0)
|
||||
if (optionsFileName.empty())
|
||||
{
|
||||
char* env = getenv("ARTISTIC_STYLE_OPTIONS");
|
||||
if (env != NULL)
|
||||
setOptionsFileName(env);
|
||||
}
|
||||
if (optionsFileName.compare("") == 0)
|
||||
if (optionsFileName.empty())
|
||||
{
|
||||
char* env = getenv("HOME");
|
||||
if (env != NULL)
|
||||
setOptionsFileName(string(env) + "/.astylerc");
|
||||
}
|
||||
if (optionsFileName.compare("") == 0)
|
||||
if (optionsFileName.empty())
|
||||
{
|
||||
char* env = getenv("USERPROFILE");
|
||||
if (env != NULL)
|
||||
setOptionsFileName(string(env) + "/astylerc");
|
||||
}
|
||||
if (optionsFileName.compare("") != 0)
|
||||
if (!optionsFileName.empty())
|
||||
standardizePath(optionsFileName);
|
||||
}
|
||||
|
||||
// create the options file vector and parse the options for errors
|
||||
ASOptions options(formatter);
|
||||
if (optionsFileName.compare("") != 0)
|
||||
if (!optionsFileName.empty())
|
||||
{
|
||||
ifstream optionsIn(optionsFileName.c_str());
|
||||
if (optionsIn)
|
||||
@ -2208,14 +2207,19 @@ void ASConsole::printVerboseHeader() const
|
||||
if (isQuiet)
|
||||
return;
|
||||
// get the date
|
||||
struct tm* ptr;
|
||||
time_t lt;
|
||||
char str[20];
|
||||
lt = time(NULL);
|
||||
ptr = localtime(<);
|
||||
struct tm* ptr = localtime(<);
|
||||
strftime(str, 20, "%x", ptr);
|
||||
// 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
|
||||
if (!optionsFileName.empty())
|
||||
printf(_("Using default options file %s\n"), optionsFileName.c_str());
|
||||
@ -2391,9 +2395,9 @@ void ASConsole::writeFile(const string &fileName_, FileEncoding encoding, ostrin
|
||||
{
|
||||
// convert utf-8 to utf-16
|
||||
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];
|
||||
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);
|
||||
assert(utf16Len == utf16Size);
|
||||
fout << string(utf16Out, utf16Len);
|
||||
@ -2426,13 +2430,13 @@ void ASConsole::writeFile(const string &fileName_, FileEncoding encoding, ostrin
|
||||
}
|
||||
}
|
||||
|
||||
#else // ASTYLE_LIB
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASLibrary class
|
||||
// used by shared object (DLL) calls
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#else // ASTYLE_LIB
|
||||
|
||||
utf16_t* ASLibrary::formatUtf16(const utf16_t* pSourceIn, // the source to be formatted
|
||||
const utf16_t* pOptions, // AStyle options
|
||||
fpError fpErrorHandler, // error handler function
|
||||
@ -2498,14 +2502,14 @@ utf16_t* ASLibrary::convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc
|
||||
size_t dataSize = strlen(utf8In);
|
||||
bool isBigEndian = utf8_16.getBigEndian();
|
||||
// return size is in number of CHARs, not utf16_t
|
||||
size_t utf16Size = (utf8_16.Utf16LengthFromUtf8(data, dataSize) + sizeof(utf16_t));
|
||||
char* utf16Out = fpMemoryAlloc(utf16Size);
|
||||
size_t utf16Size = (utf8_16.utf16LengthFromUtf8(data, dataSize) + sizeof(utf16_t));
|
||||
char* utf16Out = fpMemoryAlloc((long)utf16Size);
|
||||
if (utf16Out == NULL)
|
||||
return NULL;
|
||||
#ifdef NDEBUG
|
||||
utf8_16.Utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out);
|
||||
utf8_16.utf8ToUtf16(data, dataSize + 1, isBigEndian, utf16Out);
|
||||
#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);
|
||||
#endif
|
||||
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_t dataSize = utf8_16.utf16len(utf16In) * sizeof(utf16_t);
|
||||
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];
|
||||
if (utf8Out == NULL)
|
||||
return NULL;
|
||||
#ifdef NDEBUG
|
||||
utf8_16.Utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out);
|
||||
utf8_16.utf16ToUtf8(data, dataSize + 1, isBigEndian, true, utf8Out);
|
||||
#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);
|
||||
#endif
|
||||
assert(utf8Size == strlen(utf8Out) + 1);
|
||||
@ -2876,6 +2880,10 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
|
||||
{
|
||||
formatter.setOperatorPaddingMode(true);
|
||||
}
|
||||
else if (isOption(arg, "xg", "pad-comma"))
|
||||
{
|
||||
formatter.setCommaPaddingMode(true);
|
||||
}
|
||||
else if ( isOption(arg, "xe", "delete-empty-lines") )
|
||||
{
|
||||
formatter.setDeleteEmptyLinesMode(true);
|
||||
@ -3030,10 +3038,6 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
|
||||
formatter.setStripCommentPrefix(true);
|
||||
}
|
||||
// Objective-C options
|
||||
else if ( isOption(arg, "xM", "align-method-colon") )
|
||||
{
|
||||
formatter.setAlignMethodColon(true);
|
||||
}
|
||||
else if ( isOption(arg, "xQ", "pad-method-prefix") )
|
||||
{
|
||||
formatter.setMethodPrefixPaddingMode(true);
|
||||
@ -3042,6 +3046,18 @@ void ASOptions::parseOption(const string &arg, const string &errorInfo)
|
||||
{
|
||||
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") )
|
||||
{
|
||||
formatter.setObjCColonPaddingMode(COLON_PAD_NONE);
|
||||
@ -3310,7 +3326,7 @@ size_t Utf8_16::utf16len(const utf16* utf16In) const
|
||||
// Modified for Artistic Style by Jim Pattee.
|
||||
// Compute the length of an output utf-8 file given a utf-16 file.
|
||||
// Input inLen is the size in BYTES (not wchar_t).
|
||||
size_t Utf8_16::Utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const
|
||||
size_t Utf8_16::utf8LengthFromUtf16(const char* utf16In, size_t inLen, bool isBigEndian) const
|
||||
{
|
||||
size_t len = 0;
|
||||
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.
|
||||
// Modified for Artistic Style by Jim Pattee.
|
||||
// Convert a utf-8 file to utf-16.
|
||||
size_t Utf8_16::Utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const
|
||||
size_t Utf8_16::utf8ToUtf16(char* utf8In, size_t inLen, bool isBigEndian, char* utf16Out) const
|
||||
{
|
||||
int nCur = 0;
|
||||
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);
|
||||
state = eStart;
|
||||
break;
|
||||
// no default case is needed
|
||||
}
|
||||
++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.
|
||||
// Compute the length of an output utf-16 file given a utf-8 file.
|
||||
// Return value is the size in BYTES (not wchar_t).
|
||||
size_t Utf8_16::Utf16LengthFromUtf8(const char* utf8In, size_t len) const
|
||||
size_t Utf8_16::utf16LengthFromUtf8(const char* utf8In, size_t len) const
|
||||
{
|
||||
size_t ulen = 0;
|
||||
size_t charLen;
|
||||
@ -3442,7 +3459,7 @@ size_t Utf8_16::Utf16LengthFromUtf8(const char* utf8In, size_t len) const
|
||||
// Copyright (C) 2002 Scott Kirkwood.
|
||||
// Modified for Artistic Style by Jim Pattee.
|
||||
// Convert a utf-16 file to utf-8.
|
||||
size_t Utf8_16::Utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
|
||||
size_t Utf8_16::utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
|
||||
bool firstBlock, char* utf8Out) const
|
||||
{
|
||||
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));
|
||||
state = eStart;
|
||||
break;
|
||||
// no default case is needed
|
||||
}
|
||||
*pCur++ = static_cast<ubyte>(nCur);
|
||||
}
|
||||
@ -3610,14 +3628,25 @@ char* STDCALL javaMemoryAlloc(unsigned long memoryNeeded)
|
||||
char* buffer = new(nothrow) char[memoryNeeded];
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif // ASTYLE_JNI
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Entry point for AStyleMainUtf16 library builds
|
||||
// ASTYLE_LIB functions for library builds
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#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
|
||||
const utf16_t* pOptions, // AStyle options
|
||||
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
|
||||
//----------------------------------------------------------------------------
|
||||
/*
|
||||
* 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
|
||||
* 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();
|
||||
char* pTextOut = fpMemoryAlloc(textSizeOut + 1); // call memory allocation function
|
||||
size_t textSizeOut = out.str().length();
|
||||
char* pTextOut = fpMemoryAlloc((long)textSizeOut + 1); // call memory allocation function
|
||||
if (pTextOut == NULL)
|
||||
{
|
||||
fpErrorHandler(120, "Allocation failure on output.");
|
||||
|
@ -1,28 +1,7 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* astyle_main.h
|
||||
*
|
||||
* Copyright (C) 2014 by Jim Pattee
|
||||
* <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/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
// astyle_main.h
|
||||
// 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.
|
||||
|
||||
#ifndef ASTYLE_MAIN_H
|
||||
#define ASTYLE_MAIN_H
|
||||
@ -64,27 +43,38 @@
|
||||
#define _(a) localizer.settext(a)
|
||||
#endif // ASTYLE_LIB
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// for G++ implementation of string.compare:
|
||||
#if defined(__GNUC__) && __GNUC__ < 3
|
||||
#error - Use GNU C compiler release 3 or higher
|
||||
#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
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1200 // check for V6.0
|
||||
#error - Use Microsoft compiler version 6 or higher
|
||||
#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
|
||||
#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
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// definitions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef ASTYLE_LIB
|
||||
|
||||
// define STDCALL and EXPORT for Windows
|
||||
@ -124,7 +114,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
namespace astyle {
|
||||
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// ASStreamIterator class
|
||||
// typename will be istringstream for GUI and istream otherwise
|
||||
@ -138,7 +128,7 @@ class ASStreamIterator : public ASSourceIterator
|
||||
bool checkForEmptyLine;
|
||||
|
||||
// function declarations
|
||||
ASStreamIterator(T* in);
|
||||
explicit ASStreamIterator(T* in);
|
||||
virtual ~ASStreamIterator();
|
||||
bool getLineEndChange(int lineEndFormat) const;
|
||||
int getStreamLength() const;
|
||||
@ -154,10 +144,10 @@ class ASStreamIterator : public ASSourceIterator
|
||||
T* inStream; // pointer to the input stream
|
||||
string buffer; // current input line
|
||||
string prevBuffer; // previous input line
|
||||
string outputEOL; // next output end of line char
|
||||
int eolWindows; // number of Windows line endings, CRLF
|
||||
int eolLinux; // number of Linux line endings, LF
|
||||
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 peekStart; // starting position for peekNextLine
|
||||
bool prevLineDeleted; // the previous input line was deleted
|
||||
@ -165,7 +155,7 @@ class ASStreamIterator : public ASSourceIterator
|
||||
public: // inline functions
|
||||
bool compareToInputBuffer(const string& nextLine_) const
|
||||
{ return (nextLine_ == prevBuffer); }
|
||||
const char* getOutputEOL() const { return outputEOL; }
|
||||
const string& getOutputEOL() const { return outputEOL; }
|
||||
bool hasMoreLines() const { return !inStream->eof(); }
|
||||
};
|
||||
|
||||
@ -190,10 +180,10 @@ class Utf8_16
|
||||
bool getBigEndian() const;
|
||||
int swap16bit(int value) const;
|
||||
size_t utf16len(const utf16* utf16In) 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 Utf16LengthFromUtf8(const char* utf8In, size_t inLen) const;
|
||||
size_t Utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
|
||||
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 utf16LengthFromUtf8(const char* utf8In, size_t inLen) const;
|
||||
size_t utf16ToUtf8(char* utf16In, size_t inLen, bool isBigEndian,
|
||||
bool firstBlock, char* utf8Out) const;
|
||||
};
|
||||
|
||||
@ -205,7 +195,7 @@ class Utf8_16
|
||||
class ASOptions
|
||||
{
|
||||
public:
|
||||
ASOptions(ASFormatter &formatterArg) : formatter(formatterArg) {}
|
||||
explicit ASOptions(ASFormatter& formatterArg) : formatter(formatterArg) {}
|
||||
string getOptionErrors() const;
|
||||
void importOptions(istream& in, vector<string>& optionsVector);
|
||||
bool parseOptions(vector<string>& optionsVector, const string& errorInfo);
|
||||
@ -216,7 +206,8 @@ class ASOptions
|
||||
stringstream optionErrors; // option error messages
|
||||
|
||||
// functions
|
||||
ASOptions &operator=(ASOptions &); // not to be implemented
|
||||
ASOptions(const ASOptions&); // copy constructor not to be implemented
|
||||
ASOptions& operator=(ASOptions&); // assignment operator not to be implemented
|
||||
string getParam(const string& arg, const char* op);
|
||||
string getParam(const string& arg, const char* op1, const char* op2);
|
||||
bool isOption(const string& arg, const char* op);
|
||||
@ -259,11 +250,11 @@ class ASConsole
|
||||
int filesUnchanged; // number of files unchanged
|
||||
bool lineEndsMixed; // output has mixed line ends
|
||||
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
|
||||
|
||||
string outputEOL; // current line end
|
||||
string prevEOL; // previous line end
|
||||
string optionsFileName; // file path and name of the options file to use
|
||||
string origSuffix; // suffix= option
|
||||
string targetDirectory; // path to the directory being processed
|
||||
@ -277,7 +268,8 @@ class ASConsole
|
||||
vector<string> fileName; // files to be processed including path
|
||||
|
||||
public: // variables
|
||||
ASConsole(ASFormatter &formatterArg) : formatter(formatterArg) {
|
||||
explicit ASConsole(ASFormatter& formatterArg) : formatter(formatterArg)
|
||||
{
|
||||
// command line options
|
||||
isRecursive = false;
|
||||
isDryRun = false;
|
||||
@ -295,8 +287,6 @@ class ASConsole
|
||||
hasWildcard = false;
|
||||
filesAreIdentical = true;
|
||||
lineEndsMixed = false;
|
||||
outputEOL[0] = '\0';
|
||||
prevEOL[0] = '\0';
|
||||
origSuffix = ".orig";
|
||||
mainDirectoryLength = 0;
|
||||
filesFormatted = 0;
|
||||
@ -375,7 +365,7 @@ class ASConsole
|
||||
FileEncoding readFile(const string& fileName_, stringstream& in) const;
|
||||
void removeFile(const char* fileName_, 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;
|
||||
int waitForRemove(const char* oldFileName) const;
|
||||
int wildcmp(const char* wild, const char* data) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user