From 5585955fe703030dfcda3be1c66b81635375fc03 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 24 Apr 2015 09:40:10 +0000 Subject: StrReplace function removed git-svn-id: http://svn.miranda-ng.org/main/trunk@13076 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/src/exportimport.cpp | 42 ++++----------------------------- plugins/DbEditorPP/src/headers.h | 1 + 2 files changed, 6 insertions(+), 37 deletions(-) (limited to 'plugins') diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index a89e69265b..3537a3a04e 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -44,39 +44,6 @@ static int Openfile(TCHAR *outputFile, const char *module) return 1; } -char* StrReplace(char* Search, char* Replace, char* Resource) -{ - int i = 0; - int SearchLen = (int)_tcslen(Search); - char* Work = mir_tstrdup(Replace); - int ReplaceLen = (int)_tcslen(Work); - - char* Pointer = _tcsstr(Resource, Search); - - while (Pointer != NULL) { - int PointerLen = (int)_tcslen(Pointer); - int ResourceLen = (int)_tcslen(Resource); - - char* NewText = (char*)mir_calloc((ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); - - _tcsncpy(NewText, Resource, ResourceLen - PointerLen); - _tcscat(NewText, Work); - _tcscat(NewText, Pointer + SearchLen); - - Resource = (char*)mir_realloc(Resource, (ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); - - for (i = 0; i < (ResourceLen - SearchLen + ReplaceLen); i++) - Resource[i] = NewText[i]; - Resource[i] = 0; - mir_free(NewText); - - Pointer = _tcsstr(Resource + (ResourceLen - PointerLen + ReplaceLen), Search); - } - mir_free(Work); - - return Resource; -} - void exportModule(MCONTACT hContact, char *module, FILE *file) { char tmp[32]; @@ -107,10 +74,11 @@ void exportModule(MCONTACT hContact, char *module, FILE *file) case DBVT_ASCIIZ: case DBVT_UTF8: if (strchr(dbv.pszVal, '\r')) { - char *end = StrReplace("\\", "\\\\", dbv.pszVal); - end = StrReplace("\r", "\\r", end); - end = StrReplace("\n", "\\n", end); - fprintf(file, "\n%s=g%s", setting->name, end); + CMStringA end = dbv.pszVal; + end.Replace("\\", "\\\\"); + end.Replace("\r", "\\r"); + end.Replace("\n", "\\n"); + fprintf(file, "\n%s=g%s", setting->name, end.c_str()); break; } fprintf(file, "\n%s=%c", setting->name, (dbv.type == DBVT_UTF8) ? 'u' : 's'); diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h index 1c45c21b71..1dbf4f640c 100644 --- a/plugins/DbEditorPP/src/headers.h +++ b/plugins/DbEditorPP/src/headers.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "m_toptoolbar.h" -- cgit v1.2.3