~ubuntu-branches/ubuntu/raring/geany/raring-proposed

« back to all changes in this revision

Viewing changes to tagmanager/tm_symbol.c

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2008-05-02 11:37:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080502113745-7q62rqhl2ku02ptu
Import upstream version 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        return strcmp(s1->tag->name, s2->tag->name);
76
76
}
77
77
 
 
78
/*
 
79
 * Compares function argument lists.
 
80
 * FIXME: Compare based on types, not an exact string match.
 
81
 */
 
82
int tm_arglist_compare(const TMTag* t1, const TMTag* t2)
 
83
{
 
84
        return strcmp(NVL(t1->atts.entry.arglist, ""),
 
85
                        NVL(t2->atts.entry.arglist, ""));
 
86
}
 
87
 
78
88
/* Need this custom compare function to generate a symbol tree
79
89
in a simgle pass from tag list */
80
90
int tm_symbol_tag_compare(const TMTag **t1, const TMTag **t2)
120
130
        /* If none of them are function/prototype, they are effectively equal */
121
131
        if ((tm_tag_function_t != (*t1)->type) &&
122
132
            (tm_tag_prototype_t != (*t1)->type)&&
123
 
            (tm_tag_function_t != (*t1)->type) &&
124
 
            (tm_tag_prototype_t != (*t1)->type))
 
133
            (tm_tag_function_t != (*t2)->type) &&
 
134
            (tm_tag_prototype_t != (*t2)->type))
125
135
                return 0;
126
136
 
127
137
        /* Whichever is not a function/prototype goes first */
133
143
                return 1;
134
144
 
135
145
        /* Compare the argument list */
136
 
        s1 = strcmp(NVL((*t1)->atts.entry.arglist, ""),
137
 
          NVL((*t2)->atts.entry.arglist, ""));
 
146
        s1 = tm_arglist_compare(*t1, *t2);
138
147
        if (s1 != 0)
139
148
                return s1;
140
149
 
145
154
        if ((tm_tag_function_t != (*t1)->type) &&
146
155
            (tm_tag_function_t == (*t2)->type))
147
156
                return 1;
148
 
        
 
157
 
149
158
        /* Give up */
150
159
        return 0;
151
160
}
165
174
#ifdef TM_DEBUG
166
175
        fprintf(stderr, "Dumping all tags..\n");
167
176
        tm_tags_array_print(tags_array, stderr);
168
 
#endif  
 
177
#endif
 
178
 
169
179
        tags = tm_tags_extract(tags_array, tm_tag_max_t);
170
180
#ifdef TM_DEBUG
171
181
        fprintf(stderr, "Dumping unordered tags..\n");
172
182
        tm_tags_array_print(tags, stderr);
173
183
#endif
 
184
 
174
185
        if (tags && (tags->len > 0))
175
186
        {
176
187
                guint i;
186
197
                SYM_NEW(root);
187
198
                tm_tags_custom_sort(tags, (TMTagCompareFunc) tm_symbol_tag_compare
188
199
                  , FALSE);
 
200
 
189
201
#ifdef TM_DEBUG
190
202
                fprintf(stderr, "Dumping ordered tags..");
191
203
                tm_tags_array_print(tags, stderr);
194
206
                for (i=0; i < tags->len; ++i)
195
207
                {
196
208
                        tag = TM_TAG(tags->pdata[i]);
 
209
 
197
210
                        if (tm_tag_prototype_t == tag->type)
198
211
                        {
199
212
                                if (sym && (tm_tag_function_t == sym->tag->type) &&