Skip to content

Commit

Permalink
trunk/c.c:
Browse files Browse the repository at this point in the history
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: https://ctags.svn.sourceforge.net/svnroot/ctags/trunk@525 c5d04d22-be80-434c-894e-aa346cc9e8e8
  • Loading branch information
Elliott Hughes committed May 28, 2007
1 parent 58c2a07 commit c2a2f04
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
8 changes: 8 additions & 0 deletions 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() {
}
}
2 changes: 1 addition & 1 deletion c.c
Expand Up @@ -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);
Expand Down
21 changes: 17 additions & 4 deletions get.c
Expand Up @@ -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? */
Expand All @@ -83,6 +84,7 @@ static boolean BraceFormat = FALSE;
static cppState Cpp = {
'\0', '\0', /* ungetch characters */
FALSE, /* resolveRequired */
FALSE, /* hasAtLiteralStrings */
{
DRCTV_NONE, /* state */
FALSE, /* accept */
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -564,7 +567,7 @@ extern int cppGetc (void)

case DOUBLE_QUOTE:
Cpp.directive.accept = FALSE;
c = skipToEndOfString ();
c = skipToEndOfString (FALSE);
break;

case '#':
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion get.h
Expand Up @@ -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);
Expand Down

0 comments on commit c2a2f04

Please sign in to comment.