donaldp 02/03/20 02:03:21
Modified: cli/src/test/org/apache/avalon/excalibur/cli/test
ClutilTestCase.java
cli/src/java/org/apache/avalon/excalibur/cli
CLArgsParser.java
Log:
Reverse my "bugfix" of yesterday as the original behaviour was how it is
meant to act according to the GNU Getopt "standard"
Revision Changes Path
1.14 +8 -4
jakarta-avalon-excalibur/cli/src/test/org/apache/avalon/excalibur/cli/test/ClutilTestCase.java
Index: ClutilTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/cli/src/test/org/apache/avalon/excalibur/cli/test/ClutilTestCase.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ClutilTestCase.java 19 Mar 2002 11:58:07 -0000 1.13
+++ ClutilTestCase.java 20 Mar 2002 10:03:21 -0000 1.14
@@ -138,16 +138,20 @@
final List clOptions = parser.getArguments();
final int size = clOptions.size();
- assertEquals( "Option count", 2, size );
+ assertEquals( "Option count", 3, size );
final CLOption option0 = (CLOption)clOptions.get( 0 );
assertEquals( "Option Code: " + option0.getId(), TAINT_OPT,
option0.getId() );
assertEquals( "Option Arg: " + option0.getArgument( 0 ),
- "param", option0.getArgument( 0 ) );
+ null, option0.getArgument( 0 ) );
final CLOption option1 = (CLOption)clOptions.get( 1 );
- assertEquals( option1.getId(), ALL_OPT );
- assertEquals( option1.getArgument( 0 ), null );
+ assertEquals( option1.getId(), CLOption.TEXT_ARGUMENT );
+ assertEquals( option1.getArgument( 0 ), "param" );
+
+ final CLOption option2 = (CLOption)clOptions.get( 2 );
+ assertEquals( option2.getId(), ALL_OPT );
+ assertEquals( option2.getArgument( 0 ), null );
}
public void testShortOptArgUnenteredBeforeOtherOpt()
1.15 +1 -24
jakarta-avalon-excalibur/cli/src/java/org/apache/avalon/excalibur/cli/CLArgsParser.java
Index: CLArgsParser.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/cli/src/java/org/apache/avalon/excalibur/cli/CLArgsParser.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CLArgsParser.java 19 Mar 2002 11:57:17 -0000 1.14
+++ CLArgsParser.java 20 Mar 2002 10:03:21 -0000 1.15
@@ -628,30 +628,7 @@
}
else if( STATE_OPTIONAL_ARG == m_state )
{
- if( 0 == m_ch )
- {
- m_lastChar = INVALID;
- m_ch = peekAtChar();
-
- if( '-' == m_ch )
- {
- addOption( m_option );
- m_state = STATE_NORMAL;
- return;
- }
-
- //if the option with optional argument appears
- //at end of command line then make sure it
- //is added and finalized
- if( m_argIndex >= m_args.length )
- {
- addOption( m_option );
- m_state = STATE_NORMAL;
- return;
- }
- }
-
- if( '-' == m_ch )
+ if( '-' == m_ch || 0 == m_ch )
{
getChar(); //consume stray character
addOption( m_option );
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>