summaryrefslogtreecommitdiffstats
path: root/libidu
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>1999-04-04 00:40:44 +0000
committerGreg McGary <greg@mcgary.org>1999-04-04 00:40:44 +0000
commitf628e1a753e797f998f64219dcddbc6db6ace802 (patch)
tree51b1b1759c986f8c43a6b6b0c419833c8803cfd3 /libidu
parentf63a311d7f3a66c746fd5c7cc778d38de25737f0 (diff)
downloadidutils-f628e1a753e797f998f64219dcddbc6db6ace802.tar.gz
idutils-f628e1a753e797f998f64219dcddbc6db6ace802.tar.bz2
idutils-f628e1a753e797f998f64219dcddbc6db6ace802.zip
* Version 3.2c released.
* libidu/id-file.h (walker_verbose_flag): Add extern variable decl. * libidu/scanners.c (SCAN_CPP_DIRECTIVE): Add macro. (get_token_c, get_token_asm): Call SCAN_CPP_DIRECTIVE. * libidu/walker.c (walker_verbose_flag): Add variable defn. (print_member_file): Add function. (maybe_get_member_file): Call print_member_file in verbose mode. * src/mkid.c: Add coments. (ceil_log_2): Add function. (main): Handle 'V' option for extra verbosity. (scan_files): Use MAX (1M, n*lg(n)*64) to estimate initial size of token hash table.
Diffstat (limited to 'libidu')
-rw-r--r--libidu/idfile.h2
-rw-r--r--libidu/scanners.c175
-rw-r--r--libidu/walker.c14
3 files changed, 93 insertions, 98 deletions
diff --git a/libidu/idfile.h b/libidu/idfile.h
index 5f55073..fdfb704 100644
--- a/libidu/idfile.h
+++ b/libidu/idfile.h
@@ -219,6 +219,8 @@ extern struct member_file *find_member_file __P((struct file_link const *flink))
extern struct idhead idh;
+extern int walker_verbose_flag;
+
#define DEFAULT_ID_FILE_NAME "ID"
#endif /* not _idfile_h_ */
diff --git a/libidu/scanners.c b/libidu/scanners.c
index a4a0b70..ea533fe 100644
--- a/libidu/scanners.c
+++ b/libidu/scanners.c
@@ -480,6 +480,81 @@ parse_args_c (char **argv, int argc)
static unsigned char id_0[1<<020];
+#define SCAN_CPP_DIRECTIVE \
+ do \
+ { \
+ c = getc (in_FILE); \
+ while (ISBORING (c)) \
+ c = getc (in_FILE); \
+ if (!ISID1ST (c)) \
+ goto next; \
+ id = id_0; \
+ *id++ = c; \
+ while (ISIDREST (c = getc (in_FILE))) \
+ *id++ = c; \
+ *id = '\0'; \
+ if (strequ (id_0, "include")) \
+ { \
+ while (c == ' ' || c == '\t') \
+ c = getc (in_FILE); \
+ if (c == '\n') \
+ { \
+ new_line = 1; \
+ goto top; \
+ } \
+ id = id_0; \
+ if (c == '"') \
+ { \
+ c = getc (in_FILE); \
+ while (c != '\n' && c != EOF && c != '"') \
+ { \
+ *id++ = c; \
+ c = getc (in_FILE); \
+ } \
+ *flags = TOK_STRING; \
+ } \
+ else if (c == '<') \
+ { \
+ c = getc (in_FILE); \
+ while (c != '\n' && c != EOF && c != '>') \
+ { \
+ *id++ = c; \
+ c = getc (in_FILE); \
+ } \
+ *flags = TOK_STRING; \
+ } \
+ else if (ISID1ST (c)) \
+ { \
+ *id++ = c; \
+ while (ISIDREST (c = getc (in_FILE))) \
+ *id++ = c; \
+ *flags = TOK_NAME; \
+ } \
+ else \
+ { \
+ while (c != '\n' && c != EOF) \
+ c = getc (in_FILE); \
+ new_line = 1; \
+ goto top; \
+ } \
+ while (c != '\n' && c != EOF) \
+ c = getc (in_FILE); \
+ new_line = 1; \
+ obstack_grow0 (&tokens_obstack, id_0, id - id_0); \
+ return (struct token *) obstack_finish (&tokens_obstack); \
+ } \
+ if (strnequ (id_0, "if", 2) \
+ || strequ (id_0, "define") \
+ || strequ (id_0, "elif") /* ansi C */ \
+ || strequ (id_0, "undef")) \
+ goto next; \
+ while ((c != '\n') && (c != EOF)) \
+ c = getc (in_FILE); \
+ new_line = 1; \
+ goto top; \
+ } while (0)
+
+
/* Grab the next identifier from the C source file. This state
machine is built for speed, not elegance. */
@@ -501,75 +576,7 @@ top:
new_line = 0;
if (c != '#')
goto next;
- c = getc (in_FILE);
- while (ISBORING (c))
- c = getc (in_FILE);
- if (!ISID1ST (c))
- goto next;
- id = id_0;
- *id++ = c;
- while (ISIDREST (c = getc (in_FILE)))
- *id++ = c;
- *id = '\0';
- if (strequ (id_0, "include"))
- {
- while (c == ' ' || c == '\t')
- c = getc (in_FILE);
- if (c == '\n')
- {
- new_line = 1;
- goto top;
- }
- id = id_0;
- if (c == '"')
- {
- c = getc (in_FILE);
- while (c != '\n' && c != EOF && c != '"')
- {
- *id++ = c;
- c = getc (in_FILE);
- }
- *flags = TOK_STRING;
- }
- else if (c == '<')
- {
- c = getc (in_FILE);
- while (c != '\n' && c != EOF && c != '>')
- {
- *id++ = c;
- c = getc (in_FILE);
- }
- *flags = TOK_STRING;
- }
- else if (ISID1ST (c))
- {
- *id++ = c;
- while (ISIDREST (c = getc (in_FILE)))
- *id++ = c;
- *flags = TOK_NAME;
- }
- else
- {
- while (c != '\n' && c != EOF)
- c = getc (in_FILE);
- new_line = 1;
- goto top;
- }
- while (c != '\n' && c != EOF)
- c = getc (in_FILE);
- new_line = 1;
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
- return (struct token *) obstack_finish (&tokens_obstack);
- }
- if (strnequ (id_0, "if", 2)
- || strequ (id_0, "define")
- || strequ (id_0, "elif") /* ansi C */
- || strequ (id_0, "undef"))
- goto next;
- while ((c != '\n') && (c != EOF))
- c = getc (in_FILE);
- new_line = 1;
- goto top;
+ SCAN_CPP_DIRECTIVE;
}
next:
@@ -886,35 +893,7 @@ top:
new_line = 0;
if (c != '#')
goto next;
- while (ISBORING (c))
- c = getc (in_FILE);
- if (!ISID1ST (c))
- goto next;
- id = id_0;
- *id++ = c;
- while (ISIDREST (c = getc (in_FILE)))
- *id++ = c;
- *id = '\0';
- if (strequ (id_0, "include"))
- {
- while (c != '"' && c != '<')
- c = getc (in_FILE);
- id = id_0;
- *id++ = c = getc (in_FILE);
- while ((c = getc (in_FILE)) != '"' && c != '>')
- *id++ = c;
- *flags = TOK_STRING;
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
- return (struct token *) obstack_finish (&tokens_obstack);
- }
- if (strnequ (id_0, "if", 2)
- || strequ (id_0, "define")
- || strequ (id_0, "undef"))
- goto next;
- while (c != '\n')
- c = getc (in_FILE);
- new_line = 1;
- goto top;
+ SCAN_CPP_DIRECTIVE;
}
next:
diff --git a/libidu/walker.c b/libidu/walker.c
index 63fba09..e862c73 100644
--- a/libidu/walker.c
+++ b/libidu/walker.c
@@ -35,9 +35,12 @@
#include "pathmax.h"
#include "xalloca.h"
+int walker_verbose_flag = 0;
+
int walk_dir __P((struct file_link *dir_link));
struct member_file *get_member_file __P((struct file_link *flink));
struct lang_args *get_lang_args __P((struct file_link const *flink));
+void print_member_file (struct member_file *member);
int walk_sub_dirs __P((struct dynvec *sub_dirs_vec));
void reparent_children __P((struct file_link *dlink, struct file_link *slink));
int classify_link __P((struct file_link *flink, struct stat *stp));
@@ -302,6 +305,8 @@ maybe_get_member_file (struct file_link *flink, struct stat *stp)
alias_member->mf_link->fl_flags &= ~FL_MEMBER;
}
}
+ if (member && walker_verbose_flag)
+ print_member_file (member);
return member;
}
@@ -433,6 +438,15 @@ get_lang_args (struct file_link const *flink)
? lang_args_default : 0);
}
+void
+print_member_file (struct member_file *member)
+{
+ char *file_name = ALLOCA (char, PATH_MAX);
+ absolute_file_name (file_name, member->mf_link);
+ printf ("%ld: %s: %s\n", idh.idh_member_file_table.ht_fill - 1,
+ member->mf_lang_args->la_language->lg_name, file_name);
+}
+
/****************************************************************************/