aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/ctags
diff options
context:
space:
mode:
authorGregory Neil Shapiro <gshapiro@FreeBSD.org>2002-02-24 03:02:52 +0000
committerGregory Neil Shapiro <gshapiro@FreeBSD.org>2002-02-24 03:02:52 +0000
commitb24e2c8a237336978a372bd166b1e639a422329b (patch)
tree024b8289f10580b10acbabe34d62ac1aa6fe5079 /usr.bin/ctags
parentd7bbec76f24b6ce207501fe959da7edebe3fd5bc (diff)
downloadsrc-b24e2c8a237336978a372bd166b1e639a422329b.tar.gz
src-b24e2c8a237336978a372bd166b1e639a422329b.zip
ctags would create a corrupt tags file if the source C file used '//' style
comments such as: // The main() function Teach ctags about this style of commenting. Submitted by: Eric Allman <eric@Sendmail.ORG> MFC after: 1 week
Notes
Notes: svn path=/head/; revision=91189
Diffstat (limited to 'usr.bin/ctags')
-rw-r--r--usr.bin/ctags/C.c23
-rw-r--r--usr.bin/ctags/ctags.h2
-rw-r--r--usr.bin/ctags/yacc.c4
3 files changed, 16 insertions, 13 deletions
diff --git a/usr.bin/ctags/C.c b/usr.bin/ctags/C.c
index b1f162ded031..ad7925428080 100644
--- a/usr.bin/ctags/C.c
+++ b/usr.bin/ctags/C.c
@@ -122,8 +122,8 @@ c_entries()
* "foo() XX comment XX { int bar; }"
*/
case '/':
- if (GETC(==, '*')) {
- skip_comment();
+ if (GETC(==, '*') || c == '/') {
+ skip_comment(c);
continue;
}
(void)ungetc(c, inf);
@@ -273,8 +273,8 @@ func_entry()
break;
case '/':
/* skip comments */
- if (GETC(==, '*'))
- skip_comment();
+ if (GETC(==, '*') || c == '/')
+ skip_comment(c);
break;
case '(':
level++;
@@ -301,8 +301,8 @@ fnd:
SETLINE;
if (intoken(c) || c == '{')
break;
- if (c == '/' && GETC(==, '*'))
- skip_comment();
+ if (c == '/' && (GETC(==, '*') || c == '/'))
+ skip_comment(c);
else { /* don't ever "read" '/' */
(void)ungetc(c, inf);
return (NO);
@@ -422,7 +422,8 @@ str_entry(c)
* skip over comment
*/
void
-skip_comment()
+skip_comment(t)
+ int t; /* comment character */
{
int c; /* character read */
int star; /* '*' flag */
@@ -434,10 +435,12 @@ skip_comment()
star = YES;
break;
case '/':
- if (star)
+ if (star && t == '*')
return;
break;
case '\n':
+ if (t == '/')
+ return;
SETLINE;
/*FALLTHROUGH*/
default:
@@ -500,8 +503,8 @@ skip_key(key)
break;
case '/':
/* skip comments */
- if (GETC(==, '*')) {
- skip_comment();
+ if (GETC(==, '*') || c == '/') {
+ skip_comment(c);
break;
}
(void)ungetc(c, inf);
diff --git a/usr.bin/ctags/ctags.h b/usr.bin/ctags/ctags.h
index 1fc948b0e0a7..a7780299cac6 100644
--- a/usr.bin/ctags/ctags.h
+++ b/usr.bin/ctags/ctags.h
@@ -97,4 +97,4 @@ extern void l_entries __P((void));
extern void y_entries __P((void));
extern int PF_funcs __P((void));
extern void c_entries __P((void));
-extern void skip_comment __P((void));
+extern void skip_comment __P((int));
diff --git a/usr.bin/ctags/yacc.c b/usr.bin/ctags/yacc.c
index 025a623e38ea..9a1d9461aef0 100644
--- a/usr.bin/ctags/yacc.c
+++ b/usr.bin/ctags/yacc.c
@@ -85,8 +85,8 @@ y_entries()
(void)ungetc(c, inf);
break;
case '/':
- if (GETC(==, '*'))
- skip_comment();
+ if (GETC(==, '*') || c == '/')
+ skip_comment(c);
else
(void)ungetc(c, inf);
break;