1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
From 829066d0befb18c484f2562ddf2299f97e623909 Mon Sep 17 00:00:00 2001
From: litvin <litvindev@gmail.com>
Date: Fri, 4 Aug 2017 02:34:56 +0300
Subject: [PATCH 14/33] Make -include <file> option processing <file> as input
before processing the regular C input file
---
src/globals.c | 1 +
src/main.c | 23 ++++++++++++++++++++---
src/proto.h | 1 +
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/globals.c b/src/globals.c
index 777ba1e..b87dac0 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -312,6 +312,7 @@ S_options s_initOpt = {
0, // comment moving level
NULL, // prune name
NULL, // input files
+ NULL, // include files
RC_ZERO, // continue refactoring
0, // completion case sensitive
NULL, // xrefrc
diff --git a/src/main.c b/src/main.c
index 46d0d29..3ef299d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,7 @@ static void usage(char *s) {
fprintf(stdout,"\t-javadocavailable=<packs> - packages for which javadoc is available\n");
fprintf(stdout,"\t-p <prj> - read options from <prj> section\n");
fprintf(stdout,"\t-I <dir> - search for includes in <dir>\n");
+ fprintf(stdout,"\t-include <file> - process <file> as input before processing the regular C input file\n");
fprintf(stdout,"\t-D<mac>[=<body>] - define macro <mac> with body <body>\n");
fprintf(stdout,"\t-packages - allow packages as input files\n");
fprintf(stdout,"\t-sourcepath <path> - set java sources paths\n");
@@ -757,7 +758,14 @@ static int processIOption(int *ii, int argc, char **argv) {
mainAddStringListOption(&s_opt.includeDirs, argv[i]+2);
}
else if (strcmp(argv[i],"-include")==0) {
- i = mainHandleIncludeOption(argc, argv, i);
+ /* process file as if #include "file" */
+ i++;
+ if (i >= argc) {
+ sprintf(tmpBuff,"file name expected after -include\n");
+ error(ERR_ST,tmpBuff);
+ usage(argv[0]);
+ }
+ mainAddStringListOption(&s_opt.includeFiles, argv[i]);
}
else return(0);
*ii = i;
@@ -2029,6 +2036,12 @@ static void fileTabInit() {
/*///////////////////////// parsing /////////////////////////////////// */
static void mainParseInputFile() {
+ S_stringList *ll;
+ if (s_language == LAN_C || s_language == LAN_CCC) {
+ for (ll=s_opt.includeFiles; ll!=NULL; ll=ll->next) {
+ openInclude('<', ll->d, 0);
+ }
+ }
if (s_language == LAN_JAVA) {
uniyylval = & s_yygstate->gyylval;
javayyparse();
@@ -2321,7 +2334,7 @@ static void mainFileProcessingInitialisations(
struct stat dffstat;
char *fileName;
int lc;
- S_stringList *tmpIncludeDirs;
+ S_stringList *tmpIncludeDirs,*tmpIncludeFiles;
fileName = s_input_file_name;
mainSetLanguage(fileName, outLanguage);
@@ -2379,10 +2392,13 @@ static void mainFileProcessingInitialisations(
reInitCwd(dffname, dffsect);
tmpIncludeDirs = s_opt.includeDirs;
s_opt.includeDirs = NULL;
+ tmpIncludeFiles = s_opt.includeFiles;
+ s_opt.includeFiles = NULL;
getAndProcessXrefrcOptions(dffname, dffsect, dffsect);
getAndProcessGccIncludeOptions();
getAndProcessGccDefineOptions();
LIST_APPEND(S_stringList, s_opt.includeDirs, tmpIncludeDirs);
+ LIST_APPEND(S_stringList, s_opt.includeFiles, tmpIncludeFiles);
if (s_opt.taskRegime != RegimeEditServer && s_input_file_name == NULL) {
*outInputIn = 0;
goto fini;
@@ -2516,6 +2532,7 @@ static void mainTotalTaskEntryInitialisations(int argc, char **argv) {
DPRINTF("Initialisations.\n");
memset(&s_count, 0, sizeof(S_counters));
s_opt.includeDirs = NULL;
+ s_opt.includeFiles = NULL;
SM_INIT(ftMemory);
FT_ALLOCC(s_fileTab.tab, MAX_FILES, struct fileItem *);\
FILL_EXP_COMMAND();\
diff --git a/src/proto.h b/src/proto.h
index c050502..94488b1 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -1622,6 +1622,7 @@ struct options {
int commentMovingLevel;
S_stringList *pruneNames;
S_stringList *inputFiles;
+ S_stringList *includeFiles;
int continueRefactoring;
int completionCaseSensitive;
char *xrefrc;
--
2.18.0
|