clang-format: update c/cc coding style

Update all cc code using .clang-format; please do so as well for future PRs
etc.; emacs has a handy 'clang-format' mode to make this automatic.

For comparing old changes with git blame, we can disregard this one using
--ignore-rev

(see https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame )
This commit is contained in:
Dirk-Jan C. Binnema
2021-10-20 12:18:15 +03:00
parent 09935cc4b3
commit 3dd721d5a3
111 changed files with 13851 additions and 14579 deletions

View File

@ -36,58 +36,58 @@
using namespace Mu;
SCM
mu_guile_scm_from_str (const char *str)
mu_guile_scm_from_str(const char* str)
{
if (!str)
return SCM_BOOL_F;
else
return scm_from_stringn (str, strlen(str), "UTF-8",
SCM_FAILED_CONVERSION_QUESTION_MARK);
return scm_from_stringn(str,
strlen(str),
"UTF-8",
SCM_FAILED_CONVERSION_QUESTION_MARK);
}
SCM
mu_guile_error (const char *func_name, int status,
const char *fmt, SCM args)
mu_guile_error(const char* func_name, int status, const char* fmt, SCM args)
{
scm_error_scm (scm_from_locale_symbol ("MuError"),
scm_from_utf8_string (func_name ? func_name : "<nameless>"),
scm_from_utf8_string (fmt), args,
scm_list_1 (scm_from_int (status)));
scm_error_scm(scm_from_locale_symbol("MuError"),
scm_from_utf8_string(func_name ? func_name : "<nameless>"),
scm_from_utf8_string(fmt),
args,
scm_list_1(scm_from_int(status)));
return SCM_UNSPECIFIED;
}
SCM
mu_guile_g_error (const char *func_name, GError *err)
mu_guile_g_error(const char* func_name, GError* err)
{
scm_error_scm (scm_from_locale_symbol ("MuError"),
scm_from_utf8_string (func_name),
scm_from_utf8_string (err ? err->message : "error"),
SCM_UNDEFINED, SCM_UNDEFINED);
scm_error_scm(scm_from_locale_symbol("MuError"),
scm_from_utf8_string(func_name),
scm_from_utf8_string(err ? err->message : "error"),
SCM_UNDEFINED,
SCM_UNDEFINED);
return SCM_UNSPECIFIED;
}
/* there can be only one */
static std::unique_ptr<Mu::Store> StoreSingleton;
static gboolean
mu_guile_init_instance (const char *muhome) try
{
setlocale (LC_ALL, "");
if (!mu_runtime_init (muhome, "guile", true) || StoreSingleton)
mu_guile_init_instance(const char* muhome)
try {
setlocale(LC_ALL, "");
if (!mu_runtime_init(muhome, "guile", true) || StoreSingleton)
return FALSE;
StoreSingleton = std::make_unique<Mu::Store>(
mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB));
StoreSingleton = std::make_unique<Mu::Store>(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB));
g_debug ("mu-guile: opened store @ %s (n=%zu); maildir: %s",
StoreSingleton->metadata().database_path.c_str(),
StoreSingleton->size(),
StoreSingleton->metadata().root_maildir.c_str());
g_debug("mu-guile: opened store @ %s (n=%zu); maildir: %s",
StoreSingleton->metadata().database_path.c_str(),
StoreSingleton->size(),
StoreSingleton->metadata().root_maildir.c_str());
return TRUE;
@ -96,16 +96,15 @@ mu_guile_init_instance (const char *muhome) try
}
static void
mu_guile_uninit_instance ()
mu_guile_uninit_instance()
{
StoreSingleton.reset();
mu_runtime_uninit ();
mu_runtime_uninit();
}
Mu::Store&
mu_guile_store ()
mu_guile_store()
{
if (!StoreSingleton)
g_error("mu guile not initialized");
@ -114,124 +113,130 @@ mu_guile_store ()
}
gboolean
mu_guile_initialized ()
mu_guile_initialized()
{
g_debug ("initialized ? %u", !!StoreSingleton);
g_debug("initialized ? %u", !!StoreSingleton);
return !!StoreSingleton;
}
SCM_DEFINE_PUBLIC (mu_initialize, "mu:initialize", 0, 1, 0,
(SCM MUHOME),
"Initialize mu - needed before you call any of the other "
"functions. Optionally, you can provide MUHOME which should be an "
"absolute path to your mu home directory "
"-- typically, the default, ~/.cache/mu, should be just fine.")
SCM_DEFINE_PUBLIC(mu_initialize,
"mu:initialize",
0,
1,
0,
(SCM MUHOME),
"Initialize mu - needed before you call any of the other "
"functions. Optionally, you can provide MUHOME which should be an "
"absolute path to your mu home directory "
"-- typically, the default, ~/.cache/mu, should be just fine.")
#define FUNC_NAME s_mu_initialize
{
char *muhome;
char* muhome;
gboolean rv;
SCM_ASSERT (scm_is_string (MUHOME) || MUHOME == SCM_BOOL_F ||
SCM_UNBNDP(MUHOME), MUHOME, SCM_ARG1, FUNC_NAME);
SCM_ASSERT(scm_is_string(MUHOME) || MUHOME == SCM_BOOL_F || SCM_UNBNDP(MUHOME),
MUHOME,
SCM_ARG1,
FUNC_NAME);
if (mu_guile_initialized())
return mu_guile_error (FUNC_NAME, 0, "Already initialized",
SCM_UNSPECIFIED);
return mu_guile_error(FUNC_NAME, 0, "Already initialized", SCM_UNSPECIFIED);
if (SCM_UNBNDP(MUHOME) || MUHOME == SCM_BOOL_F)
muhome = NULL;
else
muhome = scm_to_utf8_string (MUHOME);
muhome = scm_to_utf8_string(MUHOME);
rv = mu_guile_init_instance (muhome);
free (muhome);
rv = mu_guile_init_instance(muhome);
free(muhome);
if (!rv)
return mu_guile_error (FUNC_NAME, 0, "Failed to initialize mu",
SCM_UNSPECIFIED);
return mu_guile_error(FUNC_NAME, 0, "Failed to initialize mu", SCM_UNSPECIFIED);
g_debug ("mu-guile: initialized @ %s (%p)",
muhome ? muhome : "<default>", StoreSingleton.get());
g_debug("mu-guile: initialized @ %s (%p)",
muhome ? muhome : "<default>",
StoreSingleton.get());
/* cleanup when we're exiting */
atexit (mu_guile_uninit_instance);
atexit(mu_guile_uninit_instance);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (mu_initialized_p, "mu:initialized?", 0, 0, 0,
(void), "Whether mu is initialized or not.\n")
SCM_DEFINE_PUBLIC(mu_initialized_p,
"mu:initialized?",
0,
0,
0,
(void),
"Whether mu is initialized or not.\n")
#define FUNC_NAME s_mu_initialized_p
{
return mu_guile_initialized() ? SCM_BOOL_T : SCM_BOOL_F;
}
#undef FUNC_NAME
SCM_DEFINE (log_func, "mu:c:log", 1, 0, 1, (SCM LEVEL, SCM FRM, SCM ARGS),
"log some message at LEVEL using a list of ARGS applied to FRM"
"(in 'simple-format' notation).\n")
SCM_DEFINE(log_func,
"mu:c:log",
1,
0,
1,
(SCM LEVEL, SCM FRM, SCM ARGS),
"log some message at LEVEL using a list of ARGS applied to FRM"
"(in 'simple-format' notation).\n")
#define FUNC_NAME s_log_func
{
gchar *output;
SCM str;
int level;
gchar* output;
SCM str;
int level;
SCM_ASSERT (scm_integer_p(LEVEL), LEVEL, SCM_ARG1, FUNC_NAME);
SCM_ASSERT (scm_is_string(FRM), FRM, SCM_ARG2, "<write_log>");
SCM_ASSERT(scm_integer_p(LEVEL), LEVEL, SCM_ARG1, FUNC_NAME);
SCM_ASSERT(scm_is_string(FRM), FRM, SCM_ARG2, "<write_log>");
SCM_VALIDATE_REST_ARGUMENT(ARGS);
level = scm_to_int (LEVEL);
if (level != G_LOG_LEVEL_MESSAGE &&
level != G_LOG_LEVEL_WARNING &&
level = scm_to_int(LEVEL);
if (level != G_LOG_LEVEL_MESSAGE && level != G_LOG_LEVEL_WARNING &&
level != G_LOG_LEVEL_CRITICAL)
return mu_guile_error (FUNC_NAME, 0, "invalid log level",
SCM_UNSPECIFIED);
return mu_guile_error(FUNC_NAME, 0, "invalid log level", SCM_UNSPECIFIED);
str = scm_simple_format (SCM_BOOL_F, FRM, ARGS);
str = scm_simple_format(SCM_BOOL_F, FRM, ARGS);
if (!scm_is_string (str))
if (!scm_is_string(str))
return SCM_UNSPECIFIED;
output = scm_to_utf8_string (str);
g_log (G_LOG_DOMAIN, (GLogLevelFlags)level, "%s", output);
free (output);
output = scm_to_utf8_string(str);
g_log(G_LOG_DOMAIN, (GLogLevelFlags)level, "%s", output);
free(output);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
static struct {
static struct {
const char* name;
unsigned val;
unsigned val;
} VAR_PAIRS[] = {
{ "mu:message", G_LOG_LEVEL_MESSAGE },
{ "mu:warning", G_LOG_LEVEL_WARNING },
{ "mu:critical", G_LOG_LEVEL_CRITICAL }
};
{"mu:message", G_LOG_LEVEL_MESSAGE},
{"mu:warning", G_LOG_LEVEL_WARNING},
{"mu:critical", G_LOG_LEVEL_CRITICAL}};
static void
define_vars (void)
define_vars(void)
{
unsigned u;
for (u = 0; u != G_N_ELEMENTS(VAR_PAIRS); ++u) {
scm_c_define (VAR_PAIRS[u].name,
scm_from_uint (VAR_PAIRS[u].val));
scm_c_export (VAR_PAIRS[u].name, NULL);
scm_c_define(VAR_PAIRS[u].name, scm_from_uint(VAR_PAIRS[u].val));
scm_c_export(VAR_PAIRS[u].name, NULL);
}
}
void*
mu_guile_init (void *data)
mu_guile_init(void* data)
{
define_vars ();
define_vars();
#ifndef SCM_MAGIC_SNARFER
#include "mu-guile.x"