girepository: Cleanup compiler.c formatting

This commit is contained in:
Evan Welsh 2024-01-26 02:24:39 -08:00 committed by Philip Withnall
parent 5d997cad03
commit 3bd7635516

View File

@ -26,14 +26,14 @@
#include <locale.h> #include <locale.h>
#include <string.h> #include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <girepository.h> #include <girepository.h>
#include <glib.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <io.h>
#endif #endif
#include "girmodule-private.h" #include "girmodule-private.h"
@ -77,9 +77,13 @@ write_out_typelib (gchar *prefix,
else else
{ {
if (prefix) if (prefix)
{
filename = g_strdup_printf ("%s-%s", prefix, output); filename = g_strdup_printf ("%s-%s", prefix, output);
}
else else
{
filename = g_strdup (output); filename = g_strdup (output);
}
file_obj = g_file_new_for_path (filename); file_obj = g_file_new_for_path (filename);
tmp_filename = g_strdup_printf ("%s.tmp", filename); tmp_filename = g_strdup_printf ("%s.tmp", filename);
tmp_file_obj = g_file_new_for_path (tmp_filename); tmp_file_obj = g_file_new_for_path (tmp_filename);
@ -94,9 +98,10 @@ write_out_typelib (gchar *prefix,
} }
written = fwrite (typelib->data, 1, typelib->len, file); written = fwrite (typelib->data, 1, typelib->len, file);
if (written < typelib->len) { if (written < typelib->len)
{
g_fprintf (stderr, "ERROR: Could not write the whole output: %s", g_fprintf (stderr, "ERROR: Could not write the whole output: %s",
strerror(errno)); strerror (errno));
goto out; goto out;
} }
@ -123,18 +128,17 @@ out:
GLogLevelFlags logged_levels; GLogLevelFlags logged_levels;
static void log_handler (const gchar *log_domain, static void
log_handler (const gchar *log_domain,
GLogLevelFlags log_level, GLogLevelFlags log_level,
const gchar *message, const gchar *message,
gpointer user_data) gpointer user_data)
{ {
if (log_level & logged_levels) if (log_level & logged_levels)
g_log_default_handler (log_domain, log_level, message, user_data); g_log_default_handler (log_domain, log_level, message, user_data);
} }
static GOptionEntry options[] = static GOptionEntry options[] = {
{
{ "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL }, { "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL },
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" }, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
{ "module", 'm', 0, G_OPTION_ARG_STRING, &mname, "module to compile", "NAME" }, { "module", 'm', 0, G_OPTION_ARG_STRING, &mname, "module to compile", "NAME" },
@ -147,7 +151,7 @@ static GOptionEntry options[] =
}; };
int int
main (int argc, char ** argv) main (int argc, char **argv)
{ {
GOptionContext *context; GOptionContext *context;
GError *error = NULL; GError *error = NULL;
@ -170,7 +174,7 @@ main (int argc, char ** argv)
return 1; return 1;
} }
logged_levels = G_LOG_LEVEL_MASK & ~(G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_DEBUG); logged_levels = G_LOG_LEVEL_MASK & ~(G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_DEBUG);
if (debug) if (debug)
logged_levels = logged_levels | G_LOG_LEVEL_DEBUG; logged_levels = logged_levels | G_LOG_LEVEL_DEBUG;
if (verbose) if (verbose)
@ -198,7 +202,7 @@ main (int argc, char ** argv)
parser = gi_ir_parser_new (); parser = gi_ir_parser_new ();
gi_ir_parser_set_includes (parser, (const char*const*) includedirs); gi_ir_parser_set_includes (parser, (const char *const *) includedirs);
module = gi_ir_parser_parse_file (parser, input[0], &error); module = gi_ir_parser_parse_file (parser, input[0], &error);
if (module == NULL) if (module == NULL)