mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
add clang-format and apply to sdcv.cpp
This commit is contained in:
56
.clang-format
Normal file
56
.clang-format
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
AlignEscapedNewlinesLeft: false
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
BreakBeforeBinaryOperators: true
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: true
|
||||||
|
BinPackParameters: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
IndentFunctionDeclarationAfterType: false
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Right
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
Standard: Cpp11
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
DisableFormat: false
|
||||||
|
...
|
||||||
|
|
||||||
20
src/sdcv.cpp
20
src/sdcv.cpp
@@ -23,13 +23,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
|
|
||||||
static const char gVersion[] = VERSION;
|
static const char gVersion[] = VERSION;
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
static void free_str_array(gchar **arr)
|
static void free_str_array(gchar **arr)
|
||||||
{
|
{
|
||||||
gchar **p;
|
gchar **p;
|
||||||
@@ -51,7 +52,8 @@ namespace {
|
|||||||
g_free(arr);
|
g_free(arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace glib {
|
namespace glib
|
||||||
|
{
|
||||||
typedef ResourceWrapper<gchar *, gchar *, free_str_array> StrArr;
|
typedef ResourceWrapper<gchar *, gchar *, free_str_array> StrArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +115,6 @@ int main(int argc, char *argv[]) try {
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const gchar *stardict_data_dir = g_getenv("STARDICT_DATA_DIR");
|
const gchar *stardict_data_dir = g_getenv("STARDICT_DATA_DIR");
|
||||||
std::string data_dir;
|
std::string data_dir;
|
||||||
if (!opt_data_dir) {
|
if (!opt_data_dir) {
|
||||||
@@ -172,7 +173,6 @@ int main(int argc, char *argv[]) try {
|
|||||||
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST)
|
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST)
|
||||||
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
||||||
|
|
||||||
|
|
||||||
Library lib(utf8_input, utf8_output, colorize);
|
Library lib(utf8_input, utf8_output, colorize);
|
||||||
std::list<std::string> empty_list;
|
std::list<std::string> empty_list;
|
||||||
lib.load(dicts_dir_list, empty_list, disable_list);
|
lib.load(dicts_dir_list, empty_list, disable_list);
|
||||||
@@ -192,9 +192,9 @@ int main(int argc, char *argv[]) try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
} else
|
} else {
|
||||||
fprintf(stderr, _("There are no words/phrases to translate.\n"));
|
fprintf(stderr, _("There are no words/phrases to translate.\n"));
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
fprintf(stderr, "Internal error: %s\n", ex.what());
|
fprintf(stderr, "Internal error: %s\n", ex.what());
|
||||||
|
|||||||
Reference in New Issue
Block a user