diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
commit | e38d2351b83fa65c66ccde443777647ef5cb6cff (patch) | |
tree | 1897fc20e9f73a81c520a5b9f76f8ed042124883 /src/translators/btparse/modify.c | |
download | tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip |
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/translators/btparse/modify.c')
-rw-r--r-- | src/translators/btparse/modify.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/translators/btparse/modify.c b/src/translators/btparse/modify.c new file mode 100644 index 0000000..2d8d9c1 --- /dev/null +++ b/src/translators/btparse/modify.c @@ -0,0 +1,75 @@ +/* ------------------------------------------------------------------------ +@NAME : modify.c +@DESCRIPTION: Routines for modifying the AST for a single entry. +@GLOBALS : +@CALLS : +@CREATED : 1999/11/25, Greg Ward (based on code supplied by + St�phane Genaud <[email protected]>) +@MODIFIED : +@VERSION : $Id: modify.c,v 1.2 1999/11/29 01:13:10 greg Rel $ +@COPYRIGHT : Copyright (c) 1996-99 by Gregory P. Ward. All rights reserved. + + This file is part of the btparse library. This library is + free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. +-------------------------------------------------------------------------- */ +/*#include "bt_config.h"*/ +#include <stdlib.h> +#include <string.h> +#include "btparse.h" +#include "error.h" +/*#include "my_dmalloc.h"*/ + + +/* ------------------------------------------------------------------------ +@NAME : bt_set_text () +@INPUT : node + new_text +@OUTPUT : node->text +@RETURNS : +@DESCRIPTION: Replace the text member of an AST node with a new string. + The passed in string, 'new_text', is duplicated, so the + caller may free it without worry. +@GLOBALS : +@CALLS : +@CALLERS : +@CREATED : 1999/11/25, GPW (from St�phane Genaud) +@MODIFIED : +-------------------------------------------------------------------------- */ +void bt_set_text (AST * node, char * new_text) +{ + free(node->text); + node->text = strdup (new_text); +} + + +/* ------------------------------------------------------------------------ +@NAME : bt_entry_set_key () +@INPUT : entry + new_key +@OUTPUT : entry->down->text +@RETURNS : +@DESCRIPTION: Changes the key of a regular entry to 'new_key'. If 'entry' + is not a regular entry, or if it doesn't already have a child + node holding an entry key, bombs via 'usage_error()'. + Otherwise a duplicate of 'new_key' is copied into the entry + AST (so the caller can free that string without worry). +@CALLS : bt_set_text () +@CREATED : 1999/11/25, GPW (from St�phane Genaud) +@MODIFIED : +-------------------------------------------------------------------------- */ +void bt_entry_set_key (AST * entry, char * new_key) +{ + if (entry->metatype == BTE_REGULAR && + entry->down && entry->down->nodetype == BTAST_KEY) + { + bt_set_text (entry->down, new_key); + } + else + { + usage_error ("can't set entry key -- not a regular entry, " + "or doesn't have a key already"); + } +} |