~ubuntu-branches/ubuntu/jaunty/geany/jaunty

« back to all changes in this revision

Viewing changes to tagmanager/tcl.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2008-05-09 20:40:06 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080509204006-9fu737rfvapfj7pn
Tags: 0.14-1ubuntu1
* Merge from debian unstable, remaining changes:
  - patches/20_add_debdiff_as_diff_type.dpatch:
    Also recognize .dpatch files as diff's
  - debian/geany.xpm:
    Replace icon with a .xpm of the new one
  - Modify Maintainer value to match the DebianMaintainerField
    specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
 
2
*   $Id: tcl.c 2380 2008-03-21 16:47:17Z eht16 $
2
3
*
3
 
*   Copyright (c) 2000-2001, Darren Hiebert
 
4
*   Copyright (c) 2000-2003, Darren Hiebert
4
5
*
5
6
*   This source code is released for free distribution under the terms of the
6
7
*   GNU General Public License.
11
12
/*
12
13
*   INCLUDE FILES
13
14
*/
14
 
#include "general.h"    /* must always come first */
 
15
#include "general.h"  /* must always come first */
15
16
 
16
17
#include <string.h>
17
18
 
23
24
*   DATA DEFINITIONS
24
25
*/
25
26
typedef enum {
26
 
    K_PROCEDURE
 
27
        K_CLASS, K_METHOD, K_PROCEDURE
27
28
} tclKind;
28
29
 
29
30
static kindOption TclKinds [] = {
30
 
    { TRUE, 'f', "function", "procedures" }
 
31
        { TRUE, 'c', "class",     "classes" },
 
32
        { TRUE, 'm', "member",    "methods" },
 
33
        { TRUE, 'p', "function",  "procedures" }
31
34
};
32
35
 
33
36
/*
34
37
*   FUNCTION DEFINITIONS
35
38
*/
36
39
 
 
40
static const unsigned char *makeTclTag (
 
41
                const unsigned char *cp,
 
42
                vString *const name,
 
43
                const tclKind kind)
 
44
{
 
45
        vStringClear (name);
 
46
        while ((int) *cp != '\0'  &&  ! isspace ((int) *cp))
 
47
        {
 
48
                vStringPut (name, (int) *cp);
 
49
                ++cp;
 
50
        }
 
51
        vStringTerminate (name);
 
52
        makeSimpleTag (name, TclKinds, kind);
 
53
        return cp;
 
54
}
 
55
 
 
56
static boolean match (const unsigned char *line, const char *word)
 
57
{
 
58
        return (boolean) (strncmp ((const char*) line, word, strlen (word)) == 0);
 
59
}
 
60
 
37
61
static void findTclTags (void)
38
62
{
39
 
    vString *name = vStringNew ();
40
 
    const unsigned char *line;
41
 
 
42
 
    while ((line = fileReadLine ()) != NULL)
43
 
    {
44
 
        int i;
45
 
 
46
 
        if (line [0] == '\0'  ||  line [0] == '#')
47
 
            continue;
48
 
 
49
 
        /* read first word */
50
 
        for (i = 0  ;  line [i] != '\0'  &&  ! isspace (line [i])  ;  ++i)
51
 
            ;
52
 
 
53
 
        if (strncmp ((const char*) line, "proc", (size_t) 4) == 0)
 
63
        vString *name = vStringNew ();
 
64
        const unsigned char *line;
 
65
 
 
66
        while ((line = fileReadLine ()) != NULL)
54
67
        {
55
 
            const unsigned char *cp = line + i;
56
 
            while (isspace ((int) *cp))
57
 
                ++cp;
58
 
            while (line [i] != '\0'  &&  ! isspace ((int) *cp))
59
 
            {
60
 
                vStringPut (name, (int) *cp);
61
 
                ++cp;
62
 
            }
63
 
            vStringTerminate (name);
64
 
            makeSimpleTag (name, TclKinds, K_PROCEDURE);
65
 
            vStringClear (name);
 
68
                const unsigned char *cp;
 
69
 
 
70
                while (isspace (line [0]))
 
71
                        ++line;
 
72
 
 
73
                if (line [0] == '\0'  ||  line [0] == '#')
 
74
                        continue;
 
75
 
 
76
                /* read first word */
 
77
                for (cp = line ; *cp != '\0'  &&  ! isspace ((int) *cp) ; ++cp)
 
78
                        ;
 
79
                if (! isspace ((int) *cp))
 
80
                        continue;
 
81
                while (isspace ((int) *cp))
 
82
                        ++cp;
 
83
                /* Now `line' points at first word and `cp' points at next word */
 
84
 
 
85
                if (match (line, "proc"))
 
86
                        cp = makeTclTag (cp, name, K_PROCEDURE);
 
87
                else if (match (line, "class") || match (line, "itcl::class"))
 
88
                        cp = makeTclTag (cp, name, K_CLASS);
 
89
                else if (match (line, "public") ||
 
90
                                match (line, "protected") ||
 
91
                                match (line, "private"))
 
92
                {
 
93
                        if (match (cp, "method"))
 
94
                        {
 
95
                                cp += 6;
 
96
                                while (isspace ((int) *cp))
 
97
                                        ++cp;
 
98
                                cp = makeTclTag (cp, name, K_METHOD);
 
99
                        }
 
100
                }
66
101
        }
67
 
    }
68
 
    vStringDelete (name);
 
102
        vStringDelete (name);
69
103
}
70
104
 
71
105
extern parserDefinition* TclParser (void)
72
106
{
73
 
    static const char *const extensions [] = { "tcl", "tk", "wish", NULL };
74
 
    parserDefinition* def = parserNew ("Tcl");
75
 
    def->kinds      = TclKinds;
76
 
    def->kindCount  = KIND_COUNT (TclKinds);
77
 
    def->extensions = extensions;
78
 
    def->parser     = findTclTags;
79
 
    return def;
 
107
        static const char *const extensions [] = { "tcl", "tk", "wish", "itcl", NULL };
 
108
        parserDefinition* def = parserNew ("Tcl");
 
109
        def->kinds      = TclKinds;
 
110
        def->kindCount  = KIND_COUNT (TclKinds);
 
111
        def->extensions = extensions;
 
112
        def->parser     = findTclTags;
 
113
        return def;
80
114
}
81
115
 
82
 
/* vi:set tabstop=8 shiftwidth=4: */
 
116
/* vi:set tabstop=4 shiftwidth=4: */