48 |
#include "regex.h" |
#include "regex.h" |
49 |
#include "const.h" |
#include "const.h" |
50 |
|
|
51 |
|
#if !defined(ARG_MAX) && defined(_SC_ARG_MAX) |
52 |
|
#define ARG_MAX sysconf(_SC_ARG_MAX) |
53 |
|
#endif |
54 |
|
|
55 |
static void usage(void); |
static void usage(void); |
56 |
static void help(void); |
static void help(void); |
57 |
static void setcom(int); |
static void setcom(int); |
915 |
STRBUF *sb = strbuf_open(0); |
STRBUF *sb = strbuf_open(0); |
916 |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
STRBUF *path_list = strbuf_open(MAXPATHLEN); |
917 |
int path_list_max; |
int path_list_max; |
|
int force_processing_one_file; |
|
918 |
|
|
919 |
/* |
/* |
920 |
* teach parser where is dbpath. |
* teach parser where is dbpath. |
931 |
/* |
/* |
932 |
* determine the maximum length of the list of paths. |
* determine the maximum length of the list of paths. |
933 |
*/ |
*/ |
|
#if !defined(ARG_MAX) && defined(_SC_ARG_MAX) |
|
|
#define ARG_MAX sysconf(_SC_ARG_MAX) |
|
|
#endif |
|
934 |
#ifdef ARG_MAX |
#ifdef ARG_MAX |
935 |
path_list_max = ARG_MAX; |
path_list_max = ARG_MAX; |
936 |
path_list_max -= 2048; |
path_list_max -= 2048; |
939 |
path_list_max -= env_size(); |
path_list_max -= env_size(); |
940 |
path_list_max -= strbuf_getlen(sb); |
path_list_max -= strbuf_getlen(sb); |
941 |
path_list_max -= 40; |
path_list_max -= 40; |
942 |
force_processing_one_file = (path_list_max <= 0); |
if (path_list_max < 0) |
943 |
|
path_list_max = 0; |
944 |
#else |
#else |
945 |
path_list_max = 0; |
path_list_max = 0; |
|
force_processing_one_file = 1; |
|
946 |
#endif |
#endif |
947 |
|
|
948 |
if (!(op = openfilter())) |
if (!(op = openfilter())) |
983 |
continue; |
continue; |
984 |
} |
} |
985 |
|
|
986 |
if (force_processing_one_file) { |
if (strbuf_getlen(path_list) |
987 |
count += exec_parser(parser, path, cwd, root, op); |
&& strbuf_getlen(path_list) + 1 + strlen(path) > path_list_max) { |
|
continue; |
|
|
} |
|
|
|
|
|
if (strbuf_getlen(path_list) + 1 + strlen(path) > path_list_max) { |
|
988 |
count += exec_parser(parser, strbuf_value(path_list), |
count += exec_parser(parser, strbuf_value(path_list), |
989 |
cwd, root, op); |
cwd, root, op); |
990 |
strbuf_reset(path_list); |
strbuf_reset(path_list); |