some fixes to accented characters
[tangerine.git] / rom / utility / clonetagitems.c
blob363c8e9efdade863f712fca7bd56aa7ad904ad25
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CloneTagItems()
6 Lang: english
7 */
8 #include "intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <utility/tagitem.h>
14 #include <proto/utility.h>
16 AROS_LH1(struct TagItem *, CloneTagItems,
18 /* SYNOPSIS */
19 AROS_LHA(const struct TagItem *, tagList, A0),
21 /* LOCATION */
22 struct UtilityBase *, UtilityBase, 12, Utility)
24 /* FUNCTION
25 Duplicates a TagList. The input TagList can be NULL, in which
26 case an empty TagList will be returned.
28 INPUTS
29 tagList - The TagList that you want to clone
31 RESULT
32 A TagList which contains a copy of the TagItems contained in the
33 original list. The list is cloned so that calling FindTagItem()
34 on a tag in the clone will return the same value as that in the
35 original list (assuming the original has not been modified).
37 NOTES
39 EXAMPLE
40 struct TagItem *tagList, *tagListClone;
42 \* Set up the original taglist tagList *\
44 tagListClone = CloneTagItems( tagList );
46 \* Do what you want with your TagList here *\
48 FreeTagItems( tagListClone );
50 BUGS
52 SEE ALSO
53 AllocateTagItems(), FreeTagItems(), RefreshTagItemClones()
55 INTERNALS
57 HISTORY
58 29-10-95 digulla automatically created from
59 utility_lib.fd and clib/utility_protos.h
60 11-08-96 iaint Implemented as AROS function.
61 01-09-96 iaint Updated the docs to give the same warnings
62 as the autodocs.
63 05-09-96 iaint Bit of optimisation (one variable :( )
64 23-01-97 iaint Corrected NULL TagList handling.
66 *****************************************************************************/
68 AROS_LIBFUNC_INIT
70 struct TagItem *newList;
71 LONG numTags = 1;
74 This is rather strange, if we have a NULL input, then we still
75 have to allocate a list. This is to circumvent a bug in SID v2,
76 which for some unknown reason is the only program I have seen
77 that has this problem.
79 Had to alter RefreshTagItemClones as well.
80 However, that is also what the autodoc says...
82 if (tagList)
84 const struct TagItem *tmp;
86 We start the counter at 1 since this count will not include the
87 TAG_DONE TagItem
89 newList is used here to save a variable. We don't need to do
90 anything to the value of newList afterwards, since AllocateTagitems()
91 will take care of setting it to NULL if the allocation fails.
93 tmp = tagList;
94 while (NextTagItem (&tmp) != NULL)
95 numTags++;
99 Then we shall allocate the TagList.
100 If we can actually allocate a clone tag list, then we shall copy
101 the tag values from one tag to another, the function
102 "RefreshTagItemClones()" is used here to help re-use code.
104 Of course we don't have to worry about the if and only if
105 statement, since the original is guaranteed to have not
106 been changed since CloneTagItems() :)
109 if ((newList = AllocateTagItems(numTags)))
110 RefreshTagItemClones(newList, tagList);
112 /* newList == 0 when allocation failed - AllocateTagItems handles this*/
113 return newList;
115 AROS_LIBFUNC_EXIT
116 } /* CloneTagItems */