Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit ff33dcab685d2aeb07d21ea49ac54cd2e538a4cd 1 parent 88eb538
Elliott Hughes authored
Showing with 27 additions and 6 deletions.
  1. +8 −0 Test/bug1611054.cs
  2. +1 −1  c.c
  3. +17 −4 get.c
  4. +1 −1  get.h
View
8 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() {
+ }
+}
View
2  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);
View
21 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 @@ extern int cppGetc (void)
case DOUBLE_QUOTE:
Cpp.directive.accept = FALSE;
- c = skipToEndOfString ();
+ c = skipToEndOfString (FALSE);
break;
case '#':
@@ -639,6 +642,16 @@ extern int cppGetc (void)
} 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);
View
2  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);
Please sign in to comment.
Something went wrong with that request. Please try again.