bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug #3301] NSScanner can't scan ']' properly ?


From: nobody
Subject: [Bug #3301] NSScanner can't scan ']' properly ?
Date: Tue, 22 Apr 2003 08:52:35 -0400

=================== BUG #3301: FULL BUG SNAPSHOT ===================
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3301&group_id=99

Submitted by: yjchen                  Project: GNUstep                      
Submitted on: Tue 04/22/2003 at 08:52
Category:  Base/Foundation            Severity:  5 - Major                  
Bug Group:  Bug                       Resolution:  None                     
Assigned to:  None                    Status:  Open                         

Summary:  NSScanner can't scan ']' properly ? 

Original Submission:  I try to use NSScanner to count the number of '{', '}', 
'[', ']', '\n', etc., 
and the result is unexpected. 
It happens specially for ']' and ')'. 
Below is a test code. 
Did I do something wrong ? 
I also try scanString rather than scanUpToString, and it got worse. 
Is there any  limitation for NSScanner, such as special character ? 

Thanx. 

Yen-Ju 

#include <AppKit/AppKit.h> 

int main(int argc, const char *argv[]) 
{ 
  NSAutoreleasePool *pool = [NSAutoreleasePool new]; 

  NSString *string = [NSString stringWithContentsOfFile: @"NSMatrix.m"]; 
  NSScanner *scanner = [NSScanner scannerWithString: string]; 
  NSString *ch = @"["; 
  BOOL result = YES; 
  unsigned location = 0; 
  unsigned total = 0; 

  while(result) 
   { 
     [scanner setScanLocation: location]; 
     result = [scanner scanUpToString: ch intoString: NULL]; 
     location = [scanner scanLocation]; 
     if (location >= [string length]) 
       break; 
     location++; 
     total++ 
   } 

  NSLog(@"total %d", total); 

  RELEASE(pool); 
  return 0; 
} 




No Followups Have Been Posted


CC list is empty


No files currently attached


For detailed info, follow this link:
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3301&group_id=99




reply via email to

[Prev in Thread] Current Thread [Next in Thread]