Commit 81f78133 authored by Morten Welinder's avatar Morten Welinder

Restore my copy.

parent ca8fd19d
......@@ -5,6 +5,7 @@
* Authors:
* Miguel de Icaza (miguel@gnu.org)
* Jukka-Pekka Iivonen (iivonen@iki.fi)
* Morten Welinder <terra@diku.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -37,6 +38,12 @@
#include <stdlib.h>
#include <libgnome/gnome-i18n.h>
#include "plugin.h"
#include "plugin-util.h"
#include "module-plugin-defs.h"
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
#define DAY_SECONDS (3600*24)
/***************************************************************************/
......@@ -1243,108 +1250,59 @@ gnumeric_weeknum (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
void date_functions_init(void);
const ModulePluginFunctionInfo datetime_functions[] = {
{ "date", "fff", "year,month,day", &help_date, gnumeric_date, NULL, NULL, NULL },
{ "unix2date", "f", "unixtime", &help_unix2date, gnumeric_unix2date, NULL, NULL, NULL },
{ "date2unix", "f", "serial", &help_date2unix, gnumeric_date2unix, NULL, NULL, NULL },
{ "datevalue", "S", "date_str", &help_datevalue, gnumeric_datevalue, NULL, NULL, NULL },
{ "datedif", "SSs", "date1,date2,Interval", &help_datedif, gnumeric_datedif, NULL, NULL, NULL },
{ "day", "S", "date", &help_day, gnumeric_day, NULL, NULL, NULL },
{ "days360", "SS|f", "date1,date2,method", &help_days360, gnumeric_days360, NULL, NULL, NULL },
{ "edate", "ff", "serial_number,months", &help_edate, gnumeric_edate, NULL, NULL, NULL },
{ "eomonth", "S|f", "start_date,months", &help_eomonth, gnumeric_eomonth, NULL, NULL, NULL },
{ "hour", "S", "time", &help_hour, gnumeric_hour, NULL, NULL, NULL },
{ "minute", "S", "time", &help_minute, gnumeric_minute, NULL, NULL, NULL },
{ "month", "S", "date", &help_month, gnumeric_month, NULL, NULL, NULL },
{ "networkdays", "SS|?", "start_date,end_date,holidays", &help_networkdays, gnumeric_networkdays, NULL, NULL, NULL },
{ "now", "", "", &help_now, gnumeric_now, NULL, NULL, NULL },
{ "second", "S", "time", &help_second, gnumeric_second, NULL, NULL, NULL },
{ "time", "fff", "hours,minutes,seconds", &help_time, gnumeric_time, NULL, NULL, NULL },
{ "timevalue", "S", "", &help_timevalue, gnumeric_timevalue, NULL, NULL, NULL },
{ "today", "", "", &help_today, gnumeric_today, NULL, NULL, NULL },
{ "weekday", "S|f", "date", &help_weekday, gnumeric_weekday, NULL, NULL, NULL },
{ "workday", "Sf|?", "date,days,holidays", &help_workday, gnumeric_workday, NULL, NULL, NULL },
{ "year", "S", "date", &help_year, gnumeric_year, NULL, NULL, NULL },
{ "isoweeknum", "S", "date", &help_isoweeknum, gnumeric_isoweeknum, NULL, NULL, NULL },
{ "weeknum", "S|f", "date", &help_weeknum, gnumeric_weeknum, NULL, NULL, NULL },
{NULL}
};
/* FIXME: Should be merged into the above. */
static const struct {
const char *func;
AutoFormatTypes typ;
} af_info[] = {
{ "date", AF_DATE },
{ "unix2date", AF_DATE },
{ "edate", AF_DATE },
{ "eomonth", AF_DATE },
{ "time", AF_TIME },
{ "today", AF_DATE },
{ NULL, AF_UNKNOWN }
};
void
plugin_init (void)
{
int i;
for (i = 0; af_info[i].func; i++)
auto_format_function_result_by_name (af_info[i].func, af_info[i].typ);
}
void
date_functions_init(void)
plugin_cleanup (void)
{
FunctionDefinition *def;
FunctionCategory *cat = function_get_category_with_translation ("Date / Time", _("Date / Time"));
def = function_add_args (cat, "date", "fff",
"year,month,day",
&help_date, gnumeric_date);
auto_format_function_result (def, AF_DATE);
def = function_add_args (cat, "unix2date", "f",
"unixtime",
&help_unix2date, gnumeric_unix2date);
auto_format_function_result (def, AF_DATE);
def = function_add_args (cat, "date2unix", "f",
"serial",
&help_date2unix, gnumeric_date2unix);
def = function_add_args (cat, "datevalue", "S",
"date_str",
&help_datevalue, gnumeric_datevalue);
def = function_add_args (cat, "datedif", "SSs",
"date1,date2,Interval",
&help_datedif, gnumeric_datedif);
def = function_add_args (cat, "day", "S",
"date",
&help_day, gnumeric_day);
def = function_add_args (cat, "days360", "SS|f",
"date1,date2,method",
&help_days360, gnumeric_days360);
def = function_add_args (cat, "edate", "ff",
"serial_number,months",
&help_edate, gnumeric_edate);
auto_format_function_result (def, AF_DATE);
def = function_add_args (cat, "eomonth", "S|f",
"start_date,months",
&help_eomonth, gnumeric_eomonth);
auto_format_function_result (def, AF_DATE);
def = function_add_args (cat, "hour", "S",
"time",
&help_hour, gnumeric_hour );
def = function_add_args (cat, "minute", "S",
"time",
&help_minute, gnumeric_minute );
def = function_add_args (cat, "month", "S",
"date",
&help_month, gnumeric_month);
def = function_add_args (cat, "networkdays", "SS|?",
"start_date,end_date,holidays",
&help_networkdays, gnumeric_networkdays );
def = function_add_args (cat, "now", "",
"",
&help_now, gnumeric_now );
def = function_add_args (cat, "second", "S",
"time",
&help_second, gnumeric_second );
def = function_add_args (cat, "time", "fff",
"hours,minutes,seconds",
&help_time, gnumeric_time );
auto_format_function_result (def, AF_TIME);
def = function_add_args (cat, "timevalue", "S",
"",
&help_timevalue, gnumeric_timevalue );
def = function_add_args (cat, "today", "",
"",
&help_today, gnumeric_today );
auto_format_function_result (def, AF_DATE);
def = function_add_args (cat, "weekday", "S|f",
"date",
&help_weekday, gnumeric_weekday);
def = function_add_args (cat, "workday", "Sf|?",
"date,days,holidays",
&help_workday, gnumeric_workday);
def = function_add_args (cat, "year", "S",
"date",
&help_year, gnumeric_year);
def = function_add_args (cat, "isoweeknum", "S",
"date",
&help_isoweeknum, gnumeric_isoweeknum);
def = function_add_args (cat, "weeknum", "S|f",
"date",
&help_weeknum, gnumeric_weeknum);
int i;
for (i = 0; af_info[i].func; i++)
auto_format_function_result_remove (af_info[i].func);
}
......@@ -41,6 +41,12 @@
#include <string.h>
#include <libgnome/gnome-i18n.h>
#include "plugin.h"
#include "plugin-util.h"
#include "module-plugin-defs.h"
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
/***************************************************************************/
static const char *help_char = {
......@@ -653,8 +659,9 @@ gnumeric_replace (FunctionEvalInfo *ei, Value **argv)
}
/***************************************************************************/
/* Note: help_t is a reserved symbol. */
static const char *help_t = {
static const char *help_t_ = {
N_("@FUNCTION=T\n"
"@SYNTAX=T(value)\n"
"@DESCRIPTION="
......@@ -669,8 +676,10 @@ static const char *help_t = {
"@SEEALSO=CELL, N, VALUE")
};
/* Note: gnumeric_t is a reserved symbol. */
static Value *
gnumeric_t (FunctionEvalInfo *ei, Value **argv)
gnumeric_t_ (FunctionEvalInfo *ei, Value **argv)
{
if (argv[0]->type == VALUE_STRING)
return value_duplicate (argv[0]);
......@@ -1227,57 +1236,29 @@ match_again:
/***************************************************************************/
void string_functions_init (void);
void
string_functions_init (void)
{
FunctionCategory *cat = function_get_category_with_translation ("String", _("String"));
function_add_args (cat, "char", "f", "number",
&help_char, gnumeric_char);
function_add_args (cat, "clean", "S", "text",
&help_clean, gnumeric_clean);
function_add_args (cat, "code", "S", "text",
&help_code, gnumeric_code);
function_add_nodes (cat, "concatenate",0, "text1,text2",
&help_concatenate,gnumeric_concatenate);
function_add_args (cat, "dollar", "f|f", "num,decimals",
&help_dollar, gnumeric_dollar);
function_add_args (cat, "exact", "SS", "text1,text2",
&help_exact, gnumeric_exact);
function_add_args (cat, "find", "SS|f", "text1,text2,num",
&help_find, gnumeric_find);
function_add_args (cat, "fixed", "f|fb", "num,decs,no_commas",
&help_fixed, gnumeric_fixed);
function_add_args (cat, "left", "S|f", "text,num_chars",
&help_left, gnumeric_left);
function_add_args (cat, "len", "S", "text",
&help_len, gnumeric_len);
function_add_args (cat, "lower", "S", "text",
&help_lower, gnumeric_lower);
function_add_args (cat, "proper", "S", "text",
&help_proper, gnumeric_proper);
function_add_args (cat, "mid", "Sff", "text,pos,num",
&help_mid, gnumeric_mid);
function_add_args (cat, "replace", "SffS", "old,start,num,new",
&help_replace, gnumeric_replace);
function_add_args (cat, "rept", "Sf", "text,num",
&help_rept, gnumeric_rept);
function_add_args (cat, "right", "S|f", "text,num_chars",
&help_right, gnumeric_right);
function_add_args (cat, "search", "SS|f", "find,within[,start_num]",
&help_search, gnumeric_search);
function_add_args (cat, "substitute", "SSS|f","text,old,new,num",
&help_substitute, gnumeric_substitute);
function_add_args (cat, "t", "?", "value",
&help_t, gnumeric_t);
function_add_args (cat, "text", "Ss", "value,format_text",
&help_text, gnumeric_text);
function_add_args (cat, "trim", "S", "text",
&help_trim, gnumeric_trim);
function_add_args (cat, "upper", "S", "text",
&help_upper, gnumeric_upper);
function_add_args (cat, "value", "?", "text",
&help_value, gnumeric_value);
}
const ModulePluginFunctionInfo string_functions[] = {
{ "char", "f", "number", &help_char, gnumeric_char, NULL, NULL, NULL },
{ "clean", "S", "text", &help_clean, gnumeric_clean, NULL, NULL, NULL },
{ "code", "S", "text", &help_code, gnumeric_code, NULL, NULL, NULL },
{ "concatenate", 0, "text1,text2", &help_concatenate, NULL, gnumeric_concatenate, NULL, NULL },
{ "dollar", "f|f", "num,decimals", &help_dollar, gnumeric_dollar, NULL, NULL, NULL },
{ "exact", "SS", "text1,text2", &help_exact, gnumeric_exact, NULL, NULL, NULL },
{ "find", "SS|f", "text1,text2,num", &help_find, gnumeric_find, NULL, NULL, NULL },
{ "fixed", "f|fb", "num,decs,no_commas", &help_fixed, gnumeric_fixed, NULL, NULL, NULL },
{ "left", "S|f", "text,num_chars", &help_left, gnumeric_left, NULL, NULL, NULL },
{ "len", "S", "text", &help_len, gnumeric_len, NULL, NULL, NULL },
{ "lower", "S", "text", &help_lower, gnumeric_lower, NULL, NULL, NULL },
{ "proper", "S", "text", &help_proper, gnumeric_proper, NULL, NULL, NULL },
{ "mid", "Sff", "text,pos,num", &help_mid, gnumeric_mid, NULL, NULL, NULL },
{ "replace", "SffS", "old,start,num,new", &help_replace, gnumeric_replace, NULL, NULL, NULL },
{ "rept", "Sf", "text,num", &help_rept, gnumeric_rept, NULL, NULL, NULL },
{ "right", "S|f", "text,num_chars", &help_right, gnumeric_right, NULL, NULL, NULL },
{ "search", "SS|f", "find,within[,start_num]", &help_search, gnumeric_search, NULL, NULL, NULL },
{ "substitute", "SSS|f", "text,old,new,num", &help_substitute, gnumeric_substitute, NULL, NULL, NULL },
{ "t", "?", "value", &help_t_, gnumeric_t_, NULL, NULL, NULL },
{ "text", "Ss", "value,format_text", &help_text, gnumeric_text, NULL, NULL, NULL },
{ "trim", "S", "text", &help_trim, gnumeric_trim, NULL, NULL, NULL },
{ "upper", "S", "text", &help_upper, gnumeric_upper, NULL, NULL, NULL },
{ "value", "?", "text", &help_value, gnumeric_value, NULL, NULL, NULL },
{NULL}
};
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