From 1c92e23be51ffb2d66e3a1a37d2930c3fb17844f Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 30 Oct 2023 13:04:05 -0700 Subject: [PATCH 1/2] Reformat Bifcl in Spicy style --- .clang-format | 170 +++++++++++++++++++++++++--------------- .pre-commit-config.yaml | 24 +++++- CMakeLists.txt | 91 ++++++++++----------- bif_arg.cc | 140 +++++++++++++++------------------ include/bif_arg.h | 42 +++++----- module_util.cc | 78 +++++++++--------- 6 files changed, 292 insertions(+), 253 deletions(-) diff --git a/.clang-format b/.clang-format index 4c628b3..b652ea6 100644 --- a/.clang-format +++ b/.clang-format @@ -1,74 +1,66 @@ -# Clang-format configuration for Zeek. This configuration requires -# at least clang-format 12.0.1 to format correctly. - -Language: Cpp -Standard: c++17 - -BreakBeforeBraces: Whitesmiths - -# BraceWrapping: -# AfterCaseLabel: true -# AfterClass: false -# AfterControlStatement: Always -# AfterEnum: false -# AfterFunction: true -# AfterNamespace: false -# AfterStruct: false -# AfterUnion: false -# AfterExternBlock: false -# BeforeCatch: true -# BeforeElse: true -# BeforeWhile: false -# IndentBraces: true -# SplitEmptyFunction: false -# SplitEmptyRecord: false -# SplitEmptyNamespace: false +# Copyright (c) 2020-2023 by the Zeek Project. See LICENSE for details. +--- +Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignTrailingComments: false -AllowShortBlocksOnASingleLine: Empty -AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Inline +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: true AllowShortIfStatementsOnASingleLine: false -AllowShortLambdasOnASingleLine: Empty AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes BinPackArguments: true BinPackParameters: true -BreakConstructorInitializers: BeforeColon +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false BreakInheritanceList: BeforeColon -ColumnLimit: 100 -ConstructorInitializerAllOnOneLineOrOnePerLine: false -FixNamespaceComments: false -IndentCaseLabels: true -IndentCaseBlocks: false -IndentExternBlock: NoIndent -IndentPPDirectives: None -IndentWidth: 4 -NamespaceIndentation: None -PointerAlignment: Left -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: true -SpaceInEmptyParentheses: false -SpacesInAngles: false -SpacesInConditionalStatement: true -SpacesInContainerLiterals: false -SpacesInParentheses: false -TabWidth: 4 -UseTab: AlignWithSpaces - -# Setting this to a high number causes clang-format to prefer breaking somewhere else -# over breaking after the assignment operator in a line that's over the column limit -PenaltyBreakAssignment: 100 - +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: 'NOLINT' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH IncludeBlocks: Regroup # Include categories go like this: @@ -98,3 +90,57 @@ IncludeCategories: Priority: 4 - Regex: '.*' Priority: 5 + +IncludeIsMainRegex: '$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '^BEGIN_' +MacroBlockEnd: '^END_' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 500 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 1000 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: false +SpaceAfterLogicalNot: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpacesInConditionalStatement: true +Standard: Cpp11 +StatementMacros: + - STANDARD_OPERATOR_1 +TabWidth: 4 +UseTab: Never +--- +Language: Json +... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50844cf..c0eeaf5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,17 +3,33 @@ # repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v13.0.0' + rev: 'v17.0.3' hooks: - id: clang-format + types_or: + - "c" + - "c++" + - "json" - repo: https://github.com/maxwinterstein/shfmt-py - rev: 3.3.1.8 + rev: v3.7.0.1 hooks: - id: shfmt args: ["-w", "-i", "4", "-ci"] -- repo: https://github.com/pre-commit/mirrors-yapf - rev: v0.31.0 +- repo: https://github.com/google/yapf + rev: v0.40.2 hooks: - id: yapf + +- repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format + exclude: '^auxil/.*$' + +- repo: https://github.com/crate-ci/typos + rev: v1.16.21 + hooks: + - id: typos + exclude: '^(.typos.toml|src/SmithWaterman.cc|testing/.*|auxil/.*|scripts/base/frameworks/files/magic/.*|CHANGES)$' diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d7c3b..49327b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,73 +6,74 @@ include(cmake/CommonCMakeConfig.cmake) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) -if (MSVC) +if(MSVC) add_compile_options(/J) # Similar to -funsigned-char on other platforms - set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "/wd4018") + set_property( + SOURCE bif_lex.cc + APPEND_STRING + PROPERTY COMPILE_FLAGS "/wd4018") else() - set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare") + set_property( + SOURCE bif_lex.cc + APPEND_STRING + PROPERTY COMPILE_FLAGS "-Wno-sign-compare") endif() -include_directories(BEFORE - ${BifCl_SOURCE_DIR}/include - ${BifCl_BINARY_DIR} -) +include_directories(BEFORE ${BifCl_SOURCE_DIR}/include ${BifCl_BINARY_DIR}) set(BISON_FLAGS "--debug") # BIF parser/scanner -bison_target(BIFParser builtin-func.y - ${BifCl_BINARY_DIR}/bif_parse.cc - DEFINES_FILE ${BifCl_BINARY_DIR}/bif_parse.h - COMPILE_FLAGS "${BISON_FLAGS}") +bison_target( + BIFParser builtin-func.y ${BifCl_BINARY_DIR}/bif_parse.cc + DEFINES_FILE ${BifCl_BINARY_DIR}/bif_parse.h + COMPILE_FLAGS "${BISON_FLAGS}") flex_target(BIFScanner builtin-func.l ${BifCl_BINARY_DIR}/bif_lex.cc) add_flex_bison_dependency(BIFScanner BIFParser) set(bifcl_SRCS - ${BISON_BIFParser_INPUT} - ${FLEX_BIFScanner_INPUT} - ${BISON_BIFParser_OUTPUTS} - ${FLEX_BIFScanner_OUTPUTS} - bif_arg.cc - include/bif_arg.h - module_util.cc - include/module_util.h -) + ${BISON_BIFParser_INPUT} + ${FLEX_BIFScanner_INPUT} + ${BISON_BIFParser_OUTPUTS} + ${FLEX_BIFScanner_OUTPUTS} + bif_arg.cc + include/bif_arg.h + module_util.cc + include/module_util.h) add_executable(bifcl ${bifcl_SRCS}) target_compile_features(bifcl PRIVATE cxx_std_17) set_target_properties(bifcl PROPERTIES CXX_EXTENSIONS OFF) -if (MSVC) - # If building separately from zeek, we need to add the libunistd subdirectory so - # that linking doesn't fail. - if ("${CMAKE_PROJECT_NAME}" STREQUAL "BifCl") - add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL) - endif() - target_link_libraries(bifcl PRIVATE libunistd) +if(MSVC) + # If building separately from zeek, we need to add the libunistd subdirectory + # so that linking doesn't fail. + if("${CMAKE_PROJECT_NAME}" STREQUAL "BifCl") + add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL) + endif() + target_link_libraries(bifcl PRIVATE libunistd) endif() install(TARGETS bifcl DESTINATION bin) -if (CMAKE_BUILD_TYPE) - string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType) -endif () +if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType) +endif() message( - "\n====================| Bifcl Build Summary |=====================" - "\n" - "\nBuild type: ${CMAKE_BUILD_TYPE}" - "\nBuild dir: ${PROJECT_BINARY_DIR}" - "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" - "\nDebug mode: ${ENABLE_DEBUG}" - "\n" - "\nCC: ${CMAKE_C_COMPILER}" - "\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}" - "\nCXX: ${CMAKE_CXX_COMPILER}" - "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" - "\nCPP: ${CMAKE_CXX_COMPILER}" - "\n" - "\n================================================================\n" -) + "\n====================| Bifcl Build Summary |=====================" + "\n" + "\nBuild type: ${CMAKE_BUILD_TYPE}" + "\nBuild dir: ${PROJECT_BINARY_DIR}" + "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" + "\nDebug mode: ${ENABLE_DEBUG}" + "\n" + "\nCC: ${CMAKE_C_COMPILER}" + "\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}" + "\nCXX: ${CMAKE_CXX_COMPILER}" + "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}" + "\nCPP: ${CMAKE_CXX_COMPILER}" + "\n" + "\n================================================================\n") include(UserChangedWarning) diff --git a/bif_arg.cc b/bif_arg.cc index 735b5ff..a0196d7 100644 --- a/bif_arg.cc +++ b/bif_arg.cc @@ -7,93 +7,79 @@ using namespace std; #include "bif_arg.h" -static struct - { - const char* type_enum; - const char* bif_type; - const char* zeek_type; - const char* c_type; - const char* c_type_smart; - const char* accessor; - const char* accessor_smart; - const char* cast_smart; - const char* constructor; - const char* ctor_smart; - } builtin_func_arg_type[] = { -#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, \ - cast_smart, constructor, ctor_smart) \ - {#id, bif_type, zeek_type, c_type, c_type_smart, \ - accessor, accessor_smart, cast_smart, constructor, ctor_smart}, +static struct { + const char* type_enum; + const char* bif_type; + const char* zeek_type; + const char* c_type; + const char* c_type_smart; + const char* accessor; + const char* accessor_smart; + const char* cast_smart; + const char* constructor; + const char* ctor_smart; +} builtin_func_arg_type[] = { +#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, \ + constructor, ctor_smart) \ + {#id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart}, #include "bif_type.def" #undef DEFINE_BIF_TYPE - }; +}; extern const char* arg_list_name; -BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, int arg_type) - { - name = arg_name; - type = arg_type; - type_str = ""; - attr_str = ""; - } +BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, int arg_type) { + name = arg_name; + type = arg_type; + type_str = ""; + attr_str = ""; +} -BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str, - const char* arg_attr_str) - { - name = arg_name; - type = TYPE_OTHER; - type_str = arg_type_str; - attr_str = arg_attr_str; +BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str) { + name = arg_name; + type = TYPE_OTHER; + type_str = arg_type_str; + attr_str = arg_attr_str; - for ( int i = 0; builtin_func_arg_type[i].bif_type[0] != '\0'; ++i ) - if ( ! strcmp(builtin_func_arg_type[i].bif_type, arg_type_str) ) - { - type = i; - type_str = ""; - } - } + for ( int i = 0; builtin_func_arg_type[i].bif_type[0] != '\0'; ++i ) + if ( ! strcmp(builtin_func_arg_type[i].bif_type, arg_type_str) ) { + type = i; + type_str = ""; + } +} -void BuiltinFuncArg::PrintZeek(FILE* fp) - { - fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, type_str, attr_str); - } +void BuiltinFuncArg::PrintZeek(FILE* fp) { + fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, type_str, attr_str); +} -void BuiltinFuncArg::PrintCDef(FILE* fp, int n, bool runtime_type_check) - { - // Generate a runtime type-check pre-amble for types we understand - if ( runtime_type_check && type != TYPE_OTHER && type != TYPE_ANY ) - { - fprintf(fp, "\t\t{\n"); - fprintf(fp, "\t\t// Runtime type check for %s argument\n", name); - fprintf(fp, "\t\tzeek::TypeTag __tag = (*%s)[%d]->GetType()->Tag();\n", arg_list_name, n); - fprintf(fp, "\t\tif ( __tag != %s )\n", builtin_func_arg_type[type].type_enum); - fprintf(fp, "\t\t\t{\n"); - fprintf(fp, - "\t\t\tzeek::emit_builtin_error(zeek::util::fmt(\"expected type %s for %s, got " - "%%s\", zeek::type_name(__tag)));\n", - builtin_func_arg_type[type].zeek_type, name); - fprintf(fp, "\t\t\treturn nullptr;\n"); - fprintf(fp, "\t\t\t}\n"); - fprintf(fp, "\t\t}\n"); - } - fprintf(fp, "\t%s %s = (%s) (", builtin_func_arg_type[type].c_type, name, - builtin_func_arg_type[type].c_type); +void BuiltinFuncArg::PrintCDef(FILE* fp, int n, bool runtime_type_check) { + // Generate a runtime type-check pre-amble for types we understand + if ( runtime_type_check && type != TYPE_OTHER && type != TYPE_ANY ) { + fprintf(fp, "\t\t{\n"); + fprintf(fp, "\t\t// Runtime type check for %s argument\n", name); + fprintf(fp, "\t\tzeek::TypeTag __tag = (*%s)[%d]->GetType()->Tag();\n", arg_list_name, n); + fprintf(fp, "\t\tif ( __tag != %s )\n", builtin_func_arg_type[type].type_enum); + fprintf(fp, "\t\t\t{\n"); + fprintf(fp, + "\t\t\tzeek::emit_builtin_error(zeek::util::fmt(\"expected type %s for %s, got " + "%%s\", zeek::type_name(__tag)));\n", + builtin_func_arg_type[type].zeek_type, name); + fprintf(fp, "\t\t\treturn nullptr;\n"); + fprintf(fp, "\t\t\t}\n"); + fprintf(fp, "\t\t}\n"); + } + fprintf(fp, "\t%s %s = (%s) (", builtin_func_arg_type[type].c_type, name, builtin_func_arg_type[type].c_type); - char buf[1024]; - snprintf(buf, sizeof(buf), "(*%s)[%d].get()", arg_list_name, n); - // Print the accessor expression. - fprintf(fp, builtin_func_arg_type[type].accessor, buf); + char buf[1024]; + snprintf(buf, sizeof(buf), "(*%s)[%d].get()", arg_list_name, n); + // Print the accessor expression. + fprintf(fp, builtin_func_arg_type[type].accessor, buf); - fprintf(fp, ");\n"); - } + fprintf(fp, ");\n"); +} -void BuiltinFuncArg::PrintCArg(FILE* fp, int n) - { - fprintf(fp, "%s %s", builtin_func_arg_type[type].c_type_smart, name); - } +void BuiltinFuncArg::PrintCArg(FILE* fp, int n) { + fprintf(fp, "%s %s", builtin_func_arg_type[type].c_type_smart, name); +} -void BuiltinFuncArg::PrintValConstructor(FILE* fp) - { - fprintf(fp, builtin_func_arg_type[type].ctor_smart, name); - } +void BuiltinFuncArg::PrintValConstructor(FILE* fp) { fprintf(fp, builtin_func_arg_type[type].ctor_smart, name); } diff --git a/include/bif_arg.h b/include/bif_arg.h index 67df7be..f983e89 100644 --- a/include/bif_arg.h +++ b/include/bif_arg.h @@ -2,36 +2,34 @@ #include -enum builtin_func_arg_type - { -#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, \ - cast_smart, constructor, ctor_smart) \ - id, +enum builtin_func_arg_type { +#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, \ + constructor, ctor_smart) \ + id, #include "bif_type.def" #undef DEFINE_BIF_TYPE - }; +}; extern const char* builtin_func_arg_type_bro_name[]; -class BuiltinFuncArg final - { +class BuiltinFuncArg final { public: - BuiltinFuncArg(const char* arg_name, int arg_type); - BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str = ""); + BuiltinFuncArg(const char* arg_name, int arg_type); + BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str = ""); - void SetAttrStr(const char* arg_attr_str) { attr_str = arg_attr_str; }; + void SetAttrStr(const char* arg_attr_str) { attr_str = arg_attr_str; }; - const char* Name() const { return name; } - int Type() const { return type; } + const char* Name() const { return name; } + int Type() const { return type; } - void PrintZeek(FILE* fp); - void PrintCDef(FILE* fp, int n, bool runtime_type_check = false); - void PrintCArg(FILE* fp, int n); - void PrintValConstructor(FILE* fp); + void PrintZeek(FILE* fp); + void PrintCDef(FILE* fp, int n, bool runtime_type_check = false); + void PrintCArg(FILE* fp, int n); + void PrintValConstructor(FILE* fp); private: - const char* name; - int type; - const char* type_str; - const char* attr_str; - }; + const char* name; + int type; + const char* type_str; + const char* attr_str; +}; diff --git a/module_util.cc b/module_util.cc index f2fd445..27e1141 100644 --- a/module_util.cc +++ b/module_util.cc @@ -6,61 +6,53 @@ #include #include -static int streq(const char* s1, const char* s2) - { - return ! strcmp(s1, s2); - } +static int streq(const char* s1, const char* s2) { return ! strcmp(s1, s2); } // Returns it without trailing "::". -string extract_module_name(const char* name) - { - string module_name = name; - string::size_type pos = module_name.rfind("::"); +string extract_module_name(const char* name) { + string module_name = name; + string::size_type pos = module_name.rfind("::"); - if ( pos == string::npos ) - return string(GLOBAL_MODULE_NAME); + if ( pos == string::npos ) + return string(GLOBAL_MODULE_NAME); - module_name.erase(pos); + module_name.erase(pos); - return module_name; - } + return module_name; +} -string extract_var_name(const char* name) - { - string var_name = name; - string::size_type pos = var_name.rfind("::"); +string extract_var_name(const char* name) { + string var_name = name; + string::size_type pos = var_name.rfind("::"); - if ( pos == string::npos ) - return var_name; + if ( pos == string::npos ) + return var_name; - if ( pos + 2 > var_name.size() ) - return string(""); + if ( pos + 2 > var_name.size() ) + return string(""); - return var_name.substr(pos + 2); - } + return var_name.substr(pos + 2); +} -string normalized_module_name(const char* module_name) - { - int mod_len; - if ( (mod_len = strlen(module_name)) >= 2 && streq(module_name + mod_len - 2, "::") ) - mod_len -= 2; +string normalized_module_name(const char* module_name) { + int mod_len; + if ( (mod_len = strlen(module_name)) >= 2 && streq(module_name + mod_len - 2, "::") ) + mod_len -= 2; - return string(module_name, mod_len); - } + return string(module_name, mod_len); +} -string make_full_var_name(const char* module_name, const char* var_name) - { - if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || strstr(var_name, "::") ) - { - if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) ) - return extract_var_name(var_name); +string make_full_var_name(const char* module_name, const char* var_name) { + if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || strstr(var_name, "::") ) { + if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) ) + return extract_var_name(var_name); - return string(var_name); - } + return string(var_name); + } - string full_name = normalized_module_name(module_name); - full_name += "::"; - full_name += var_name; + string full_name = normalized_module_name(module_name); + full_name += "::"; + full_name += var_name; - return full_name; - } + return full_name; +} From db8de104674561d3f77a1ed701bb9978ca1ab5b0 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 30 Oct 2023 13:05:55 -0700 Subject: [PATCH 2/2] Update .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..78f61e3 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# clang-format: Reformat Bifcl in Spicy style +1c92e23be51ffb2d66e3a1a37d2930c3fb17844f \ No newline at end of file