SF.net SVN: geany:[5734] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sat Apr 23 12:18:33 UTC 2011


Revision: 5734
          http://geany.svn.sourceforge.net/geany/?rev=5734&view=rev
Author:   ntrel
Date:     2011-04-23 12:18:32 +0000 (Sat, 23 Apr 2011)

Log Message:
-----------
Replace dates on template insertion, not when loading templates.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/templates.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-04-23 11:44:31 UTC (rev 5733)
+++ trunk/ChangeLog	2011-04-23 12:18:32 UTC (rev 5734)
@@ -4,6 +4,8 @@
    plugins/geanyfunctions.h:
    Add utils_find_open_xml_tag_pos() API function (patch by Eugene
    Arshinov, thanks).
+ * src/templates.c:
+   Replace dates on template insertion, not when loading templates.
 
 
 2011-04-19  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c	2011-04-23 11:44:31 UTC (rev 5733)
+++ trunk/src/templates.c	2011-04-23 12:18:32 UTC (rev 5734)
@@ -104,27 +104,6 @@
 }
 
 
-/* TODO the callers should use GStrings instead of char arrays */
-static gchar *replace_all(gchar *text, const gchar *year, const gchar *date, const gchar *datetime)
-{
-	GString *str;
-
-	if (text == NULL)
-		return NULL;
-
-	str = g_string_new(text);
-
-	g_free(text);
-	templates_replace_valist(str,
-		"{year}", year,
-		"{date}", date,
-		"{datetime}", datetime,
-		NULL);
-
-	return g_string_free(str, FALSE);
-}
-
-
 /* called when inserting templates into an existing document */
 static void convert_eol_characters(GString *template, GeanyDocument *doc)
 {
@@ -140,20 +119,14 @@
 }
 
 
-static void init_general_templates(const gchar *year, const gchar *date, const gchar *datetime)
+static void init_general_templates(void)
 {
-	guint id;
-
 	/* read the contents */
 	read_template("fileheader", GEANY_TEMPLATE_FILEHEADER);
 	read_template("gpl", GEANY_TEMPLATE_GPL);
 	read_template("bsd", GEANY_TEMPLATE_BSD);
 	read_template("function", GEANY_TEMPLATE_FUNCTION);
 	read_template("changelog", GEANY_TEMPLATE_CHANGELOG);
-
-	/* FIXME: we should replace the dates on insertion, not on loading */
-	for (id = 0; id < GEANY_MAX_TEMPLATES; id++)
-		templates[id] = replace_all(templates[id], year, date, datetime);
 }
 
 
@@ -344,17 +317,10 @@
 /* warning: also called when reloading template settings */
 void templates_init(void)
 {
-	gchar *year = utils_get_date_time(template_prefs.year_format, NULL);
-	gchar *date = utils_get_date_time(template_prefs.date_format, NULL);
-	gchar *datetime = utils_get_date_time(template_prefs.datetime_format, NULL);
 	static gboolean init_done = FALSE;
 
-	init_general_templates(year, date, datetime);
+	init_general_templates();
 
-	g_free(date);
-	g_free(datetime);
-	g_free(year);
-
 	create_file_template_menu();
 	/* we hold our own ref for the menu as it has no parent whilst being moved */
 	g_object_ref(new_with_template_menu);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list