Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/chcg/notepad-plus-plus in…
Browse files Browse the repository at this point in the history
…to GWLP_648
  • Loading branch information
chcg committed May 28, 2015
2 parents c8254f8 + f45f58b commit e1d8e05
Show file tree
Hide file tree
Showing 29 changed files with 158 additions and 137 deletions.
19 changes: 3 additions & 16 deletions PowerEditor/src/MISC/Process/ProcessAvecThread/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ BOOL Process::run()

void Process::listenerStdOut()
{
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent"));
//FILE *fp = NULL;

int taille = 0;
TCHAR bufferOut[MAX_LINE_LENGTH + 1];
//TCHAR bufferErr[MAX_LINE_LENGTH + 1];

int nExitCode = STILL_ACTIVE;

Expand All @@ -150,8 +145,7 @@ void Process::listenerStdOut()
while (goOn)
{ // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
//memset(bufferErr,0x00,MAX_LINE_LENGTH + 1);
taille = sizeof(bufferOut) - sizeof(TCHAR);
int taille = sizeof(bufferOut) - sizeof(TCHAR);

Sleep(50);

Expand All @@ -171,7 +165,7 @@ void Process::listenerStdOut()
break;
}
}
//outbytesRead = strlen(bufferOut);

bufferOut[outbytesRead] = '\0';
generic_string s;
s.assign(bufferOut);
Expand All @@ -198,19 +192,13 @@ void Process::listenerStdOut()

void Process::listenerStdErr()
{
//BOOL Result = 0;
//DWORD size = 0;
DWORD bytesAvail = 0;
BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent"));

int taille = 0;
//TCHAR bufferOut[MAX_LINE_LENGTH + 1];
TCHAR bufferErr[MAX_LINE_LENGTH + 1];

int nExitCode = STILL_ACTIVE;

DWORD errbytesRead;

::ResumeThread(_hProcessThread);

Expand All @@ -221,7 +209,7 @@ void Process::listenerStdErr()
taille = sizeof(bufferErr) - sizeof(TCHAR);

Sleep(50);

DWORD errbytesRead;
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
{
bytesAvail = 0;
Expand All @@ -238,7 +226,6 @@ void Process::listenerStdErr()
break;
}
}
//outbytesRead = strlen(bufferOut);
bufferErr[errbytesRead] = '\0';
generic_string s;
s.assign(bufferErr);
Expand Down
22 changes: 11 additions & 11 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,12 +956,12 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
if (posFound != -1 && posFound != -2)
{
const char *encodingBlockRegExpr = "encoding[ \\t]*=[ \\t]*\"[^\".]+\"";
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingBlockRegExpr), (LPARAM)encodingBlockRegExpr);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingBlockRegExpr), (LPARAM)encodingBlockRegExpr);

const char *encodingRegExpr = "\".+\"";
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingRegExpr), (LPARAM)encodingRegExpr);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingRegExpr), (LPARAM)encodingRegExpr);

posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr);

startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART));
endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND));
Expand Down Expand Up @@ -998,9 +998,9 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
if (posFound == -1 || posFound == -2)
return -1;
}
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock);
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(intermediaire), (LPARAM)intermediaire);
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(intermediaire), (LPARAM)intermediaire);
_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE);

startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART));
endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND));
Expand Down Expand Up @@ -6074,7 +6074,8 @@ void Notepad_plus::showQuote(const char *quote, const char *quoter, bool doTroll
void Notepad_plus::launchDocumentBackupTask()
{
HANDLE hThread = ::CreateThread(NULL, 0, backupDocument, NULL, 0, NULL);
::CloseHandle(hThread);
if (hThread)
::CloseHandle(hThread);
}

DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/)
Expand Down Expand Up @@ -6150,7 +6151,6 @@ bool Notepad_plus::undoStreamComment()
generic_string white_space(TEXT(" "));
int start_comment_length = start_comment.length();
int end_comment_length = end_comment.length();
int startCommentLength, endCommentLength;

do { // do as long as stream-comments are within selection

Expand All @@ -6166,7 +6166,7 @@ bool Notepad_plus::undoStreamComment()

//-- First, search all start_comment and end_comment before and after the selectionStart and selectionEnd position.
const int iSelStart=0, iSelEnd=1;
#define N_CMNT 2
const size_t N_CMNT = 2;
int posStartCommentBefore[N_CMNT], posEndCommentBefore[N_CMNT], posStartCommentAfter[N_CMNT], posEndCommentAfter[N_CMNT];
bool blnStartCommentBefore[N_CMNT], blnEndCommentBefore[N_CMNT], blnStartCommentAfter[N_CMNT], blnEndCommentAfter[N_CMNT];
int posStartComment, posEndComment;
Expand Down Expand Up @@ -6238,8 +6238,8 @@ bool Notepad_plus::undoStreamComment()
//-- Ok, there are valid start-comment and valid end-comment around the caret-position.
// Now, un-comment stream-comment:
retVal = true;
startCommentLength = start_comment_length;
endCommentLength = end_comment_length;
int startCommentLength = start_comment_length;
int endCommentLength = end_comment_length;
//-- First delete end-comment, so that posStartCommentBefore does not change!
//-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too!
_pEditView->getGenericText(charbuf, charbufLen, posEndComment-1, posEndComment);
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/Notepad_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ friend class FileManager;
int getLangFromMenuName(const TCHAR * langName);
generic_string getLangFromMenu(const Buffer * buf);

generic_string Notepad_plus::exts2Filters(generic_string exts) const;
generic_string exts2Filters(generic_string exts) const;
int setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType = -1);
void markSelectedTextInc(bool enable);
Style * getStyleFromName(const TCHAR *styleName);
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/Notepad_plus_Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum

class Notepad_plus_Window : public Window {
public:
Notepad_plus_Window() {};
Notepad_plus_Window() : _isPrelaunch(false), _disablePluginsManager(false) {};
void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams);

bool isDlgsMsg(MSG *msg) const;
Expand All @@ -86,7 +86,7 @@ class Notepad_plus_Window : public Window {
::DestroyWindow(_hSelf);
};

static const TCHAR * Notepad_plus_Window::getClassName() {
static const TCHAR * getClassName() {
return _className;
};
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
Expand Down
10 changes: 5 additions & 5 deletions PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,10 +1489,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
else
{
SCNotification scnN;
scnN.nmhdr.code = NPPN_BEFORESHUTDOWN;
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
scnN.nmhdr.idFrom = 0;
SCNotification scnN;
scnN.nmhdr.code = NPPN_BEFORESHUTDOWN;
scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);

if (_pTrayIco)
Expand Down Expand Up @@ -1522,7 +1522,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!allClosed)
{
//User cancelled the shutdown
scnN.nmhdr.code = NPPN_CANCELSHUTDOWN;
scnN.nmhdr.code = NPPN_CANCELSHUTDOWN;
_pluginsManager.notify(&scnN);

return FALSE;
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isRe
if (isWow64Off)
{
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false;
//isWow64Off = false;
}
return buffer;
}
Expand Down Expand Up @@ -439,7 +439,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
if (isWow64Off)
{
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false;
//isWow64Off = false;
}
}

Expand Down
17 changes: 8 additions & 9 deletions PowerEditor/src/NppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (_rebarBottom.getHSelf() == lpnm->hdr.hwndFrom)
notifRebar = &_rebarBottom;
//If N++ ID, use proper object
switch(lpnm->wID) {
case REBAR_BAR_TOOLBAR: {
POINT pt;
pt.x = lpnm->rc.left;
pt.y = lpnm->rc.bottom;
ClientToScreen(notifRebar->getHSelf(), &pt);
_toolBar.doPopop(pt);
return TRUE;
break; }
if (lpnm->wID == REBAR_BAR_TOOLBAR)
{
POINT pt;
pt.x = lpnm->rc.left;
pt.y = lpnm->rc.bottom;
ClientToScreen(notifRebar->getHSelf(), &pt);
_toolBar.doPopop(pt);
return TRUE;
}
//Else forward notification to window of rebarband
REBARBANDINFO rbBand;
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct CmdLineParams {

CmdLineParams() : _isNoPlugin(false), _isReadOnly(false), _isNoSession(false), _isNoTab(false),_showLoadingTime(false),\
_isPreLaunch(false), _line2go(-1), _column2go(-1), _langType(L_EXTERNAL), _isPointXValid(false), _isPointYValid(false),\
_localizationPath(TEXT("")), _easterEggName(TEXT("")), _quoteType(0)
_alwaysOnTop(false), _localizationPath(TEXT("")), _easterEggName(TEXT("")), _quoteType(0)
{
_point.x = 0;
_point.y = 0;
Expand Down
5 changes: 2 additions & 3 deletions PowerEditor/src/ScitillaComponent/AutoCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ static bool getPathsForPathCompletion(generic_string input, generic_string &rawP
}
else
{
locale loc;
size_t last_occurrence = rawPath.rfind(L"\\");
if(last_occurrence == std::string::npos) // No match.
return false;
Expand Down Expand Up @@ -765,10 +764,10 @@ bool AutoCompletion::setLanguage(LangType language) {
//Cache the keywords
//Iterate through all keywords
TiXmlElement *funcNode = _pXmlKeyword;
const TCHAR * name = NULL;

for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) )
{
name = funcNode->Attribute(TEXT("name"));
const TCHAR *name = funcNode->Attribute(TEXT("name"));
if (name)
{
size_t len = lstrlen(name);
Expand Down
7 changes: 3 additions & 4 deletions PowerEditor/src/ScitillaComponent/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i
if (isWow64Off)
{
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false;
//isWow64Off = false;
}
return isOK;
}
Expand Down Expand Up @@ -1121,12 +1121,11 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d

int FileManager::detectCodepage(char* buf, size_t len)
{
int codepage = -1;
uchardet_t ud = uchardet_new();
uchardet_handle_data(ud, buf, len);
uchardet_data_end(ud);
const char* cs = uchardet_get_charset(ud);
codepage = EncodingMapper::getInstance()->getEncodingFromString(cs);
int codepage = EncodingMapper::getInstance()->getEncodingFromString(cs);
uchardet_delete(ud);
return codepage;
}
Expand Down Expand Up @@ -1203,7 +1202,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea

do {
lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar;
if (lenFile <= 0) break;
if (lenFile == 0) break;

// check if file contain any BOM
if (isFirstTime)
Expand Down
55 changes: 37 additions & 18 deletions PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@ FindOption FindReplaceDlg::_options;
#define SHIFTED 0x8000


int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length) { //query may equal to result, since it always gets smaller
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length)
{ //query may equal to result, since it always gets smaller
int i = 0, j = 0;
int charLeft = length;
bool isGood = true;
TCHAR current;
while(i < length) { //because the backslash escape quences always reduce the size of the generic_string, no overflow checks have to be made for target, assuming parameters are correct
while (i < length)
{ //because the backslash escape quences always reduce the size of the generic_string, no overflow checks have to be made for target, assuming parameters are correct
current = query[i];
--charLeft;
if (current == '\\' && charLeft) { //possible escape sequence
if (current == '\\' && charLeft)
{ //possible escape sequence
++i;
--charLeft;
current = query[i];
switch(current) {
switch(current)
{
case 'r':
result[j] = '\r';
break;
Expand All @@ -70,38 +73,54 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
case 'd':
case 'o':
case 'x':
case 'u': {
case 'u':
{
int size = 0, base = 0;
if (current == 'b') { //11111111
if (current == 'b')
{ //11111111
size = 8, base = 2;
} else if (current == 'o') { //377
}
else if (current == 'o')
{ //377
size = 3, base = 8;
} else if (current == 'd') { //255
}
else if (current == 'd')
{ //255
size = 3, base = 10;
} else if (current == 'x') { //0xFF
}
else if (current == 'x')
{ //0xFF
size = 2, base = 16;
} else if (current == 'u') { //0xCDCD
}
else if (current == 'u')
{ //0xCDCD
size = 4, base = 16;
}
if (charLeft >= size) {

if (charLeft >= size)
{
int res = 0;
if (Searching::readBase(query+(i+1), &res, base, size)) {
if (Searching::readBase(query+(i+1), &res, base, size))
{
result[j] = (TCHAR)res;
i+=size;
i += size;
break;
}
}
//not enough chars to make parameter, use default method as fallback
}
default: { //unknown sequence, treat as regular text
}

default:
{ //unknown sequence, treat as regular text
result[j] = '\\';
++j;
result[j] = current;
isGood = false;
break;
}
}
} else {
}
else
{
result[j] = query[i];
}
++i;
Expand Down
Loading

0 comments on commit e1d8e05

Please sign in to comment.