| File: | idlc/source/idlccompile.cxx |
| Location: | line 388, column 15 |
| Description: | Value stored to 'nErrors' during its initialization is never read |
| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * This file is part of the LibreOffice project. |
| 4 | * |
| 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/. |
| 8 | * |
| 9 | * This file incorporates work covered by the following license notice: |
| 10 | * |
| 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 . |
| 18 | */ |
| 19 | |
| 20 | #include <idlc/idlc.hxx> |
| 21 | #include <rtl/ustring.hxx> |
| 22 | #include <rtl/strbuf.hxx> |
| 23 | #include <osl/process.h> |
| 24 | #include <osl/diagnose.h> |
| 25 | #include <osl/thread.h> |
| 26 | #include <osl/file.hxx> |
| 27 | |
| 28 | #if defined(SAL_W32) |
| 29 | #include <io.h> |
| 30 | #endif |
| 31 | |
| 32 | #ifdef SAL_UNX |
| 33 | #include <errno(*__errno_location ()).h> |
| 34 | #include <unistd.h> |
| 35 | #if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) || \ |
| 36 | defined(AIX) || defined(OPENBSD) || defined(DRAGONFLY) |
| 37 | #include <sys/wait.h> |
| 38 | #else |
| 39 | #include <wait.h> |
| 40 | #endif |
| 41 | #endif |
| 42 | |
| 43 | #include <string.h> |
| 44 | |
| 45 | using namespace ::rtl; |
| 46 | using namespace ::osl; |
| 47 | |
| 48 | extern int yyparse(); |
| 49 | extern FILE* yyin; |
| 50 | extern int yydebug; |
| 51 | |
| 52 | sal_Int32 lineNumber = 1; |
| 53 | |
| 54 | |
| 55 | static OUString TMP(RTL_CONSTASCII_USTRINGPARAM("TMP")(&("TMP")[0]), ((sal_Int32)((sizeof ("TMP") / sizeof (("TMP" )[0]))-1)), (((rtl_TextEncoding) 11))); |
| 56 | static OUString TEMP(RTL_CONSTASCII_USTRINGPARAM("TEMP")(&("TEMP")[0]), ((sal_Int32)((sizeof ("TEMP") / sizeof (( "TEMP")[0]))-1)), (((rtl_TextEncoding) 11))); |
| 57 | static sal_Char tmpFilePattern[512]; |
| 58 | |
| 59 | sal_Bool isFileUrl(const OString& fileName) |
| 60 | { |
| 61 | if (fileName.indexOf("file://") == 0 ) |
| 62 | return sal_True((sal_Bool)1); |
| 63 | return sal_False((sal_Bool)0); |
| 64 | } |
| 65 | |
| 66 | OString convertToAbsoluteSystemPath(const OString& fileName) |
| 67 | { |
| 68 | OUString uSysFileName; |
| 69 | OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); |
| 70 | if ( isFileUrl(fileName) ) |
| 71 | { |
| 72 | if (FileBase::getSystemPathFromFileURL(uFileName, uSysFileName) |
| 73 | != FileBase::E_None) |
| 74 | { |
| 75 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "75" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 76 | } |
| 77 | } else |
| 78 | { |
| 79 | OUString uWorkingDir, uUrlFileName, uTmp; |
| 80 | if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) |
| 81 | { |
| 82 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "82" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 83 | } |
| 84 | if (FileBase::getFileURLFromSystemPath(uFileName, uTmp) |
| 85 | != FileBase::E_None) |
| 86 | { |
| 87 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "87" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 88 | } |
| 89 | if (FileBase::getAbsoluteFileURL(uWorkingDir, uTmp, uUrlFileName) |
| 90 | != FileBase::E_None) |
| 91 | { |
| 92 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "92" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 93 | } |
| 94 | if (FileBase::getSystemPathFromFileURL(uUrlFileName, uSysFileName) |
| 95 | != FileBase::E_None) |
| 96 | { |
| 97 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "97" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return OUStringToOString(uSysFileName, osl_getThreadTextEncoding()); |
| 102 | } |
| 103 | |
| 104 | OString convertToFileUrl(const OString& fileName) |
| 105 | { |
| 106 | if ( !isFileUrl(fileName) ) |
| 107 | { |
| 108 | OString tmp = convertToAbsoluteSystemPath(fileName); |
| 109 | OUString uFileName(tmp.getStr(), tmp.getLength(), osl_getThreadTextEncoding()); |
| 110 | OUString uUrlFileName; |
| 111 | if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) |
| 112 | != FileBase::E_None) |
| 113 | { |
| 114 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "114" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 115 | } |
| 116 | return OUStringToOString(uUrlFileName, osl_getThreadTextEncoding()); |
| 117 | } |
| 118 | |
| 119 | return fileName; |
| 120 | } |
| 121 | |
| 122 | OString makeTempName(const OString& prefix) |
| 123 | { |
| 124 | OUString uTmpPath; |
| 125 | OString tmpPath; |
| 126 | |
| 127 | if ( osl_getEnvironment(TMP.pData, &uTmpPath.pData) != osl_Process_E_None ) |
| 128 | { |
| 129 | if ( osl_getEnvironment(TEMP.pData, &uTmpPath.pData) != osl_Process_E_None ) |
| 130 | { |
| 131 | #if defined(SAL_W32) |
| 132 | tmpPath = OString("c:\\temp"); |
| 133 | #else |
| 134 | tmpPath = OString("/tmp"); |
| 135 | #endif |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | if ( !uTmpPath.isEmpty() ) |
| 140 | tmpPath = OUStringToOString(uTmpPath, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); |
| 141 | |
| 142 | #if defined(SAL_W32) || defined(SAL_UNX) |
| 143 | |
| 144 | OSL_ASSERT( sizeof(tmpFilePattern) >do { if (true && (!(sizeof(tmpFilePattern) > (size_t ) ( tmpPath.getLength() + ((sal_Int32)((sizeof ("/") / sizeof (("/")[0]))-1)) + prefix.getLength() + ((sal_Int32)((sizeof ( "XXXXXX") / sizeof (("XXXXXX")[0]))-1)) )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "148" ": "), "OSL_ASSERT: %s", "sizeof(tmpFilePattern) > (size_t) ( tmpPath.getLength() + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR ) + prefix.getLength() + RTL_CONSTASCII_LENGTH( \"XXXXXX\") )" ); } } while (false) |
| 145 | (size_t) ( tmpPath.getLength()do { if (true && (!(sizeof(tmpFilePattern) > (size_t ) ( tmpPath.getLength() + ((sal_Int32)((sizeof ("/") / sizeof (("/")[0]))-1)) + prefix.getLength() + ((sal_Int32)((sizeof ( "XXXXXX") / sizeof (("XXXXXX")[0]))-1)) )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "148" ": "), "OSL_ASSERT: %s", "sizeof(tmpFilePattern) > (size_t) ( tmpPath.getLength() + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR ) + prefix.getLength() + RTL_CONSTASCII_LENGTH( \"XXXXXX\") )" ); } } while (false) |
| 146 | + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR )do { if (true && (!(sizeof(tmpFilePattern) > (size_t ) ( tmpPath.getLength() + ((sal_Int32)((sizeof ("/") / sizeof (("/")[0]))-1)) + prefix.getLength() + ((sal_Int32)((sizeof ( "XXXXXX") / sizeof (("XXXXXX")[0]))-1)) )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "148" ": "), "OSL_ASSERT: %s", "sizeof(tmpFilePattern) > (size_t) ( tmpPath.getLength() + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR ) + prefix.getLength() + RTL_CONSTASCII_LENGTH( \"XXXXXX\") )" ); } } while (false) |
| 147 | + prefix.getLength()do { if (true && (!(sizeof(tmpFilePattern) > (size_t ) ( tmpPath.getLength() + ((sal_Int32)((sizeof ("/") / sizeof (("/")[0]))-1)) + prefix.getLength() + ((sal_Int32)((sizeof ( "XXXXXX") / sizeof (("XXXXXX")[0]))-1)) )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "148" ": "), "OSL_ASSERT: %s", "sizeof(tmpFilePattern) > (size_t) ( tmpPath.getLength() + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR ) + prefix.getLength() + RTL_CONSTASCII_LENGTH( \"XXXXXX\") )" ); } } while (false) |
| 148 | + RTL_CONSTASCII_LENGTH( "XXXXXX") ) )do { if (true && (!(sizeof(tmpFilePattern) > (size_t ) ( tmpPath.getLength() + ((sal_Int32)((sizeof ("/") / sizeof (("/")[0]))-1)) + prefix.getLength() + ((sal_Int32)((sizeof ( "XXXXXX") / sizeof (("XXXXXX")[0]))-1)) )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "148" ": "), "OSL_ASSERT: %s", "sizeof(tmpFilePattern) > (size_t) ( tmpPath.getLength() + RTL_CONSTASCII_LENGTH( PATH_SEPARATOR ) + prefix.getLength() + RTL_CONSTASCII_LENGTH( \"XXXXXX\") )" ); } } while (false); |
| 149 | |
| 150 | tmpFilePattern[ sizeof(tmpFilePattern)-1 ] = '\0'; |
| 151 | strncpy(tmpFilePattern, tmpPath.getStr(), sizeof(tmpFilePattern)-1); |
| 152 | strncat(tmpFilePattern, PATH_SEPARATOR"/", sizeof(tmpFilePattern)-1-strlen(tmpFilePattern)); |
| 153 | strncat(tmpFilePattern, prefix.getStr(), sizeof(tmpFilePattern)-1-strlen(tmpFilePattern)); |
| 154 | strncat(tmpFilePattern, "XXXXXX", sizeof(tmpFilePattern)-1-strlen(tmpFilePattern)); |
| 155 | |
| 156 | #ifdef SAL_UNX |
| 157 | int nDescriptor = mkstemp(tmpFilePattern); |
| 158 | if( -1 == nDescriptor ) |
| 159 | { |
| 160 | fprintf(stderrstderr, "idlc: mkstemp(\"%s\") failed: %s\n", tmpFilePattern, strerror(errno(*__errno_location ()))); |
| 161 | exit( 1 ); |
| 162 | } |
| 163 | // the file shall later be reopened by stdio functions |
| 164 | close( nDescriptor ); |
| 165 | #else |
| 166 | (void) mktemp(tmpFilePattern); |
| 167 | #endif |
| 168 | #endif |
| 169 | |
| 170 | return OString(tmpFilePattern); |
| 171 | } |
| 172 | |
| 173 | sal_Bool copyFile(const OString* source, const OString& target) |
| 174 | { |
| 175 | sal_Bool bRet = sal_True((sal_Bool)1); |
| 176 | |
| 177 | FILE* pSource = source == 0 ? stdinstdin : fopen(source->getStr(), "rb"); |
| 178 | if ( !pSource ) |
| 179 | return sal_False((sal_Bool)0); |
| 180 | |
| 181 | FILE* pTarget = fopen(target.getStr(), "wb"); |
| 182 | if ( !pTarget ) |
| 183 | { |
| 184 | fclose(pSource); |
| 185 | return sal_False((sal_Bool)0); |
| 186 | } |
| 187 | |
| 188 | size_t totalSize = 512; |
| 189 | size_t readSize = 0; |
| 190 | char pBuffer[513]; |
| 191 | |
| 192 | while ( !feof(pSource) ) |
| 193 | { |
| 194 | if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0 && !ferror(pSource) ) |
| 195 | { |
| 196 | if ( (fwrite(pBuffer, 1, readSize, pTarget)) != readSize || ferror(pTarget) ) |
| 197 | { |
| 198 | if (source != 0) { |
| 199 | fclose(pSource); |
| 200 | } |
| 201 | fclose(pTarget); |
| 202 | return sal_False((sal_Bool)0); |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | if (source != 0) { |
| 208 | fclose(pSource); |
| 209 | } |
| 210 | if ( fflush(pTarget) ) |
| 211 | bRet = sal_False((sal_Bool)0); |
| 212 | fclose(pTarget); |
| 213 | |
| 214 | return bRet; |
| 215 | } |
| 216 | |
| 217 | sal_Int32 compileFile(const OString * pathname) |
| 218 | { |
| 219 | // preprocess input file |
| 220 | OString tmpFile = makeTempName(OString("idli_")); |
| 221 | OString preprocFile = makeTempName(OString("idlf_")); |
| 222 | |
| 223 | OString fileName; |
| 224 | if (pathname == 0) { |
| 225 | fileName = "stdin"; |
| 226 | } else { |
| 227 | fileName = *pathname; |
| 228 | } |
| 229 | |
| 230 | if ( !copyFile(pathname, tmpFile) ) |
| 231 | { |
| 232 | fprintf(stderrstderr, "%s: could not copy %s%s to %s\n", |
| 233 | idlc()->getOptions()->getProgramName().getStr(), |
| 234 | pathname == 0 ? "" : "file ", fileName.getStr(), |
| 235 | tmpFile.getStr()); |
| 236 | exit(99); |
| 237 | } |
| 238 | |
| 239 | idlc()->setFileName(fileName); |
| 240 | idlc()->setMainFileName(fileName); |
| 241 | idlc()->setRealFileName(tmpFile); |
| 242 | |
| 243 | ::std::vector< ::rtl::OUString> lCppArgs; |
| 244 | lCppArgs.push_back("-DIDL"); |
| 245 | lCppArgs.push_back("-C"); |
| 246 | lCppArgs.push_back("-zI"); |
| 247 | |
| 248 | OStringBuffer cppArgs(256); |
| 249 | Options* pOptions = idlc()->getOptions(); |
| 250 | |
| 251 | OString filePath; |
| 252 | sal_Int32 index = fileName.lastIndexOf(SEPARATOR'/'); |
| 253 | |
| 254 | if ( index > 0) |
| 255 | { |
| 256 | filePath = fileName.copy(0, index); |
| 257 | |
| 258 | if ( !filePath.isEmpty() ) |
| 259 | { |
| 260 | cppArgs.append("-I"); |
| 261 | cppArgs.append(filePath); |
| 262 | lCppArgs.push_back(rtl::OStringToOUString( |
| 263 | cppArgs.makeStringAndClear().replace('\\', '/'), |
| 264 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | if ( pOptions->isValid("-D") ) |
| 269 | { |
| 270 | OString token, dOpt = pOptions->getOption("-D"); |
| 271 | sal_Int32 nIndex = 0; |
| 272 | do |
| 273 | { |
| 274 | token = dOpt.getToken( 0, ' ', nIndex ); |
| 275 | if (token.getLength()) |
| 276 | lCppArgs.push_back(rtl::OStringToOUString("-D" + token, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
| 277 | } while( nIndex != -1 ); |
| 278 | } |
| 279 | |
| 280 | if ( pOptions->isValid("-I") ) |
| 281 | { |
| 282 | OString token, incOpt = pOptions->getOption("-I"); |
| 283 | sal_Int32 nIndex = 0; |
| 284 | do |
| 285 | { |
| 286 | token = incOpt.getToken( 0, ' ', nIndex ); |
| 287 | if (token.getLength()) |
| 288 | lCppArgs.push_back(rtl::OStringToOUString("-I" + token, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
| 289 | } while( nIndex != -1 ); |
| 290 | } |
| 291 | |
| 292 | lCppArgs.push_back(OUString(RTL_CONSTASCII_USTRINGPARAM("-o")(&("-o")[0]), ((sal_Int32)((sizeof ("-o") / sizeof (("-o" )[0]))-1)), (((rtl_TextEncoding) 11)))); |
| 293 | |
| 294 | cppArgs.append(preprocFile); |
| 295 | lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
| 296 | |
| 297 | cppArgs.append(tmpFile); |
| 298 | lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); |
| 299 | |
| 300 | OUString cpp; |
| 301 | OUString startDir; |
| 302 | if (osl_getExecutableFile(&cpp.pData) != osl_Process_E_None) { |
| 303 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "303" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 304 | } |
| 305 | |
| 306 | sal_Int32 idx= cpp.lastIndexOf("idlc"); |
| 307 | cpp = cpp.copy(0, idx); |
| 308 | |
| 309 | #if defined(SAL_W32) |
| 310 | cpp += OUString( RTL_CONSTASCII_USTRINGPARAM("ucpp.exe")(&("ucpp.exe")[0]), ((sal_Int32)((sizeof ("ucpp.exe") / sizeof (("ucpp.exe")[0]))-1)), (((rtl_TextEncoding) 11))); |
| 311 | #else |
| 312 | cpp += OUString( RTL_CONSTASCII_USTRINGPARAM("ucpp")(&("ucpp")[0]), ((sal_Int32)((sizeof ("ucpp") / sizeof (( "ucpp")[0]))-1)), (((rtl_TextEncoding) 11))); |
| 313 | #endif |
| 314 | |
| 315 | oslProcess hProcess = NULL__null; |
| 316 | oslProcessError procError = osl_Process_E_None; |
| 317 | |
| 318 | const int nCmdArgs = lCppArgs.size(); |
| 319 | rtl_uString** pCmdArgs = 0; |
| 320 | pCmdArgs = (rtl_uString**)rtl_allocateZeroMemory(nCmdArgs * sizeof(rtl_uString*)); |
| 321 | |
| 322 | ::std::vector< ::rtl::OUString >::iterator iter = lCppArgs.begin(); |
| 323 | ::std::vector< ::rtl::OUString >::iterator end = lCppArgs.end(); |
| 324 | int i = 0; |
| 325 | while ( iter != end ) { |
| 326 | pCmdArgs[i++] = (*iter).pData; |
| 327 | ++iter; |
| 328 | } |
| 329 | |
| 330 | procError = osl_executeProcess( cpp.pData, pCmdArgs, nCmdArgs, osl_Process_WAIT0x0001, |
| 331 | 0, startDir.pData, 0, 0, &hProcess ); |
| 332 | |
| 333 | oslProcessInfo hInfo; |
| 334 | hInfo.Size = (sal_uInt32)(sizeof(oslProcessInfo)); |
| 335 | if (osl_getProcessInfo(hProcess, osl_Process_EXITCODE0x0002, &hInfo) |
| 336 | != osl_Process_E_None) |
| 337 | { |
| 338 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/idlc/source/idlccompile.cxx" ":" "338" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); |
| 339 | } |
| 340 | |
| 341 | if ( procError || (hInfo.Code != 0) ) |
| 342 | { |
| 343 | if ( procError != osl_Process_E_None ) |
| 344 | fprintf(stderrstderr, "%s: starting preprocessor failed\n", pOptions->getProgramName().getStr()); |
| 345 | else |
| 346 | fprintf(stderrstderr, "%s: preprocessing %s%s failed\n", |
| 347 | pOptions->getProgramName().getStr(), |
| 348 | pathname == 0 ? "" : "file ", fileName.getStr()); |
| 349 | |
| 350 | osl_freeProcessHandle(hProcess); |
| 351 | rtl_freeMemory(pCmdArgs); |
| 352 | exit(hInfo.Code ? hInfo.Code : 99); |
| 353 | } |
| 354 | osl_freeProcessHandle(hProcess); |
| 355 | rtl_freeMemory(pCmdArgs); |
| 356 | |
| 357 | if (unlink(tmpFile.getStr()) != 0) |
| 358 | { |
| 359 | fprintf(stderrstderr, "%s: Could not remove cpp input file %s\n", |
| 360 | pOptions->getProgramName().getStr(), tmpFile.getStr()); |
| 361 | exit(99); |
| 362 | } |
| 363 | |
| 364 | if ( pOptions->isValid("-E") ) |
| 365 | { |
| 366 | if (unlink(preprocFile.getStr()) != 0) |
| 367 | { |
| 368 | fprintf(stderrstderr, "%s: Could not remove parser input file %s\n", |
| 369 | pOptions->getProgramName().getStr(), preprocFile.getStr()); |
| 370 | exit(99); |
| 371 | } |
| 372 | exit(0); |
| 373 | } |
| 374 | |
| 375 | // parse file |
| 376 | yyin = fopen(preprocFile.getStr(), "r"); |
| 377 | if (yyin == NULL__null) |
| 378 | { |
| 379 | fprintf(stderrstderr, "%s: Could not open cpp output file %s\n", |
| 380 | pOptions->getProgramName().getStr(), preprocFile.getStr()); |
| 381 | exit(99); |
| 382 | } |
| 383 | |
| 384 | //yydebug = 0 no trace information |
| 385 | //yydebug = 1 parser produce trace information |
| 386 | yydebug = 0; |
| 387 | |
| 388 | sal_Int32 nErrors = yyparse(); |
Value stored to 'nErrors' during its initialization is never read | |
| 389 | nErrors = idlc()->getErrorCount(); |
| 390 | |
| 391 | fclose(yyin); |
| 392 | if (unlink(preprocFile.getStr()) != 0) |
| 393 | { |
| 394 | fprintf(stderrstderr, "%s: Could not remove parser input file %s\n", |
| 395 | pOptions->getProgramName().getStr(), preprocFile.getStr()); |
| 396 | exit(99); |
| 397 | } |
| 398 | |
| 399 | return nErrors; |
| 400 | } |
| 401 | |
| 402 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |