~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to sdk/codelite_indexer/libctags/tcl.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-02-10 02:27:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090210022755-m5692nfc1t5uf1w9
Tags: 1.0.2759+dfsg-0ubuntu1
* New upstream release (LP: #327216).
* debian/patches/series, debian/patches/00_fix-ia64-build.patch:
  + Dropped, applied upstream already.
* debian/patches/02_fix-desktop.patch,
  debian/patches/03_fix-sh.patch:
  + Refreshed to patch cleanly.
* debian/rules:
  + Make get-orig-source honour UPSTREAM_VERSION if set.
* debian/ctags-le.1,
  debian/codelite_indexer.1,
  debian/codelite.manpages:
  + Dropped ctags-le manpage, since ctags-le was replaced by
    codelite_indexer.
  + Added codelite_indexer manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*   $Id: tcl.c,v 1.8 2006/05/30 04:37:13 darren Exp $
 
3
*
 
4
*   Copyright (c) 2000-2003, Darren Hiebert
 
5
*
 
6
*   This source code is released for free distribution under the terms of the
 
7
*   GNU General Public License.
 
8
*
 
9
*   This module contains functions for generating tags for TCL scripts.
 
10
*/
 
11
 
 
12
/*
 
13
*   INCLUDE FILES
 
14
*/
 
15
#include "general.h"  /* must always come first */
 
16
 
 
17
#include <string.h>
 
18
 
 
19
#include "parse.h"
 
20
#include "read.h"
 
21
#include "vstring.h"
 
22
 
 
23
/*
 
24
*   DATA DEFINITIONS
 
25
*/
 
26
typedef enum {
 
27
        K_CLASS, K_METHOD, K_PROCEDURE
 
28
} tclKind;
 
29
 
 
30
static kindOption TclKinds [] = {
 
31
        { TRUE, 'c', "class",     "classes" },
 
32
        { TRUE, 'm', "method",    "methods" },
 
33
        { TRUE, 'p', "procedure", "procedures" }
 
34
};
 
35
 
 
36
/*
 
37
*   FUNCTION DEFINITIONS
 
38
*/
 
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
 
 
61
static void findTclTags (void)
 
62
{
 
63
        vString *name = vStringNew ();
 
64
        const unsigned char *line;
 
65
 
 
66
        while ((line = fileReadLine ()) != NULL)
 
67
        {
 
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
                }
 
101
        }
 
102
        vStringDelete (name);
 
103
}
 
104
 
 
105
extern parserDefinition* TclParser (void)
 
106
{
 
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;
 
114
}
 
115
 
 
116
/* vi:set tabstop=4 shiftwidth=4: */