[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about reserved word file
From: |
Hideki IWAMOTO |
Subject: |
Re: question about reserved word file |
Date: |
Tue, 12 Oct 2004 22:57:43 +0900 |
On Tue, 12 Oct 2004 00:37:48 +0900, Hideki IWAMOTO wrote...
> The buffer holding the string without blanks can be referred
> from the outside of the function to warn about unknown preprocessing
> directives.
Since it was hard to avoid this problem, I gave up changing reserved_sharp.
I want to make the following change according to the current method.
asm_scan.l | 20 +++++++++++++++++++-
gctags.c | 34 ++++++++++++++++++++++++++++++++++
gctags.h | 1 +
3 files changed, 54 insertions(+), 1 deletion(-)
Index: gctags/asm_scan.l
===================================================================
RCS file: /cvsroot/global/global/gctags/asm_scan.l,v
retrieving revision 1.1
diff -u -r1.1 asm_scan.l
--- gctags/asm_scan.l 9 Oct 2004 04:14:33 -0000 1.1
+++ gctags/asm_scan.l 12 Oct 2004 13:51:46 -0000
@@ -23,10 +23,17 @@
#include <config.h>
#endif
#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
#include "asm_parse.h"
+#include "asm_res.h"
#include "die.h"
#include "gctags.h"
+#include "gparam.h"
#include "linetable.h"
#include "strbuf.h"
@@ -116,7 +123,18 @@
<INITIAL>{
^[ \t]*\#[ \t]*define { yy_push_state(PREPROCESSOR_LINE); return
ASM_DEFINE; }
^[ \t]*\#[ \t]*undef { yy_push_state(PREPROCESSOR_LINE); return
ASM_UNDEF; }
- ^[ \t]*\#[ \t]*{WORD} |
+ ^[ \t]*\#[ \t]*{WORD} {
+ static char buf[IDENTLEN];
+ int len;
+
+ len = copy_string_removing_blanks(buf, yytext, sizeof buf);
+ if (reserved_sharp(buf, len)) {
+ yy_push_state(PREPROCESSOR_LINE);
+ return ASM_DIRECTIVE;
+ } else {
+ yy_push_state(LINE_COMMENT);
+ }
+ }
^[ \t]*\# { yy_push_state(PREPROCESSOR_LINE); return
ASM_DIRECTIVE; }
(call|jsr) { return ASM_CALL; }
^(ENTRY|ALTENTRY|NENTRY|GLOBAL_ENTRY|JSBENTRY|C_SYMBOL_NAME|C_ENTRY) {
Index: gctags/gctags.c
===================================================================
RCS file: /cvsroot/global/global/gctags/gctags.c,v
retrieving revision 1.27
diff -u -r1.27 gctags.c
--- gctags/gctags.c 9 Oct 2004 04:14:33 -0000 1.27
+++ gctags/gctags.c 12 Oct 2004 13:51:46 -0000
@@ -22,6 +22,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <ctype.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
@@ -43,6 +44,10 @@
#include "gctags.h"
#include "const.h"
+#ifndef isblank
+#define isblank(c) ((c) == ' ' || (c) == '\t')
+#endif
+
int main(int, char **);
static void usage(void);
static void help(void);
@@ -303,3 +308,32 @@
fprintf(stderr, " ");
fprintf(stderr, "%s\n", s);
}
+
+/*
+ * copy_string_removing_blanks:
+ *
+ * o) dest destination string
+ * i) src source string
+ * i) limit size of dest
+ * r) length of the string written to dest
+ */
+int
+copy_string_removing_blanks(dest, src, limit)
+ char *dest;
+ const char *src;
+ int limit;
+{
+ const char *p = src;
+ int c, len;
+
+ for (len = 0; len < limit; len++) {
+ do {
+ c = (unsigned char)*p++;
+ } while (isblank(c));
+ dest[len] = c;
+ if (c == '\0')
+ return len;
+ }
+
+ die("Too long name '%s'.", src);
+}
Index: gctags/gctags.h
===================================================================
RCS file: /cvsroot/global/global/gctags/gctags.h,v
retrieving revision 1.13
diff -u -r1.13 gctags.h
--- gctags/gctags.h 9 Oct 2004 04:14:33 -0000 1.13
+++ gctags/gctags.h 12 Oct 2004 13:51:46 -0000
@@ -61,3 +61,4 @@
void assembler(const char *);
void java(void);
void php(const char *);
+int copy_string_removing_blanks(char *, const char *, int);
----
Hideki IWAMOTO address@hidden
- question about reserved word file, Hideki IWAMOTO, 2004/10/09
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/09
- Re: question about reserved word file, Hideki IWAMOTO, 2004/10/09
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/10
- Re: question about reserved word file, Hideki IWAMOTO, 2004/10/11
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/11
- Re: question about reserved word file, Hideki IWAMOTO, 2004/10/11
- Re: question about reserved word file,
Hideki IWAMOTO <=
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/12
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/12
- Re: question about reserved word file, Hideki IWAMOTO, 2004/10/12
- Re: question about reserved word file, Shigio Yamaguchi, 2004/10/12