• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why isn't NSString's caseInsensitiveCompare working correctly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why isn't NSString's caseInsensitiveCompare working correctly?


  • Subject: Why isn't NSString's caseInsensitiveCompare working correctly?
  • From: Wesley Spikes <email@hidden>
  • Date: Sat, 21 Mar 2009 11:26:19 -0700

Odds are, it's a bug that is based entirely in my code, but it's bugging me
now, and I've hit a road block mentally. Any help provided would be greatly
appreciated.

Please excuse the crypticness of this message, but I'm only able to disclose
the parts of the code in question.

The basic overview of what's happening in the code is [classInst
findIndexOfFilename:inData:] is being called, with the filename being passed
in from a directory enumeration. A manual browsing through the data makes it
look like all aspects of it appear like it should work.

If anything further needs to be known, just let me know, I'll likely be able
to provide.

At the moment, I'm pretty sure it should work by the looks of it. What's
really bothersome about it to me is that the output of the first error shows
that the entry at 10:28:17.401 is the only entry that is outputted by
findIndexOfFilename:inData:, and none of the subsequent entries are
presented as having been checked. *scratches head*

==== First failed output record in the XCode console
[Session started at 2009-03-21 10:28:17 -0700.]
2009-03-21 10:28:17.400 IX2[52319:10b] "Contents"
2009-03-21 10:28:17.401 IX2[52319:10b] "Contents" != "Contents"
2009-03-21 10:28:17.407 IX2[52319:10b] Hmm, it appears that "Contents" is
not in passed data pointer. pname=<<cut path>>/Contents

==== The code to find the index -- before this is called, the caller is
currently calling NSLog(@"%@", fn);
- (int) findIndexOfFilename:(NSString*)fn
                     inData:(S_KH_DATA*)data
{
  int ctr       = 0;
  NSString *s;

  // this would indicate a failure in our build process
  assert( data[0].filename != NULL );

  do {
    s = [NSString stringWithCString:data[ctr].filename
encoding:NSUTF8StringEncoding];
    if( [fn length] != [s length] ) continue; // don't go and do a full
compare if diff lens
    if( [fn caseInsensitiveCompare:s] ) break;
    NSLog(@"%@ != %@", fn, s);
  } while( data[++ctr].filename != NULL );

  if( data[ctr].filename != NULL )
    return ctr;
  return -1;
}

==== The structure that is the data[x]
typedef struct _S_KH_DATA
  {
    uint8_t   fs_type;                      // 1 is directory, 2 is plain
file, 3 is executable file, 0 is unset/ignore
    char     *filename;                     // filename is the name of the
filesystem
    uint8_t   hash[SHA512_DIGEST_LENGTH];   // sha2-512
  } S_KH_DATA;

==== The data being passed (first entries only, abbreviated)
S_KH_DATA kh_data [] = {
  { KHD_TYPE_DIRECTORY, "", 0 },
  { KHD_TYPE_DIRECTORY, "Contents", 0 },
  { KHD_TYPE_DIRECTORY, "Contents/MacOS", 0 },
  { KHD_TYPE_PLAIN_FILE, "Contents/Info.plist", { 0x82, ..., 0xe3, } },
  ...
  { 0, NULL, 0 },
};


--
Wesley Spikes
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why isn't NSString's caseInsensitiveCompare working correctly?
      • From: Julien Jalon <email@hidden>
  • Prev by Date: Re: What is -launchApplication:'s "name of the application"
  • Next by Date: nstableview **very** basic question
  • Previous by thread: Re: What is -launchApplication:'s "name of the application"
  • Next by thread: Re: Why isn't NSString's caseInsensitiveCompare working correctly?
  • Index(es):
    • Date
    • Thread