options.cxx (5979ef3c) options.cxx (3b906df9)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 16 unchanged lines hidden (view full) ---

25#include "precompiled_idlc.hxx"
26
27#include "idlc/options.hxx"
28
29#include "osl/diagnose.h"
30#include "rtl/string.hxx"
31#include "rtl/strbuf.hxx"
32
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 16 unchanged lines hidden (view full) ---

25#include "precompiled_idlc.hxx"
26
27#include "idlc/options.hxx"
28
29#include "osl/diagnose.h"
30#include "rtl/string.hxx"
31#include "rtl/strbuf.hxx"
32
33#include "rtl/ustring.hxx"
34#include "osl/file.hxx"
35
36#ifdef WNT
37# include <windows.h>
38#endif
39
40/*
41#ifndef WIN32_LEAN_AND_MEAN
42# define WIN32_LEAN_AND_MEAN
43# ifdef _MSC_VER
44# pragma warning(push,1)
45# endif
46# include <windows.h>
47# ifdef _MSC_VER
48# pragma warning(pop)
49# endif
50# include <tchar.h>
51# undef WIN32_LEAN_AND_MEAN
52#endif
53*/
54
33#include <stdio.h>
34#include <string.h>
35
36using rtl::OString;
37using rtl::OStringBuffer;
38
39#ifdef SAL_UNX
40#define SEPARATOR '/'

--- 136 unchanged lines hidden (view full) ---

177bool Options::setOption(char const * option, std::string const & rArg)
178{
179 bool result = (0 == strcmp(option, rArg.c_str()));
180 if (result)
181 m_options[rArg.c_str()] = OString(rArg.c_str(), rArg.size());
182 return (result);
183}
184
55#include <stdio.h>
56#include <string.h>
57
58using rtl::OString;
59using rtl::OStringBuffer;
60
61#ifdef SAL_UNX
62#define SEPARATOR '/'

--- 136 unchanged lines hidden (view full) ---

199bool Options::setOption(char const * option, std::string const & rArg)
200{
201 bool result = (0 == strcmp(option, rArg.c_str()));
202 if (result)
203 m_options[rArg.c_str()] = OString(rArg.c_str(), rArg.size());
204 return (result);
205}
206
207#ifdef WNT
208/* Helper functiopn to convert windows paths including spaces, brackets etc. into
209 a windows short Url. The ucpp preprocessor has problems with such paths and returns
210 with error.
211*/
212OString convertIncPathtoShortWindowsPath(const OString& incPath) {
213 rtl::OUString path = OStringToOUString(incPath, RTL_TEXTENCODING_UTF8);
214
215 std::vector<sal_Unicode> vec(path.getLength() + 1);
216 //GetShortPathNameW only works if the file can be found!
217 const DWORD len = GetShortPathNameW(
218 reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
219
220 rtl::OUString ret = rtl::OUString(&vec[0], len);
221
222 if (len > 0)
223 return OUStringToOString(ret, RTL_TEXTENCODING_UTF8);
224
225 return incPath;
226}
227#endif
228
185bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument)
186{
187 std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
188 for (; first != last; ++first)
189 {
190 if ((*first)[0] != '-')
191 {
192 OString filename((*first).c_str(), (*first).size());

--- 27 unchanged lines hidden (view full) ---

220 }
221 OString param((*first).c_str(), (*first).size());
222 {
223 // quote param token(s).
224 OStringBuffer buffer;
225 sal_Int32 k = 0;
226 do
227 {
229bool Options::initOptions(std::vector< std::string > & rArgs) throw(IllegalArgument)
230{
231 std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end();
232 for (; first != last; ++first)
233 {
234 if ((*first)[0] != '-')
235 {
236 OString filename((*first).c_str(), (*first).size());

--- 27 unchanged lines hidden (view full) ---

264 }
265 OString param((*first).c_str(), (*first).size());
266 {
267 // quote param token(s).
268 OStringBuffer buffer;
269 sal_Int32 k = 0;
270 do
271 {
228 OStringBuffer token; token.append("-I"); token.append(param.getToken(0, ';', k));
272 OStringBuffer token;
273 token.append("-I");
274#ifdef WNT
275 rtl::OString incpath = convertIncPathtoShortWindowsPath(param.getToken(0, ';', k));
276#else
277 rtl::OString incpath = param.getToken(0, ';', k);
278#endif
279 token.append(incpath);
280 //token.append(param.getToken(0, ';', k));
229 if (buffer.getLength() > 0)
230 buffer.append(' ');
231 buffer.append(token);
232 } while (k != -1);
233 param = buffer.makeStringAndClear();
234 }
235 if (m_options.count("-I") > 0)
236 {

--- 151 unchanged lines hidden ---
281 if (buffer.getLength() > 0)
282 buffer.append(' ');
283 buffer.append(token);
284 } while (k != -1);
285 param = buffer.makeStringAndClear();
286 }
287 if (m_options.count("-I") > 0)
288 {

--- 151 unchanged lines hidden ---