summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-23 16:21:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-10-24 09:24:51 +0100
commit7ed36e0d7beb71667e70dcf256a3a610e839073b (patch)
tree759a5cf9a3ef47c155cf6514fa340b938dbb576d /idlc
parentb536f9ae625cf4e91066c1263f4814a356d0a41e (diff)
coverity#441992 Uncaught exception
Change-Id: Ibd07b854bbcf9d9e83236669addfd61fe639882a
Diffstat (limited to 'idlc')
-rw-r--r--idlc/source/idlcmain.cxx211
1 files changed, 106 insertions, 105 deletions
diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx
index 52e05f0eb247..270bf7a193a1 100644
--- a/idlc/source/idlcmain.cxx
+++ b/idlc/source/idlcmain.cxx
@@ -35,131 +35,132 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
}
Options options(argv[0]);
+ sal_Int32 nErrors = 0;
+
try
{
if (!options.initOptions(args))
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;
- if (options.readStdin()) {
- if ( !options.quiet() )
- fprintf(
- stdout, "%s: Compiling stdin\n",
- options.getProgramName().getStr());
- nErrors = compileFile(0);
- if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) {
- fprintf(
- stdout, "%s: detected %lu warnings compiling stdin\n",
- options.getProgramName().getStr(),
- sal::static_int_cast< unsigned long >(
- idlc()->getWarningCount()));
- }
- OString outputUrl;
- if (options.isValid("-O")) {
- outputUrl = convertToFileUrl(options.getOption("-O"));
- if (!outputUrl.endsWith("/")) {
- outputUrl += "/";
+ setIdlc(&options);
+
+ if (options.readStdin()) {
+ if ( !options.quiet() )
+ fprintf(
+ stdout, "%s: Compiling stdin\n",
+ options.getProgramName().getStr());
+ nErrors = compileFile(0);
+ if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) {
+ fprintf(
+ stdout, "%s: detected %lu warnings compiling stdin\n",
+ options.getProgramName().getStr(),
+ sal::static_int_cast< unsigned long >(
+ idlc()->getWarningCount()));
+ }
+ OString outputUrl;
+ if (options.isValid("-O")) {
+ outputUrl = convertToFileUrl(options.getOption("-O"));
+ if (!outputUrl.endsWith("/")) {
+ outputUrl += "/";
+ }
+ outputUrl += "stdin.urd";
+ } else {
+ outputUrl = convertToFileUrl("stdin.urd");
}
- outputUrl += "stdin.urd";
- } else {
- outputUrl = convertToFileUrl("stdin.urd");
+ if (nErrors > 0) {
+ removeIfExists(outputUrl);
+ } else {
+ nErrors = produceFile(outputUrl, 0);
+ }
+ idlc()->reset();
}
- if (nErrors > 0) {
- removeIfExists(outputUrl);
- } else {
- nErrors = produceFile(outputUrl, 0);
+ StringVector const & files = options.getInputFiles();
+ if ( options.verbose() )
+ {
+ fprintf( stdout, "%s: compiling %i source files ... \n",
+ options.getProgramName().getStr(), (int)files.size() );
+ fflush( stdout );
}
- idlc()->reset();
- }
- StringVector const & files = options.getInputFiles();
- if ( options.verbose() )
- {
- 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);
+ for (StringVector::const_iterator i(files.begin());
+ i != files.end() && nErrors == 0; ++i)
+ {
+ OString sysFileName( convertToAbsoluteSystemPath(*i) );
- if ( idlc()->getWarningCount() && !options.quiet() )
- fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n",
- options.getProgramName().getStr(),
- sal::static_int_cast< unsigned long >(
- idlc()->getWarningCount()),
+ if ( !options.quiet() )
+ fprintf(stdout, "Compiling: %s\n",
(*i).getStr());
-
- // 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('/');
+ nErrors = compileFile(&sysFileName);
+
+ if ( idlc()->getWarningCount() && !options.quiet() )
+ fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n",
+ options.getProgramName().getStr(),
+ sal::static_int_cast< unsigned long >(
+ idlc()->getWarningCount()),
+ (*i).getStr());
+
+ // 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(
- strippedFileName.getLength() -3 , 3, "urd");
- } else {
- outputFile =
- sysFileName.replaceAt(sysFileName.getLength() -3 , 3, "urd");
- }
- OString const outputFileUrl = convertToFileUrl(outputFile);
+ OString const outputFileUrl = convertToFileUrl(outputFile);
- OString depFileUrl;
- if (options.isValid("-M")) {
- depFileUrl = convertToFileUrl(options.getOption("-M"));
- if (!depFileUrl.endsWith("/")) {
- depFileUrl += "/";
+ OString depFileUrl;
+ if (options.isValid("-M")) {
+ depFileUrl = convertToFileUrl(options.getOption("-M"));
+ if (!depFileUrl.endsWith("/")) {
+ depFileUrl += "/";
+ }
+ depFileUrl += strippedFileName.replaceAt(
+ strippedFileName.getLength() -3 , 3, "d");
}
- depFileUrl += strippedFileName.replaceAt(
- strippedFileName.getLength() -3 , 3, "d");
- }
- if ( nErrors ) {
- if (options.isValid("-M")) {
- removeIfExists(depFileUrl);
+ if ( nErrors ) {
+ if (options.isValid("-M")) {
+ 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 )
- {
- 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",
+ if ( nErrors > 0 )
+ {
+ 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.prepareVersion().getStr());
+ }
+ } catch(const IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal argument: %s\n%s",
+ e.m_message.getStr(),
+ options.prepareVersion().getStr());
+ return (99);
}
+
return nErrors;
}