1 | #include "common.h"
|
---|
2 |
|
---|
3 | CRegExp obj_RegExp;
|
---|
4 |
|
---|
5 | CRegExp::CRegExp(){
|
---|
6 | char temporary[MAX_PATH];
|
---|
7 | sprintf(temporary,"%sSubOperation\\BREGEXP.DLL",pj_editor_Dir);
|
---|
8 |
|
---|
9 | hLib=LoadLibrary(temporary);
|
---|
10 |
|
---|
11 | BMatch=(PFUNC_BMatch)GetProcAddress(hLib,"BMatch");
|
---|
12 | BSubst=(PFUNC_BSubst)GetProcAddress(hLib,"BSubst");
|
---|
13 | BTrans=(PFUNC_BTrans)GetProcAddress(hLib,"BTrans");
|
---|
14 | BSplit=(PFUNC_BSplit)GetProcAddress(hLib,"BSplit");
|
---|
15 | BRegfree=(PFUNC_BRegfree)GetProcAddress(hLib,"BRegfree");
|
---|
16 | BRegexpVersion=(PFUNC_BRegexpVersion)GetProcAddress(hLib,"BRegexpVersion");
|
---|
17 | }
|
---|
18 | CRegExp::~CRegExp(){
|
---|
19 | FreeLibrary(hLib);
|
---|
20 | }
|
---|
21 |
|
---|
22 | char *CRegExp::compare(HWND hFindDlg,char *buffer,char *exp,BOOL IsBigSmall, bool isWordUnit ,int *pLength){
|
---|
23 | BREGEXP *rxp=0;
|
---|
24 | char msg[255];
|
---|
25 |
|
---|
26 | char *pTemp;
|
---|
27 | pTemp=(char *)HeapAlloc(hHeap,0,lstrlen(exp)+255);
|
---|
28 | if(strstr(exp,"/")){
|
---|
29 | if(strstr(exp,"#")){
|
---|
30 | sprintf(pTemp,"m@(%s)@",exp);
|
---|
31 | }
|
---|
32 | else sprintf(pTemp,"m#(%s)#",exp);
|
---|
33 | }
|
---|
34 | else sprintf(pTemp,"m/(%s)/",exp);
|
---|
35 |
|
---|
36 | //Shift-JISで表現
|
---|
37 | lstrcat(pTemp,"k");
|
---|
38 |
|
---|
39 | //大文字・小文字
|
---|
40 | if(!IsBigSmall) lstrcat(pTemp,"i");
|
---|
41 |
|
---|
42 | int result;
|
---|
43 | result=BMatch(pTemp,buffer,buffer+lstrlen(buffer),&rxp,msg);
|
---|
44 |
|
---|
45 | HeapDefaultFree(pTemp);
|
---|
46 |
|
---|
47 | if(!result){
|
---|
48 | if(rxp) BRegfree(rxp);
|
---|
49 | return 0;
|
---|
50 | }
|
---|
51 | else if(result==-1){
|
---|
52 | if(rxp) BRegfree(rxp);
|
---|
53 | MessageBox(hFindDlg,msg,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
|
---|
54 | return (char *)-1;
|
---|
55 | }
|
---|
56 |
|
---|
57 | *pLength=(rxp->outendp) - (rxp->outp);
|
---|
58 | if((*pLength)==0) return 0;
|
---|
59 |
|
---|
60 | pTemp=ComparisonString(buffer,(char *)rxp->outp,false, isWordUnit);
|
---|
61 |
|
---|
62 | if(rxp) BRegfree(rxp);
|
---|
63 |
|
---|
64 | return pTemp;
|
---|
65 | }
|
---|
66 | char *CRegExp::GetPermuStr(HWND hFindDlg,char *buffer,char *exp,char *szPermu,BOOL IsBigSmall){
|
---|
67 | BREGEXP *rxp=0;
|
---|
68 | char msg[255];
|
---|
69 |
|
---|
70 | char *pTemp;
|
---|
71 | pTemp=(char *)HeapAlloc(hHeap,0,lstrlen(exp)+255);
|
---|
72 | if(strstr(exp,"/")||strstr(szPermu,"/")){
|
---|
73 | if(strstr(exp,"#")||strstr(szPermu,"#")){
|
---|
74 | sprintf(pTemp,"s@%s@%s@",exp,szPermu);
|
---|
75 | }
|
---|
76 | else sprintf(pTemp,"s#%s#%s#",exp,szPermu);
|
---|
77 | }
|
---|
78 | else sprintf(pTemp,"s/%s/%s/",exp,szPermu);
|
---|
79 |
|
---|
80 | //Shift-JISで表現
|
---|
81 | lstrcat(pTemp,"k");
|
---|
82 |
|
---|
83 | //大文字・小文字
|
---|
84 | if(!IsBigSmall) lstrcat(pTemp,"i");
|
---|
85 |
|
---|
86 | int result;
|
---|
87 | result=BSubst(pTemp,buffer,buffer+lstrlen(buffer),&rxp,msg);
|
---|
88 |
|
---|
89 | HeapDefaultFree(pTemp);
|
---|
90 |
|
---|
91 | if(!result){
|
---|
92 | if(rxp) BRegfree(rxp);
|
---|
93 | return 0;
|
---|
94 | }
|
---|
95 | else if(result==-1){
|
---|
96 | if(rxp) BRegfree(rxp);
|
---|
97 | MessageBox(hFindDlg,msg,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
|
---|
98 | return (char *)-1;
|
---|
99 | }
|
---|
100 |
|
---|
101 | int length;
|
---|
102 | length=(rxp->outendp) - (rxp->outp);
|
---|
103 |
|
---|
104 | pTemp=(char *)HeapAlloc(hHeap,0,length+1);
|
---|
105 | memcpy(pTemp,rxp->outp,length);
|
---|
106 | pTemp[length]=0;
|
---|
107 |
|
---|
108 | if(rxp) BRegfree(rxp);
|
---|
109 |
|
---|
110 | return pTemp;
|
---|
111 | }
|
---|