Re-add previously removed code to fix broken calltips.
Merge some minor bugfixes to C/C++ parser from CTags SVN and remove compiler warning. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1653 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
6f4b4c4fa7
commit
96b14c8c3d
@ -2,6 +2,10 @@
|
||||
|
||||
* src/dialogs.c:
|
||||
Set also previous colour when setting the colour for the dialog.
|
||||
* tagmanager/c.c, tagmanager/get.c, tagmanager/get.h:
|
||||
Re-add previously removed code to fix broken calltips.
|
||||
Merge some minor bugfixes to C/C++ parser from CTags SVN and
|
||||
remove compiler warning.
|
||||
|
||||
|
||||
2007-06-28 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
@ -29,9 +29,7 @@
|
||||
/*
|
||||
* MACROS
|
||||
*/
|
||||
#define MaxFields 6
|
||||
|
||||
#define stringValue(a) #a
|
||||
#define activeToken(st) ((st)->token [(int) (st)->tokenIndex])
|
||||
#define parentDecl(st) ((st)->parent == NULL ? \
|
||||
DECL_NONE : (st)->parent->declaration)
|
||||
@ -578,14 +576,14 @@ static void deleteToken (tokenInfo *const token)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *accessString (const accessType access)
|
||||
static const char *accessString (const accessType laccess)
|
||||
{
|
||||
static const char *const names [] ={
|
||||
"?", "private", "protected", "public", "default"
|
||||
};
|
||||
Assert (sizeof (names) / sizeof (names [0]) == ACCESS_COUNT);
|
||||
Assert ((int) access < ACCESS_COUNT);
|
||||
return names [(int) access];
|
||||
Assert ((int) laccess < ACCESS_COUNT);
|
||||
return names [(int) laccess];
|
||||
}
|
||||
|
||||
static const char *implementationString (const impType imp)
|
||||
@ -715,7 +713,6 @@ static boolean isDataTypeKeyword (const tokenInfo *const token)
|
||||
return TRUE;
|
||||
default: return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean isVariableKeyword (const tokenInfo *const token)
|
||||
@ -790,7 +787,6 @@ static void initMemberInfo (statementInfo *const st)
|
||||
{
|
||||
case DECL_ENUM:
|
||||
case DECL_NAMESPACE:
|
||||
case DECL_UNION:
|
||||
accessDefault = ACCESS_UNDEFINED;
|
||||
break;
|
||||
|
||||
@ -803,6 +799,7 @@ static void initMemberInfo (statementInfo *const st)
|
||||
|
||||
case DECL_INTERFACE:
|
||||
case DECL_STRUCT:
|
||||
case DECL_UNION:
|
||||
accessDefault = ACCESS_PUBLIC;
|
||||
break;
|
||||
|
||||
@ -1054,7 +1051,7 @@ static void addOtherFields (tagEntryInfo* const tag, const tagType type,
|
||||
}
|
||||
if (st->implementation != IMP_DEFAULT &&
|
||||
(isLanguage (Lang_cpp) || isLanguage (Lang_csharp) ||
|
||||
isLanguage (Lang_java)))
|
||||
isLanguage (Lang_java) || isLanguage (Lang_d) || isLanguage (Lang_ferite)))
|
||||
{
|
||||
tag->extensionFields.implementation =
|
||||
implementationString (st->implementation);
|
||||
@ -1063,7 +1060,11 @@ static void addOtherFields (tagEntryInfo* const tag, const tagType type,
|
||||
{
|
||||
tag->extensionFields.access = accessField (st);
|
||||
}
|
||||
break;
|
||||
if ((TRUE == st->gotArgs) && (TRUE == Option.extensionFields.argList) &&
|
||||
((TAG_FUNCTION == type) || (TAG_METHOD == type) || (TAG_PROTOTYPE == type))) {
|
||||
tag->extensionFields.arglist = getArglistFromPos(tag->filePosition, tag->name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ((TAG_FIELD == tag->type) || (TAG_MEMBER == tag->type) ||
|
||||
@ -1498,6 +1499,14 @@ static void readIdentifier (tokenInfo *const token, const int firstChar)
|
||||
|
||||
initToken (token);
|
||||
|
||||
/* Bug #1585745 (CTags): strangely, C++ destructors allow whitespace between
|
||||
* the ~ and the class name. */
|
||||
if (isLanguage (Lang_cpp) && firstChar == '~')
|
||||
{
|
||||
vStringPut (name, c);
|
||||
c = skipToNonWhite ();
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
vStringPut (name, c);
|
||||
@ -1650,7 +1659,7 @@ static void copyToken (tokenInfo *const dest, const tokenInfo *const src)
|
||||
vStringCopy (dest->name, src->name);
|
||||
}
|
||||
|
||||
static void setAccess (statementInfo *const st, const accessType access)
|
||||
static void setAccess (statementInfo *const st, const accessType laccess)
|
||||
{
|
||||
if (isMember (st))
|
||||
{
|
||||
@ -1663,9 +1672,9 @@ static void setAccess (statementInfo *const st, const accessType access)
|
||||
else
|
||||
cppUngetc (c);
|
||||
|
||||
st->member.accessDefault = access;
|
||||
st->member.accessDefault = laccess;
|
||||
}
|
||||
st->member.access = access;
|
||||
st->member.access = laccess;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2346,7 +2355,7 @@ static void processInitializer (statementInfo *const st)
|
||||
setToken (st, TOKEN_SEMICOLON);
|
||||
else if (c == ',')
|
||||
setToken (st, TOKEN_COMMA);
|
||||
else if ('}' && inEnumBody)
|
||||
else if (c == '}' && inEnumBody)
|
||||
{
|
||||
cppUngetc (c);
|
||||
setToken (st, TOKEN_COMMA);
|
||||
@ -2629,7 +2638,7 @@ static void tagCheck (statementInfo *const st)
|
||||
else if (isType (prev, TOKEN_NAME))
|
||||
{
|
||||
if (isContextualKeyword (prev2))
|
||||
st->scope = SCOPE_EXTERN;
|
||||
makeTag (prev, st, TRUE, TAG_EXTERN_VAR);
|
||||
else
|
||||
{
|
||||
if (!isLanguage (Lang_java))
|
||||
|
137
tagmanager/get.c
137
tagmanager/get.c
@ -662,4 +662,141 @@ process:
|
||||
return c;
|
||||
}
|
||||
|
||||
extern char *getArglistFromPos(fpos_t startPosition, const char *tokenName)
|
||||
{
|
||||
fpos_t originalPosition;
|
||||
char *result = NULL;
|
||||
char *arglist = NULL;
|
||||
long pos1, pos2 = ftell(File.fp);
|
||||
|
||||
fgetpos(File.fp, &originalPosition);
|
||||
fsetpos(File.fp, &startPosition);
|
||||
pos1 = ftell(File.fp);
|
||||
if (pos2 > pos1)
|
||||
{
|
||||
result = (char *) g_malloc(sizeof(char ) * (pos2 - pos1 + 2));
|
||||
if (result != NULL)
|
||||
{
|
||||
fread(result, sizeof(char), pos2 - pos1 + 1, File.fp);
|
||||
result[pos2-pos1+1] = '\0';
|
||||
arglist = getArglistFromStr(result, tokenName);
|
||||
free(result);
|
||||
}
|
||||
}
|
||||
fsetpos(File.fp, &originalPosition);
|
||||
return arglist;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
st_none_t,
|
||||
st_escape_t,
|
||||
st_c_comment_t,
|
||||
st_cpp_comment_t,
|
||||
st_double_quote_t,
|
||||
st_single_quote_t
|
||||
} ParseState;
|
||||
|
||||
static void stripCodeBuffer(char *buf)
|
||||
{
|
||||
int i = 0, pos = 0;
|
||||
ParseState state = st_none_t, prev_state = st_none_t;
|
||||
|
||||
while (buf[i] != '\0')
|
||||
{
|
||||
switch(buf[i])
|
||||
{
|
||||
case '/':
|
||||
if (st_none_t == state)
|
||||
{
|
||||
/* Check if this is the start of a comment */
|
||||
if (buf[i+1] == '*') /* C comment */
|
||||
state = st_c_comment_t;
|
||||
else if (buf[i+1] == '/') /* C++ comment */
|
||||
state = st_cpp_comment_t;
|
||||
else /* Normal character */
|
||||
buf[pos++] = '/';
|
||||
}
|
||||
else if (st_c_comment_t == state)
|
||||
{
|
||||
/* Check if this is the end of a C comment */
|
||||
if (buf[i-1] == '*')
|
||||
{
|
||||
if ((pos > 0) && (buf[pos-1] != ' '))
|
||||
buf[pos++] = ' ';
|
||||
state = st_none_t;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '"':
|
||||
if (st_none_t == state)
|
||||
state = st_double_quote_t;
|
||||
else if (st_double_quote_t == state)
|
||||
state = st_none_t;
|
||||
break;
|
||||
case '\'':
|
||||
if (st_none_t == state)
|
||||
state = st_single_quote_t;
|
||||
else if (st_single_quote_t == state)
|
||||
state = st_none_t;
|
||||
break;
|
||||
default:
|
||||
if ((buf[i] == '\\') && (st_escape_t != state))
|
||||
{
|
||||
prev_state = state;
|
||||
state = st_escape_t;
|
||||
}
|
||||
else if (st_escape_t == state)
|
||||
{
|
||||
state = prev_state;
|
||||
prev_state = st_none_t;
|
||||
}
|
||||
else if ((buf[i] == '\n') && (st_cpp_comment_t == state))
|
||||
{
|
||||
if ((pos > 0) && (buf[pos-1] != ' '))
|
||||
buf[pos++] = ' ';
|
||||
state = st_none_t;
|
||||
}
|
||||
else if (st_none_t == state)
|
||||
{
|
||||
if (isspace(buf[i]))
|
||||
{
|
||||
if ((pos > 0) && (buf[pos-1] != ' '))
|
||||
buf[pos++] = ' ';
|
||||
}
|
||||
else
|
||||
buf[pos++] = buf[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
buf[pos] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
extern char *getArglistFromStr(char *buf, const char *name)
|
||||
{
|
||||
char *start, *end;
|
||||
int level;
|
||||
if ((NULL == buf) || (NULL == name) || ('\0' == name[0]))
|
||||
return NULL;
|
||||
stripCodeBuffer(buf);
|
||||
if (NULL == (start = strstr(buf, name)))
|
||||
return NULL;
|
||||
if (NULL == (start = strchr(start, '(')))
|
||||
return NULL;
|
||||
for (level = 1, end = start + 1; level > 0; ++end)
|
||||
{
|
||||
if ('\0' == *end)
|
||||
break;
|
||||
else if ('(' == *end)
|
||||
++ level;
|
||||
else if (')' == *end)
|
||||
-- level;
|
||||
}
|
||||
*end = '\0';
|
||||
return strdup(start);
|
||||
}
|
||||
|
||||
/* vi:set tabstop=4 shiftwidth=4: */
|
||||
|
@ -44,6 +44,8 @@ extern void cppEndStatement (void);
|
||||
extern void cppUngetc (const int c);
|
||||
extern int cppGetc (void);
|
||||
extern int skipOverCComment (void);
|
||||
extern char *getArglistFromPos(fpos_t startPosition, const char *tokenName);
|
||||
extern char *getArglistFromStr(char *buf, const char *name);
|
||||
|
||||
#endif /* _GET_H */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user