Cleaned up code using CppCheck

This commit is contained in:
Zane U. Ji 2013-11-13 00:30:07 +08:00
parent f73803ab6d
commit 13b5bb6a87
27 changed files with 134 additions and 244 deletions

View File

@ -114,26 +114,25 @@ void AssociateDialog::OnOk ( wxCommandEvent& e )
void AssociateDialog::OnContextHelp ( wxHelpEvent& e ) void AssociateDialog::OnContextHelp ( wxHelpEvent& e )
{ {
wxTipWindow *tw;
int id = e.GetId(); int id = e.GetId();
if ( id == ID_URL ) if ( id == ID_URL )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to type the path of the file" ) ); _ ( "Provides a space for you to type the path of the file" ) );
else if ( id == ID_BROWSE ) else if ( id == ID_BROWSE )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Opens a standard file dialog" ) ); _ ( "Opens a standard file dialog" ) );
else if ( id == ID_AUX ) else if ( id == ID_AUX )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to type additional information" ) ); _ ( "Provides a space for you to type additional information" ) );
else if ( id == wxID_CANCEL ) else if ( id == wxID_CANCEL )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Closes this dialog without making any changes" ) ); _ ( "Closes this dialog without making any changes" ) );
else if ( id == wxID_OK ) else if ( id == wxID_OK )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Selects the file specified" ) ); _ ( "Selects the file specified" ) );
else else

View File

@ -21,12 +21,12 @@
#include "contexthandler.h" #include "contexthandler.h"
ContextMatch ContextHandler::getContext ( ContextMatch ContextHandler::getContext (
char *s, const char *s,
int len, int len,
char *origin, const char *origin,
int context ) int context )
{ {
char *t, *u; const char *t, *u;
int maxrange = context * 20; int maxrange = context * 20;
int range = context + 1, i = 0; int range = context + 1, i = 0;

View File

@ -41,9 +41,9 @@ class ContextHandler
{ {
public: public:
static ContextMatch getContext ( static ContextMatch getContext (
char *s, const char *s,
int len, int len,
char *origin, const char *origin,
int context ); int context );
}; };

View File

@ -156,7 +156,6 @@ ExportDialog::~ExportDialog()
void ExportDialog::OnOk ( wxCommandEvent& e ) void ExportDialog::OnOk ( wxCommandEvent& e )
{ {
std::string urlUtf8, urlParamsUtf8;
#ifdef __WXMSW__ #ifdef __WXMSW__
url = urlCtrl->GetTextCtrlValue(); url = urlCtrl->GetTextCtrlValue();
#else #else
@ -171,30 +170,27 @@ void ExportDialog::OnOk ( wxCommandEvent& e )
rtf = rtfCheckbox->IsChecked(); rtf = rtfCheckbox->IsChecked();
doc = docCheckbox->IsChecked(); doc = docCheckbox->IsChecked();
fullDaisy = fullDaisyCheckbox->IsChecked(); fullDaisy = fullDaisyCheckbox->IsChecked();
urlUtf8 = ( const char * ) url.mb_str ( wxConvUTF8 );
e.Skip(); e.Skip();
} }
void ExportDialog::OnContextHelp ( wxHelpEvent& e ) void ExportDialog::OnContextHelp ( wxHelpEvent& e )
{ {
wxTipWindow *tw;
int id = e.GetId(); int id = e.GetId();
if ( id == ID_URL ) if ( id == ID_URL )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to enter or select a stylesheet for conversion to canonical XHTML" ) ); _ ( "Provides a space for you to enter or select a stylesheet for conversion to canonical XHTML" ) );
if ( id == ID_FOLDER ) if ( id == ID_FOLDER )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to enter or select the output folder" ) ); _ ( "Provides a space for you to enter or select the output folder" ) );
else if ( id == wxID_OK ) else if ( id == wxID_OK )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Starts the export" ) ); _ ( "Starts the export" ) );
else if ( id == wxID_CANCEL ) else if ( id == wxID_CANCEL )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Closes the dialog box without exporting the file" ) ); _ ( "Closes the dialog box without exporting the file" ) );
else else

View File

@ -71,7 +71,6 @@ class ExportDialog : public wxDialog
}; };
private: private:
wxStaticText *urlLabel, *folderLabel;
wxString url, folder; wxString url, folder;
wxCheckBox *quietCheckbox, wxCheckBox *quietCheckbox,
*suppressOptionalCheckbox, *suppressOptionalCheckbox,

View File

@ -138,35 +138,33 @@ void GlobalReplaceDialog::OnOk ( wxCommandEvent& e )
void GlobalReplaceDialog::OnContextHelp ( wxHelpEvent& e ) void GlobalReplaceDialog::OnContextHelp ( wxHelpEvent& e )
{ {
wxTipWindow *tw;
int id = e.GetId(); int id = e.GetId();
if ( id == ID_FIND ) if ( id == ID_FIND )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to type the text you want to find" ) ); _ ( "Provides a space for you to type the text you want to find" ) );
else if ( id == ID_REPLACE ) else if ( id == ID_REPLACE )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Provides a space for you to type the text you want to replace the text you typed in Find what" ) ); _ ( "Provides a space for you to type the text you want to replace the text you typed in Find what" ) );
else if ( id == ID_MATCHCASE ) else if ( id == ID_MATCHCASE )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Finds only text with lowercase and uppercase letters as specified in Find what" ) ); _ ( "Finds only text with lowercase and uppercase letters as specified in Find what" ) );
else if ( id == ID_ALLDOCUMENTS ) else if ( id == ID_ALLDOCUMENTS )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Extends the scope to all open documents" ) ); _ ( "Extends the scope to all open documents" ) );
else if ( id == ID_REGEX ) else if ( id == ID_REGEX )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Interprets the text specified in Find what as a regular expression" ) ); _ ( "Interprets the text specified in Find what as a regular expression" ) );
else if ( id == wxID_OK ) else if ( id == wxID_OK )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Finds all instances of the text specified in Find what and replaces them with the text in Replace with" ) ); _ ( "Finds all instances of the text specified in Find what and replaces them with the text in Replace with" ) );
else if ( id == wxID_CANCEL ) else if ( id == wxID_CANCEL )
tw = new wxTipWindow ( new wxTipWindow (
this, this,
_ ( "Closes the dialog box without saving any changes you have made" ) ); _ ( "Closes the dialog box without saving any changes you have made" ) );
else else

View File

@ -53,7 +53,6 @@ class GlobalReplaceDialog : public wxDialog
private: private:
wxTextCtrl *findCtrl, *replaceCtrl; wxTextCtrl *findCtrl, *replaceCtrl;
wxStaticText *findLabel, *replaceLabel;
wxCheckBox *matchCaseBox, *allDocumentsBox, *regexBox; wxCheckBox *matchCaseBox, *allDocumentsBox, *regexBox;
wxString find, replace; wxString find, replace;
bool matchCase, allDocuments, regex; bool matchCase, allDocuments, regex;

View File

@ -67,10 +67,9 @@ LocationPanel::LocationPanel ( wxWindow *parentWindowParameter, int id ) :
} }
void LocationPanel::update ( void LocationPanel::update (
XmlDoc *docParameter, XmlDoc *doc,
const wxString& parentParameter ) const wxString& parentParameter )
{ {
doc = docParameter;
parent = parentParameter; parent = parentParameter;
wxString previous = edit->GetValue(); wxString previous = edit->GetValue();

View File

@ -36,7 +36,6 @@ class LocationPanel : public wxPanel
private: private:
void indentStructure ( wxString& structure ); void indentStructure ( wxString& structure );
MyFrame *parentWindow; MyFrame *parentWindow;
XmlDoc *doc;
wxBoxSizer *sizer; wxBoxSizer *sizer;
wxTextCtrl *edit; wxTextCtrl *edit;
wxStyledTextCtrl *structureEdit; wxStyledTextCtrl *structureEdit;

View File

@ -47,7 +47,6 @@ void XMLCALL Mp3Album::start ( void *data,
Mp3AlbumData *ad; Mp3AlbumData *ad;
ad = ( Mp3AlbumData * ) data; ad = ( Mp3AlbumData * ) data;
std::string value;
char noArray[5]; char noArray[5];
int currentNo; int currentNo;

View File

@ -32,15 +32,15 @@ MyPropertySheet::MyPropertySheet (
wxWindow *parent, wxWindow *parent,
XmlCtrlProperties& propertiesParameter, XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter, wxString& applicationDirParameter,
bool rememberOpenTabsParameter, bool &rememberOpenTabsParameter,
bool libxmlNetAccessParameter, bool &libxmlNetAccessParameter,
bool singleInstanceCheckParameter, bool &singleInstanceCheckParameter,
bool saveBomParameter, bool &saveBomParameter,
bool unlimitedUndoParameter, bool &unlimitedUndoParameter,
bool restoreLayoutParameter, bool &restoreLayoutParameter,
bool expandInternalEntitiesParameter, bool &expandInternalEntitiesParameter,
bool showFullPathOnFrameParameter, bool &showFullPathOnFrameParameter,
int lang, int &lang,
const std::set<const wxLanguageInfo *> &translations, const std::set<const wxLanguageInfo *> &translations,
wxWindowID id, wxWindowID id,
wxString title, wxString title,
@ -51,6 +51,15 @@ MyPropertySheet::MyPropertySheet (
: wxPropertySheetDialog ( parent, id, title, position, size, style ) : wxPropertySheetDialog ( parent, id, title, position, size, style )
, properties ( propertiesParameter ) , properties ( propertiesParameter )
, applicationDir ( applicationDirParameter ) , applicationDir ( applicationDirParameter )
, rememberOpenTabs ( rememberOpenTabsParameter )
, libxmlNetAccess ( libxmlNetAccessParameter )
, singleInstanceCheck ( singleInstanceCheckParameter )
, saveBom ( saveBomParameter )
, unlimitedUndo ( unlimitedUndoParameter )
, restoreLayout ( restoreLayoutParameter )
, expandInternalEntities ( expandInternalEntitiesParameter )
, showFullPathOnFrame ( showFullPathOnFrameParameter )
, lang ( lang )
{ {
CreateButtons ( wxOK | wxCANCEL ); CreateButtons ( wxOK | wxCANCEL );
@ -241,6 +250,15 @@ MyPropertySheet::~MyPropertySheet()
void MyPropertySheet::OnOk ( wxCommandEvent& e ) void MyPropertySheet::OnOk ( wxCommandEvent& e )
{ {
wxString testDir = applicationDirEdit->GetValue();
if ( !wxFileName::DirExists ( testDir ) )
{
wxMessageBox ( _ ( "Cannot access application directory" ), _ ( "Options" ) );
// tbd: show general tab
return;
}
applicationDir = testDir;
properties.completion = completionBox->GetValue(); properties.completion = completionBox->GetValue();
properties.fold = foldBox->GetValue(); properties.fold = foldBox->GetValue();
properties.number = numberBox->GetValue(); properties.number = numberBox->GetValue();
@ -255,16 +273,6 @@ void MyPropertySheet::OnOk ( wxCommandEvent& e )
properties.font = fontBox->GetStringSelection(); properties.font = fontBox->GetStringSelection();
properties.highlightSyntax = highlightSyntaxBox->GetValue(); properties.highlightSyntax = highlightSyntaxBox->GetValue();
wxString testDir = applicationDirEdit->GetValue();
if ( !wxFileName::DirExists ( testDir ) )
{
wxMessageBox ( _ ( "Cannot access application directory" ), _ ( "Options" ) );
// tbd: show general tab
return;
}
else
applicationDir = testDir;
singleInstanceCheck = singleInstanceCheckBox->GetValue(); singleInstanceCheck = singleInstanceCheckBox->GetValue();
restoreLayout = restoreLayoutBox->GetValue(); restoreLayout = restoreLayoutBox->GetValue();
rememberOpenTabs = rememberOpenTabsBox->GetValue(); rememberOpenTabs = rememberOpenTabsBox->GetValue();
@ -289,58 +297,3 @@ void MyPropertySheet::OnApplicationDirBrowse ( wxCommandEvent& e )
if ( browseDialog->ShowModal() == wxID_OK ) if ( browseDialog->ShowModal() == wxID_OK )
applicationDirEdit->SetValue ( browseDialog->GetPath() ); applicationDirEdit->SetValue ( browseDialog->GetPath() );
} }
XmlCtrlProperties MyPropertySheet::getProperties()
{
return properties;
}
wxString MyPropertySheet::getApplicationDir()
{
return applicationDir;
}
bool MyPropertySheet::getSingleInstanceCheck()
{
return singleInstanceCheck;
}
bool MyPropertySheet::getRememberOpenTabs()
{
return rememberOpenTabs;
}
bool MyPropertySheet::getLibxmlNetAccess()
{
return libxmlNetAccess;
}
bool MyPropertySheet::getSaveBom()
{
return saveBom;
}
bool MyPropertySheet::getUnlimitedUndo()
{
return unlimitedUndo;
}
int MyPropertySheet::getLang()
{
return lang;
}
bool MyPropertySheet::getRestoreLayout()
{
return restoreLayout;
}
bool MyPropertySheet::getExpandInternalEntities()
{
return expandInternalEntities;
}
bool MyPropertySheet::getShowFullPathOnFrame()
{
return showFullPathOnFrame;
}

View File

@ -38,15 +38,15 @@ class MyPropertySheet : public wxPropertySheetDialog
wxWindow *parent, wxWindow *parent,
XmlCtrlProperties& propertiesParameter, XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter, wxString& applicationDirParameter,
bool rememberOpenTabsParameter, bool &rememberOpenTabsParameter,
bool libxmlNetAccess, bool &libxmlNetAccess,
bool singleInstanceCheck, bool &singleInstanceCheck,
bool saveBom, bool &saveBom,
bool unlimitedUndo, bool &unlimitedUndo,
bool restoreLayout, bool &restoreLayout,
bool expandInternalEntities, bool &expandInternalEntities,
bool showFullPathOnFrame, bool &showFullPathOnFrame,
int lang, int &lang,
const std::set<const wxLanguageInfo *> &translations, const std::set<const wxLanguageInfo *> &translations,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
wxString title = _T ( "" ), wxString title = _T ( "" ),
@ -56,19 +56,8 @@ class MyPropertySheet : public wxPropertySheetDialog
~MyPropertySheet(); ~MyPropertySheet();
void OnOk ( wxCommandEvent& e ); void OnOk ( wxCommandEvent& e );
void OnApplicationDirBrowse ( wxCommandEvent& e ); void OnApplicationDirBrowse ( wxCommandEvent& e );
XmlCtrlProperties getProperties();
wxString getApplicationDir();
bool getSingleInstanceCheck();
bool getRememberOpenTabs();
bool getLibxmlNetAccess();
bool getSaveBom();
bool getUnlimitedUndo();
bool getRestoreLayout();
bool getExpandInternalEntities();
bool getShowFullPathOnFrame();
int getLang();
private: private:
int lang; int &lang;
wxCheckBox *completionBox, wxCheckBox *completionBox,
*currentLineBox, *currentLineBox,
*foldBox, *foldBox,
@ -91,17 +80,17 @@ class MyPropertySheet : public wxPropertySheetDialog
*insertCloseTagBox; *insertCloseTagBox;
wxChoice *languageBox, *fontBox; wxChoice *languageBox, *fontBox;
wxTextCtrl *applicationDirEdit; wxTextCtrl *applicationDirEdit;
XmlCtrlProperties properties; XmlCtrlProperties &properties;
wxString applicationDir; wxString &applicationDir;
bool singleInstanceCheck, bool &singleInstanceCheck,
rememberOpenTabs, &rememberOpenTabs,
libxmlNetAccess, &libxmlNetAccess,
saveBom, &saveBom,
unlimitedUndo, &unlimitedUndo,
restoreLayout, &restoreLayout,
expandInternalEntities, &expandInternalEntities,
showFullPathOnFrame, &showFullPathOnFrame;
insertCloseTag;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -28,6 +28,7 @@ class ParserData
public: public:
ParserData() ParserData()
{ {
state = 0;
count = 0; count = 0;
} }
~ParserData() ~ParserData()

View File

@ -31,7 +31,9 @@ Rule::Rule (
matchCase, matchCase,
replace, replace,
arrayLength ) arrayLength )
{ } {
adjustCaseAttribute = tentativeAttribute = false;
}
bool Rule::getAdjustCaseAttribute() bool Rule::getAdjustCaseAttribute()
{ {

View File

@ -30,9 +30,10 @@
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <mem.h> #include <mem.h>
#endif #endif
#include <boost/utility.hpp>
template<class T> template<class T>
class StringSetNode class StringSetNode : private boost::noncopyable
{ {
public: public:
StringSetNode ( T *keyParameter, size_t lenParameter ) StringSetNode ( T *keyParameter, size_t lenParameter )

View File

@ -103,6 +103,7 @@ StyleDialog::StyleDialog (
position, position,
size, size,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ),
indexForContextMenu ( -1 ),
bufferUtf8 ( bufferParameterUtf8 ), bufferUtf8 ( bufferParameterUtf8 ),
#if !defined(USE_ENCHANT) && defined(__WXMSW__) #if !defined(USE_ENCHANT) && defined(__WXMSW__)
aspellDataPath ( aspellDataPathParameter ), aspellDataPath ( aspellDataPathParameter ),

View File

@ -96,6 +96,7 @@ void WrapLibxml::Init ( const wxString &catalogPath ) throw()
WrapLibxml::WrapLibxml ( bool netAccessParameter ) WrapLibxml::WrapLibxml ( bool netAccessParameter )
: netAccess ( netAccessParameter ) : netAccess ( netAccessParameter )
, errorLine ( 0 )
{ {
WrapLibxml::Init(); WrapLibxml::Init();
} }
@ -117,19 +118,13 @@ bool WrapLibxml::validate ( const std::string& fileName )
return false; return false;
} }
bool returnValue = false;
docPtr = xmlCtxtReadFile ( docPtr = xmlCtxtReadFile (
ctxt, ctxt,
fileName.c_str(), fileName.c_str(),
NULL, NULL,
( netAccess ) ? XML_PARSE_DTDVALID : XML_PARSE_DTDVALID | XML_PARSE_NONET ); ( netAccess ) ? XML_PARSE_DTDVALID : XML_PARSE_DTDVALID | XML_PARSE_NONET );
if ( docPtr == NULL )
; bool returnValue = docPtr != NULL && ctxt->valid != 0;
else if ( ctxt->valid == 0 )
;
else
returnValue = true;
xmlFreeDoc ( docPtr ); xmlFreeDoc ( docPtr );
xmlFreeParserCtxt ( ctxt ); xmlFreeParserCtxt ( ctxt );

View File

@ -33,11 +33,15 @@ WrapRegex::WrapRegex (
const string& replaceParameter, const string& replaceParameter,
const int arrayLengthParameter ) : const int arrayLengthParameter ) :
replace ( replaceParameter ), replace ( replaceParameter ),
arrayLength ( arrayLengthParameter ) arrayLength ( arrayLengthParameter ),
returnValue ( 0 )
{ {
if ( pattern.empty() || pattern == ".*" ) if ( pattern.empty() || pattern == ".*" )
{ {
disabled = true; disabled = true;
matchArray = NULL;
patternStructure = NULL;
patternExtraStructure = NULL;
return; return;
} }
disabled = false; disabled = false;
@ -67,17 +71,10 @@ WrapRegex::~WrapRegex()
if ( disabled ) if ( disabled )
return; return;
try
{
pcre_free ( patternStructure ); pcre_free ( patternStructure );
pcre_free ( patternExtraStructure ); pcre_free ( patternExtraStructure );
delete[] matchArray; delete[] matchArray;
} }
catch ( ... )
{
throw runtime_error ( "Wrapregex::~WrapRegex" );
}
}
int WrapRegex::matchPatternGlobal ( int WrapRegex::matchPatternGlobal (
string &buffer, string &buffer,
@ -105,7 +102,7 @@ string WrapRegex::replaceGlobal (
if ( disabled ) if ( disabled )
return buffer; return buffer;
char *s = ( char * ) buffer.c_str(); const char *s = buffer.c_str();
string output, match; string output, match;
@ -143,12 +140,12 @@ int WrapRegex::matchPatternGlobal_ (
if ( disabled ) if ( disabled )
return 0; return 0;
char *s, *origin; const char *s, *origin;
int matchcount; int matchcount;
size_t offset; size_t offset;
ContextMatch match; ContextMatch match;
s = origin = ( char * ) buffer; s = origin = buffer;
matchcount = 0; matchcount = 0;
offset = 0; offset = 0;
@ -193,13 +190,12 @@ int WrapRegex::matchPatternGlobal_ (
return matchcount; return matchcount;
} }
string WrapRegex::getInterpolatedString_ ( char *buffer, char *source ) string WrapRegex::getInterpolatedString_ ( const char *buffer, const char *source )
{ {
if ( disabled ) if ( disabled )
return ""; return "";
char *s, *origin; const char *s = source;
s = origin = ( char * ) source;
string interpol_string; string interpol_string;
@ -213,7 +209,7 @@ string WrapRegex::getInterpolatedString_ ( char *buffer, char *source )
{ {
if ( isdigit ( * ( s + 1 ) ) ) if ( isdigit ( * ( s + 1 ) ) )
{ {
char *number, *it; const char *number, *it;
number = s + 1; number = s + 1;
for ( it = number; *it && isdigit ( * ( it + 1 ) ); ++it ) for ( it = number; *it && isdigit ( * ( it + 1 ) ); ++it )
; ;
@ -253,7 +249,7 @@ string WrapRegex::getInterpolatedString_ ( char *buffer, char *source )
return interpol_string; return interpol_string;
} }
string WrapRegex::getSubpattern_ ( char *s, unsigned subpattern ) string WrapRegex::getSubpattern_ ( const char *s, unsigned subpattern )
{ {
if ( disabled ) if ( disabled )
return ""; return "";
@ -263,6 +259,6 @@ string WrapRegex::getSubpattern_ ( char *s, unsigned subpattern )
if ( ret == PCRE_ERROR_NOSUBSTRING || ret == PCRE_ERROR_NOMEMORY ) if ( ret == PCRE_ERROR_NOSUBSTRING || ret == PCRE_ERROR_NOMEMORY )
return ""; return "";
string subString ( sub ); string subString ( sub );
pcre_free ( ( char * ) sub ); pcre_free_substring ( sub );
return subString; return subString;
} }

View File

@ -24,11 +24,12 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <pcre.h> #include <pcre.h>
#include <boost/utility.hpp>
#include "contexthandler.h" #include "contexthandler.h"
using namespace std; using namespace std;
class WrapRegex class WrapRegex : private boost::noncopyable
{ {
public: public:
WrapRegex ( WrapRegex (
@ -55,8 +56,9 @@ class WrapRegex
pcre_extra *patternExtraStructure; pcre_extra *patternExtraStructure;
int *matchArray; int *matchArray;
string getInterpolatedString_ ( char *buffer, char *source ); string getInterpolatedString_ ( const char *buffer,
string getSubpattern_ ( char *buffer, unsigned subpattern ); const char *source );
string getSubpattern_ ( const char *buffer, unsigned subpattern );
int matchPatternGlobal_ ( int matchPatternGlobal_ (
const char *buffer, const char *buffer,
size_t buflen, size_t buflen,

View File

@ -25,6 +25,7 @@
#include <wx/buffer.h> #include <wx/buffer.h>
#include <string> #include <string>
#include <utility> #include <utility>
#include <boost/utility.hpp>
#if !wxCHECK_GCC_VERSION(4,7) #if !wxCHECK_GCC_VERSION(4,7)
#define XERCES_TMPLSINC #define XERCES_TMPLSINC
@ -36,7 +37,7 @@
using namespace xercesc; using namespace xercesc;
class WrapXerces class WrapXerces : private boost::noncopyable
{ {
public: public:
static void Init() throw (); static void Init() throw ();

View File

@ -104,7 +104,7 @@ void XMLCALL XmlAssociateXsd::start ( void *data,
!strcmp ( *attr, "xmlns" ) || !strcmp ( *attr, "xmlns" ) ||
!strcmp ( *attr, "xsi:noNamespaceSchemaLocation" ) || !strcmp ( *attr, "xsi:noNamespaceSchemaLocation" ) ||
!strcmp ( *attr, "xsi:schemaLocation" ) ) !strcmp ( *attr, "xsi:schemaLocation" ) )
; {}
else else
{ {
d->buffer += " "; d->buffer += " ";

View File

@ -388,7 +388,7 @@ bool MyApp::OnInit()
getAvailableTranslations ( &prefixes, &catalog ); getAvailableTranslations ( &prefixes, &catalog );
if ( !myLocale.AddCatalog ( catalog ) ) if ( !myLocale.AddCatalog ( catalog ) )
; {}
#ifndef __WXMSW__ #ifndef __WXMSW__
{ {
@ -862,7 +862,6 @@ MyFrame::MyFrame (
commandString = wxEmptyString; commandString = wxEmptyString;
exportStylesheet = exportFolder = wxEmptyString; exportStylesheet = exportFolder = wxEmptyString;
exportQuiet = exportMp3Album = false;
exportQuiet = exportMp3Album = exportSuppressOptional = exportHtml = exportQuiet = exportMp3Album = exportSuppressOptional = exportHtml =
exportEpub = exportRtf = exportDoc = exportFullDaisy = true; exportEpub = exportRtf = exportDoc = exportFullDaisy = true;
@ -894,7 +893,6 @@ MyFrame::MyFrame (
largeFileProperties.indentLines = false; largeFileProperties.indentLines = false;
largeFileProperties.protectHiddenElements = false; largeFileProperties.protectHiddenElements = false;
largeFileProperties.toggleLineBackground = false; largeFileProperties.toggleLineBackground = false;
largeFileProperties.toggleLineBackground = false;
largeFileProperties.insertCloseTag = false; largeFileProperties.insertCloseTag = false;
largeFileProperties.deleteWholeTag = false; largeFileProperties.deleteWholeTag = false;
largeFileProperties.highlightSyntax = false; largeFileProperties.highlightSyntax = false;
@ -1437,7 +1435,8 @@ void MyFrame::OnPageClosing ( wxAuiNotebookEvent& event ) //wxNotebookEvent& eve
{ {
int selection; int selection;
wxString fileName; wxString fileName;
if ( ( selection = mainBook->GetSelection() ) != -1 ) selection = mainBook->GetSelection();
if ( selection != -1 )
fileName = doc->getShortFileName(); fileName = doc->getShortFileName();
int answer = wxMessageBox ( int answer = wxMessageBox (
@ -1962,10 +1961,9 @@ void MyFrame::OnDialogReplace ( wxFindDialogEvent& event )
if ( !doc->GetSelectedText().IsEmpty() ) if ( !doc->GetSelectedText().IsEmpty() )
{ {
int regexWidth = 0;
if ( findReplacePanel->getRegex() ) if ( findReplacePanel->getRegex() )
{ {
regexWidth = doc->ReplaceTargetRE ( event.GetReplaceString() ); doc->ReplaceTargetRE ( event.GetReplaceString() );
} }
else else
{ {
@ -2049,7 +2047,7 @@ void MyFrame::OnPrintPreview ( wxCommandEvent &WXUNUSED ( event ) )
wxString htmlBuffer = getHtmlBuffer(); wxString htmlBuffer = getHtmlBuffer();
statusProgress ( wxEmptyString ); statusProgress ( wxEmptyString );
if ( ! ( htmlPrinting->PreviewText ( htmlBuffer ) ) ) if ( ! ( htmlPrinting->PreviewText ( htmlBuffer ) ) )
; {}
} }
void MyFrame::OnPrint ( wxCommandEvent &WXUNUSED ( event ) ) void MyFrame::OnPrint ( wxCommandEvent &WXUNUSED ( event ) )
@ -2070,7 +2068,7 @@ void MyFrame::OnPrint ( wxCommandEvent &WXUNUSED ( event ) )
wxString htmlBuffer = getHtmlBuffer(); wxString htmlBuffer = getHtmlBuffer();
statusProgress ( wxEmptyString ); statusProgress ( wxEmptyString );
if ( ! ( htmlPrinting->PrintText ( htmlBuffer ) ) ) if ( ! ( htmlPrinting->PrintText ( htmlBuffer ) ) )
; {}
} }
wxString MyFrame::getHtmlBuffer() wxString MyFrame::getHtmlBuffer()
@ -2632,18 +2630,7 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
title ) ); title ) );
if ( mpsd->ShowModal() == wxID_OK ) if ( mpsd->ShowModal() == wxID_OK )
{ {
properties = mpsd->getProperties();
applyEditorProperties(); applyEditorProperties();
applicationDir = mpsd->getApplicationDir();
rememberOpenTabs = mpsd->getRememberOpenTabs();
libxmlNetAccess = mpsd->getLibxmlNetAccess();
singleInstanceCheck = mpsd->getSingleInstanceCheck();
saveBom = mpsd->getSaveBom();
unlimitedUndo = mpsd->getUnlimitedUndo();
restoreLayout = mpsd->getRestoreLayout();
expandInternalEntities = mpsd->getExpandInternalEntities();
showFullPathOnFrame = mpsd->getShowFullPathOnFrame();
lang = mpsd->getLang();
updatePaths(); updatePaths();
} }
if ( doc ) if ( doc )
@ -2734,8 +2721,7 @@ void MyFrame::OnFindReplace ( wxCommandEvent& WXUNUSED ( event ) )
void MyFrame::OnGlobalReplace ( wxCommandEvent& event ) void MyFrame::OnGlobalReplace ( wxCommandEvent& event )
{ {
XmlDoc *doc; if ( getActiveDocument() == NULL )
if ( ( doc = getActiveDocument() ) == NULL )
return; return;
size_t flags = findData.GetFlags(); size_t flags = findData.GetFlags();
@ -3052,7 +3038,6 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
} }
wxString wideError; wxString wideError;
std::string buffer;
pair<int, int> posPair; pair<int, int> posPair;
XmlDoc *doc; XmlDoc *doc;
@ -3363,7 +3348,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
std::string MyFrame::getApproximateEncoding ( char *docBuffer, std::string MyFrame::getApproximateEncoding ( char *docBuffer,
size_t docBufferLen ) size_t docBufferLen )
{ {
std::string line, encoding; std::string line;
char *it; char *it;
size_t i; size_t i;
@ -3573,7 +3558,7 @@ void MyFrame::save()
} }
if ( !saveFile ( doc, fileName, true ) ) if ( !saveFile ( doc, fileName, true ) )
; // handle messages in saveFile {} // handle messages in saveFile
} }
void MyFrame::OnReload ( wxCommandEvent& event ) void MyFrame::OnReload ( wxCommandEvent& event )
@ -3679,13 +3664,7 @@ void MyFrame::OnUpdateReload ( wxUpdateUIEvent& event )
void MyFrame::OnUpdateCutCopy ( wxUpdateUIEvent& event ) void MyFrame::OnUpdateCutCopy ( wxUpdateUIEvent& event )
{ {
XmlDoc *doc; event.Enable ( getActiveDocument() != NULL );
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
} }
void MyFrame::OnUpdateLocationPaneVisible ( wxUpdateUIEvent& event ) void MyFrame::OnUpdateLocationPaneVisible ( wxUpdateUIEvent& event )
@ -3704,30 +3683,17 @@ void MyFrame::OnUpdateSavedOnly ( wxUpdateUIEvent& event )
event.Enable ( false ); event.Enable ( false );
return; return;
} }
event.Enable ( event.Enable ( !doc->getFullFileName().empty() );
( doc->getFullFileName().empty() ) ? false : true );
} }
void MyFrame::OnUpdateDocRange ( wxUpdateUIEvent& event ) void MyFrame::OnUpdateDocRange ( wxUpdateUIEvent& event )
{ {
XmlDoc *doc; event.Enable ( getActiveDocument() != NULL );
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
} }
void MyFrame::OnUpdateReplaceRange ( wxUpdateUIEvent& event ) void MyFrame::OnUpdateReplaceRange ( wxUpdateUIEvent& event )
{ {
XmlDoc *doc; event.Enable ( getActiveDocument() != NULL );
if ( ( doc = getActiveDocument() ) == NULL ) // || protectTags)
{
event.Enable ( false );
return;
}
event.Enable ( true );
} }
void MyFrame::OnUpdateFindAgain ( wxUpdateUIEvent& event ) void MyFrame::OnUpdateFindAgain ( wxUpdateUIEvent& event )
@ -3768,13 +3734,7 @@ void MyFrame::OnUpdateRedo ( wxUpdateUIEvent& event )
void MyFrame::OnUpdatePaste ( wxUpdateUIEvent& event ) void MyFrame::OnUpdatePaste ( wxUpdateUIEvent& event )
{ {
XmlDoc *doc; event.Enable ( getActiveDocument() != NULL );
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
} }
void MyFrame::OnUpdatePreviousDocument ( wxUpdateUIEvent& event ) void MyFrame::OnUpdatePreviousDocument ( wxUpdateUIEvent& event )
@ -3992,7 +3952,7 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
// XMLCatalogResolver // XMLCatalogResolver
#ifdef __WXMSW__ #ifdef __WXMSW__
{ {
std::string rawBuffer, schemaLocation; std::string rawBuffer;
getRawText ( doc, rawBuffer ); getRawText ( doc, rawBuffer );
if ( !XmlEncodingHandler::setUtf8 ( rawBuffer ) ) if ( !XmlEncodingHandler::setUtf8 ( rawBuffer ) )
{ {
@ -4010,7 +3970,6 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
#endif #endif
wxString fileName; wxString fileName;
std::string tempFileNameLocal;
fileName = doc->getFullFileName(); fileName = doc->getFullFileName();
WrapTempFileName wtfn ( fileName ); WrapTempFileName wtfn ( fileName );

View File

@ -1291,13 +1291,11 @@ bool XmlCtrl::canMoveLeftAt ( int pos )
void XmlCtrl::adjustPosRight() void XmlCtrl::adjustPosRight()
{ {
int pos, max; int pos, max;
bool canInsert = false;
pos = GetCurrentPos(); pos = GetCurrentPos();
max = GetLength(); max = GetLength();
for ( ; pos <= max; pos++ ) for ( ; pos <= max; pos++ )
if ( canInsertAt ( pos ) ) if ( canInsertAt ( pos ) )
{ {
canInsert = true;
break; break;
} }
SetSelection ( pos, pos ); SetSelection ( pos, pos );
@ -1306,7 +1304,6 @@ void XmlCtrl::adjustPosRight()
void XmlCtrl::adjustPosLeft() void XmlCtrl::adjustPosLeft()
{ {
int pos; int pos;
bool canInsert = false;
pos = GetCurrentPos() - 1; pos = GetCurrentPos() - 1;
if ( pos < 0 ) if ( pos < 0 )
{ {
@ -1316,7 +1313,6 @@ void XmlCtrl::adjustPosLeft()
for ( ; pos > 0; pos-- ) for ( ; pos > 0; pos-- )
if ( canInsertAt ( pos ) ) if ( canInsertAt ( pos ) )
{ {
canInsert = true;
break; break;
} }
SetSelection ( pos, pos ); SetSelection ( pos, pos );

View File

@ -165,8 +165,8 @@ void XMLCALL XmlPromptGenerator::doctypedeclstarthandler (
const XML_Char *pubid, const XML_Char *pubid,
int has_internal_subset ) int has_internal_subset )
{ {
PromptGeneratorData *d; //PromptGeneratorData *d;
d = ( PromptGeneratorData * ) data; //d = ( PromptGeneratorData * ) data;
} }
void XMLCALL XmlPromptGenerator::doctypedeclendhandler ( void *data ) void XMLCALL XmlPromptGenerator::doctypedeclendhandler ( void *data )

View File

@ -35,6 +35,7 @@ RuleData::RuleData (
passiveDictionary ( passiveDictionaryParameter ), passiveDictionary ( passiveDictionaryParameter ),
ruleVector ( ruleVectorParameter ) ruleVector ( ruleVectorParameter )
{ {
cipher = false;
dictionaryFound = false; dictionaryFound = false;
initialiseAttributes(); initialiseAttributes();
ruleCount = 0; ruleCount = 0;

View File

@ -252,7 +252,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
{ {
wxString &schema = data.schema; wxString &schema = data.schema;
if ( data.children.size() == 0 && data.attrMap.size() == 0 ) if ( data.children.empty() && data.attrMap.empty() )
{ {
if ( !mInlineSimpleType ) if ( !mInlineSimpleType )
{ {
@ -267,7 +267,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
addIndent ( schema, nIndent++ ); addIndent ( schema, nIndent++ );
schema << _T("<xs:element name=\"") << data.name << _T("\">") << getEOL(); schema << _T("<xs:element name=\"") << data.name << _T("\">") << getEOL();
if ( data.children.size() > 0 ) if ( !data.children.empty() )
{ {
addIndent ( schema, nIndent++ ); addIndent ( schema, nIndent++ );
schema << _T("<xs:complexType>") << getEOL(); schema << _T("<xs:complexType>") << getEOL();
@ -305,8 +305,8 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
if ( mInlineSimpleType ) if ( mInlineSimpleType )
{ // Check if it's a simple type { // Check if it's a simple type
const ElmtData *childElmt = &mElements[*seqItr]; const ElmtData *childElmt = &mElements[*seqItr];
if ( childElmt->children.size() == 0 if ( childElmt->children.empty()
&& childElmt->attrMap.size() == 0 ) && childElmt->attrMap.empty() )
{ {
schema << _T("<xs:element name=\"") << *seqItr schema << _T("<xs:element name=\"") << *seqItr
<< _T("\" type=\"xs:string\"/>") << getEOL(); << _T("\" type=\"xs:string\"/>") << getEOL();
@ -338,7 +338,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
schema << _T("</xs:choice>") << getEOL(); schema << _T("</xs:choice>") << getEOL();
} }
} }
else if ( data.attrMap.size() != 0 ) else if ( !data.attrMap.empty() )
{ {
addIndent ( schema, nIndent++ ); addIndent ( schema, nIndent++ );
schema << _T("<xs:complexType>") << getEOL(); schema << _T("<xs:complexType>") << getEOL();

View File

@ -32,7 +32,12 @@
struct XmlShallowValidatorData : public ParserData struct XmlShallowValidatorData : public ParserData
{ {
XmlShallowValidatorData() XmlShallowValidatorData()
{} {
isValid = segmentOnly = false;
depth = maxLine = 0;
p = 0;
overrideFailure = false;
}
std::map<wxString, std::set<wxString> > elementMap; std::map<wxString, std::set<wxString> > elementMap;
std::map<wxString, std::map<wxString, std::set<wxString> > > std::map<wxString, std::map<wxString, std::set<wxString> > >
attributeMap; attributeMap;