trunk/c.c:

trunk/get.c: 
trunk/get.h: (bug #1515910) add support for C# verbatim string literals such as @"C:\" which causes ctags 5.6 to swallow everything up to the next ".

trunk/Test/bug1611054.cs: add a test case.


git-svn-id: svn://svn.code.sf.net/p/ctags/code/trunk@525 c5d04d22-be80-434c-894e-aa346cc9e8e8
This commit is contained in:
elliotth 2007-05-28 01:50:41 +00:00
parent 837dc20f84
commit 652cc550b5
4 changed files with 27 additions and 6 deletions

8
Test/bug1611054.cs Normal file
View File

@ -0,0 +1,8 @@
class C {
public String a() {
return @"c:\";
}
// this tag is missing in ctags 5.6
public void b() {
}
}

2
c.c
View File

@ -2761,7 +2761,7 @@ static boolean findCTags (const unsigned int passCount)
boolean retry; boolean retry;
Assert (passCount < 3); Assert (passCount < 3);
cppInit ((boolean) (passCount > 1)); cppInit ((boolean) (passCount > 1), isLanguage (Lang_csharp));
Signature = vStringNew (); Signature = vStringNew ();
exception = (exception_t) setjmp (Exception); exception = (exception_t) setjmp (Exception);

21
get.c
View File

@ -63,6 +63,7 @@ enum eState {
typedef struct sCppState { typedef struct sCppState {
int ungetch, ungetch2; /* ungotten characters, if any */ int ungetch, ungetch2; /* ungotten characters, if any */
boolean resolveRequired; /* must resolve if/else/elif/endif branch */ boolean resolveRequired; /* must resolve if/else/elif/endif branch */
boolean hasAtLiteralStrings; /* supports @"c:\" strings */
struct sDirective { struct sDirective {
enum eState state; /* current directive being processed */ enum eState state; /* current directive being processed */
boolean accept; /* is a directive syntatically permitted? */ boolean accept; /* is a directive syntatically permitted? */
@ -83,6 +84,7 @@ static boolean BraceFormat = FALSE;
static cppState Cpp = { static cppState Cpp = {
'\0', '\0', /* ungetch characters */ '\0', '\0', /* ungetch characters */
FALSE, /* resolveRequired */ FALSE, /* resolveRequired */
FALSE, /* hasAtLiteralStrings */
{ {
DRCTV_NONE, /* state */ DRCTV_NONE, /* state */
FALSE, /* accept */ FALSE, /* accept */
@ -106,13 +108,14 @@ extern unsigned int getDirectiveNestLevel (void)
return Cpp.directive.nestLevel; return Cpp.directive.nestLevel;
} }
extern void cppInit (const boolean state) extern void cppInit (const boolean state, const boolean hasAtLiteralStrings)
{ {
BraceFormat = state; BraceFormat = state;
Cpp.ungetch = '\0'; Cpp.ungetch = '\0';
Cpp.ungetch2 = '\0'; Cpp.ungetch2 = '\0';
Cpp.resolveRequired = FALSE; Cpp.resolveRequired = FALSE;
Cpp.hasAtLiteralStrings = hasAtLiteralStrings;
Cpp.directive.state = DRCTV_NONE; Cpp.directive.state = DRCTV_NONE;
Cpp.directive.accept = TRUE; Cpp.directive.accept = TRUE;
@ -477,13 +480,13 @@ static int skipOverCplusComment (void)
/* Skips to the end of a string, returning a special character to /* Skips to the end of a string, returning a special character to
* symbolically represent a generic string. * symbolically represent a generic string.
*/ */
static int skipToEndOfString (void) static int skipToEndOfString (boolean ignoreBackslash)
{ {
int c; int c;
while ((c = fileGetc ()) != EOF) while ((c = fileGetc ()) != EOF)
{ {
if (c == BACKSLASH) if (c == BACKSLASH && ! ignoreBackslash)
fileGetc (); /* throw away next character, too */ fileGetc (); /* throw away next character, too */
else if (c == DOUBLE_QUOTE) else if (c == DOUBLE_QUOTE)
break; break;
@ -564,7 +567,7 @@ process:
case DOUBLE_QUOTE: case DOUBLE_QUOTE:
Cpp.directive.accept = FALSE; Cpp.directive.accept = FALSE;
c = skipToEndOfString (); c = skipToEndOfString (FALSE);
break; break;
case '#': case '#':
@ -639,6 +642,16 @@ process:
} break; } break;
default: default:
if (c == '@' && Cpp.hasAtLiteralStrings)
{
int next = fileGetc ();
if (next == DOUBLE_QUOTE)
{
Cpp.directive.accept = FALSE;
c = skipToEndOfString (TRUE);
break;
}
}
Cpp.directive.accept = FALSE; Cpp.directive.accept = FALSE;
if (directive) if (directive)
ignore = handleDirective (c); ignore = handleDirective (c);

2
get.h
View File

@ -37,7 +37,7 @@
*/ */
extern boolean isBraceFormat (void); extern boolean isBraceFormat (void);
extern unsigned int getDirectiveNestLevel (void); extern unsigned int getDirectiveNestLevel (void);
extern void cppInit (const boolean state); extern void cppInit (const boolean state, const boolean hasAtLiteralStrings);
extern void cppTerminate (void); extern void cppTerminate (void);
extern void cppBeginStatement (void); extern void cppBeginStatement (void);
extern void cppEndStatement (void); extern void cppEndStatement (void);