Skip to content

Commit

Permalink
Imp: MinGW32 コンパイル対応
Browse files Browse the repository at this point in the history
upatchid:271
Contributed by minoki


git-svn-id: https://svn.code.sf.net/p/sakura-editor/code/sakura/trunk2@2543 f7ce1907-e4c7-47ca-9f76-12c87ed2c91c
  • Loading branch information
moca_skr committed Jan 2, 2013
1 parent 93104b8 commit a05c879
Show file tree
Hide file tree
Showing 132 changed files with 1,032 additions and 330 deletions.
86 changes: 86 additions & 0 deletions btool/mrc2grc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

bool sjis_1(char* p)
{
unsigned char* x = reinterpret_cast<unsigned char*>(p);
return (static_cast<unsigned int>((*x) ^ 0x20) - 0xa1 < 0x3c);
}

bool sjis_2(char *p)
{
unsigned char* x = reinterpret_cast<unsigned char*>(p);
return (0x40 <= (*x) && (*x) <= 0xfc && (*x) != 0x7f);
}

void convert(const char* infile, const char* outfile)
{
FILE* fin = fopen(infile, "r");
FILE* fout = fopen(outfile, "w");
if( NULL == fin ){
fprintf(stderr, "infile cannot open.\n");
return;
}
if( NULL == fout ){
fprintf(stderr, "outfile cannot open.\n");
return;
}
const int nBufferSize = 100;
char buffer[nBufferSize];
char outbuffer[nBufferSize*2];
int carrierlen = 0;
while( NULL != fgets(buffer + carrierlen, nBufferSize-carrierlen, fin) ){
char* p = buffer;
char* o = outbuffer;
carrierlen = 0;
while( '\0' != *p ){
if( sjis_1(p) && sjis_2(p+1) ){
*o++ = *p++;
// SJISの2バイト目が\だったときだけ\を付加する
if( *p == '\\' ){
*o++ = '\\';
}
*o++ = *p++;
}else if( sjis_1(p) && *(p+1) == '\0' ){
// 1byte次回持越し
buffer[0] = *p++;
buffer[1] = '\0';
carrierlen = 1;
}else{
*o++ = *p++;
}
}
*o = '\0';
fputs(outbuffer, fout);
}
fclose(fin);
fclose(fout);
return;
}

void usage(char* av0)
{
char* fn;

fn = strrchr( av0, '\\' );
if( fn != NULL ){
fn++;
}else{
fn = av0;
}

fprintf(stderr, "%s inputfile outputfile", fn);
return ;
}

int main( int ac, char *av[] )
{
if( ac <= 2 )
{
usage(av[0]);
exit(0);
}
convert( av[1], av[2] );
return 0;
}
8 changes: 6 additions & 2 deletions sakura/sakura.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,10 @@
RelativePath="..\sakura_core\view\colors\CColorStrategy.h"
>
</File>
<File
RelativePath="..\sakura_core\view\colors\EColorIndexType.h"
>
</File>
</Filter>
<Filter
Name="figures"
Expand Down Expand Up @@ -2905,11 +2909,11 @@
>
</File>
<File
RelativePath="..\sakura_core\debug\Debug.cpp"
RelativePath="..\sakura_core\debug\Debug1.cpp"
>
</File>
<File
RelativePath="..\sakura_core\debug\Debug.h"
RelativePath="..\sakura_core\debug\Debug1.h"
>
</File>
<File
Expand Down
8 changes: 8 additions & 0 deletions sakura_core/CBackupAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,17 @@ class CInvalidParameterHandler{
CInvalidParameterHandler()
{
bInvalid = false; // エラーの有無
#if 1400 <= _MSC_VER
oldParamFunc = _set_invalid_parameter_handler( newParamFunc ); // Release 用(無効パラメータハンドラ)
oldRepoFunc = _CrtSetReportHook( newRepoFunc ); // Debug 用(デバッグレポートフック)
#endif
}
~CInvalidParameterHandler()
{
#if 1400 <= _MSC_VER
_set_invalid_parameter_handler(oldParamFunc);
_CrtSetReportHook(oldRepoFunc);
#endif
}
bool IsInvalid(){ return bInvalid; }
private:
Expand All @@ -301,12 +305,16 @@ class CInvalidParameterHandler{
return TRUE;
}
static bool bInvalid;
#if 1400 <= _MSC_VER
static _invalid_parameter_handler oldParamFunc;
static _CRT_REPORT_HOOK oldRepoFunc;
#endif
};
bool CInvalidParameterHandler::bInvalid;
#if 1400 <= _MSC_VER
_invalid_parameter_handler CInvalidParameterHandler::oldParamFunc;
_CRT_REPORT_HOOK CInvalidParameterHandler::oldRepoFunc;
#endif


/*! バックアップの作成
Expand Down
20 changes: 12 additions & 8 deletions sakura_core/CDataProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,34 @@
#include "CProfile.h"

//文字列バッファの型
struct StringBufferW{
struct StringBufferW_{
WCHAR* pData;
const int nDataCount;

StringBufferW() : pData(L""), nDataCount(0) { }
StringBufferW(WCHAR* _pData, int _nDataCount) : pData(_pData), nDataCount(_nDataCount) { }
// StringBufferW_() : pData(L""), nDataCount(0) { }
StringBufferW_(WCHAR* _pData, int _nDataCount) : pData(_pData), nDataCount(_nDataCount) { }

StringBufferW& operator = (const StringBufferW& rhs)
StringBufferW_& operator = (const StringBufferW_& rhs)
{
auto_strcpy_s(pData,nDataCount,rhs.pData);
return *this;
}
};
struct StringBufferA{
struct StringBufferA_{
ACHAR* pData;
int nDataCount;

StringBufferA() : pData(""), nDataCount(0) { }
StringBufferA(ACHAR* _pData, int _nDataCount) : pData(_pData), nDataCount(_nDataCount) { }
// StringBufferA_() : pData(""), nDataCount(0) { }
StringBufferA_(ACHAR* _pData, int _nDataCount) : pData(_pData), nDataCount(_nDataCount) { }

StringBufferA& operator = (const StringBufferA& rhs)
StringBufferA_& operator = (const StringBufferA_& rhs)
{
auto_strcpy_s(pData,nDataCount,rhs.pData);
return *this;
}
};
typedef const StringBufferA_ StringBufferA;
typedef const StringBufferW_ StringBufferW;
#ifdef _UNICODE
typedef StringBufferW StringBufferT;
#else
Expand All @@ -74,7 +76,9 @@ class CDataProfile : public CProfile{
private:
//専用型
typedef std::wstring wstring;
#ifndef UNICODE
typedef std::tstring tstring;
#endif

protected:
static const wchar_t* _work_itow(int n)
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/CDicMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ BOOL CDicMgr::Search(
CRunningTimer cRunningTimer( "CDicMgr::Search" );
#endif
long i;
wchar_t* pszDelimit = L" /// ";
const wchar_t* pszDelimit = L" /// ";
wchar_t* pszWork;
int nRes;
wchar_t* pszToken;
wchar_t* pszKeySeps = L",\0";
const wchar_t* pszKeySeps = L",\0";


/* 辞書ファイル */
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/CDllHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template <class DLLIMP> class CDllHandler{
DLLIMP* operator->(){ return m_pcDllImp; }

//! 利用状態のチェック(operator版)
bool operator!() const { return IsAvailable(); }
bool operator!() const { return m_pcDllImp->IsAvailable(); }

private:
DLLIMP* m_pcDllImp;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/CGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CGraphics::Init(HDC hdc)
//ブラシ
m_hbrOrg = NULL;
m_hbrCurrent = NULL;
m_bDynamicBrush = NULL;
m_bDynamicBrush = false;
}

CGraphics::~CGraphics()
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/CHokanMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int CHokanMgr::Search(
nX -= nCX - 8;
}else{
// サイズを調整して右に表示
nCX = __max((int)(rcDesktop.right - nX) , 100); // 最低サイズを100くらいに
nCX = std::max((int)(rcDesktop.right - nX) , 100); // 最低サイズを100くらいに
}

// 2001/06/19 End
Expand Down
9 changes: 4 additions & 5 deletions sakura_core/CMenuDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,10 @@ TCHAR CMenuDrawer::GetAccelCharFromLabel( const TCHAR* pszLabel )




struct WorkData{
int idx;
MENUITEMINFO mii;
};

/*! メニューアクセスキー押下時の処理(WM_MENUCHAR処理) */
LRESULT CMenuDrawer::OnMenuChar( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
Expand All @@ -1591,10 +1594,6 @@ LRESULT CMenuDrawer::OnMenuChar( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
chUser = _totupper( chUser );
}

struct WorkData{
int idx;
MENUITEMINFO mii;
};
// 2011.11.18 vector化
std::vector<WorkData> vecAccel;
size_t nAccelSel = 99999;
Expand Down
1 change: 0 additions & 1 deletion sakura_core/COpe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "StdAfx.h"
#include "COpe.h"
#include "debug/Debug.h"
#include "mem/CMemory.h"// 2002/2/10 aroka


Expand Down
1 change: 0 additions & 1 deletion sakura_core/COpeBlk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <windows.h>
#include <stdlib.h>
#include "COpeBlk.h"
#include "debug/Debug.h"


// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
Expand Down
1 change: 0 additions & 1 deletion sakura_core/COpeBuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "StdAfx.h"
#include "COpeBuf.h"
#include "COpeBlk.h"// 2002/2/10 aroka
#include "debug/Debug.h"


// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
Expand Down
1 change: 0 additions & 1 deletion sakura_core/CPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <winspool.h>
#include "CPrint.h"
#include "_main/global.h"
#include "debug/Debug.h" // 2002/2/10 aroka


// 2006.08.14 Moca 用紙名一覧の重複削除・情報の統合
Expand Down
1 change: 0 additions & 1 deletion sakura_core/CPrintPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//#include "dlg/CDlgPrintPage.h"
#include "dlg/CDlgCancel.h"/// 2002/2/3 aroka from here
#include "dlg/CDlgInput1.h" /// 2007.02.11 Moca
//#include "debug/Debug.h"///
//#include <stdio.h>/// 2002/2/3 aroka to here
//#include <vector>
#include "CEditApp.h"
Expand Down
1 change: 0 additions & 1 deletion sakura_core/CProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
*/
#include "StdAfx.h"
#include "CProfile.h"
#include "debug/Debug.h"
#include "io/CTextStream.h"
#include "charset/CUtf8.h" // Resource読み込みに使用
#include "util/file.h"
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/CProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CProfile
{
//文字列型
typedef std::wstring wstring;
typedef std::tstring tstring;
typedef std::string string;

typedef std::pair< wstring, wstring > PAIR_STR_STR;
typedef std::map< wstring, wstring > MAP_STR_STR;
Expand Down
Loading

0 comments on commit a05c879

Please sign in to comment.