for (char *ptr = nameFromURL; *ptr; ptr++)
for (char *ptr = nameFromURL; *ptr; ptr++) {
nsString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *suggestedName ) {    nsString result;    if ( *suggestedName ) {        // Exclude any path information from this!  This is mandatory as        // this suggested name comes from a http response header and could        // try to overwrite c:\config.sys or something.        nsCOMPtr<nsILocalFile> localFile;        nsCAutoString suggestedFileName(suggestedName);        if ( NS_SUCCEEDED( NS_NewLocalFile( nsUnescape(suggestedFileName), PR_FALSE, getter_AddRefs( localFile ) ) ) ) {            // We want base part of name only.            nsXPIDLString baseName;            if ( NS_SUCCEEDED( localFile->GetUnicodeLeafName( getter_Copies( baseName ) ) ) ) {                result = baseName.get();            }        }    } else if ( aChannel ) {        // Get URI from channel and spec from URI.        nsCOMPtr<nsIURI> uri;        nsresult rv = aChannel->GetURI( getter_AddRefs( uri ) );        if ( NS_SUCCEEDED( rv ) && uri ) {            // Try to get URL from URI.            nsCOMPtr<nsIFileURL> fileurl( do_QueryInterface( uri, &rv ) );            if ( NS_SUCCEEDED( rv ) && fileurl)            {              nsCOMPtr<nsIFile> localeFile;              rv = fileurl->GetFile(getter_AddRefs(localeFile));              if ( NS_SUCCEEDED( rv ) && localeFile)              {                nsXPIDLString baseName;                if ( NS_SUCCEEDED( localeFile->GetUnicodeLeafName( getter_Copies( baseName ) ) ) ) {                  result = baseName.get();                  return result;                }              }            }            nsCOMPtr<nsIURL> url( do_QueryInterface( uri, &rv ) );            if ( NS_SUCCEEDED( rv ) && url ) {                char *nameFromURL = 0;                rv = url->GetFileName( &nameFromURL );                if ( NS_SUCCEEDED( rv ) && nameFromURL ) {                    // Unescape the file name (GetFileName escapes it).                    nsUnescape( nameFromURL );                    //make sure nameFromURL only contains ascii,                    //otherwise we have no idea about urlname's original charset, suggest nothing                    for (char *ptr = nameFromURL; *ptr; ptr++)                      if (*ptr & '\200')                        break;                    if (!(*ptr))                      result = NS_ConvertASCIItoUCS2(nameFromURL).GetUnicode();                    nsCRT::free( nameFromURL );                }            }        }    }    return result;}