[gnumeric] docs: make sure argument names, as documented, are unique.



commit 2fb662ffd4540b6368daad3227f36927fc06bc93
Author: Morten Welinder <terra gnome org>
Date:   Fri Jul 23 21:32:00 2010 -0400

    docs: make sure argument names, as documented, are unique.

 ChangeLog  |   13 +++++++++----
 NEWS       |    1 +
 src/func.c |   19 ++++++++++++++++++-
 3 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f4f28c4..3ac1590 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-23  Morten Welinder  <terra gnome org>
+
+	* src/func.c (gnm_func_sanity_check1): Make sure argument names,
+	as documented, are unique.
+
 2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* schemas/gnumeric-general.schemas.in: add tooltip preferences
@@ -16,10 +21,10 @@
 	* src/func.h (gnm_func_get_description): new
 	* src/symbol.c (symbol_names_cb): new
 	(symbol_names): rewrite to work in gtk 2.12 and to provide more info
-	
+
 2010-07-20  Andreas J. Guelzow <aguelzow pyrshep ca>
 
-	* src/wbc-gtk-actions.c (cb_help_function): use 
+	* src/wbc-gtk-actions.c (cb_help_function): use
 	  dialog_function_select_help instead of dialog_function_select
 
 2010-07-20  Andreas J. Guelzow <aguelzow pyrshep ca>
@@ -30,7 +35,7 @@
 2010-07-19  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* configure.in: checks for g_date_set_time_t and g_slice_alloc have
-	  been superceded by the glib 2.12 requirement; check for 
+	  been superceded by the glib 2.12 requirement; check for
 	  g_hash_table_get_keys
 	* src/dependent.c: remove HAVE_G_SLICE_ALLOC throughout
 	* src/func.c (gnm_func_lookup_prefix): new
@@ -52,7 +57,7 @@
 	(cmd_selection_format_toggle_font_style_cb): new
 	(cmd_selection_format_toggle_font_style_filter): new
 	* src/sheet.c (sheet_apply_style_cb): call sheet_flag_style_update_range
-	* src/wbc-gtk-actions.c (toggle_font_attr): use 
+	* src/wbc-gtk-actions.c (toggle_font_attr): use
 	  cmd_selection_format_toggle_font_style
 
 2010-07-18  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/NEWS b/NEWS
index caafec7..6afb762 100644
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,7 @@ Morten:
 	* Fix gtk_show_uri problem affecting win32.  [#623605]
 	* Fix mistakes pointed out by sparse.
 	* Fix win32 versioning problem.  [#624171]
+	* Improve function doc checks.
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.7
diff --git a/src/func.c b/src/func.c
index 2469351..112164d 100644
--- a/src/func.c
+++ b/src/func.c
@@ -571,6 +571,10 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
 	int counts[(int)GNM_FUNC_HELP_ODF + 1];
 	int res = 0;
 	size_t nlen = strlen (fd->name);
+	GHashTable *allargs;
+
+	allargs = g_hash_table_new_full
+		(g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL);
 
 	memset (counts, 0, sizeof (counts));
 	for (h = fd->help; h->type != GNM_FUNC_HELP_END; h++) {
@@ -603,7 +607,9 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
 			break;
 		case GNM_FUNC_HELP_ARG: {
 			const char *aend = strchr (h->text, ':');
-			if (aend == NULL) {
+			char *argname;
+
+			if (aend == NULL || aend == h->text) {
 				g_printerr ("%s: Invalid ARG record\n",
 					    fd->name);
 				res = 1;
@@ -630,6 +636,15 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
 					    fd->name);
 				res = 1;
 			}
+			argname = g_strndup (h->text, aend - h->text);
+			if (g_hash_table_lookup (allargs, argname)) {
+				g_printerr ("%s: Duplicate argument name %s\n",
+					    fd->name, argname);
+				res = 1;
+				g_free (argname);
+				g_printerr ("%s\n", h->text);
+			} else
+				g_hash_table_insert (allargs, argname, argname);
 			break;
 		}
 		case GNM_FUNC_HELP_DESCRIPTION:
@@ -654,6 +669,8 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
 		}
 	}
 
+	g_hash_table_destroy (allargs);
+
 	if (fd->fn_type == GNM_FUNC_TYPE_ARGS) {
 		int n = counts[GNM_FUNC_HELP_ARG];
 		if (n != fd->fn.args.max_args) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]