Skip to content

Commit

Permalink
source: reformat C with clang-format-11
Browse files Browse the repository at this point in the history
  • Loading branch information
mpranj committed Jan 31, 2021
1 parent 65c8af7 commit 833beb9
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/bindings/cpp/benchmarks/benchmark_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Person : public ThreadString
: ThreadString (ks, context_, Key ("/%layer1%/person", KEY_META, "default", "no name", KEY_END))
{
}
using ThreadString::operator= ;
using ThreadString::operator=;

private:
Person () = delete;
Expand All @@ -56,7 +56,7 @@ class Nested : public ThreadInteger
: ThreadInteger (ks, context_, Key ("/test/%layer1%/%thread%/%layer2%/nested", KEY_META, "default", s_value, KEY_END))
{
}
using ThreadInteger::operator= ;
using ThreadInteger::operator=;
};

class Environment : public ThreadBoolean
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/tests/testcpp_contextual_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ValueWrapper : public kdb::ContextualValue<T, PolicySetter1, PolicySetter2

kdb::ContextualValue<T, PolicySetter1, PolicySetter2, PolicySetter3, PolicySetter4, PolicySetter5> value;

using kdb::ContextualValue<T, PolicySetter1, PolicySetter2, PolicySetter3, PolicySetter4, PolicySetter5>::operator= ;
using kdb::ContextualValue<T, PolicySetter1, PolicySetter2, PolicySetter3, PolicySetter4, PolicySetter5>::operator=;
};

TEST (test_contextual_policy, ValueWrapper)
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/directoryvalue/directoryvalue_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ kdb::KeySet removeBaseName (kdb::KeySet const & keys)
for (auto key : keys)
{
ELEKTRA_LOG_DEBUG ("Remove basename from “%s”: “%s”", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isBinary () ? "binary value!" : key.getString ().c_str ());
key.getBinarySize () == 0 ? "NULL" :
key.isBinary () ? "binary value!" :
key.getString ().c_str ());
kdb::Key directory = key.dup ();
directory.delBaseName ();
directories.append (directory);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/directoryvalue/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ void logKeySet (kdb::KeySet const & keys)
}

ELEKTRA_LOG_DEBUG ("\t“%s”: “%s”%s", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isBinary () ? "binary value!" : key.getString ().c_str (),
key.getBinarySize () == 0 ? "NULL" :
key.isBinary () ? "binary value!" :
key.getString ().c_str (),
metadata.c_str ());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dump/dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class pipebuf : public std::streambuf
this->setg (this->buffer_, this->buffer_, this->buffer_ + r);
}
return this->gptr () == this->egptr () ? std::char_traits<char>::eof () :
std::char_traits<char>::to_int_type (*this->gptr ());
std::char_traits<char>::to_int_type (*this->gptr ());
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/resolver/filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static int elektraResolveDir (ElektraResolved * handle, ElektraResolveTempfile t
{
// now put together the filename
filename = handle->relPath[0] == '/' ? elektraFormat ("%s%s", dn, handle->relPath) :
elektraFormat ("%s/" KDB_DB_DIR "/%s", dn, handle->relPath);
elektraFormat ("%s/" KDB_DB_DIR "/%s", dn, handle->relPath);

struct stat buf;
if (stat (filename, &buf) == 0)
Expand All @@ -603,7 +603,7 @@ static int elektraResolveDir (ElektraResolved * handle, ElektraResolveTempfile t
// nothing found, so we use most specific
elektraFree (filename);
filename = handle->relPath[0] == '/' ? elektraFormat ("%s%s", cwd, handle->relPath) :
elektraFormat ("%s/" KDB_DB_DIR "/%s", cwd, handle->relPath);
elektraFormat ("%s/" KDB_DB_DIR "/%s", cwd, handle->relPath);
}

elektraFree (cwd);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/type/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static char * calculateStringValue (KeySet * validValues, char delimiter, kdb_un
else if (*val != 0 && (*val & value) == *val)
{
char * tmp = stringValue[0] == '\0' ? elektraFormat ("%s", name) :
elektraFormat ("%s%c%s", stringValue, delimiter, name);
elektraFormat ("%s%c%s", stringValue, delimiter, name);
elektraFree (stringValue);
stringValue = tmp;

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/yamlcpp/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ void logKeySet (kdb::KeySet const & keys)
}

ELEKTRA_LOG_DEBUG ("\t“%s”: “%s”%s", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isBinary () ? "binary value!" : key.getString ().c_str (),
key.getBinarySize () == 0 ? "NULL" :
key.isBinary () ? "binary value!" :
key.getString ().c_str (),
metadata.c_str ());
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/plugins/yamlcpp/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ Key createLeafKey (Node const & node, string const & name)
key.setMeta ("type", "binary");
}
ELEKTRA_LOG_DEBUG ("Add key “%s: %s”", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isBinary () ? "binary value!" : key.get<string> ().c_str ());
key.getBinarySize () == 0 ? "NULL" :
key.isBinary () ? "binary value!" :
key.get<string> ().c_str ());
return key;
}

Expand All @@ -149,9 +151,11 @@ Key createLeafKey (Node const & node, string const & name)
Key convertMetaNodeToKey (Node const & node, Key & parent)
{
auto key = node[0].IsNull () ? Key{ parent.getName (), KEY_BINARY, KEY_END } :
Key{ parent.getName (), KEY_VALUE, node[0].as<string> ().c_str (), KEY_END };
Key{ parent.getName (), KEY_VALUE, node[0].as<string> ().c_str (), KEY_END };
ELEKTRA_LOG_DEBUG ("Add key “%s”: “%s”", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isString () ? key.getString ().c_str () : "binary value!");
key.getBinarySize () == 0 ? "NULL" :
key.isString () ? key.getString ().c_str () :
"binary value!");
return key;
}

Expand Down
9 changes: 6 additions & 3 deletions src/plugins/yamlcpp/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ Node createLeafNode (Key & key)

if (metaNode.size () <= 0)
{
ELEKTRA_LOG_DEBUG ("Return leaf node with value “%s”",
dataNode.IsNull () ? "~" : dataNode.IsSequence () ? "[]" : dataNode.as<string> ().c_str ());
ELEKTRA_LOG_DEBUG ("Return leaf node with value “%s”", dataNode.IsNull () ? "~" :
dataNode.IsSequence () ? "[]" :
dataNode.as<string> ().c_str ());
return dataNode;
}

Expand Down Expand Up @@ -242,7 +243,9 @@ void addKeys (Node & data, KeySet const & mappings, Key const & parent)
for (auto key : mappings)
{
ELEKTRA_LOG_DEBUG ("Convert key “%s”: “%s”", key.getName ().c_str (),
key.getBinarySize () == 0 ? "NULL" : key.isString () ? key.getString ().c_str () : "binary value!");
key.getBinarySize () == 0 ? "NULL" :
key.isString () ? key.getString ().c_str () :
"binary value!");

if (key.hasMeta ("array"))
{
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/yanlr/yaml_lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ void YAMLLexer::addBlockEnd (size_t const lineIndex)
ELEKTRA_LOG_DEBUG ("Add block end");
size_t index = input->index ();
tokens.push_back (levels.top ().type == Level::Type::MAP ?
commonToken (MAP_END, getPosition (), index, "end of map") :
commonToken (SEQUENCE_END, getPosition (), index, "end of sequence"));
commonToken (MAP_END, getPosition (), index, "end of map") :
commonToken (SEQUENCE_END, getPosition (), index, "end of sequence"));
levels.pop ();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/kdb/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CommandAbortException : public CommandException
virtual const char * what () const throw () override
{
return !m_msg.empty () ? m_msg.c_str () :
"A situation had occurred where the command had to abort, but no message is available.";
"A situation had occurred where the command had to abort, but no message is available.";
}

virtual int errorCode () const throw () override
Expand Down
2 changes: 1 addition & 1 deletion src/tools/kdb/gen/highlevel/highlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline std::string getArgDescription (const kdb::Key & key, kdb_long_long
auto indexStr = std::to_string (index);
auto metaName = "gen/arg/description/#" + std::string (indexStr.length () - 1, '_') + indexStr;
return key.hasMeta (metaName) ? key.getMeta<std::string> (metaName) :
"Replaces occurrence no. " + indexStr + " of " + kind + " in the keyname.";
"Replaces occurrence no. " + indexStr + " of " + kind + " in the keyname.";
}

static void getKeyArgs (const kdb::Key & key, const size_t parentKeyParts, kainjow::mustache::list & args, std::string & fmtString)
Expand Down
6 changes: 3 additions & 3 deletions src/tools/kdb/gen/highlevel/structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ bool StructFieldsProcessor::shouldGenerateUnion (const kdb::Key & key)
std::string StructFieldsProcessor::discriminatorField (const kdb::Key & key, const std::string & refFieldName)
{
auto result = key.hasMeta ("gen/reference/discriminator") ? key.getMeta<std::string> ("gen/reference/discriminator") :
refFieldName + "Discriminator";
refFieldName + "Discriminator";
escapeNonAlphaNum (result);
return result;
}

std::string StructFieldsProcessor::arraySizeName (const kdb::Key & key, const std::string & arrayFieldName)
{
auto result = key.hasMeta ("gen/struct/array/sizefield") ? key.getMeta<std::string> ("gen/struct/array/sizefield") :
arrayFieldName + "Size";
arrayFieldName + "Size";
escapeNonAlphaNum (result);
return result;
}
Expand All @@ -44,7 +44,7 @@ std::string StructFieldsProcessor::getName (const kdb::Key & key, const std::str
std::string StructFieldsProcessor::discriminatorKey (const kdb::Key & key)
{
auto result = key.hasMeta ("gen/reference/discriminator/key") ? key.getMeta<std::string> ("gen/reference/discriminator/key") :
"discriminator";
"discriminator";
escapeNonAlphaNum (result);
return result;
}
Expand Down
12 changes: 5 additions & 7 deletions src/tools/kdb/gen/mustache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ class parser
const bool tag_is_unescaped_var{ current_delimiter_is_brace && tag_location_start != (input_size - 2) &&
input.at (tag_contents_location) == ctx.delim_set.begin.at (0) };
const string_type & current_tag_delimiter_end{ tag_is_unescaped_var ? brace_delimiter_end_unescaped :
ctx.delim_set.end };
ctx.delim_set.end };
const auto current_tag_delimiter_end_size = current_tag_delimiter_end.size ();
if (tag_is_unescaped_var)
{
Expand Down Expand Up @@ -970,7 +970,7 @@ class parser
process_current_text ();

// Check for sections without an ending tag
root_component.walk_children ([&error_message](component<string_type> & comp) ->
root_component.walk_children ([&error_message] (component<string_type> & comp) ->
typename component<string_type>::walk_control {
if (!comp.tag.is_section_begin ())
{
Expand Down Expand Up @@ -1178,7 +1178,7 @@ class basic_mustache
void render (const render_handler & handler, context_internal<string_type> & ctx)
{
root_component_.walk_children (
[&handler, &ctx, this](component<string_type> & comp) ->
[&handler, &ctx, this] (component<string_type> & comp) ->
typename component<string_type>::walk_control { return render_component (handler, ctx, comp); });
// process the last line
render_current_line (handler, ctx, nullptr);
Expand Down Expand Up @@ -1390,10 +1390,8 @@ class basic_mustache
void render_section (const render_handler & handler, context_internal<string_type> & ctx, component<string_type> & incomp,
const basic_data<string_type> * var)
{
const auto callback = [&handler, &ctx, this](component<string_type> & comp) -> typename component<string_type>::walk_control
{
return render_component (handler, ctx, comp);
};
const auto callback = [&handler, &ctx, this] (component<string_type> & comp) ->
typename component<string_type>::walk_control { return render_component (handler, ctx, comp); };
if (var && var->is_non_empty_list ())
{
for (const auto & item : var->list_value ())
Expand Down

0 comments on commit 833beb9

Please sign in to comment.