* Copyright (C) 1999,2000 the Free Software Foundation.
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2001-2011 George (Jiri) Lebl
- * Copyright © 2019-2021 Nick Bowler
+ * Copyright © 2019-2022 Nick Bowler
*
* Author: George (Jiri) Lebl
*
#include "out.h"
#include "util.h"
#include "checks.h"
+#include "help.h"
#include "main.h"
gboolean no_self_alias = FALSE;
gboolean always_private_struct = FALSE;
gboolean gtk3_ok = FALSE;
-
-gint prealloc = 0;
-
-
-
+gint npreallocs = 0;
gboolean use_m4 = FALSE; /* preprocess sources with m4 */
char *m4_commandline = NULL;
#define M4_INCLUDE_DIR PKGDATADIR "/m4"
filebase = replace_sep (((Class *)class)->otype, file_sep);
gob_strdown (filebase);
- if (output_dir != NULL &&
- output_dir[0] != '\0') {
- fullfilebase = g_build_filename (output_dir, filebase, NULL);
+ if (output_dir != NULL && output_dir[0] != '\0') {
+ fullfilebase = g_strdup_printf("%s%c%s", output_dir,
+ G_DIR_SEPARATOR, filebase);
} else {
fullfilebase = g_strdup (filebase);
}
"\t\t(GInstanceInitFunc) %s_init,\n"
"\t\tNULL\n"
"\t};\n\n",
- typebase, funcbase, typebase, prealloc, funcbase);
+ typebase, funcbase, typebase, npreallocs, funcbase);
}
static void
"perhaps it was misspelled",
flag);
}
- g_string_sprintfa(gs, " | G_SIGNAL_%s", flag);
+ g_string_append_printf(gs, " | G_SIGNAL_%s", flag);
}
{
if(strcmp(argflags[i], flag)==0)
break;
}
- g_string_sprintfa(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
+ g_string_append_printf(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
}
g_string_append (flags, ")");
if(strcmp(argflags[i], flag)==0)
break;
}
- g_string_sprintfa(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
+ g_string_append_printf(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
}
g_string_append (flags, ")");
get_arg_names_for_macro (Method *m)
{
const char *sep;
+ char *ret;
GList *li;
GString *gs = g_string_new(NULL);
sep = "";
for(li=m->args;li;li=g_list_next(li)) {
FuncArg *arg = li->data;
- g_string_sprintfa (gs, "%s___%s", sep, arg->name);
+ g_string_append_printf(gs, "%s___%s", sep, arg->name);
sep = ",";
}
- return g_string_free (gs, FALSE);
+
+ ret = gs->str;
+ g_string_free(gs, FALSE);
+ return ret;
}
static gboolean method_is_void(Method *m)
static void print_version(void)
{
printf("%s (%s) %s\n", PACKAGE_NAME, PACKAGE_TARNAME, PACKAGE_VERSION);
- putchar('\n');
puts("Copyright (C) 2013 George (Jiri) Lebl et al.");
- puts("Copyright (C) 2020 Nick Bowler");
- puts("License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>.");
+ puts("Copyright (C) 2022 Nick Bowler");
+ puts("License GPLv2+: GNU GPL version 2 or any later version");
puts("This is free software: you are free to change and redistribute it.");
puts("There is NO WARRANTY, to the extent permitted by law.");
-
}
static void print_usage(FILE *f)
}
}
-/*
- * Given a long option, return the corresponding short option character,
- * or 0 if there is no such character.
- */
-static char lopt_to_sopt(const char *sopts, const struct option *opt)
-{
- int val = opt->val;
- const char *c;
-
- if (val <= 0 || val > CHAR_MAX)
- return 0;
-
- if (val == ':' || val == '+' || val == '-')
- return 0;
-
- c = strchr(sopts, opt->val);
- if (c)
- return *c;
- return 0;
-}
-
-/*
- * Print a string, with each line indented by i spaces. The first line
- * will be indented by w fewer spaces (to account for the cursor being in
- * some other column).
- */
-static void print_block(const char *s, int i, int w)
-{
- for (; *s; w = 0) {
- const char *nl = strchr(s, '\n');
- int n = (nl ? nl-s : -1);
-
- printf("%*s%.*s\n", i-w, "", n, s);
- if (!nl)
- break;
-
- s = nl+1;
- }
-}
-
static void print_help(void)
{
const struct option *opt;
puts("\nOptions:");
for (opt = lopts; opt->name; opt++) {
struct lopt_help help;
- char sopt;
- int w;
/* Don't display obsolete options that don't do anything */
if (!opt->flag && !opt->val)
if (!lopt_get_help(opt, &help))
continue;
- if ((sopt = lopt_to_sopt(sopts, opt))) {
- w = printf(opt->has_arg == 0 ? " -%c, --%s"
- : opt->has_arg == 1 ? " -%c, --%s=%s"
- : " -%c, --%s[=%s]",
- sopt, opt->name, help.arg);
- } else {
- w = printf(opt->has_arg == 0 ? " --%s"
- : opt->has_arg == 1 ? " --%s=%s"
- : " --%s[=%s]",
- opt->name, help.arg);
- }
-
- if (w < 0 || w > 18) {
- putchar('\n');
- w = 0;
- }
-
- print_block(help.desc, 20, w);
+ help_print_option(opt, help.arg, help.desc, 20);
}
putchar('\n');