Commit eff417e3 authored by Morten Welinder's avatar Morten Welinder

Docs: add option to sanity check help texts.

parent 42897730
2009-08-14 Morten Welinder <terra@gnome.org>
* src/main-application.c (main): Add new --func-sanity-check
option.
* src/func.c (gnm_func_sanity_check, gnm_func_sanity_check1): New
functions.
2009-08-13 Morten Welinder <terra@gnome.org>
* src/func.c (func_def_cmp, function_category_compare): Take
......
......@@ -41,6 +41,7 @@ Morten:
* Avoid using gtk_tree_view_column_get_cell_renderers. [#589105]
* Fix DEC2HEX and friends for large values. [#588997]
* Make undo/redo visible for vertical toolbar.
* Add some checking of help texts' sanity.
--------------------------------------------------------------------------
Gnumeric 1.9.9
......
......@@ -27,6 +27,8 @@
#include "value.h"
#include "number-match.h"
#include "func-builtin.h"
#include "command-context-stderr.h"
#include "gnm-plugin.h"
#include <goffice/goffice.h>
#include <glib.h>
......@@ -520,6 +522,74 @@ function_dump_defs (char const *filename, int dump_type)
/* ------------------------------------------------------------------------- */
static int
gnm_func_sanity_check1 (GnmFunc const *fd)
{
GnmFuncHelp const *h;
int counts[(int)GNM_FUNC_HELP_ODF + 1];
int res = 0;
memset (counts, 0, sizeof (counts));
for (h = fd->help; h->type != GNM_FUNC_HELP_END; h++) {
g_assert (h->type <= GNM_FUNC_HELP_ODF);
counts[h->type]++;
switch (h->type) {
case GNM_FUNC_HELP_NAME: {
size_t nlen = strlen (fd->name);
if (g_ascii_strncasecmp (fd->name, h->text, nlen) ||
h->text[nlen] != ':') {
g_printerr ("%s: Invalid NAME record\n",
fd->name);
res = 1;
}
break;
}
case GNM_FUNC_HELP_ARG:
break;
default:
; /* Nothing */
}
}
return res;
}
int
gnm_func_sanity_check (void)
{
int res;
GOCmdContext *cc = cmd_context_stderr_new ();
GPtrArray *ordered;
unsigned ui;
gnm_plugins_init (cc);
res = cmd_context_stderr_get_status (COMMAND_CONTEXT_STDERR (cc));
if (res)
goto out;
ordered = g_ptr_array_new ();
g_hash_table_foreach (global_symbol_table->hash,
copy_hash_table_to_ptr_array, ordered);
if (ordered->len > 0)
qsort (&g_ptr_array_index (ordered, 0),
ordered->len, sizeof (gpointer),
func_def_cmp);
for (ui = 0; ui < ordered->len; ui++) {
GnmFunc const *fd = g_ptr_array_index (ordered, ui);
if (gnm_func_sanity_check1 (fd))
res = 1;
}
g_ptr_array_free (ordered, TRUE);
out:
return res;
}
/* ------------------------------------------------------------------------- */
static void
gnm_func_group_free (GnmFuncGroup *fn_group)
{
......
......@@ -12,6 +12,7 @@ void functions_init (void);
void functions_shutdown (void);
void function_dump_defs (char const *filename, int dump_type);
int gnm_func_sanity_check (void);
/******************************************************************************/
/* Function group support */
......
......@@ -35,6 +35,7 @@
#include "gutils.h"
#include "gnm-plugin.h"
#include "application.h"
#include "func.h"
#include <gtk/gtk.h>
#include <glib/gstdio.h>
......@@ -61,6 +62,7 @@ static gboolean split_funcdocs = FALSE;
static gboolean immediate_exit_flag = FALSE;
static gboolean gnumeric_no_splash = FALSE;
static gboolean gnumeric_no_warnings = FALSE;
static gboolean func_sanity_check = FALSE;
static gchar *func_def_file = NULL;
static gchar *func_state_file = NULL;
static gchar *ext_refs_file = NULL;
......@@ -107,6 +109,10 @@ static const GOptionEntry gnumeric_options [] = {
N_("Generate new help and po files"),
NULL
},
{ "func-sanity-check", 0, 0, G_OPTION_ARG_NONE, &func_sanity_check,
N_("Sanity check functions' help texts"),
NULL
},
{
"quit", 0,
G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &immediate_exit_flag,
......@@ -368,6 +374,8 @@ main (int argc, char const **argv)
return gnm_dump_func_defs (NULL, 2);
if (ext_refs_file)
return gnm_dump_func_defs (ext_refs_file, 4);
if (func_sanity_check)
return gnm_func_sanity_check ();
/* Keep in sync with .desktop file */
g_set_application_name (_("Gnumeric Spreadsheet"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment