Commit 17bed2f2 authored by Morten Welinder's avatar Morten Welinder

Func: simplify placeholder creation, part 2.

parent 91a677f5
......@@ -3,6 +3,7 @@
* src/func.c (gnm_func_lookup_or_add_placeholder): Drop copy_name
argument and assume TRUE. Drop scope name and assume NULL (which
is what all callers should have used). All callers changed.
(gnm_func_add_placeholder): Ditto.
* src/gnm-plugin.c (plugin_service_function_group_activate):
Upgrade existing placeholder functions as needed.
......
......@@ -1613,7 +1613,7 @@ applix_func_map_in (GnmConventions const *conv, Workbook *scope,
NULL != (new_name = g_hash_table_lookup (namemap, name)))
name = new_name;
if (NULL == (f = gnm_func_lookup (name, scope)))
f = gnm_func_add_placeholder (scope, name, "", TRUE);
f = gnm_func_add_placeholder (scope, name, "");
return gnm_expr_new_funcall (f, args);
}
......
......@@ -3997,7 +3997,7 @@ excel_read_NAME (BiffQuery *q, GnmXLImporter *importer, ExcelReadSheet *esheet)
else if ((flags & 0xE) == 0xE) /* Function & VB-Proc & Proc */
gnm_func_add_placeholder (importer->wb,
expr_name_name (nexpr), "VBA", TRUE);
expr_name_name (nexpr), "VBA");
}
}
......
......@@ -662,7 +662,7 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
f_name, numargs););
if (name == NULL)
name = gnm_func_add_placeholder (wb, f_name, "UNKNOWN", TRUE);
name = gnm_func_add_placeholder (wb, f_name, "UNKNOWN");
gnm_expr_free (tmp);
parse_list_push (stack, gnm_expr_new_funcall (name, args));
......@@ -695,7 +695,7 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
if (fd->name) {
name = gnm_func_lookup (fd->name, wb);
if (name == NULL)
name = gnm_func_add_placeholder (wb, fd->name, "UNKNOWN", TRUE);
name = gnm_func_add_placeholder (wb, fd->name, "UNKNOWN");
}
/* This should not happen */
if (!name) {
......
......@@ -384,7 +384,7 @@ lotus_placeholder (char const *lname)
char *gname = g_strconcat ("LOTUS_", lname, NULL);
GnmFunc *func = gnm_func_lookup (gname, NULL);
if (!func)
func = gnm_func_add_placeholder (NULL, gname, "Lotus ", TRUE);
func = gnm_func_add_placeholder (NULL, gname, "Lotus");
g_free (gname);
return func;
}
......
......@@ -981,7 +981,7 @@ sc_func_map_in (GnmConventions const *conv, Workbook *scope,
NULL != (new_name = g_hash_table_lookup (namemap, name)))
name = new_name;
if (NULL == (f = gnm_func_lookup (name, scope)))
f = gnm_func_add_placeholder (scope, name, "", TRUE);
f = gnm_func_add_placeholder (scope, name, "");
return gnm_expr_new_funcall (f, args);
}
......
......@@ -1268,11 +1268,12 @@ invent_name (const char *pref, GHashTable *h, const char *template)
static GnmFunc *
gnm_func_add_placeholder_full (Workbook *scope,
char const *gname, char const *lname,
char const *type, gboolean copy_gname)
char const *type)
{
GnmFuncDescriptor desc;
GnmFunc *func;
char const *unknown_cat_name = N_("Unknown Function");
gboolean copy_gname = TRUE;
gboolean copy_lname = TRUE;
g_return_val_if_fail (gname || lname, NULL);
......@@ -1353,16 +1354,15 @@ gnm_func_add_placeholder_full (Workbook *scope,
*/
GnmFunc *
gnm_func_add_placeholder (Workbook *scope,
char const *name, char const *type,
gboolean copy_name)
char const *name, char const *type)
{
return gnm_func_add_placeholder_full (scope, name, NULL, type, copy_name);
return gnm_func_add_placeholder_full (scope, name, NULL, type);
}
GnmFunc *
gnm_func_add_placeholder_localized (char const *gname, char const *lname)
{
return gnm_func_add_placeholder_full (NULL, gname, lname, "?", TRUE);
return gnm_func_add_placeholder_full (NULL, gname, lname, "?");
}
/* Utility routine to be used for import and analysis tools */
......@@ -1371,7 +1371,7 @@ gnm_func_lookup_or_add_placeholder (char const *name)
{
GnmFunc * f = gnm_func_lookup (name, NULL);
if (f == NULL)
f = gnm_func_add_placeholder (NULL, name, "", TRUE);
f = gnm_func_add_placeholder (NULL, name, "");
return f;
}
......
......@@ -240,8 +240,7 @@ GnmFunc *gnm_func_add (GnmFuncGroup *group,
const char *textdomain);
GnmFunc *gnm_func_add_placeholder (Workbook *optional_scope,
char const *name,
char const *type,
gboolean copy_name);
char const *type);
GnmFunc *gnm_func_add_placeholder_localized (char const *gname, char const *lname);
GnmFunc *gnm_func_lookup_or_add_placeholder (char const *name);
void gnm_func_upgrade_placeholder
......
......@@ -217,8 +217,7 @@ plugin_service_function_group_activate (GOPluginService *service, GOErrorInfo **
g_printerr ("Reusing placeholder for %s\n", fname);
#endif
} else {
fd = gnm_func_add_placeholder
(NULL, fname, "?", TRUE);
fd = gnm_func_add_placeholder (NULL, fname, "?");
}
if (fd->flags & GNM_FUNC_IS_PLACEHOLDER) {
gnm_func_set_user_data (fd, service);
......
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