From 0e183345d75183c944280a1fe865ce00ff783910 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 23 May 2009 02:36:03 +0000 Subject: [PATCH] Should not be modifying the program's arguments. Problem raised by const correctness in gcc 4.4 and reported by Diego. git-svn-id: http://svn.complang.org/ragel/trunk@872 052ea7fc-9027-0410-9066-f65837a77df0 --- ragel/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ragel/main.cpp b/ragel/main.cpp index 1330cf8..5894c3c 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -336,16 +336,17 @@ void processArgs( int argc, const char **argv, InputData &id ) printStatistics = true; break; case '-': { - char *eq = strchr( pc.paramArg, '=' ); + char *arg = strdup( pc.paramArg ); + char *eq = strchr( arg, '=' ); if ( eq != 0 ) *eq++ = 0; - if ( strcmp( pc.paramArg, "help" ) == 0 ) + if ( strcmp( arg, "help" ) == 0 ) usage(); - else if ( strcmp( pc.paramArg, "version" ) == 0 ) + else if ( strcmp( arg, "version" ) == 0 ) version(); - else if ( strcmp( pc.paramArg, "error-format" ) == 0 ) { + else if ( strcmp( arg, "error-format" ) == 0 ) { if ( eq == 0 ) error() << "expecting '=value' for error-format" << endl; else if ( strcmp( eq, "gnu" ) == 0 ) @@ -355,12 +356,13 @@ void processArgs( int argc, const char **argv, InputData &id ) else error() << "invalid value for error-format" << endl; } - else if ( strcmp( pc.paramArg, "rbx" ) == 0 ) + else if ( strcmp( arg, "rbx" ) == 0 ) rubyImpl = Rubinius; else { error() << "--" << pc.paramArg << " is an invalid argument" << endl; } + free( arg ); break; } -- 2.7.4