Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B99F7BBB for ; Tue, 15 Nov 2011 16:12:34 +0000 (UTC) Received: (qmail 40335 invoked by uid 500); 15 Nov 2011 16:12:34 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 40299 invoked by uid 500); 15 Nov 2011 16:12:34 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 40292 invoked by uid 99); 15 Nov 2011 16:12:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 16:12:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 16:12:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 52A3423888E4; Tue, 15 Nov 2011 16:12:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1202270 - in /incubator/ooo/trunk/main/tools: Executable_rscdep.mk bootstrp/rscdep.cxx Date: Tue, 15 Nov 2011 16:12:05 -0000 To: ooo-commits@incubator.apache.org From: pfg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111115161205.52A3423888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pfg Date: Tue Nov 15 16:12:04 2011 New Revision: 1202270 URL: http://svn.apache.org/viewvc?rev=1202270&view=rev Log: i118595 - Removal of the use of getopt() from rscdep. Patch by Andre. Modified: incubator/ooo/trunk/main/tools/Executable_rscdep.mk incubator/ooo/trunk/main/tools/bootstrp/rscdep.cxx Modified: incubator/ooo/trunk/main/tools/Executable_rscdep.mk URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/tools/Executable_rscdep.mk?rev=1202270&r1=1202269&r2=1202270&view=diff ============================================================================== --- incubator/ooo/trunk/main/tools/Executable_rscdep.mk (original) +++ incubator/ooo/trunk/main/tools/Executable_rscdep.mk Tue Nov 15 16:12:04 2011 @@ -55,17 +55,4 @@ $(eval $(call gb_Executable_add_exceptio tools/bootstrp/rscdep \ )) -ifeq ($(OS),WNT) -ifeq ($(HAVE_GETOPT),YES) -$(eval $(call gb_Executable_set_cxxflags,rscdep,\ - $$(CXXFLAGS) \ - -DHAVE_GETOPT \ -)) -else -$(eval $(call gb_Executable_add_linked_libs,rscdep,\ - gnu_getopt \ -)) -endif -endif - # vim: set noet sw=4 ts=4: Modified: incubator/ooo/trunk/main/tools/bootstrp/rscdep.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/tools/bootstrp/rscdep.cxx?rev=1202270&r1=1202269&r2=1202270&view=diff ============================================================================== --- incubator/ooo/trunk/main/tools/bootstrp/rscdep.cxx (original) +++ incubator/ooo/trunk/main/tools/bootstrp/rscdep.cxx Tue Nov 15 16:12:04 2011 @@ -41,16 +41,6 @@ #include "cppdep.hxx" -#if defined WNT -#if !defined HAVE_GETOPT -#define __STDC__ 1 -#define __GNU_LIBRARY__ -#include -#else -#include -#endif -#endif - class RscHrcDep : public CppDep { public: @@ -78,7 +68,6 @@ void RscHrcDep::Execute() int main( int argc, char** argv ) { - int c; char aBuf[255]; char pFileNamePrefix[255]; char pOutputFileName[255]; @@ -89,44 +78,96 @@ int main( int argc, char** argv ) // who needs anything but '/' ? // String aDelim = String(DirEntry::GetAccessDelimiter()); String aDelim = '/'; - RscHrcDep *pDep = new RscHrcDep; - + + // When the options are processed, the non-option arguments are + // collected at the head of the argv array. + // nLastNonOption points to the last of them. + int nLastNonOption (-1); + pOutputFileName[0] = 0; pSrsFileName[0] = 0; for ( int i=1; iAddSearchPath( &aBuf[2] ); - } - if (aBuf[0] == '-' && aBuf[1] == 'I' ) - { - //printf("Include : %s\n", &aBuf[2] ); - pDep->AddSearchPath( &aBuf[2] ); - } - if (aBuf[0] == '@' ) + const sal_Int32 nLength (strlen(aBuf)); + + printf("option %d is [%s] and has length %d\n", i, aBuf, nLength); + + if (nLength == 0) + { + // Is this even possible? + continue; + } + if (aBuf[0] == '-' && nLength > 0) + { + bool bIsKnownOption (true); + // Make a switch on the first character after the - for a + // preselection of the option. + // This is faster then multiple ifs and improves readability. + switch (aBuf[1]) + { + case 'p': + if (nLength>1 && aBuf[2] == '=' ) + strcpy(pFileNamePrefix, &aBuf[3]); + else + bIsKnownOption = false; + break; + + case 'f': + if (nLength>2 && aBuf[2] == 'o' && aBuf[3] == '=' ) + { + strcpy(pOutputFileName, &aBuf[4]); + } + else if (nLength>2 && aBuf[2] == 'p' && aBuf[3] == '=' ) + { + strcpy(pSrsFileName, &aBuf[4]); + String aName( pSrsFileName, gsl_getSystemTextEncoding()); + DirEntry aDest( aName ); + aSrsBaseName = aDest.GetBase(); + } + else + bIsKnownOption = false; + break; + + case 'i': + case 'I': +#ifdef DEBUG_VERBOSE + printf("Include : %s\n", &aBuf[2] ); +#endif + pDep->AddSearchPath( &aBuf[2] ); + break; + + case 'h' : + case 'H' : + case '?' : + printf("RscDep 1.0\n"); + break; + + case 'a' : +#ifdef DEBUG_VERBOSE + printf("option a\n"); +#endif + break; + + case 'l' : +#ifdef DEBUG_VERBOSE + printf("option l with Value %s\n", &aBuf[2] ); +#endif + pDep->AddSource(&aBuf[2]); + break; + + default: + bIsKnownOption = false; + break; + } +#ifdef DEBUG_VERBOSE + if ( ! bIsKnownOption) + printf("Unknown option error [%s]\n", aBuf); +#endif + } + else if (aBuf[0] == '@' ) { ByteString aToken; String aRespName( &aBuf[1], gsl_getSystemTextEncoding()); @@ -172,47 +213,14 @@ int main( int argc, char** argv ) } } } + else + { + // Collect all non-options at the head of argv. + if (++nLastNonOption < i) + argv[nLastNonOption] = argv[i]; + } } - while( 1 ) - { - c = getopt( argc, argv, - "_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\""); - if ( c == -1 ) - break; - - switch( c ) - { - case 0: - break; - case 'a' : -#ifdef DEBUG_VERBOSE - printf("option a\n"); -#endif - break; - - case 'l' : -#ifdef DEBUG_VERBOSE - printf("option l with Value %s\n", optarg ); -#endif - pDep->AddSource( optarg ); - break; - - case 'h' : - case 'H' : - case '?' : - printf("RscDep 1.0\n"); - break; - - default: -#ifdef DEBUG_VERBOSE - printf("Unknown getopt error\n"); -#endif - ; - } - } - - DirEntry aEntry("."); aEntry.ToAbs(); // String aCwd = aEntry.GetName(); @@ -241,8 +249,10 @@ int main( int argc, char** argv ) //fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr()); aOutStream.Open( aFileName, STREAM_WRITE ); + // Process the yet unhandled non-options. These are supposed to + // be names of files on which the target depends. ByteString aString; - if ( optind < argc ) + if (nLastNonOption >= 0) { #ifdef DEBUG_VERBOSE printf("further arguments : "); @@ -251,17 +261,14 @@ int main( int argc, char** argv ) aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); aString += ByteString(" : " ); - while ( optind < argc ) + for (sal_Int32 nIndex=0; nIndex<=nLastNonOption; ++nIndex) { + printf("option at %d is [%s]\n", nIndex, argv[nIndex]); if (!bSource ) { aString += ByteString(" " ); - aString += ByteString( argv[optind]); - pDep->AddSource( argv[optind++]); - } - else - { - optind++; + aString += ByteString( argv[nIndex]); + pDep->AddSource( argv[nIndex]); } } }