Kaydet (Commit) 7ed36e0d authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#441992 Uncaught exception

Change-Id: Ibd07b854bbcf9d9e83236669addfd61fe639882a
üst b536f9ae
...@@ -35,131 +35,132 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) ...@@ -35,131 +35,132 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
} }
Options options(argv[0]); Options options(argv[0]);
sal_Int32 nErrors = 0;
try try
{ {
if (!options.initOptions(args)) if (!options.initOptions(args))
return (0); return (0);
}
catch(const IllegalArgument& e)
{
fprintf(stderr, "Illegal argument: %s\n%s",
e.m_message.getStr(),
options.prepareVersion().getStr());
return (99);
}
setIdlc(&options);
sal_Int32 nErrors = 0; setIdlc(&options);
if (options.readStdin()) {
if ( !options.quiet() ) if (options.readStdin()) {
fprintf( if ( !options.quiet() )
stdout, "%s: Compiling stdin\n", fprintf(
options.getProgramName().getStr()); stdout, "%s: Compiling stdin\n",
nErrors = compileFile(0); options.getProgramName().getStr());
if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) { nErrors = compileFile(0);
fprintf( if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) {
stdout, "%s: detected %lu warnings compiling stdin\n", fprintf(
options.getProgramName().getStr(), stdout, "%s: detected %lu warnings compiling stdin\n",
sal::static_int_cast< unsigned long >( options.getProgramName().getStr(),
idlc()->getWarningCount())); sal::static_int_cast< unsigned long >(
} idlc()->getWarningCount()));
OString outputUrl; }
if (options.isValid("-O")) { OString outputUrl;
outputUrl = convertToFileUrl(options.getOption("-O")); if (options.isValid("-O")) {
if (!outputUrl.endsWith("/")) { outputUrl = convertToFileUrl(options.getOption("-O"));
outputUrl += "/"; if (!outputUrl.endsWith("/")) {
outputUrl += "/";
}
outputUrl += "stdin.urd";
} else {
outputUrl = convertToFileUrl("stdin.urd");
} }
outputUrl += "stdin.urd"; if (nErrors > 0) {
} else { removeIfExists(outputUrl);
outputUrl = convertToFileUrl("stdin.urd"); } else {
nErrors = produceFile(outputUrl, 0);
}
idlc()->reset();
} }
if (nErrors > 0) { StringVector const & files = options.getInputFiles();
removeIfExists(outputUrl); if ( options.verbose() )
} else { {
nErrors = produceFile(outputUrl, 0); fprintf( stdout, "%s: compiling %i source files ... \n",
options.getProgramName().getStr(), (int)files.size() );
fflush( stdout );
} }
idlc()->reset(); for (StringVector::const_iterator i(files.begin());
} i != files.end() && nErrors == 0; ++i)
StringVector const & files = options.getInputFiles(); {
if ( options.verbose() ) OString sysFileName( convertToAbsoluteSystemPath(*i) );
{
fprintf( stdout, "%s: compiling %i source files ... \n",
options.getProgramName().getStr(), (int)files.size() );
fflush( stdout );
}
for (StringVector::const_iterator i(files.begin());
i != files.end() && nErrors == 0; ++i)
{
OString sysFileName( convertToAbsoluteSystemPath(*i) );
if ( !options.quiet() )
fprintf(stdout, "Compiling: %s\n",
(*i).getStr());
nErrors = compileFile(&sysFileName);
if ( idlc()->getWarningCount() && !options.quiet() ) if ( !options.quiet() )
fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n", fprintf(stdout, "Compiling: %s\n",
options.getProgramName().getStr(),
sal::static_int_cast< unsigned long >(
idlc()->getWarningCount()),
(*i).getStr()); (*i).getStr());
nErrors = compileFile(&sysFileName);
// prepare output file name
OString const strippedFileName( if ( idlc()->getWarningCount() && !options.quiet() )
sysFileName.copy(sysFileName.lastIndexOf(SEPARATOR) + 1)); fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n",
OString outputFile; options.getProgramName().getStr(),
if ( options.isValid("-O") ) sal::static_int_cast< unsigned long >(
{ idlc()->getWarningCount()),
outputFile = (options.getOption("-O")); (*i).getStr());
if (!outputFile.endsWith("/")) {
outputFile += OString('/'); // prepare output file name
OString const strippedFileName(
sysFileName.copy(sysFileName.lastIndexOf(SEPARATOR) + 1));
OString outputFile;
if ( options.isValid("-O") )
{
outputFile = (options.getOption("-O"));
if (!outputFile.endsWith("/")) {
outputFile += OString('/');
}
outputFile += strippedFileName.replaceAt(
strippedFileName.getLength() -3 , 3, "urd");
} else {
outputFile =
sysFileName.replaceAt(sysFileName.getLength() -3 , 3, "urd");
} }
outputFile += strippedFileName.replaceAt( OString const outputFileUrl = convertToFileUrl(outputFile);
strippedFileName.getLength() -3 , 3, "urd");
} else {
outputFile =
sysFileName.replaceAt(sysFileName.getLength() -3 , 3, "urd");
}
OString const outputFileUrl = convertToFileUrl(outputFile);
OString depFileUrl; OString depFileUrl;
if (options.isValid("-M")) { if (options.isValid("-M")) {
depFileUrl = convertToFileUrl(options.getOption("-M")); depFileUrl = convertToFileUrl(options.getOption("-M"));
if (!depFileUrl.endsWith("/")) { if (!depFileUrl.endsWith("/")) {
depFileUrl += "/"; depFileUrl += "/";
}
depFileUrl += strippedFileName.replaceAt(
strippedFileName.getLength() -3 , 3, "d");
} }
depFileUrl += strippedFileName.replaceAt(
strippedFileName.getLength() -3 , 3, "d");
}
if ( nErrors ) { if ( nErrors ) {
if (options.isValid("-M")) { if (options.isValid("-M")) {
removeIfExists(depFileUrl); removeIfExists(depFileUrl);
}
removeIfExists(outputFileUrl);
} else {
sPair_t const pair(depFileUrl, outputFile);
nErrors = produceFile(outputFileUrl,
(options.isValid("-M")) ? &pair : 0);
} }
removeIfExists(outputFileUrl);
} else {
sPair_t const pair(depFileUrl, outputFile);
nErrors = produceFile(outputFileUrl,
(options.isValid("-M")) ? &pair : 0);
}
idlc()->reset(); idlc()->reset();
} }
if ( nErrors > 0 ) if ( nErrors > 0 )
{ {
fprintf(stderr, "%s: detected %ld errors%s", fprintf(stderr, "%s: detected %ld errors%s",
options.getProgramName().getStr(),
sal::static_int_cast< long >(nErrors),
options.prepareVersion().getStr());
} else
{
if ( options.verbose() )
fprintf(stdout, "%s: returned successful%s",
options.getProgramName().getStr(), options.getProgramName().getStr(),
sal::static_int_cast< long >(nErrors),
options.prepareVersion().getStr()); options.prepareVersion().getStr());
} else
{
if ( options.verbose() )
fprintf(stdout, "%s: returned successful%s",
options.getProgramName().getStr(),
options.prepareVersion().getStr());
}
} catch(const IllegalArgument& e)
{
fprintf(stderr, "Illegal argument: %s\n%s",
e.m_message.getStr(),
options.prepareVersion().getStr());
return (99);
} }
return nErrors; return nErrors;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment