cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp
branchRCL_3
changeset 64 1934667b0e2b
parent 61 269724087bed
child 72 4b59561a31c0
--- a/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Tue Sep 14 21:37:10 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Wed Sep 15 12:23:51 2010 +0300
@@ -254,8 +254,8 @@
     if(!iCmd.Eos())
         {
         chr = iCmd.Peek();
-        while(!iCmd.Eos() && chr != ',' && !chr.IsSpace() && !chr.IsControl())
-            {// Stop at any of those chars: comma, space or control
+        while(!iCmd.Eos() && chr != ',' && !chr.IsControl())
+            {// Stop at any comma or control character
             iCmd.Inc();
             chr = iCmd.Peek();
             }
@@ -264,12 +264,30 @@
     // Extract the token at this point            
     TPtrC8 retVal = iCmd.MarkedToken();
     
+	//ignore all space characters at the end
+    if(retVal.Length() > 1)
+    {
+        TInt pos = retVal.Length() - 1; 
+        for ( ; pos >= 0; pos-- )
+            {
+            const TChar ch( retVal[pos] );
+            if( !ch.IsSpace() )
+                {
+                break;
+                }
+            }
+        retVal.Set( retVal.Mid( 0, pos + 1 ) );
+    }
+    
+    
     // Skip comma, space and control chars
-    while(!iCmd.Eos() && (chr == ',' || chr.IsSpace() || chr.IsControl()))
-        {
-        iCmd.Inc();
-        chr = iCmd.Peek();
-        }
+    do
+      {
+      iCmd.Inc();
+      chr = iCmd.Peek();
+      }
+    while(!iCmd.Eos() && (chr.IsSpace() || chr.IsControl()));
+    
     TRACE_FUNC_EXIT
     return retVal;
     }
@@ -310,8 +328,21 @@
         }
     else
         {
-        TLex8 lex(param);
-        retVal = lex.Val(aValue);
+        //check if param contains only digits - TLex doesn't do that
+        for(TInt pos = param.Length() - 1; pos >= 0; pos--)
+            {
+            if(( param[pos] < '0' ) || ( param[pos] > '9' ))
+                {
+                retVal = KErrArgument;
+                break;
+                }
+            }
+        
+        if(retVal == KErrNone)
+            {
+            TLex8 lex(param);
+            retVal = lex.Val(aValue);
+            }
         }
     TRACE_FUNC_EXIT
     return retVal;