summaryrefslogtreecommitdiffstats
path: root/libidu
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>1999-04-06 07:44:19 +0000
committerGreg McGary <greg@mcgary.org>1999-04-06 07:44:19 +0000
commit06fa9166e54cea74bebaf0135f3eacfae4dab0c7 (patch)
tree6ec31699f499dfbc86d4bf974254b9f4e964e5a1 /libidu
parent626a5396f0341a9aee84ee25700a591c5ab39529 (diff)
downloadidutils-06fa9166e54cea74bebaf0135f3eacfae4dab0c7.tar.gz
idutils-06fa9166e54cea74bebaf0135f3eacfae4dab0c7.tar.bz2
idutils-06fa9166e54cea74bebaf0135f3eacfae4dab0c7.zip
* libidu/idfile.h (largest_member_file): Add variable decl.
(MAX_LARGEST_MEMBER_FILE): Add constant. * libidu/scanners.h (scanner_buffer): Add variable decl. * libidu/scanners.c (scanner_buffer): Rename from id_0. * libidu/walker.c (largest_member_file): Add veriable defn. (walk_flink): Maintain largest_member_file. Call print_member_file. (maybe_get_member_file): Don't call print_member_file. (classify_link): Return 0 if file size is zero. * src/mkid.c (scan_files): Report size of largest file. Cap scanner_buffer size at MAX_LARGEST_MEMBER_FILE. Allocate scanner_buffer. * src/xtokid.c (scan_files): Cap scanner_buffer size at MAX_LARGEST_MEMBER_FILE. Allocate scanner_buffer.
Diffstat (limited to 'libidu')
-rw-r--r--libidu/idfile.h3
-rw-r--r--libidu/scanners.c51
-rw-r--r--libidu/scanners.h1
-rw-r--r--libidu/walker.c16
4 files changed, 41 insertions, 30 deletions
diff --git a/libidu/idfile.h b/libidu/idfile.h
index 8ff4b97..d69fda1 100644
--- a/libidu/idfile.h
+++ b/libidu/idfile.h
@@ -221,6 +221,9 @@ extern struct idhead idh;
extern int walker_verbose_flag;
+extern off_t largest_member_file;
+#define MAX_LARGEST_MEMBER_FILE (2*1024*1024-1)
+
#define DEFAULT_ID_FILE_NAME "ID"
#endif /* not _idfile_h_ */
diff --git a/libidu/scanners.c b/libidu/scanners.c
index ea533fe..7786c52 100644
--- a/libidu/scanners.c
+++ b/libidu/scanners.c
@@ -478,7 +478,7 @@ parse_args_c (char **argv, int argc)
return args;
}
-static unsigned char id_0[1<<020];
+unsigned char *scanner_buffer;
#define SCAN_CPP_DIRECTIVE \
do \
@@ -488,12 +488,12 @@ static unsigned char id_0[1<<020];
c = getc (in_FILE); \
if (!ISID1ST (c)) \
goto next; \
- id = id_0; \
+ id = scanner_buffer; \
*id++ = c; \
while (ISIDREST (c = getc (in_FILE))) \
*id++ = c; \
*id = '\0'; \
- if (strequ (id_0, "include")) \
+ if (strequ (scanner_buffer, "include")) \
{ \
while (c == ' ' || c == '\t') \
c = getc (in_FILE); \
@@ -502,7 +502,7 @@ static unsigned char id_0[1<<020];
new_line = 1; \
goto top; \
} \
- id = id_0; \
+ id = scanner_buffer; \
if (c == '"') \
{ \
c = getc (in_FILE); \
@@ -540,13 +540,14 @@ static unsigned char id_0[1<<020];
while (c != '\n' && c != EOF) \
c = getc (in_FILE); \
new_line = 1; \
- obstack_grow0 (&tokens_obstack, id_0, id - id_0); \
+ obstack_grow0 (&tokens_obstack, scanner_buffer, \
+ id - scanner_buffer); \
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")) \
+ if (strnequ (scanner_buffer, "if", 2) \
+ || strequ (scanner_buffer, "define") \
+ || strequ (scanner_buffer, "elif") /* ansi C */ \
+ || strequ (scanner_buffer, "undef")) \
goto next; \
while ((c != '\n') && (c != EOF)) \
c = getc (in_FILE); \
@@ -564,7 +565,7 @@ get_token_c (FILE *in_FILE, void const *args, int *flags)
#define ARGS ((struct args_c const *) args)
static int new_line = 1;
unsigned short const *rct = &ARGS->ctype[1];
- unsigned char *id = id_0;
+ unsigned char *id = scanner_buffer;
int c;
obstack_blank (&tokens_obstack, OFFSETOF_TOKEN_NAME);
@@ -586,7 +587,7 @@ next:
switch (c)
{
case '"':
- id = id_0;
+ id = scanner_buffer;
*id++ = c = getc (in_FILE);
for (;;)
{
@@ -602,19 +603,19 @@ next:
break;
}
*--id = '\0';
- id = id_0;
+ id = scanner_buffer;
while (ISSTRKEEP (*id))
id++;
- if (*id || id == id_0)
+ if (*id || id == scanner_buffer)
{
c = getc (in_FILE);
goto next;
}
*flags = TOK_STRING;
- if (ARGS->strip_underscore && id_0[0] == '_' && id_0[1])
- obstack_grow0 (&tokens_obstack, id_0 + 1, id - id_0 - 1);
+ if (ARGS->strip_underscore && scanner_buffer[0] == '_' && scanner_buffer[1])
+ obstack_grow0 (&tokens_obstack, scanner_buffer + 1, id - scanner_buffer - 1);
else
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
+ obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
case '\'':
@@ -674,7 +675,7 @@ next:
obstack_free (&tokens_obstack, obstack_finish (&tokens_obstack));
return 0;
}
- id = id_0;
+ id = scanner_buffer;
*id++ = c;
if (ISID1ST (c))
{
@@ -697,7 +698,7 @@ next:
}
ungetc (c, in_FILE);
*flags |= TOK_LITERAL;
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
+ obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
}
#undef ARGS
@@ -881,7 +882,7 @@ get_token_asm (FILE *in_FILE, void const *args, int *flags)
#define ARGS ((struct args_asm const *) args)
static int new_line = 1;
unsigned char const *rct = &ARGS->ctype[1];
- unsigned char *id = id_0;
+ unsigned char *id = scanner_buffer;
int c;
obstack_blank (&tokens_obstack, OFFSETOF_TOKEN_NAME);
@@ -945,7 +946,7 @@ next:
goto next;
}
- id = id_0;
+ id = scanner_buffer;
if (ARGS->strip_underscore && c == '_' && !ISID1ST (c = getc (in_FILE)))
{
obstack_grow0 (&tokens_obstack, "_", 1);
@@ -974,12 +975,12 @@ next:
}
*id = '\0';
- for (id = id_0; *id; id++)
+ for (id = scanner_buffer; *id; id++)
if (ISIGNORE (*id))
goto next;
ungetc (c, in_FILE);
*flags |= TOK_LITERAL;
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
+ obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
#undef ARGS
}
@@ -1139,7 +1140,7 @@ get_token_text (FILE *in_FILE, void const *args, int *flags)
#define ARGS ((struct args_text const *) args)
unsigned char const *rct = &ARGS->ctype[1];
int c;
- unsigned char *id = id_0;
+ unsigned char *id = scanner_buffer;
obstack_blank (&tokens_obstack, OFFSETOF_TOKEN_NAME);
@@ -1152,7 +1153,7 @@ top:
obstack_free (&tokens_obstack, obstack_finish (&tokens_obstack));
return 0;
}
- id = id_0;
+ id = scanner_buffer;
*id++ = c;
if (ISID1ST (c))
{
@@ -1178,7 +1179,7 @@ top:
ungetc (c, in_FILE);
*flags |= TOK_LITERAL;
- obstack_grow0 (&tokens_obstack, id_0, id - id_0);
+ obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
#undef ARGS
}
diff --git a/libidu/scanners.h b/libidu/scanners.h
index 771433a..7f49734 100644
--- a/libidu/scanners.h
+++ b/libidu/scanners.h
@@ -70,5 +70,6 @@ extern struct lang_args *lang_args_default;
extern struct lang_args *lang_args_list;
extern struct obstack tokens_obstack;
+extern unsigned char *scanner_buffer;
#endif /* not _scanners_h_ */
diff --git a/libidu/walker.c b/libidu/walker.c
index 10490fe..73dc4d3 100644
--- a/libidu/walker.c
+++ b/libidu/walker.c
@@ -36,6 +36,7 @@
#include "xalloca.h"
int walker_verbose_flag = 0;
+off_t largest_member_file = 0;
int walk_dir __P((struct file_link *dir_link));
struct member_file *get_member_file __P((struct file_link *flink));
@@ -198,8 +199,13 @@ walk_flink (struct file_link *flink, struct dynvec *sub_dirs_vec)
#else
member = get_member_file (flink);
#endif
- if (member == 0)
- return;
+ if (member)
+ {
+ if (st.st_size > largest_member_file)
+ largest_member_file = st.st_size;
+ if (walker_verbose_flag)
+ print_member_file (member);
+ }
}
}
@@ -305,8 +311,6 @@ 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;
}
@@ -721,7 +725,9 @@ classify_link (struct file_link *flink, struct stat *stp)
flags |= FL_SYM_LINK;
}
#endif
- if (S_ISDIR (stp->st_mode))
+ if (stp->st_size == 0)
+ return 0;
+ else if (S_ISDIR (stp->st_mode))
flags |= FL_TYPE_DIR;
else if (S_ISREG (stp->st_mode))
flags |= FL_TYPE_FILE;