* mu: small cleanups to pass 'make cc10', 'make line35'

This commit is contained in:
djcb
2012-10-23 20:57:46 +03:00
parent 924e3c62df
commit 94fcf1c5ad
3 changed files with 26 additions and 33 deletions

View File

@ -156,30 +156,23 @@ get_descriptions (MuScriptInfo *msi, const char *prefix)
return FALSE; return FALSE;
} }
descr = oneline = NULL; for (descr = oneline = NULL, line = NULL;
line = NULL; getline (&line, &n, script) != -1; free (line), line = NULL) {
while (getline (&line, &n, script) != -1) {
if (!g_str_has_prefix(line, prefix)) { if (!g_str_has_prefix(line, prefix))
free (line);
line = NULL;
continue; continue;
}
if (!oneline) if (!oneline)
oneline = g_strdup (line + strlen (prefix)); oneline = g_strdup (line + strlen (prefix));
else { else {
char *tmp; char *tmp;
tmp = descr; tmp = descr;
descr = g_strdup_printf ( descr = g_strdup_printf ("%s%s", descr ? descr : "",
"%s%s", descr ? descr : "", line + strlen(prefix));
line + strlen(prefix));
g_free (tmp); g_free (tmp);
} }
free (line);
line = NULL;
} }
fclose (script); fclose (script);
msi->_oneline = oneline; msi->_oneline = oneline;
@ -286,7 +279,6 @@ mu_script_guile_run (MuScriptInfo *msi, const char *muhome,
mu_script_info_name (msi), mu_script_info_name (msi),
muhome, muhome,
mainargs ? mainargs : ""); mainargs ? mainargs : "");
g_print ("[%s]\n", mainargs);
g_free (mainargs); g_free (mainargs);
argv[4] = expr; argv[4] = expr;

View File

@ -38,12 +38,26 @@
#define MU_GUILE_EXT ".scm" #define MU_GUILE_EXT ".scm"
#define MU_GUILE_DESCR_PREFIX ";; INFO: " #define MU_GUILE_DESCR_PREFIX ";; INFO: "
static void
print_script (const char *name, const char *oneline, const char *descr,
gboolean verbose)
{
g_print ("%s%s%s%s",
verbose ? "\n" : " * ",
name,
oneline ? ": " : "",
oneline ? oneline :"");
if (verbose && descr)
g_print ("%s", descr);
}
static gboolean static gboolean
print_scripts (GSList *scripts, gboolean verbose, const char *rxstr, print_scripts (GSList *scripts, gboolean verbose, const char *rxstr,
GError **err) GError **err)
{ {
GSList *cur; GSList *cur;
gboolean first;
if (!scripts) { if (!scripts) {
g_print ("No scripts available\n"); g_print ("No scripts available\n");
@ -55,7 +69,7 @@ print_scripts (GSList *scripts, gboolean verbose, const char *rxstr,
else else
g_print ("Available scripts:\n"); g_print ("Available scripts:\n");
for (cur = scripts, first = TRUE; cur; cur = g_slist_next (cur)) { for (cur = scripts; cur; cur = g_slist_next (cur)) {
MuScriptInfo *msi; MuScriptInfo *msi;
const char* descr, *oneline, *name; const char* descr, *oneline, *name;
@ -72,19 +86,7 @@ print_scripts (GSList *scripts, gboolean verbose, const char *rxstr,
continue; continue;
} }
/* whitespace between */ print_script (name, oneline, descr, verbose);
if (verbose && !first)
g_print ("\n");
first = FALSE;
g_print ("%s%s%s%s",
verbose ? "" : " * ",
name,
oneline ? ": " : "",
oneline ? oneline :"");
if (verbose && descr)
g_print ("%s", descr);
} }
return TRUE; return TRUE;

View File

@ -640,13 +640,14 @@ parse_params (int *argcp, char ***argvp)
err = NULL; err = NULL;
rv = TRUE; rv = TRUE;
g_option_context_set_main_group(context,
config_options_group_mu());
switch (MU_CONFIG.cmd) { switch (MU_CONFIG.cmd) {
case MU_CONFIG_CMD_NONE: show_usage(); break; case MU_CONFIG_CMD_NONE: show_usage(); break;
case MU_CONFIG_CMD_HELP: case MU_CONFIG_CMD_HELP:
/* 'help' is special; sucks in the options of the /* 'help' is special; sucks in the options of the
* command after it */ * command after it */
g_option_context_set_main_group(context,
config_options_group_mu());
rv = g_option_context_parse (context, argcp, argvp, &err) && rv = g_option_context_parse (context, argcp, argvp, &err) &&
cmd_help (); cmd_help ();
break; break;
@ -656,8 +657,6 @@ parse_params (int *argcp, char ***argvp)
g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_set_ignore_unknown_options (context, TRUE);
/* fall through */ /* fall through */
default: default:
g_option_context_set_main_group(context,
config_options_group_mu());
group = get_option_group (MU_CONFIG.cmd); group = get_option_group (MU_CONFIG.cmd);
if (group) if (group)
g_option_context_add_group(context, group); g_option_context_add_group(context, group);