if (!Substring(opt, 0, 2).Equals(NS_LITERAL_CSTRING("--"))) {
if (!Substring(opt, 0, 2).EqualsLiteral("--")) {
int main(int argc, char** argv){#ifdef NS_TRACE_MALLOC    NS_TraceMallocStartupArgs(argc, argv);#endif#ifdef MOZ_JPROF    setupProfilingStuff();#endif    char* xalan = PR_GetEnv("XALAN_DIR");    if (!xalan) {        printHelp();        return 1;    }    nsresult rv;    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);    NS_ENSURE_SUCCESS(rv, rv);    nsCOMPtr<nsIFile> conf, gold, resFile;    rv = setupXalan(xalan, getter_AddRefs(conf), getter_AddRefs(gold),                    getter_AddRefs(resFile));    if (NS_FAILED(rv)) {        NS_ShutdownXPCOM(nsnull);        printHelp();        return -1;    }    //-- handle output stream    ostream* resultOutput = &cout;    ofstream resultFileStream;    int argn = 1;    // skip -- gnu style options    while (argn < argc) {        nsDependentCString opt(argv[argn]);        if (!Substring(opt, 0, 2).Equals(NS_LITERAL_CSTRING("--"))) {            break;        }        ++argn;    }    if (argn < argc) {        nsDependentCString opt(argv[argn]);        if (Substring(opt, 0, 2).Equals(NS_LITERAL_CSTRING("-o"))) {            if (opt.Length() > 2) {                const nsAFlatCString& fname =                     PromiseFlatCString(Substring(opt, 2, opt.Length()-2));                resultFileStream.open(fname.get(), ios::out);            }            else {                ++argn;                if (argn < argc) {                    resultFileStream.open(argv[argn], ios::out);                }            }            if (!resultFileStream) {                cerr << "error opening output file" << endl;                PRBool exists;                if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)                    resFile->Remove(PR_FALSE);                NS_ShutdownXPCOM(nsnull);                return -1;            }            ++argn;            resultOutput = &resultFileStream;        }    }    if (!txXSLTProcessor::init()) {        PRBool exists;        if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)            resFile->Remove(PR_FALSE);        NS_ShutdownXPCOM(nsnull);        return 1;    }    *resultOutput << "<?xml version=\"1.0\"?>\n" <<         "<RDF:RDF xmlns:NC=\"http://home.netscape.com/NC-rdf#\"\n" <<        "         xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">" << endl;    txRDFOut* rdfOut = new txRDFOut(resultOutput);    nsCOMPtr<nsIFile> tempFile;    if (argn < argc) {        // categories are specified        while (argn < argc) {            nsDependentCString cat(argv[argn++]);            rv = conf->AppendNative(cat);            if (NS_SUCCEEDED(rv)) {                rv = gold->AppendNative(cat);                if (NS_SUCCEEDED(rv)) {                    runCategory(conf, gold, resFile, rdfOut);                    rv = gold->GetParent(getter_AddRefs(tempFile));                    NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");                    gold = tempFile;                }                rv = conf->GetParent(getter_AddRefs(tempFile));                NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");                conf = tempFile;            }        }    }    else {        // no category specified, do everything        nsCOMPtr<nsISimpleEnumerator> cats;        rv = conf->GetDirectoryEntries(getter_AddRefs(cats));        PRBool hasMore, isDir;        nsCAutoString leaf;        while (NS_SUCCEEDED(cats->HasMoreElements(&hasMore)) && hasMore) {            nsCOMPtr<nsILocalFile> cat;            cats->GetNext(getter_AddRefs(cat));            rv = cat->IsDirectory(&isDir);            if (NS_SUCCEEDED(rv) && isDir) {                rv = cat->GetNativeLeafName(leaf);                if (NS_SUCCEEDED(rv) &&                     !leaf.Equals(NS_LITERAL_CSTRING("CVS"))) {                    rv = gold->AppendNative(leaf);                    if (NS_SUCCEEDED(rv)) {                        runCategory(cat, gold, resFile, rdfOut);                        rv = gold->GetParent(getter_AddRefs(tempFile));                        gold = tempFile;                    }                }            }        }    }    delete rdfOut;    rdfOut = nsnull;    *resultOutput << "</RDF:RDF>" << endl;    PRBool exists;    if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)        resFile->Remove(PR_FALSE);    resultFileStream.close();    txXSLTProcessor::shutdown();    rv = NS_ShutdownXPCOM(nsnull);#ifdef NS_TRACE_MALLOC    NS_TraceMallocShutdown();#endif    NS_ENSURE_SUCCESS(rv, rv);    return 0;}