From 60b39594f53fffdccf2f37bd86ee63d3c144ff65 Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Tue, 30 Mar 2004 15:47:20 +0000 Subject: INTEGRATION: CWS sb14 (1.12.48); FILE MERGED 2004/03/01 12:59:25 sb 1.12.48.1: #i21150# Added optional interface inheritance; added -stdin switch; do not warn about bad member names of com.sun.star.uno.Uik; some general clean up and added const qualifiers. --- idlc/source/idlccompile.cxx | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'idlc') diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx index 165c461b0..4891b1190 100644 --- a/idlc/source/idlccompile.cxx +++ b/idlc/source/idlccompile.cxx @@ -2,9 +2,9 @@ * * $RCSfile: idlccompile.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: hr $ $Date: 2003-03-26 12:11:08 $ + * last change: $Author: rt $ $Date: 2004-03-30 16:47:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -213,16 +213,16 @@ OString makeTempName(const OString& prefix, const OString& postfix) return OString(tmpFilePattern); } -sal_Bool copyFile(const OString& sourceFile, const OString& targetFile) +sal_Bool copyFile(const OString* source, const OString& target) { sal_Bool bRet = sal_True; - FILE* pSource = fopen(sourceFile.getStr(), "rb"); + FILE* pSource = source == 0 ? stdin : fopen(source->getStr(), "rb"); if ( !pSource ) return sal_False; - FILE* pTarget = fopen(targetFile.getStr(), "wb"); + FILE* pTarget = fopen(target.getStr(), "wb"); if ( !pTarget ) { @@ -241,14 +241,18 @@ sal_Bool copyFile(const OString& sourceFile, const OString& targetFile) { if ( (writeSize = fwrite(pBuffer, 1, readSize, pTarget)) != readSize || ferror(pTarget) ) { - fclose(pSource); + if (source != 0) { + fclose(pSource); + } fclose(pTarget); return sal_False; } } } - fclose(pSource); + if (source != 0) { + fclose(pSource); + } if ( fflush(pTarget) ) bRet = sal_False; fclose(pTarget); @@ -256,16 +260,25 @@ sal_Bool copyFile(const OString& sourceFile, const OString& targetFile) return bRet; } -sal_Int32 SAL_CALL compileFile(const OString& fileName) +sal_Int32 compileFile(const OString * pathname) { // preporcess input file OString tmpFile = makeTempName(OString("idli_"), OString(".idl")); OString preprocFile = makeTempName(OString("idlf_"), OString(".idl")); - if ( !copyFile(fileName, tmpFile) ) + OString fileName; + if (pathname == 0) { + fileName = "stdin"; + } else { + fileName = *pathname; + } + + if ( !copyFile(pathname, tmpFile) ) { - fprintf(stderr, "%s: couldn't copy file '%s' to '%s'\n", - idlc()->getOptions()->getProgramName().getStr(), fileName.getStr(), tmpFile.getStr()); + fprintf(stderr, "%s: could not copy %s%s to %s\n", + idlc()->getOptions()->getProgramName().getStr(), + pathname == 0 ? "" : "file ", fileName.getStr(), + tmpFile.getStr()); exit(99); } @@ -278,7 +291,7 @@ sal_Int32 SAL_CALL compileFile(const OString& fileName) Options* pOptions = idlc()->getOptions(); OString filePath; - sal_uInt32 index = fileName.lastIndexOf(SEPARATOR); + sal_Int32 index = fileName.lastIndexOf(SEPARATOR); if ( index > 0) { @@ -349,7 +362,9 @@ sal_Int32 SAL_CALL compileFile(const OString& fileName) if ( procError != osl_Process_E_None ) fprintf(stderr, "%s: starting preprocessor failed\n", pOptions->getProgramName().getStr()); else - fprintf(stderr, "%s: preprocessing \"%s\" failed\n", pOptions->getProgramName().getStr(), fileName.getStr()); + fprintf(stderr, "%s: preprocessing %s%s failed\n", + pOptions->getProgramName().getStr(), + pathname == 0 ? "" : "file ", fileName.getStr()); unlink(tmpFile.getStr()); unlink(preprocFile.getStr()); -- cgit v1.2.3