Moved xmlUpdater and IExplorerShell to tools folder.

Add xmlApiSorter tool.
Update tool files to point to correct directories.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@254 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
harrybharry 2008-06-23 23:33:01 +00:00
parent ec66a22890
commit 70bfdcf84d
11 changed files with 349 additions and 21 deletions

View File

@ -0,0 +1,176 @@
#include <cstdlib>
#include <iostream>
#include "tinyxml.h"
#include <vector>
#include <algorithm>
using namespace std;
struct xmlname{
TiXmlElement * node;
const char * name;
xmlname(TiXmlElement * n, const char * na) { node = n; name = na;}
};
//true if x1 smaller
bool sortXMLCase(const xmlname & x1, const xmlname & x2) {
return (strcmp(x1.name, x2.name) < 0);
}
inline bool lower(char c) {
return (c >= 'a' && c <= 'z');
}
inline bool match(char c1, char c2) {
if (c1 == c2) return true;
if (lower(c1))
return ((c1-32) == c2);
if (lower(c2))
return ((c2-32) == c1);
return false;
}
//true if x1 smaller
bool sortXML(const xmlname & x1, const xmlname & x2) {
const char * n1 = x1.name, * n2 = x2.name;
int i = 0;
while(match(n2[i], n1[i])) {
if (n1[i] == 0) {
return true; //equal
}
i++;
}
int subs1 = lower(n1[i])?32:0;
int subs2 = lower(n2[i])?32:0;
return ( (n1[i]-subs1) < (n2[i]-subs2) );
}
void merge(TiXmlElement * n1, TiXmlElement * n2);
int main(int argc, char *argv[])
{
const char * file = NULL;
if (argc < 2) {
cout << "Usage: sorter.exe xmlfile.xml" << endl;
return 1;
}
file = argv[1];
TiXmlDocument *pXmlApi = NULL;
pXmlApi = new TiXmlDocument(file);
bool loadOkay = pXmlApi->LoadFile();
if (!loadOkay) return 1;
TiXmlNode *root = pXmlApi->FirstChild("NotepadPlus");
if (!root) {
cout << "NotepadPlus node not found\n";
return 1;
}
TiXmlElement *autoc = root->FirstChildElement("AutoComplete");
if (!autoc) {
cout << "AutoComplete node not found\n";
return 1;
}
const char * langName = autoc->Attribute("language");
TiXmlElement *envNode = autoc->FirstChildElement("Environment");
bool ignoreCase = false;
if (envNode) {
cout << "Found environment settings\n";
const char * ignoreCaseText = envNode->Attribute("ignoreCase");
if (ignoreCaseText) {
ignoreCase = (strcmp(ignoreCaseText, "yes") == 0);
if (ignoreCase) {
cout << "Sorting case insensitive\n";
} else {
cout << "Sorting case sensitive\n";
}
} else {
cout <<"Cannot find attribute \"ignoreCase\", defaulting to case sensitive sort\nConsider adding the node\n";
}
} else {
cout << "No environment settings found, defaulting to case sensitive sort\nConsider adding the node\n";
}
vector<xmlname> words;
for (TiXmlElement *childNode = autoc->FirstChildElement("KeyWord");
childNode ;
childNode = childNode->NextSiblingElement("KeyWord") )
{
const char * name = childNode->Attribute("name");
if (!name) {
cout << "Warning: KeyWord without name!, skipping...\n";
continue;
} else {
int i = 0;
while(name[i] != 0) {
if (!isalnum(name[i]) && name[i] != '_') {
cout << "Warning, keyword " << name << " contains unsupported characters!\n";
break;
}
i++;
}
words.push_back(xmlname(childNode, name));
}
}
if (ignoreCase)
sort(words.begin(), words.end(), sortXML);
else
sort(words.begin(), words.end(), sortXMLCase);
for(size_t i = 1; i < words.size(); i++) {
//merge duplicates
if (!strcmp(words[i].name, words[i-1].name)) {
merge(words[i-1].node, words[i].node);
words.erase(words.begin() + i);
}
}
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "Windows-1252", "" );
doc.LinkEndChild( decl );
TiXmlElement * element = new TiXmlElement( "NotepadPlus" );
doc.LinkEndChild( element );
TiXmlElement * element2 = new TiXmlElement( "AutoComplete" );
element->LinkEndChild( element2 );
if (langName)
element2->SetAttribute("language", langName);
if (envNode)
element2->LinkEndChild(envNode);
for(size_t i = 0; i < words.size(); i++) {
element2->LinkEndChild(words[i].node);
}
doc.SaveFile( file );
return 0;
}
void merge(TiXmlElement * n1, TiXmlElement * n2) {
const char * funcAttr = NULL;
funcAttr = n2->Attribute("func");
if (!funcAttr || !strcmp(funcAttr, "yes")) {
return;
}
n1->SetAttribute("func", "yes");
for (TiXmlElement *childNode = n2->FirstChildElement("Overload");
childNode ;
childNode = childNode->NextSiblingElement("Overload") )
{
n1->LinkEndChild(childNode);
}
return;
}

View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="sorter"
ProjectGUID="{DC172735-2C6B-43D1-BDCD-C725B7ACCA96}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\TinyXml"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/../sorter.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/sorter.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\TinyXml"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/../sorter.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\sorter.cpp">
</File>
<Filter
Name="TinyXml"
Filter="">
<File
RelativePath="..\..\TinyXml\tinystr.cpp">
</File>
<File
RelativePath="..\..\TinyXml\tinyxml.cpp">
</File>
<File
RelativePath="..\..\TinyXml\tinyxmlerror.cpp">
</File>
<File
RelativePath="..\..\TinyXml\tinyxmlparser.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<Filter
Name="TinyXml"
Filter="">
<File
RelativePath="..\..\TinyXml\tinystr.h">
</File>
<File
RelativePath="..\..\TinyXml\tinyxml.h">
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -22,7 +22,7 @@ CFLAGS = -Wall -Os -DNDEBUG
MAINOBJS = xmlUpdater.o
TINYXMLOBJS = tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o
TINYXMLDIR = ../TinyXml
TINYXMLDIR = ../../TinyXml
OBJS = $(MAINOBJS) $(TINYXMLOBJS)

View File

@ -20,7 +20,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;E:\Sources\notepad++\PowerEditor\src\TinyXml&quot;"
AdditionalIncludeDirectories="..\..\TinyXml"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@ -36,11 +36,11 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xmlUpdater.exe"
OutputFile="$(OutDir)/../xmlUpdater.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/xmlUpdater.pdb"
SubSystem="2"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
@ -71,7 +71,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;E:\Sources\notepad++\PowerEditor\src\TinyXml&quot;"
AdditionalIncludeDirectories="..\..\TinyXml"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
@ -82,10 +82,10 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xmlUpdater.exe"
OutputFile="$(OutDir)/../xmlUpdater.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
@ -119,16 +119,16 @@
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\TinyXml\tinystr.cpp">
RelativePath="..\..\TinyXml\tinystr.cpp">
</File>
<File
RelativePath="..\TinyXml\tinyxml.cpp">
RelativePath="..\..\TinyXml\tinyxml.cpp">
</File>
<File
RelativePath="..\TinyXml\tinyxmlerror.cpp">
RelativePath="..\..\TinyXml\tinyxmlerror.cpp">
</File>
<File
RelativePath="..\TinyXml\tinyxmlparser.cpp">
RelativePath="..\..\TinyXml\tinyxmlparser.cpp">
</File>
<File
RelativePath=".\xmlUpdater.cpp">
@ -139,20 +139,12 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath="..\TinyXml\tinystr.h">
RelativePath="..\..\TinyXml\tinystr.h">
</File>
<File
RelativePath="..\TinyXml\tinyxml.h">
RelativePath="..\..\TinyXml\tinyxml.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>