From c906b40fe9ef0c465c243c1e61f9d3dae24300a2 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 30 Nov 2006 20:57:52 +0000 Subject: [PATCH] - bye bye fixdef svn path=/trunk/; revision=25006 --- reactos/tools/fixdef/fixdef.cpp | 311 -------------------------------- reactos/tools/fixdef/fixdef.mak | 46 ----- reactos/tools/tools.mak | 3 +- 3 files changed, 1 insertion(+), 359 deletions(-) delete mode 100644 reactos/tools/fixdef/fixdef.cpp delete mode 100644 reactos/tools/fixdef/fixdef.mak diff --git a/reactos/tools/fixdef/fixdef.cpp b/reactos/tools/fixdef/fixdef.cpp deleted file mode 100644 index a0db322a508..00000000000 --- a/reactos/tools/fixdef/fixdef.cpp +++ /dev/null @@ -1,311 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#define _FINDDATA_T_DEFINED -#include -#include - - typedef std::basic_string string; - typedef std::basic_istringstream istringstream; - -#ifdef UNICODE - - using std::wcout; - using std::wcerr; - using std::endl; - -#define cout wcout -#define cerr wcerr - -#else - - using std::cout; - using std::cerr; - using std::endl; - -#endif - -using std::vector; -using std::endl; - - -bool scan_dir(string current_dir, vector & def_files) -{ - vector vect; - string val = current_dir; - val.insert (val.length(), _T("\\*")); - - struct _tfinddatai64_t c_file; - intptr_t hFile = _tfindfirsti64(val.c_str(), &c_file); - - if (hFile == -1L) - { - cerr << "scan_dir failed" << val << endl; - return false; - } - - do - { - - do - { - TCHAR * pos; - if ((pos = _tcsstr(c_file.name, _T(".def")))) - { - string modulename = c_file.name; - if (modulename.find (_T(".spec.def")) != string::npos) - { - /// - /// ignore spec files - /// - continue; - } - string fname = current_dir; - fname.insert (fname.length (), _T("\\")); - fname.insert (fname.length (), modulename); - cout << "adding file to scan list: "<< fname << endl; - def_files.push_back(fname); - } - if (c_file.attrib & _A_SUBDIR) - { - if (!_tcscmp(c_file.name, _T(".svn"))) - { - /// - /// ignore .svn directories - /// - continue; - } - if (c_file.name[0] != _T('.')) - { - string path = current_dir; - path.insert (path.length(), _T("\\")); - path.insert (path.length(), c_file.name); - vect.push_back (path); - } - } - - }while(_tfindnexti64(hFile, &c_file) == 0); - - _findclose(hFile); - hFile = -1L; - - while(!vect.empty ()) - { - current_dir = vect.front (); - vect.erase (vect.begin()); - val = current_dir; - val.insert (val.length(), _T("\\*")); - hFile = _tfindfirsti64(val.c_str(), &c_file); - if (hFile != -1L) - { - break; - } - } - - if (hFile == -1L) - { - break; - } - - }while(1); - - return !def_files.empty (); -} - -bool readFile(string filename, vector & file) -{ - FILE * fd = _tfopen(filename.c_str(), _T("rt")); - if (!fd) - { - cerr << "Error: failed to open file " << filename << endl; - return false; - } - - do - { - TCHAR szBuffer[256]; - memset(szBuffer, 0x0, sizeof(szBuffer)); - - if(_fgetts(szBuffer, sizeof(szBuffer) / sizeof(char), fd)) - { - string line = szBuffer; - file.push_back (line); - } - }while(!feof(fd)); - - fclose(fd); - return true; -} - -bool has_cdecl_convention(string & line) -{ - if (line[0] == _T('_')) - { - return true; - } - return false; -} - -bool has_fastcall_convention(string & line) -{ - if (line[0] == _T('@')) - { - return true; - } - return false; -} - -bool has_stdcall_convention(string & line) -{ - if (!has_cdecl_convention(line) && !has_fastcall_convention(line)) - { - size_t pos = line.find (_T("@")); - if (pos == string::npos) - { - /// - /// the stdcall decorate is removed - /// - return false; - } - assert(pos > 1); - if (line[pos-1] == _T(' ')) - { - /// - /// its an export ordinal - /// - return false; - } - - return true; - } - else - { - return false; - } -} - - -bool has_export_ordinal(string & line) -{ - if (line.find_last_of (_T(" @")) != string::npos) - { - return true; - } - return false; -} - -void remove_stdcall_convention(string & line) -{ - size_t pos = line.find (_T("@")); - assert(pos != string::npos); - line.erase (pos, 1); - - while(_istdigit(line[pos])) - line.erase (pos, 1); -} - - - - -bool convertFile(string filename, vector & file) -{ - bool modified = false; - //cerr << "entered with: "<< filename << " size: " << file.size () << endl; - - for(size_t i = 0; i < file.size(); i++) - { - string & line = file[i]; - if (line[0] == _T(';')) - { - /// - /// line is a comment ignore - /// - continue; - } - size_t pos = line.find (_T("=")); - if (pos != string::npos) - { - string part1 = line.substr (0, pos); - string part2 = line.substr (pos+1, line.length () - pos - 1); - if (has_stdcall_convention(part1)) - { - modified = true; - remove_stdcall_convention(part1); - } - if (has_stdcall_convention(part2)) - { - modified = true; - remove_stdcall_convention(part2); - } - line = part1; - line.insert (line.length (), _T("=")); - line.insert (line.length (), part2); - } - else if (has_stdcall_convention(line)) - { - modified = true; - remove_stdcall_convention(line); - } - //cout << line; - } - return modified; -} - -bool writeFile(string filename, vector & file) -{ - FILE * fd = _tfopen(filename.c_str(), _T("wt")); - if (!fd) - { - cerr << "Error: failed to open file " << filename << endl; - return false; - } - - for(size_t i = 0; i < file.size (); i++) - { - string & line = file[i]; - _fputts(line.c_str (), fd); - } - return true; -} - - -int _tmain(int argc, TCHAR ** argv) -{ - string current_dir; - vector def_files; - - if (argc < 2) - { - cout << "Usage: " << argv[0] << "path to source" << endl; - return -1; - } - - if (!scan_dir(argv[1], def_files) || def_files.size() == 0) - { - cout << "Error: found no def files or invalid directory" << endl; - return -1; - } - - for (size_t i = 0; i < def_files.size(); i++) - { - vector file; - file.clear (); - string filename = def_files[i]; - - - if (readFile(filename, file)) - { - convertFile(filename, file); - filename.insert (filename.find(_T(".")), _T("_msvc")); - cout << "Writing file: " << filename << endl; - writeFile(filename, file); - } - } - - return 0; -} diff --git a/reactos/tools/fixdef/fixdef.mak b/reactos/tools/fixdef/fixdef.mak deleted file mode 100644 index 4f19bf978b2..00000000000 --- a/reactos/tools/fixdef/fixdef.mak +++ /dev/null @@ -1,46 +0,0 @@ -FIXDEF_BASE = $(TOOLS_BASE)$(SEP)fixdef -FIXDEF_BASE_ = $(FIXDEF_BASE)$(SEP) -FIXDEF_INT = $(INTERMEDIATE_)$(FIXDEF_BASE) -FIXDEF_INT_ = $(FIXDEF_INT)$(SEP) -FIXDEF_OUT = $(OUTPUT_)$(FIXDEF_BASE) -FIXDEF_OUT_ = $(FIXDEF_OUT)$(SEP) - -$(FIXDEF_INT): | $(TOOLS_INT) - $(ECHO_MKDIR) - ${mkdir} $@ - -ifneq ($(INTERMEDIATE),$(OUTPUT)) -$(FIXDEF_OUT): | $(TOOLS_OUT) - $(ECHO_MKDIR) - ${mkdir} $@ -endif - -FIXDEF_TARGET = \ - $(EXEPREFIX)$(FIXDEF_OUT_)FIXDEF$(EXEPOSTFIX) - -FIXDEF_SOURCES = $(addprefix $(FIXDEF_BASE_), \ - fixdef.cpp \ - ) - -FIXDEF_OBJECTS = \ - $(addprefix $(INTERMEDIATE_), $(FIXDEF_SOURCES:.cpp=.o)) - -FIXDEF_HOST_CFLAGS = $(TOOLS_CFLAGS) -D__USE_W32API -Iinclude -Iinclude/reactos -Iinclude/psdk - -FIXDEF_HOST_LFLAGS = $(TOOLS_LFLAGS) -lntdll - -.PHONY: FIXDEF -FIXDEF: $(FIXDEF_TARGET) - -$(FIXDEF_TARGET): $(FIXDEF_OBJECTS) | $(FIXDEF_OUT) - $(ECHO_LD) - ${host_gpp} $(FIXDEF_OBJECTS) $(FIXDEF_HOST_LFLAGS) -o $@ - -$(FIXDEF_INT_)fixdef.o: $(FIXDEF_BASE_)fixdef.cpp | $(FIXDEF_INT) - $(ECHO_CC) - ${host_gpp} $(FIXDEF_HOST_CFLAGS) -c $< -o $@ - -.PHONY: FIXDEF_clean -FIXDEF_clean: - -@$(rm) $(FIXDEF_TARGET) $(FIXDEF_OBJECTS) 2>$(NUL) -clean: FIXDEF_clean \ No newline at end of file diff --git a/reactos/tools/tools.mak b/reactos/tools/tools.mak index 899a2e4666f..ff8f187acbe 100644 --- a/reactos/tools/tools.mak +++ b/reactos/tools/tools.mak @@ -59,5 +59,4 @@ include tools/wmc/wmc.mak include tools/wpp/wpp.mak include tools/wrc/wrc.mak include tools/sysreg/sysreg.mak -include tools/dbgprint/dbgprint.mak -include tools/fixdef/fixdef.mak \ No newline at end of file +include tools/dbgprint/dbgprint.mak \ No newline at end of file