[Gnucash-changes] r14488 - gnucash/trunk - r12825 at cliodev: warlord | 2006-07-12 14:16:29 -0400
Derek Atkins
warlord at cvs.gnucash.org
Wed Jul 12 14:17:04 EDT 2006
Author: warlord
Date: 2006-07-12 14:17:02 -0400 (Wed, 12 Jul 2006)
New Revision: 14488
Trac: http://svn.gnucash.org/trac/changeset/14488
Modified:
gnucash/trunk/
gnucash/trunk/ChangeLog
gnucash/trunk/src/engine/Group.c
Log:
r12825 at cliodev: warlord | 2006-07-12 14:16:29 -0400
Allow account-separator character in account names (#347321).
Revert to previous behavior of xaccGetAccountFromFullName()
which was changed in r13467 when the function was restructured.
This patch returns to the old behavior (but uses the new
function structure).
Property changes on: gnucash/trunk
___________________________________________________________________
Name: svk:merge
- d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:12822
+ d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:12825
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-07-12 16:32:14 UTC (rev 14487)
+++ gnucash/trunk/ChangeLog 2006-07-12 18:17:02 UTC (rev 14488)
@@ -1,3 +1,12 @@
+2006-07-12 Derek Atkins <derek at ihtfp.com>
+
+ * src/engine/Group.c:
+ Allow account-separator character in account names (#347321).
+ Revert to previous behavior of xaccGetAccountFromFullName()
+ which was changed in r13467 when the function was restructured.
+ This patch returns to the old behavior (but uses the new
+ function structure).
+
2006-07-09 Chris Lyttle <chris at wilddev.net>
* NEWS: Added some text about the release.
Modified: gnucash/trunk/src/engine/Group.c
===================================================================
--- gnucash/trunk/src/engine/Group.c 2006-07-12 16:32:14 UTC (rev 14487)
+++ gnucash/trunk/src/engine/Group.c 2006-07-12 18:17:02 UTC (rev 14488)
@@ -556,35 +556,74 @@
xaccGetAccountFromFullNameHelper (const AccountGroup *grp,
gchar **names)
{
- Account *found;
+ Account *found = NULL;
GList *node;
+ gchar *name_str, *temp_str;
+ const gchar *separator;
+ gboolean str_alloced = FALSE;
g_return_val_if_fail(grp, NULL);
g_return_val_if_fail(names, NULL);
- /* Look for the first name in the children. */
- for (node = grp->accounts; node; node = node->next) {
- Account *account = node->data;
+ separator = gnc_get_account_separator_string();
+ /* start with the first name in the list */
+ name_str = names[0];
- if (safe_strcmp(xaccAccountGetName (account), names[0]) == 0) {
- /* We found an account. If the next entry is NULL, there is
- * nothing left in the name, so just return the account. */
- if (names[1] == NULL)
- return account;
+ /* Make sure we actually HAVE a string! */
+ if (name_str == NULL)
+ return NULL;
- /* No children? We're done. */
- if (!account->children)
- return NULL;
+ while (1)
+ {
+ /* Look for the first name in the children. */
+ for (node = grp->accounts; node; node = node->next) {
+ Account *account = node->data;
- /* There's stuff left to search for. Search recursively. */
- found = xaccGetAccountFromFullNameHelper(account->children, &names[1]);
- if (found != NULL) {
- return found;
+ if (safe_strcmp(xaccAccountGetName (account), name_str) == 0) {
+ /* We found an account. If the next entry is NULL, there is
+ * nothing left in the name, so just return the account. */
+ if (names[1] == NULL) {
+ found = account;
+ goto done;
+ }
+
+ /* No children? We're done. */
+ if (!account->children) {
+ found = NULL;
+ goto done;
+ }
+
+ /* There's stuff left to search for. Search recursively. */
+ found = xaccGetAccountFromFullNameHelper(account->children, &names[1]);
+ if (found != NULL) {
+ goto done;
+ }
}
}
+
+ /* If we got here then we didn't find a match based on name_str
+ * so build a new name_str using the next token and try again.
+ */
+
+ /* If there's no more names then we're done. We didn't find anything */
+ if (names[1] == NULL) {
+ found = NULL;
+ break;
+ }
+
+ /* Build the new name string */
+ temp_str = g_strconcat(name_str, separator, names[1], NULL);
+ if (str_alloced)
+ g_free(name_str);
+ str_alloced = TRUE;
+ names++;
+ name_str = temp_str;
}
- return NULL;
+done:
+ if (str_alloced)
+ g_free(name_str);
+ return found;
}
More information about the gnucash-changes
mailing list