From 652cc550b535ceacd7f5ea3d6b236b7bf493d803 Mon Sep 17 00:00:00 2001 From: elliotth Date: Mon, 28 May 2007 01:50:41 +0000 Subject: [PATCH] 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 --- Test/bug1611054.cs | 8 ++++++++ c.c | 2 +- get.c | 21 +++++++++++++++++---- get.h | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 Test/bug1611054.cs diff --git a/Test/bug1611054.cs b/Test/bug1611054.cs new file mode 100644 index 0000000..545f3e3 --- /dev/null +++ b/Test/bug1611054.cs @@ -0,0 +1,8 @@ +class C { + public String a() { + return @"c:\"; + } + // this tag is missing in ctags 5.6 + public void b() { + } +} diff --git a/c.c b/c.c index b1d04dd..6201312 100644 --- a/c.c +++ b/c.c @@ -2761,7 +2761,7 @@ static boolean findCTags (const unsigned int passCount) boolean retry; Assert (passCount < 3); - cppInit ((boolean) (passCount > 1)); + cppInit ((boolean) (passCount > 1), isLanguage (Lang_csharp)); Signature = vStringNew (); exception = (exception_t) setjmp (Exception); diff --git a/get.c b/get.c index 7d4ad48..8c88efb 100644 --- a/get.c +++ b/get.c @@ -63,6 +63,7 @@ enum eState { typedef struct sCppState { int ungetch, ungetch2; /* ungotten characters, if any */ boolean resolveRequired; /* must resolve if/else/elif/endif branch */ + boolean hasAtLiteralStrings; /* supports @"c:\" strings */ struct sDirective { enum eState state; /* current directive being processed */ boolean accept; /* is a directive syntatically permitted? */ @@ -83,6 +84,7 @@ static boolean BraceFormat = FALSE; static cppState Cpp = { '\0', '\0', /* ungetch characters */ FALSE, /* resolveRequired */ + FALSE, /* hasAtLiteralStrings */ { DRCTV_NONE, /* state */ FALSE, /* accept */ @@ -106,13 +108,14 @@ extern unsigned int getDirectiveNestLevel (void) return Cpp.directive.nestLevel; } -extern void cppInit (const boolean state) +extern void cppInit (const boolean state, const boolean hasAtLiteralStrings) { BraceFormat = state; Cpp.ungetch = '\0'; Cpp.ungetch2 = '\0'; Cpp.resolveRequired = FALSE; + Cpp.hasAtLiteralStrings = hasAtLiteralStrings; Cpp.directive.state = DRCTV_NONE; Cpp.directive.accept = TRUE; @@ -477,13 +480,13 @@ static int skipOverCplusComment (void) /* Skips to the end of a string, returning a special character to * symbolically represent a generic string. */ -static int skipToEndOfString (void) +static int skipToEndOfString (boolean ignoreBackslash) { int c; while ((c = fileGetc ()) != EOF) { - if (c == BACKSLASH) + if (c == BACKSLASH && ! ignoreBackslash) fileGetc (); /* throw away next character, too */ else if (c == DOUBLE_QUOTE) break; @@ -564,7 +567,7 @@ process: case DOUBLE_QUOTE: Cpp.directive.accept = FALSE; - c = skipToEndOfString (); + c = skipToEndOfString (FALSE); break; case '#': @@ -639,6 +642,16 @@ process: } break; default: + if (c == '@' && Cpp.hasAtLiteralStrings) + { + int next = fileGetc (); + if (next == DOUBLE_QUOTE) + { + Cpp.directive.accept = FALSE; + c = skipToEndOfString (TRUE); + break; + } + } Cpp.directive.accept = FALSE; if (directive) ignore = handleDirective (c); diff --git a/get.h b/get.h index 5bd7799..09b3da9 100644 --- a/get.h +++ b/get.h @@ -37,7 +37,7 @@ */ extern boolean isBraceFormat (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 cppBeginStatement (void); extern void cppEndStatement (void);