~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to tagmanager/php.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
*   $Id: php.c 4618 2010-01-31 21:51:00Z eht16 $
 
2
*   $Id: php.c 4830 2010-04-17 16:12:32Z eht16 $
3
3
*
4
4
*   Copyright (c) 2000, Jesus Castagnetto <jmcastagnetto@zkey.com>
5
5
*
19
19
#include "general.h"  /* must always come first */
20
20
 
21
21
#include <string.h>
22
 
 
 
22
#include "main.h"
23
23
#include "parse.h"
24
24
#include "read.h"
25
25
#include "vstring.h"
67
67
#define ALPHA "[:alpha:]"
68
68
#define ALNUM "[:alnum:]"
69
69
 
 
70
static void function_cb(const char *line, const regexMatch *matches, unsigned int count);
70
71
 
71
72
static void installPHPRegex (const langType language)
72
73
{
78
79
                "\\1", "m,macro,macros", NULL);
79
80
        addTagRegex(language, "^[ \t]*const[ \t]*([" ALPHA "_][" ALNUM "_]*)[ \t]*[=;]",
80
81
                "\\1", "m,macro,macros", NULL);
81
 
        addTagRegex(language, "^[ \t]*((public|protected|private|static)[ \t]+)*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)",
82
 
                "\\3", "f,function,functions", NULL);
 
82
        addCallbackRegex(language,
 
83
        "^[ \t]*[(public|protected|private|static)[ \t]*]*[ \t]*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)[[:space:]]*(\\(.*\\))",
 
84
                        NULL, function_cb);
83
85
        addTagRegex(language, "^[ \t]*(\\$|::\\$|\\$this->)([" ALPHA "_][" ALNUM "_]*)[ \t]*=",
84
86
                "\\2", "v,variable,variables", NULL);
85
87
        addTagRegex(language, "^[ \t]*((var|public|protected|private|static)[ \t]+)+\\$([" ALPHA "_][" ALNUM "_]*)[ \t]*[=;]",
94
96
                "\\3", "j,jsfunction,javascript functions", NULL);
95
97
}
96
98
 
 
99
 
 
100
static void function_cb(const char *line, const regexMatch *matches, unsigned int count)
 
101
{
 
102
        char *name, *arglist;
 
103
        char kind = 'f';
 
104
        static char *kindName = "function";
 
105
        tagEntryInfo e;
 
106
        const regexMatch *match_funcname = NULL;
 
107
        const regexMatch *match_arglist = NULL;
 
108
 
 
109
        if (count > 2)
 
110
        {
 
111
                match_funcname = &matches[count - 2];
 
112
                match_arglist = &matches[count - 1];
 
113
        }
 
114
 
 
115
        if (match_funcname != NULL)
 
116
        {
 
117
                name = xMalloc(match_funcname->length + 1, char);
 
118
                strncpy(name, line + match_funcname->start, match_funcname->length);
 
119
                *(name+match_funcname->length) = '\x0';
 
120
                arglist = xMalloc(match_arglist->length + 1, char);
 
121
                strncpy(arglist, line + match_arglist->start, match_arglist->length);
 
122
                *(arglist+match_arglist->length) = '\x0';
 
123
 
 
124
                initTagEntry (&e, name);
 
125
                e.kind = kind;
 
126
                e.kindName = kindName;
 
127
                e.extensionFields.arglist = arglist;
 
128
                makeTagEntry (&e);
 
129
        }
 
130
}
 
131
 
97
132
/* Create parser definition structure */
98
133
extern parserDefinition* PhpParser (void)
99
134
{