1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
26 #if (defined(_WIN32) || defined(__IBMC__))
34 #if defined(MACOSX) || defined(_WIN32)
40 int Pflag
= 0; /* print no line information */
41 int Iflag
= 0; /* print includes */
42 int Mflag
= 0; /* print macro expansion */
43 int Xflag
= 0; /* print pragma for include/import */
44 int Vflag
= 0; /* verbose flag */
45 int Cflag
= 0; /* do not remove any comments */
46 int Dflag
= 0; /* add parameter check to delete op */
50 setup(int argc
, char **argv
)
57 #if defined(MACOSX) || defined(_WIN32)
58 while ((c
= stgetopt(argc
, argv
, "NOPV:I:D:U:F:A:X:u:l:+")) != -1)
60 while ((c
= getopt(argc
, argv
, "NOPV:I:D:U:F:A:X:u:l:+")) != -1)
65 for (i
= 0; i
< NINCLUDE
; i
++)
66 if (includelist
[i
].always
== 1)
67 includelist
[i
].deleted
= 1;
71 for (i
= NINCLUDE
- 2; i
>= 0; i
--)
73 if (includelist
[i
].file
== NULL
)
75 includelist
[i
].always
= 1;
76 includelist
[i
].file
= optarg
;
81 error(FATAL
, "Too many -I directives");
87 setsource("<cmdarg>", -1, -1, optarg
, 0);
89 // coverity[overrun-buffer-arg: FALSE] - a multiple of trp->max is allocated, not trp->max itself
96 case 'P': /* Lineinfo */
125 fprintf(stderr
, "%s\n", argv
[0]);
129 error(WARNING
, "Unknown verbose option %c", c
);
156 n
+= (int)strlen(dp
);
157 while (isspace((unsigned char)*dp
)) dp
++;
159 for (i
= NINCLUDE
- 1; i
>= 0; i
--)
161 if (wraplist
[i
].file
== NULL
)
163 wraplist
[i
].file
= dp
;
168 error(WARNING
, "Too many -Xw directives");
172 error(WARNING
, "Unknown extension option %c", c
);
181 case 'u': /* -undef for GCC (dummy) */
182 case 'l': /* -lang-c++ for GCC (dummy) */
193 if ((fp
= strrchr(argv
[optind
], '/')) != NULL
)
195 int len
= (int)(fp
- argv
[optind
]);
197 dp
= (char *) newstring((uchar
*) argv
[optind
], len
+ 1, 0);
200 fp
= (char *) newstring((uchar
*) argv
[optind
], strlen(argv
[optind
]), 0);
201 if ((fd
= open(fp
, O_RDONLY
)) <= 0)
202 error(FATAL
, "Can't open input file %s", fp
);
205 if (optind
+ 1 < argc
)
207 int fdo
= creat(argv
[optind
+ 1], 0666);
210 error(FATAL
, "Can't open output file %s", argv
[optind
+ 1]);
213 // coverity[leaked_handle] - on purpose
215 includelist
[NINCLUDE
- 1].always
= 0;
216 includelist
[NINCLUDE
- 1].file
= dp
;
217 setsource(fp
, -1, fd
, NULL
, 0);
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */