Lines 45-60
Link Here
|
45 |
|
45 |
|
46 |
#include "cppdep.hxx" |
46 |
#include "cppdep.hxx" |
47 |
|
47 |
|
48 |
#if defined WNT |
|
|
49 |
#if !defined HAVE_GETOPT |
50 |
#define __STDC__ 1 |
51 |
#define __GNU_LIBRARY__ |
52 |
#include <external/glibc/getopt.h> |
53 |
#else |
54 |
#include <getopt.h> |
55 |
#endif |
56 |
#endif |
57 |
|
58 |
class RscHrcDep : public CppDep |
48 |
class RscHrcDep : public CppDep |
59 |
{ |
49 |
{ |
60 |
public: |
50 |
public: |
Lines 82-88
void RscHrcDep::Execute()
Link Here
|
82 |
|
72 |
|
83 |
int main( int argc, char** argv ) |
73 |
int main( int argc, char** argv ) |
84 |
{ |
74 |
{ |
85 |
int c; |
|
|
86 |
char aBuf[255]; |
75 |
char aBuf[255]; |
87 |
char pFileNamePrefix[255]; |
76 |
char pFileNamePrefix[255]; |
88 |
char pOutputFileName[255]; |
77 |
char pOutputFileName[255]; |
Lines 93-136
int main( int argc, char** argv )
Link Here
|
93 |
// who needs anything but '/' ? |
82 |
// who needs anything but '/' ? |
94 |
// String aDelim = String(DirEntry::GetAccessDelimiter()); |
83 |
// String aDelim = String(DirEntry::GetAccessDelimiter()); |
95 |
String aDelim = '/'; |
84 |
String aDelim = '/'; |
96 |
|
|
|
97 |
RscHrcDep *pDep = new RscHrcDep; |
85 |
RscHrcDep *pDep = new RscHrcDep; |
98 |
|
86 |
|
|
|
87 |
// When the options are processed, the non-option arguments are |
88 |
// collected at the head of the argv array. |
89 |
// nLastNonOption points to the last of them. |
90 |
int nLastNonOption (-1); |
91 |
|
99 |
pOutputFileName[0] = 0; |
92 |
pOutputFileName[0] = 0; |
100 |
pSrsFileName[0] = 0; |
93 |
pSrsFileName[0] = 0; |
101 |
|
94 |
|
102 |
for ( int i=1; i<argc; i++) |
95 |
for ( int i=1; i<argc; i++) |
103 |
{ |
96 |
{ |
104 |
strcpy( aBuf, (const char *)argv[i] ); |
97 |
strcpy( aBuf, (const char *)argv[i] ); |
105 |
if ( aBuf[0] == '-' && aBuf[1] == 'p' && aBuf[2] == '=' ) |
98 |
const sal_Int32 nLength (strlen(aBuf)); |
106 |
{ |
99 |
|
107 |
strcpy(pFileNamePrefix, &aBuf[3]); |
100 |
printf("option %d is [%s] and has length %d\n", i, aBuf, nLength); |
108 |
//break; |
101 |
|
109 |
} |
102 |
if (nLength == 0) |
110 |
if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'o' && aBuf[3] == '=' ) |
103 |
{ |
111 |
{ |
104 |
// Is this even possible? |
112 |
strcpy(pOutputFileName, &aBuf[4]); |
105 |
continue; |
113 |
//break; |
106 |
} |
114 |
} |
107 |
if (aBuf[0] == '-' && nLength > 0) |
115 |
if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'p' && aBuf[3] == '=' ) |
108 |
{ |
116 |
{ |
109 |
bool bIsKnownOption (true); |
117 |
strcpy(pSrsFileName, &aBuf[4]); |
110 |
// Make a switch on the first character after the - for a |
118 |
String aName( pSrsFileName, gsl_getSystemTextEncoding()); |
111 |
// preselection of the option. |
119 |
DirEntry aDest( aName ); |
112 |
// This is faster then multiple ifs and improves readability. |
120 |
aSrsBaseName = aDest.GetBase(); |
113 |
switch (aBuf[1]) |
121 |
//break; |
114 |
{ |
122 |
} |
115 |
case 'p': |
123 |
if (aBuf[0] == '-' && aBuf[1] == 'i' ) |
116 |
if (nLength>1 && aBuf[2] == '=' ) |
124 |
{ |
117 |
strcpy(pFileNamePrefix, &aBuf[3]); |
125 |
//printf("Include : %s\n", &aBuf[2] ); |
118 |
else |
126 |
pDep->AddSearchPath( &aBuf[2] ); |
119 |
bIsKnownOption = false; |
127 |
} |
120 |
break; |
128 |
if (aBuf[0] == '-' && aBuf[1] == 'I' ) |
121 |
|
129 |
{ |
122 |
case 'f': |
130 |
//printf("Include : %s\n", &aBuf[2] ); |
123 |
if (nLength>2 && aBuf[2] == 'o' && aBuf[3] == '=' ) |
131 |
pDep->AddSearchPath( &aBuf[2] ); |
124 |
{ |
132 |
} |
125 |
strcpy(pOutputFileName, &aBuf[4]); |
133 |
if (aBuf[0] == '@' ) |
126 |
} |
|
|
127 |
else if (nLength>2 && aBuf[2] == 'p' && aBuf[3] == '=' ) |
128 |
{ |
129 |
strcpy(pSrsFileName, &aBuf[4]); |
130 |
String aName( pSrsFileName, gsl_getSystemTextEncoding()); |
131 |
DirEntry aDest( aName ); |
132 |
aSrsBaseName = aDest.GetBase(); |
133 |
} |
134 |
else |
135 |
bIsKnownOption = false; |
136 |
break; |
137 |
|
138 |
case 'i': |
139 |
case 'I': |
140 |
#ifdef DEBUG_VERBOSE |
141 |
printf("Include : %s\n", &aBuf[2] ); |
142 |
#endif |
143 |
pDep->AddSearchPath( &aBuf[2] ); |
144 |
break; |
145 |
|
146 |
case 'h' : |
147 |
case 'H' : |
148 |
case '?' : |
149 |
printf("RscDep 1.0\n"); |
150 |
break; |
151 |
|
152 |
case 'a' : |
153 |
#ifdef DEBUG_VERBOSE |
154 |
printf("option a\n"); |
155 |
#endif |
156 |
break; |
157 |
|
158 |
case 'l' : |
159 |
#ifdef DEBUG_VERBOSE |
160 |
printf("option l with Value %s\n", &aBuf[2] ); |
161 |
#endif |
162 |
pDep->AddSource(&aBuf[2]); |
163 |
break; |
164 |
|
165 |
default: |
166 |
bIsKnownOption = false; |
167 |
break; |
168 |
} |
169 |
#ifdef DEBUG_VERBOSE |
170 |
if ( ! bIsKnownOption) |
171 |
printf("Unknown option error [%s]\n", aBuf); |
172 |
#endif |
173 |
} |
174 |
else if (aBuf[0] == '@' ) |
134 |
{ |
175 |
{ |
135 |
ByteString aToken; |
176 |
ByteString aToken; |
136 |
String aRespName( &aBuf[1], gsl_getSystemTextEncoding()); |
177 |
String aRespName( &aBuf[1], gsl_getSystemTextEncoding()); |
Lines 176-222
int main( int argc, char** argv )
Link Here
|
176 |
} |
217 |
} |
177 |
} |
218 |
} |
178 |
} |
219 |
} |
|
|
220 |
else |
221 |
{ |
222 |
// Collect all non-options at the head of argv. |
223 |
if (++nLastNonOption < i) |
224 |
argv[nLastNonOption] = argv[i]; |
225 |
} |
179 |
} |
226 |
} |
180 |
|
227 |
|
181 |
while( 1 ) |
|
|
182 |
{ |
183 |
c = getopt( argc, argv, |
184 |
"_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\""); |
185 |
if ( c == -1 ) |
186 |
break; |
187 |
|
188 |
switch( c ) |
189 |
{ |
190 |
case 0: |
191 |
break; |
192 |
case 'a' : |
193 |
#ifdef DEBUG_VERBOSE |
194 |
printf("option a\n"); |
195 |
#endif |
196 |
break; |
197 |
|
198 |
case 'l' : |
199 |
#ifdef DEBUG_VERBOSE |
200 |
printf("option l with Value %s\n", optarg ); |
201 |
#endif |
202 |
pDep->AddSource( optarg ); |
203 |
break; |
204 |
|
205 |
case 'h' : |
206 |
case 'H' : |
207 |
case '?' : |
208 |
printf("RscDep 1.0\n"); |
209 |
break; |
210 |
|
211 |
default: |
212 |
#ifdef DEBUG_VERBOSE |
213 |
printf("Unknown getopt error\n"); |
214 |
#endif |
215 |
; |
216 |
} |
217 |
} |
218 |
|
219 |
|
220 |
DirEntry aEntry("."); |
228 |
DirEntry aEntry("."); |
221 |
aEntry.ToAbs(); |
229 |
aEntry.ToAbs(); |
222 |
// String aCwd = aEntry.GetName(); |
230 |
// String aCwd = aEntry.GetName(); |
Lines 245-252
int main( int argc, char** argv )
Link Here
|
245 |
//fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr()); |
253 |
//fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr()); |
246 |
aOutStream.Open( aFileName, STREAM_WRITE ); |
254 |
aOutStream.Open( aFileName, STREAM_WRITE ); |
247 |
|
255 |
|
|
|
256 |
// Process the yet unhandled non-options. These are supposed to |
257 |
// be names of files on which the target depends. |
248 |
ByteString aString; |
258 |
ByteString aString; |
249 |
if ( optind < argc ) |
259 |
if (nLastNonOption >= 0) |
250 |
{ |
260 |
{ |
251 |
#ifdef DEBUG_VERBOSE |
261 |
#ifdef DEBUG_VERBOSE |
252 |
printf("further arguments : "); |
262 |
printf("further arguments : "); |
Lines 255-271
int main( int argc, char** argv )
Link Here
|
255 |
aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); |
265 |
aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); |
256 |
aString += ByteString(" : " ); |
266 |
aString += ByteString(" : " ); |
257 |
|
267 |
|
258 |
while ( optind < argc ) |
268 |
for (sal_Int32 nIndex=0; nIndex<=nLastNonOption; ++nIndex) |
259 |
{ |
269 |
{ |
|
|
270 |
printf("option at %d is [%s]\n", nIndex, argv[nIndex]); |
260 |
if (!bSource ) |
271 |
if (!bSource ) |
261 |
{ |
272 |
{ |
262 |
aString += ByteString(" " ); |
273 |
aString += ByteString(" " ); |
263 |
aString += ByteString( argv[optind]); |
274 |
aString += ByteString( argv[nIndex]); |
264 |
pDep->AddSource( argv[optind++]); |
275 |
pDep->AddSource( argv[nIndex]); |
265 |
} |
|
|
266 |
else |
267 |
{ |
268 |
optind++; |
269 |
} |
276 |
} |
270 |
} |
277 |
} |
271 |
} |
278 |
} |