not part of the build. these directories are probably going to be removed shortly.
This commit is contained in:
Родитель
2869e41340
Коммит
36dd396e4d
|
@ -20,13 +20,13 @@
|
|||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = y:/mozilla
|
||||
srcdir = y:/mozilla/htmlparser/tests/html
|
||||
VPATH = y:/mozilla/htmlparser/tests/html
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = TestParser.exe
|
||||
PROGRAM = TestParser$(BIN_SUFFIX)
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = y:/mozilla
|
||||
srcdir = y:/mozilla/htmlparser/tests/logparse
|
||||
VPATH = y:/mozilla/htmlparser/tests/logparse
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = logparse.exe
|
||||
PROGRAM = logparse$(BIN_SUFFIX)
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
|
@ -44,5 +44,7 @@ LIBS = \
|
|||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../../src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -39,14 +39,19 @@
|
|||
#include "nsXPCOM.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIURI.h"
|
||||
#include "CNavDTD.h"
|
||||
#include <fstream.h>
|
||||
|
||||
// Class IID's
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
// Interface IID's
|
||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||
|
@ -54,88 +59,98 @@ static NS_DEFINE_IID(kILoggingSinkIID, NS_ILOGGING_SINK_IID);
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static const char* kWorkingDir = "s:/mozilla/htmlparser/tests/logparse";
|
||||
static const char* kWorkingDir = "./";
|
||||
|
||||
nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineFilename) {
|
||||
nsresult result=NS_OK;
|
||||
nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineFilename)
|
||||
{
|
||||
if (!aSourceFilename || !aBaselineFilename)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if(aSourceFilename && aBaselineFilename) {
|
||||
nsresult rv;
|
||||
|
||||
fstream theInputStream(aSourceFilename,ios::in | ios::nocreate);
|
||||
// Create a parser
|
||||
nsCOMPtr<nsIParser> parser(do_CreateInstance(kParserCID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
cout << "Unable to create a parser (" << rv << ")" <<endl;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create a parser
|
||||
nsIParser* parser;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser);
|
||||
if (NS_OK != rv) {
|
||||
cout << "Unable to create a parser (" << rv << ")" <<endl;
|
||||
return -1;
|
||||
}
|
||||
// Create a sink
|
||||
nsCOMPtr<nsILoggingSink> sink(do_CreateInstance(kLoggingSinkCID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
cout << "Unable to create a sink (" << rv << ")" <<endl;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create a sink
|
||||
nsILoggingSink* sink;
|
||||
rv = nsComponentManager::CreateInstance(kLoggingSinkCID,nsnull,kILoggingSinkIID,(void**)&sink);
|
||||
if (NS_OK != rv) {
|
||||
cout << "Unable to create a sink (" << rv << ")" <<endl;
|
||||
return -1;
|
||||
}
|
||||
nsCOMPtr<nsILocalFile> localfile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
{
|
||||
fstream theOutputStream(aBaselineFilename,ios::out);
|
||||
sink->SetOutputStream(theOutputStream);
|
||||
localfile->InitWithNativePath(nsDependentCString(aSourceFilename));
|
||||
nsCOMPtr<nsIURI> inputURI;
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = ioService->NewFileURI(localfile, getter_AddRefs(inputURI));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
localfile->InitWithNativePath(nsDependentCString(aBaselineFilename));
|
||||
PRFileDesc *outputfile;
|
||||
localfile->OpenNSPRFileDesc(0660, PR_WRONLY | PR_CREATE_FILE, &outputfile);
|
||||
sink->SetOutputStream(outputfile);
|
||||
|
||||
// Parse the document, having the sink write the data to fp
|
||||
nsIDTD* dtd = nsnull;
|
||||
NS_NewNavHTMLDTD(&dtd);
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetContentSink(sink);
|
||||
result = parser->Parse(theInputStream);
|
||||
NS_RELEASE(parser);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
// Parse the document, having the sink write the data to fp
|
||||
nsIDTD* dtd = nsnull;
|
||||
NS_NewNavHTMLDTD(&dtd);
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
}
|
||||
return (NS_OK == result) ? 0 : -1;
|
||||
rv = parser->Parse(inputURI, 0, PR_FALSE, 0, eDTDMode_unknown);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PRBool CompareFiles(const char* aFilename1, const char* aFilename2) {
|
||||
PRBool result=PR_TRUE;
|
||||
PRBool result=PR_TRUE;
|
||||
|
||||
fstream theFirstStream(aFilename1,ios::in | ios::nocreate);
|
||||
fstream theSecondStream(aFilename2,ios::in | ios::nocreate);
|
||||
|
||||
PRBool done=PR_FALSE;
|
||||
char ch1,ch2;
|
||||
fstream theFirstStream(aFilename1,ios::in | ios::nocreate);
|
||||
fstream theSecondStream(aFilename2,ios::in | ios::nocreate);
|
||||
|
||||
PRBool done=PR_FALSE;
|
||||
char ch1,ch2;
|
||||
|
||||
while(!done) {
|
||||
theFirstStream >> ch1;
|
||||
theSecondStream >> ch2;
|
||||
if(ch1!=ch2) {
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
done=PRBool((theFirstStream.ipfx(1)==0) || (theSecondStream.ipfx(1)==0));
|
||||
}
|
||||
return result;
|
||||
while(!done) {
|
||||
theFirstStream >> ch1;
|
||||
theSecondStream >> ch2;
|
||||
if(ch1!=ch2) {
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
done=PRBool((theFirstStream.ipfx(1)==0) || (theSecondStream.ipfx(1)==0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void ComputeTempFilename(const char* anIndexFilename, char* aTempFilename) {
|
||||
if(anIndexFilename) {
|
||||
strcpy(aTempFilename,anIndexFilename);
|
||||
char* pos=strrchr(aTempFilename,'\\');
|
||||
if(!pos)
|
||||
pos=strrchr(aTempFilename,'/');
|
||||
if(pos) {
|
||||
(*pos)=0;
|
||||
strcat(aTempFilename,"/temp.blx");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//fall back to our last resort...
|
||||
strcpy(aTempFilename,"c:/windows/temp/temp.blx");
|
||||
if(anIndexFilename) {
|
||||
strcpy(aTempFilename,anIndexFilename);
|
||||
char* pos=strrchr(aTempFilename,'\\');
|
||||
if(!pos)
|
||||
pos=strrchr(aTempFilename,'/');
|
||||
if(pos) {
|
||||
(*pos)=0;
|
||||
strcat(aTempFilename,"/temp.blx");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//fall back to our last resort...
|
||||
strcpy(aTempFilename,"c:/windows/temp/temp.blx");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -147,33 +162,33 @@ static const char* kResultMsg[2] = {" failed!"," ok."};
|
|||
|
||||
void ValidateBaselineFiles(const char* anIndexFilename) {
|
||||
|
||||
fstream theIndexFile(anIndexFilename,ios::in | ios::nocreate);
|
||||
char theFilename[500];
|
||||
char theBaselineFilename[500];
|
||||
char theTempFilename[500];
|
||||
PRBool done=PR_FALSE;
|
||||
fstream theIndexFile(anIndexFilename,ios::in | ios::nocreate);
|
||||
char theFilename[500];
|
||||
char theBaselineFilename[500];
|
||||
char theTempFilename[500];
|
||||
PRBool done=PR_FALSE;
|
||||
|
||||
ComputeTempFilename(anIndexFilename,theTempFilename);
|
||||
ComputeTempFilename(anIndexFilename,theTempFilename);
|
||||
|
||||
while(!done) {
|
||||
theIndexFile >> theFilename;
|
||||
theIndexFile >> theBaselineFilename;
|
||||
if(theFilename[0] && theBaselineFilename[0]) {
|
||||
if(0==GenerateBaselineFile(theFilename,theTempFilename)) {
|
||||
PRBool matches=CompareFiles(theTempFilename,theBaselineFilename);
|
||||
cout << theFilename << kResultMsg[matches] << endl;
|
||||
}
|
||||
}
|
||||
theFilename[0]=0;
|
||||
theBaselineFilename[0]=0;
|
||||
done=PRBool(theIndexFile.ipfx(1)==0);
|
||||
}
|
||||
while(!done) {
|
||||
theIndexFile >> theFilename;
|
||||
theIndexFile >> theBaselineFilename;
|
||||
if(theFilename[0] && theBaselineFilename[0]) {
|
||||
if(NS_SUCCEEDED(GenerateBaselineFile(theFilename,theTempFilename))) {
|
||||
PRBool matches=CompareFiles(theTempFilename,theBaselineFilename);
|
||||
cout << theFilename << kResultMsg[matches] << endl;
|
||||
}
|
||||
}
|
||||
theFilename[0]=0;
|
||||
theBaselineFilename[0]=0;
|
||||
done=PRBool(theIndexFile.ipfx(1)==0);
|
||||
}
|
||||
|
||||
|
||||
// Now it's time to compare our output to the baseline...
|
||||
// if(!CompareFiles(aBaselineFilename,aBaselineFilename)){
|
||||
// cout << "File: \"" << aSourceFilename << "\" does not match baseline." << endl;
|
||||
// }
|
||||
// Now it's time to compare our output to the baseline...
|
||||
// if(!CompareFiles(aBaselineFilename,aBaselineFilename)){
|
||||
// cout << "File: \"" << aSourceFilename << "\" does not match baseline." << endl;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -182,46 +197,46 @@ void ValidateBaselineFiles(const char* anIndexFilename) {
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
cout << "Usage: " << kAppName << " [options] [filename]" << endl;
|
||||
cout << " -c [filelist] " << kOption1 << endl;
|
||||
cout << " -g [in] [out] " << kOption2 << endl;
|
||||
return -1;
|
||||
}
|
||||
if (argc < 2) {
|
||||
cout << "Usage: " << kAppName << " [options] [filename]" << endl;
|
||||
cout << " -c [filelist] " << kOption1 << endl;
|
||||
cout << " -g [in] [out] " << kOption2 << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result=0;
|
||||
int result=0;
|
||||
|
||||
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("NS_InitXPCOM2 failed\n");
|
||||
return 1;
|
||||
}
|
||||
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("NS_InitXPCOM2 failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0==strcmp("-c",argv[1])) {
|
||||
if(0==strcmp("-c",argv[1])) {
|
||||
|
||||
if(argc>2) {
|
||||
cout << kOption1 << "..." << endl;
|
||||
if(argc>2) {
|
||||
cout << kOption1 << "..." << endl;
|
||||
|
||||
//Open the master filelist, and read the filenames.
|
||||
//Each line contains a source filename and a baseline filename, separated by a space.
|
||||
ValidateBaselineFiles(argv[2]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filelist missing for -c option -- nothing to do." << endl;
|
||||
}
|
||||
//Open the master filelist, and read the filenames.
|
||||
//Each line contains a source filename and a baseline filename, separated by a space.
|
||||
ValidateBaselineFiles(argv[2]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filelist missing for -c option -- nothing to do." << endl;
|
||||
}
|
||||
|
||||
}
|
||||
else if(0==strcmp("-g",argv[1])) {
|
||||
if(argc>3) {
|
||||
cout << kOption2 << argv[3] << " from " << argv[2] << "..." << endl;
|
||||
GenerateBaselineFile(argv[2],argv[3]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filename(s) missing for -g option -- nothing to do." << endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Unknown options -- nothing to do." << endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if(0==strcmp("-g",argv[1])) {
|
||||
if(argc>3) {
|
||||
cout << kOption2 << argv[3] << " from " << argv[2] << "..." << endl;
|
||||
GenerateBaselineFile(argv[2],argv[3]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filename(s) missing for -g option -- nothing to do." << endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Unknown options -- nothing to do." << endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = y:/mozilla
|
||||
srcdir = y:/mozilla/htmlparser/tests/html
|
||||
VPATH = y:/mozilla/htmlparser/tests/html
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = TestParser.exe
|
||||
PROGRAM = TestParser$(BIN_SUFFIX)
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = y:/mozilla
|
||||
srcdir = y:/mozilla/htmlparser/tests/logparse
|
||||
VPATH = y:/mozilla/htmlparser/tests/logparse
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = logparse.exe
|
||||
PROGRAM = logparse$(BIN_SUFFIX)
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
|
@ -44,5 +44,7 @@ LIBS = \
|
|||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../../src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -39,14 +39,19 @@
|
|||
#include "nsXPCOM.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIURI.h"
|
||||
#include "CNavDTD.h"
|
||||
#include <fstream.h>
|
||||
|
||||
// Class IID's
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
// Interface IID's
|
||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||
|
@ -54,88 +59,98 @@ static NS_DEFINE_IID(kILoggingSinkIID, NS_ILOGGING_SINK_IID);
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static const char* kWorkingDir = "s:/mozilla/htmlparser/tests/logparse";
|
||||
static const char* kWorkingDir = "./";
|
||||
|
||||
nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineFilename) {
|
||||
nsresult result=NS_OK;
|
||||
nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineFilename)
|
||||
{
|
||||
if (!aSourceFilename || !aBaselineFilename)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if(aSourceFilename && aBaselineFilename) {
|
||||
nsresult rv;
|
||||
|
||||
fstream theInputStream(aSourceFilename,ios::in | ios::nocreate);
|
||||
// Create a parser
|
||||
nsCOMPtr<nsIParser> parser(do_CreateInstance(kParserCID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
cout << "Unable to create a parser (" << rv << ")" <<endl;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create a parser
|
||||
nsIParser* parser;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser);
|
||||
if (NS_OK != rv) {
|
||||
cout << "Unable to create a parser (" << rv << ")" <<endl;
|
||||
return -1;
|
||||
}
|
||||
// Create a sink
|
||||
nsCOMPtr<nsILoggingSink> sink(do_CreateInstance(kLoggingSinkCID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
cout << "Unable to create a sink (" << rv << ")" <<endl;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create a sink
|
||||
nsILoggingSink* sink;
|
||||
rv = nsComponentManager::CreateInstance(kLoggingSinkCID,nsnull,kILoggingSinkIID,(void**)&sink);
|
||||
if (NS_OK != rv) {
|
||||
cout << "Unable to create a sink (" << rv << ")" <<endl;
|
||||
return -1;
|
||||
}
|
||||
nsCOMPtr<nsILocalFile> localfile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
{
|
||||
fstream theOutputStream(aBaselineFilename,ios::out);
|
||||
sink->SetOutputStream(theOutputStream);
|
||||
localfile->InitWithNativePath(nsDependentCString(aSourceFilename));
|
||||
nsCOMPtr<nsIURI> inputURI;
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = ioService->NewFileURI(localfile, getter_AddRefs(inputURI));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
localfile->InitWithNativePath(nsDependentCString(aBaselineFilename));
|
||||
PRFileDesc *outputfile;
|
||||
localfile->OpenNSPRFileDesc(0660, PR_WRONLY | PR_CREATE_FILE, &outputfile);
|
||||
sink->SetOutputStream(outputfile);
|
||||
|
||||
// Parse the document, having the sink write the data to fp
|
||||
nsIDTD* dtd = nsnull;
|
||||
NS_NewNavHTMLDTD(&dtd);
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetContentSink(sink);
|
||||
result = parser->Parse(theInputStream);
|
||||
NS_RELEASE(parser);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
// Parse the document, having the sink write the data to fp
|
||||
nsIDTD* dtd = nsnull;
|
||||
NS_NewNavHTMLDTD(&dtd);
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
}
|
||||
return (NS_OK == result) ? 0 : -1;
|
||||
rv = parser->Parse(inputURI, 0, PR_FALSE, 0, eDTDMode_unknown);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PRBool CompareFiles(const char* aFilename1, const char* aFilename2) {
|
||||
PRBool result=PR_TRUE;
|
||||
PRBool result=PR_TRUE;
|
||||
|
||||
fstream theFirstStream(aFilename1,ios::in | ios::nocreate);
|
||||
fstream theSecondStream(aFilename2,ios::in | ios::nocreate);
|
||||
|
||||
PRBool done=PR_FALSE;
|
||||
char ch1,ch2;
|
||||
fstream theFirstStream(aFilename1,ios::in | ios::nocreate);
|
||||
fstream theSecondStream(aFilename2,ios::in | ios::nocreate);
|
||||
|
||||
PRBool done=PR_FALSE;
|
||||
char ch1,ch2;
|
||||
|
||||
while(!done) {
|
||||
theFirstStream >> ch1;
|
||||
theSecondStream >> ch2;
|
||||
if(ch1!=ch2) {
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
done=PRBool((theFirstStream.ipfx(1)==0) || (theSecondStream.ipfx(1)==0));
|
||||
}
|
||||
return result;
|
||||
while(!done) {
|
||||
theFirstStream >> ch1;
|
||||
theSecondStream >> ch2;
|
||||
if(ch1!=ch2) {
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
done=PRBool((theFirstStream.ipfx(1)==0) || (theSecondStream.ipfx(1)==0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void ComputeTempFilename(const char* anIndexFilename, char* aTempFilename) {
|
||||
if(anIndexFilename) {
|
||||
strcpy(aTempFilename,anIndexFilename);
|
||||
char* pos=strrchr(aTempFilename,'\\');
|
||||
if(!pos)
|
||||
pos=strrchr(aTempFilename,'/');
|
||||
if(pos) {
|
||||
(*pos)=0;
|
||||
strcat(aTempFilename,"/temp.blx");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//fall back to our last resort...
|
||||
strcpy(aTempFilename,"c:/windows/temp/temp.blx");
|
||||
if(anIndexFilename) {
|
||||
strcpy(aTempFilename,anIndexFilename);
|
||||
char* pos=strrchr(aTempFilename,'\\');
|
||||
if(!pos)
|
||||
pos=strrchr(aTempFilename,'/');
|
||||
if(pos) {
|
||||
(*pos)=0;
|
||||
strcat(aTempFilename,"/temp.blx");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//fall back to our last resort...
|
||||
strcpy(aTempFilename,"c:/windows/temp/temp.blx");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -147,33 +162,33 @@ static const char* kResultMsg[2] = {" failed!"," ok."};
|
|||
|
||||
void ValidateBaselineFiles(const char* anIndexFilename) {
|
||||
|
||||
fstream theIndexFile(anIndexFilename,ios::in | ios::nocreate);
|
||||
char theFilename[500];
|
||||
char theBaselineFilename[500];
|
||||
char theTempFilename[500];
|
||||
PRBool done=PR_FALSE;
|
||||
fstream theIndexFile(anIndexFilename,ios::in | ios::nocreate);
|
||||
char theFilename[500];
|
||||
char theBaselineFilename[500];
|
||||
char theTempFilename[500];
|
||||
PRBool done=PR_FALSE;
|
||||
|
||||
ComputeTempFilename(anIndexFilename,theTempFilename);
|
||||
ComputeTempFilename(anIndexFilename,theTempFilename);
|
||||
|
||||
while(!done) {
|
||||
theIndexFile >> theFilename;
|
||||
theIndexFile >> theBaselineFilename;
|
||||
if(theFilename[0] && theBaselineFilename[0]) {
|
||||
if(0==GenerateBaselineFile(theFilename,theTempFilename)) {
|
||||
PRBool matches=CompareFiles(theTempFilename,theBaselineFilename);
|
||||
cout << theFilename << kResultMsg[matches] << endl;
|
||||
}
|
||||
}
|
||||
theFilename[0]=0;
|
||||
theBaselineFilename[0]=0;
|
||||
done=PRBool(theIndexFile.ipfx(1)==0);
|
||||
}
|
||||
while(!done) {
|
||||
theIndexFile >> theFilename;
|
||||
theIndexFile >> theBaselineFilename;
|
||||
if(theFilename[0] && theBaselineFilename[0]) {
|
||||
if(NS_SUCCEEDED(GenerateBaselineFile(theFilename,theTempFilename))) {
|
||||
PRBool matches=CompareFiles(theTempFilename,theBaselineFilename);
|
||||
cout << theFilename << kResultMsg[matches] << endl;
|
||||
}
|
||||
}
|
||||
theFilename[0]=0;
|
||||
theBaselineFilename[0]=0;
|
||||
done=PRBool(theIndexFile.ipfx(1)==0);
|
||||
}
|
||||
|
||||
|
||||
// Now it's time to compare our output to the baseline...
|
||||
// if(!CompareFiles(aBaselineFilename,aBaselineFilename)){
|
||||
// cout << "File: \"" << aSourceFilename << "\" does not match baseline." << endl;
|
||||
// }
|
||||
// Now it's time to compare our output to the baseline...
|
||||
// if(!CompareFiles(aBaselineFilename,aBaselineFilename)){
|
||||
// cout << "File: \"" << aSourceFilename << "\" does not match baseline." << endl;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -182,46 +197,46 @@ void ValidateBaselineFiles(const char* anIndexFilename) {
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
cout << "Usage: " << kAppName << " [options] [filename]" << endl;
|
||||
cout << " -c [filelist] " << kOption1 << endl;
|
||||
cout << " -g [in] [out] " << kOption2 << endl;
|
||||
return -1;
|
||||
}
|
||||
if (argc < 2) {
|
||||
cout << "Usage: " << kAppName << " [options] [filename]" << endl;
|
||||
cout << " -c [filelist] " << kOption1 << endl;
|
||||
cout << " -g [in] [out] " << kOption2 << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result=0;
|
||||
int result=0;
|
||||
|
||||
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("NS_InitXPCOM2 failed\n");
|
||||
return 1;
|
||||
}
|
||||
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("NS_InitXPCOM2 failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(0==strcmp("-c",argv[1])) {
|
||||
if(0==strcmp("-c",argv[1])) {
|
||||
|
||||
if(argc>2) {
|
||||
cout << kOption1 << "..." << endl;
|
||||
if(argc>2) {
|
||||
cout << kOption1 << "..." << endl;
|
||||
|
||||
//Open the master filelist, and read the filenames.
|
||||
//Each line contains a source filename and a baseline filename, separated by a space.
|
||||
ValidateBaselineFiles(argv[2]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filelist missing for -c option -- nothing to do." << endl;
|
||||
}
|
||||
//Open the master filelist, and read the filenames.
|
||||
//Each line contains a source filename and a baseline filename, separated by a space.
|
||||
ValidateBaselineFiles(argv[2]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filelist missing for -c option -- nothing to do." << endl;
|
||||
}
|
||||
|
||||
}
|
||||
else if(0==strcmp("-g",argv[1])) {
|
||||
if(argc>3) {
|
||||
cout << kOption2 << argv[3] << " from " << argv[2] << "..." << endl;
|
||||
GenerateBaselineFile(argv[2],argv[3]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filename(s) missing for -g option -- nothing to do." << endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Unknown options -- nothing to do." << endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if(0==strcmp("-g",argv[1])) {
|
||||
if(argc>3) {
|
||||
cout << kOption2 << argv[3] << " from " << argv[2] << "..." << endl;
|
||||
GenerateBaselineFile(argv[2],argv[3]);
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Filename(s) missing for -g option -- nothing to do." << endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cout << kAppName << ": Unknown options -- nothing to do." << endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче