Skip to content

Commit

Permalink
[runtime] Miscellaneous printf cleanup (dotnet#2177)
Browse files Browse the repository at this point in the history
Done to unblock the externs. More work should probably be done, see mono/mono#18580.

Co-authored-by: Ryan Lucia <[email protected]>
  • Loading branch information
monojenkins and CoffeeFlux committed Jan 27, 2020
1 parent be728a0 commit b9f0973
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ typedef enum {

G_ENUM_FUNCTIONS (GLogLevelFlags)

void g_printv (const gchar *format, va_list args);
gint g_printv (const gchar *format, va_list args);
void g_print (const gchar *format, ...);
void g_printerr (const gchar *format, ...);
GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
Expand Down
23 changes: 20 additions & 3 deletions src/mono/mono/eglib/goutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,23 @@ g_assert_abort (void)
abort ();
}

void
gint
g_printv (const gchar *format, va_list args)
{
char *msg;
int ret;

if (g_vasprintf (&msg, format, args) < 0)
return;
ret = g_vasprintf (&msg, format, args);
if (ret < 0)
return -1;

if (!stdout_handler)
stdout_handler = default_stdout_handler;

stdout_handler (msg);
g_free (msg);

return ret;
}

void
Expand All @@ -81,6 +85,19 @@ g_print (const gchar *format, ...)
va_end (args);
}

gint
g_printf (gchar const *format, ...)
{
va_list args;
gint ret;

va_start (args, format);
ret = g_printv (format, args);
va_end (args);

return ret;
}

void
g_printerr (const gchar *format, ...)
{
Expand Down
13 changes: 0 additions & 13 deletions src/mono/mono/eglib/gstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,19 +610,6 @@ g_strchomp (gchar *str)
return str;
}

gint
g_printf(gchar const *format, ...)
{
va_list args;
gint ret;

va_start(args, format);
ret = vprintf(format, args);
va_end(args);

return ret;
}

gint
g_fprintf(FILE *file, gchar const *format, ...)
{
Expand Down

0 comments on commit b9f0973

Please sign in to comment.