1 #include "include_c.h"
\r
3 enum { gs_PathLengthMax = 1024 };
\r
5 typedef struct _MainWorkClass MainWorkClass;
\r
6 struct _MainWorkClass {
\r
8 int NotEnglishCount_InReading;
\r
9 bool IsTry_ForCRT; /* CRT = C language runtime library */
\r
10 bool IsError_InCRT; /* CRT = C language runtime library */
\r
11 _invalid_parameter_handler old_invalid_parameter_handler;
\r
13 MainWorkClass g_MainWorkClass;
\r
15 int Main_getFilePathFromNestFind( FileT_CallByNestFindData* m );
\r
16 void Main_atExit( const wchar_t * expression, const wchar_t * function,
\r
17 const wchar_t* file, unsigned int line, uintptr_t pReserved );
\r
21 /***********************************************************************
\r
23 ************************************************************************/
\r
24 int _tmain( int argc, TCHAR* argv[] )
\r
27 MainWorkClass* work = &g_MainWorkClass;
\r
32 StrMatchKey* except_name;
\r
33 StrMatchKey* except_name_over;
\r
37 TCHAR check_folder_path[ gs_PathLengthMax ];
\r
38 TCHAR base_path[ gs_PathLengthMax ];
\r
39 TCHAR setting_path[ gs_PathLengthMax ];
\r
41 StrT_Mul_initConst( &paths );
\r
42 Set2_initConst( &except_names );
\r
43 work->ReadingPath = NULL;
\r
44 work->IsTry_ForCRT = false;
\r
45 work->IsError_InCRT = false;
\r
48 Globals_initConst();
\r
49 e= Globals_initialize(); IF(e){goto fin;}
\r
52 SetBreakErrorID( 1 );
\r
54 _tprintf( _T(" ((( CheckEnglishOnly )))\n") );
\r
55 _tprintf( _T("
\83e
\83L
\83X
\83g
\83t
\83@
\83C
\83\8b\82ª
\89p
\8cê
\82¾
\82¯
\82É
\82È
\82Á
\82Ä
\82¢
\82é
\82©
\83`
\83F
\83b
\83N
\82µ
\82Ü
\82·
\81B\n") );
\r
58 work->old_invalid_parameter_handler = _set_invalid_parameter_handler( Main_atExit );
\r
61 /* Set "check_folder_path" :
\89p
\8cê
\82¾
\82¯
\82©
\82ð
\83`
\83F
\83b
\83N
\82·
\82é
\83t
\83H
\83\8b\83_
\81[
\82Ì
\83p
\83X
\81A
\82Ü
\82½
\82Í
\81A
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X */
\r
62 _tcscpy_s( check_folder_path, _countof(check_folder_path), _T("") ); // default
\r
63 e= GetCommandLineNamed( _T("Folder"), false, check_folder_path, sizeof(check_folder_path) );
\r
64 if ( e != E_NOT_FOUND_SYMBOL ) { IF(e){goto fin;} }
\r
66 _tprintf( _T("
\83`
\83F
\83b
\83N
\82·
\82é
\83t
\83@
\83C
\83\8b\82Ü
\82½
\82Í
\83t
\83H
\83\8b\83_
\81[
\82Ì
\83p
\83X: %s\n"), check_folder_path );
\r
67 IF( ! FileT_isDir( check_folder_path ) ) goto err_fo;
\r
70 /* Set "setting_path" :
\90Ý
\92è
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X */
\r
71 _tcscpy_s( setting_path, _countof(setting_path), _T("") ); // default
\r
72 e= GetCommandLineNamed( _T("Setting"), false, setting_path, sizeof(setting_path) );
\r
73 if ( e != E_NOT_FOUND_SYMBOL ) { IF(e){goto fin;} }
\r
75 _tprintf( _T("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X: %s\n"), setting_path );
\r
76 IF( setting_path[0] != _T('\0') && ! FileT_isFile( setting_path ) ) {goto err_st;}
\r
78 if ( setting_path[0] != _T('\0') ) {
\r
79 e= StrT_getParentFullPath( base_path, sizeof( base_path ), setting_path, NULL );
\r
82 e= StrT_getFullPath( base_path, sizeof( base_path ), check_folder_path, NULL );
\r
87 /* Set "except_names" :
\90Ý
\92è
\83t
\83@
\83C
\83\8b\82É
\8ew
\92è
\82µ
\82½ "ExceptFile" */
\r
88 e= Set2_init( &except_names, 0x20 ); IF(e){goto fin;}
\r
89 if ( setting_path[0] != _T('\0') ) {
\r
91 TCHAR full_path[ gs_PathLengthMax ];
\r
93 e= FileT_openForRead( &f, setting_path ); IF(e){goto fin;}
\r
95 _fgetts( line, _countof(line), f );
\r
97 right = IniStr_refRight( line, true );
\r
98 if ( IniStr_isLeft( line, _T("ExceptFile") ) ) {
\r
100 if ( right[0] == _T('*') ) {
\r
101 e= StrT_cpy( full_path, sizeof( full_path ), right ); IF(e){goto fin;}
\r
103 e= StrT_getFullPath( full_path, sizeof( full_path ),
\r
104 right, base_path );
\r
108 e= Set2_alloc( &except_names, &except_name, StrMatchKey ); IF(e){goto fin;}
\r
109 StrMatchKey_initConst( except_name );
\r
110 e= StrMatchKey_init( except_name, full_path ); IF(e){goto fin;}
\r
112 if ( feof( f ) ) break;
\r
114 fclose( f ); f = NULL;
\r
118 /* Set "paths" :
\83`
\83F
\83b
\83N
\82·
\82é
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X
\82Ì
\8fW
\8d\87\81B"path"
\82Í
\83t
\83\8b \83p
\83X */
\r
119 e= StrT_Mul_init( &paths ); IF(e){goto fin;}
\r
120 e= FileT_callByNestFind( check_folder_path, 0, &paths, (FuncType) Main_getFilePathFromNestFind );
\r
123 for ( StrT_Mul_forEach( &paths, &path ) ) {
\r
125 /* "path"
\82ª
\81A
\83`
\83F
\83b
\83N
\82ð
\82µ
\82È
\82¢
\83t
\83@
\83C
\83\8b "except_names"
\82É
\8aÜ
\82Ü
\82ê
\82é
\82È
\82ç
\83X
\83L
\83b
\83v
\82·
\82é */
\r
126 except_name_over = (StrMatchKey*) except_names.Next;
\r
127 for ( except_name = (StrMatchKey*) except_names.First; except_name < except_name_over; except_name++ ) {
\r
128 if ( StrMatchKey_isMatch( except_name, path ) ) { break; }
\r
130 if ( except_name < except_name_over ) { continue; }
\r
133 /* "path"
\83t
\83@
\83C
\83\8b\82ð
\8aJ
\82 */
\r
134 e= FileT_openForRead( &f, path ); IF(e){goto fin;}
\r
135 work->ReadingPath = path;
\r
136 work->NotEnglishCount_InReading = 0;
\r
140 /*
\83`
\83F
\83b
\83N
\82·
\82é
\83t
\83@
\83C
\83\8b\82Ì
\8ds
\82Ì
\83\8b\81[
\83v */
\r
142 line[0] = _T('\0');
\r
143 work->IsTry_ForCRT = true;
\r
144 _fgetts( line, _countof(line), f );
\r
145 work->IsTry_ForCRT = false;
\r
146 IF( ferror( f ) ) goto err;
\r
147 IF( work->IsError_InCRT ) { e=E_BINARY_FILE; goto fin; }
\r
149 if ( line[0] != _T('\0') ) {
\r
151 TCHAR step_path[ gs_PathLengthMax ];
\r
153 /* 1
\8ds
\95ª
\82Ì
\83e
\83L
\83X
\83g
\82ª
\81A
\82·
\82×
\82Ä
\89p
\8cê
\82Å
\82È
\82¯
\82ê
\82Î
\81A
\83G
\83\89\81[
\83\81\83b
\83Z
\81[
\83W
\82Æ
\93à
\97e
\82ð
\95\
\8e¦
\82·
\82é */
\r
154 for ( p = &line[0]; *p != _T('\0'); p++ ) {
\r
156 work->NotEnglishCount_InReading += 1;
\r
157 if ( work->NotEnglishCount_InReading == 1 ) {
\r
158 e= StrT_getStepPath( step_path, sizeof( step_path ),
\r
162 _tprintf( _T("\n<FILE path=\"%s\">\n"), step_path );
\r
164 e= StrT_trim( line, sizeof(line), line ); IF(e){goto fin;}
\r
165 e= StrT_changeToXML_Attribute( line, sizeof(line), line ); IF(e){goto fin;}
\r
166 _tprintf( _T(" <LINE num=\"%d\" text=\"%s\"/>\n"), line_num, line );
\r
171 if ( feof( f ) ) break;
\r
173 if ( work->NotEnglishCount_InReading > 0 ) {
\r
174 _tprintf( _T(" <SUMMARY count=\"%d\"/>\n"), work->NotEnglishCount_InReading );
\r
175 _tprintf( _T("</FILE>\n") );
\r
178 e= FileT_closeAndNULL( &f, 0 ); IF(e){goto fin;}
\r
179 work->ReadingPath = NULL;
\r
181 if ( is_eng ) goto err;
\r
185 e= FileT_closeAndNULL( &f, e );
\r
186 e= StrT_Mul_finish( &paths, e );
\r
188 except_name_over = (StrMatchKey*) except_names.Next;
\r
189 for ( except_name = (StrMatchKey*) except_names.First; except_name < except_name_over; except_name++ ) {
\r
190 e= StrMatchKey_finish( except_name, e );
\r
192 e= Set2_finish( &except_names, e );
\r
194 e= Globals_finalize( e );
\r
195 Error4_showToStdErr( e );
\r
203 Error4_printf( _T("<ERROR msg=\"
\83t
\83H
\83\8b\83_
\81[
\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ\"/>") );
\r
207 Error4_printf( _T("<ERROR msg=\"
\90Ý
\92è
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ\"/>") );
\r
213 /***********************************************************************
\r
214 <<< [Main_getFilePathFromNestFind] >>>
\r
215 ************************************************************************/
\r
216 int Main_getFilePathFromNestFind( FileT_CallByNestFindData* m )
\r
220 TCHAR full_path[ gs_PathLengthMax ];
\r
222 paths = (StrT_Mul*) m->CallerArgument;
\r
223 e= StrT_getFullPath( full_path, sizeof(full_path), m->FullPath, NULL ); IF(e){goto fin;}
\r
224 e= StrT_Mul_add( paths, full_path, NULL ); IF(e){goto fin;}
\r
233 /***********************************************************************
\r
234 <<< [Main_atExit] >>>
\r
235 ************************************************************************/
\r
236 void Main_atExit( const wchar_t * expression, const wchar_t * function,
\r
237 const wchar_t* file, unsigned int line, uintptr_t pReserved )
\r
239 MainWorkClass* work = &g_MainWorkClass;
\r
241 if ( work->IsTry_ForCRT ) {
\r
243 if ( work->NotEnglishCount_InReading == 0 ) {
\r
244 _tprintf( _T("<FILE path=\"%s\">\n"), work->ReadingPath );
\r
246 _tprintf( _T(" <LINE num=\"0\" text=\"(This is binary file)\"/>\n") );
\r
247 _tprintf( _T("</FILE>\n") );
\r
248 work->IsError_InCRT = true;
\r
251 work->old_invalid_parameter_handler( expression, function, file, line, pReserved );
\r