i post here an example code
two functions use the same code
except one thing
one function uses PellesC memmove
the other uses Mymemmove
watch the results:
// *********************************************************************
// Created with BCX - BASIC To C/C++ Translator (V) 7.00 (10.11.15)
// BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
// Translated for compiling with a C Compiler
// *********************************************************************
#include <windows.h> // Win32 Header File
#include <windowsx.h> // Win32 Header File
#include <commctrl.h> // Win32 Header File
#include <commdlg.h> // Win32 Header File
#include <mmsystem.h> // Win32 Header File
#include <shellapi.h> // Win32 Header File
#include <shlobj.h> // Win32 Header File
#include <richedit.h> // Win32 Header File
#include <wchar.h> // Win32 Header File
#include <objbase.h> // Win32 Header File
#include <ocidl.h> // Win32 Header File
#include <winuser.h> // Win32 Header File
#include <olectl.h> // Win32 Header File
#include <oaidl.h> // Win32 Header File
#include <ole2.h> // Win32 Header File
#include <oleauto.h> // Win32 Header File
#include <winsock.h> // Win32 Header File
#include <conio.h>
#include <direct.h>
#include <ctype.h>
#include <io.h>
#include <fcntl.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <process.h>
// ***************************************************
// Compiler Defines
// ***************************************************
// C++
#if defined( __cplusplus )
#define overloaded
#define C_EXPORT EXTERN_C __declspec(dllexport)
#define C_IMPORT EXTERN_C __declspec(dllimport)
#else
#define C_EXPORT __declspec(dllexport)
#define C_IMPORT __declspec(dllimport)
#endif
// Open Watcom defs
#if defined( __WATCOM_CPLUSPLUS__ ) || defined( __TINYC__ )
#define atanl atan
#define sinl sin
#define cosl cos
#define tanl tan
#define asinl asin
#define acosl acos
#define log10l log10
#define logl log
#define _fcloseall fcloseall
#endif
// Borland C++ 5.5.1 defs - bcc32.exe
#if defined( __BCPLUSPLUS__ )
// ===== Borland Libraries ==========
#include <dos.h>
#pragma comment(lib,"import32.lib")
#pragma comment(lib,"cw32.lib")
// ==================================
#endif
// Microsoft VC++
#ifndef DECLSPEC_UUID
#if (_MSC_VER >= 1100) && defined ( __cplusplus )
#define DECLSPEC_UUID(x) __declspec(uuid(x))
#else
#define DECLSPEC_UUID(x)
#endif
#endif
#define BCX_STRING_SIZE 2048
// *************************************************
#if !defined( __LCC__ )
// *************************************************
// Instruct Linker to Search Object/Import Libraries
// *************************************************
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"advapi32.lib")
#pragma comment(lib,"winspool.lib")
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"ole32.lib")
#pragma comment(lib,"oleaut32.lib")
#pragma comment(lib,"uuid.lib")
#pragma comment(lib,"odbc32.lib")
#pragma comment(lib,"odbccp32.lib")
#pragma comment(lib,"winmm.lib")
#pragma comment(lib,"comdlg32.lib")
#pragma comment(lib,"imagehlp.lib")
#pragma comment(lib,"version.lib")
#else
#pragma lib <winspool.lib>
#pragma lib <shell32.lib>
#pragma lib <ole32.lib>
#pragma lib <oleaut32.lib>
#pragma lib <uuid.lib>
#pragma lib <odbc32.lib>
#pragma lib <odbccp32.lib>
#pragma lib <winmm.lib>
#pragma lib <imagehlp.lib>
#pragma lib <version.lib>
// *************************************************
// End of Object/Import Libraries To Search
// *************************************************
#endif
// *************************************************
// User Global Initialized Arrays
// *************************************************
// *************************************************
// Runtime Functions
// *************************************************
// *************************************************
// Main Program
// *************************************************
char myBuf[100];
char *MyPtr1;
#define TranslateSlash 1
void Mymemmove(char *dest,char *src,int sze) {
register int i = sze;
dest+=i;
src+=i;
while(i) {
src--;
dest--;
dest[0]=src[0];
i--;
}
}
void Test1(void)
{
int j,eStr = 1;
MyPtr1 = myBuf;
strcpy(MyPtr1,"\"0rntx\\\"");
printf("the token is =%s=\n",MyPtr1);
REPEAT0000:;
do {
++MyPtr1;
if(MyPtr1[0]==92)
{
++MyPtr1;
if(TranslateSlash)
{
if(eStr)
{
j=strlen(MyPtr1);
printf("MyPtr =%s= Len=%d\n",MyPtr1,(int)j);
memmove(MyPtr1+1,MyPtr1,j+1);
printf("the token after poke is =%s=\n ptr after poke is=%s=\n",myBuf,MyPtr1);
MyPtr1[0] = 92;
}
goto REPEAT0000;
}
goto EndSelect_3;
}
if(MyPtr1[0]==2)
{
MyPtr1[0] = 92;
goto REPEAT0000;
}
EndSelect_3:;
}while(!(MyPtr1[0]==0));
printf("the token after slash =%s=\n",myBuf);
}
void Test2(void)
{
int j,eStr = 1;
MyPtr1 = myBuf;
strcpy(MyPtr1,"\"0rntx\\\"");
printf("the token is =%s=\n",MyPtr1);
REPEAT0000:;
do {
++MyPtr1;
if(MyPtr1[0]==92)
{
++MyPtr1;
if(TranslateSlash)
{
if(eStr)
{
j=strlen(MyPtr1);
printf("MyPtr =%s= Len=%d\n",MyPtr1,(int)j);
Mymemmove(MyPtr1+1,MyPtr1,j+1);
printf("the token after poke is =%s=\n ptr after poke is=%s=\n",myBuf,MyPtr1);
MyPtr1[0] = 92;
}
goto REPEAT0000;
}
goto EndSelect_3;
}
if(MyPtr1[0]==2)
{
MyPtr1[0] = 92;
goto REPEAT0000;
}
EndSelect_3:;
}while(!(MyPtr1[0]==0));
printf("the token after slash =%s=\n",myBuf);
}
int __cdecl main(int argc, char** argv)
{
printf("using PellesC memmove\n");
Test1();
printf("\n\nnow using my memmove\n");
Test2();
} // End of main program
the output of this is:
using PellesC memmove
the token is ="0rntx\"=
MyPtr ="= Len=1
the token after poke is ="0rntx\"=
ptr after poke is="=
the token after slash ="0rntx\\=
now using my memmove
the token is ="0rntx\"=
MyPtr ="= Len=1
the token after poke is ="0rntx\""=
ptr after poke is=""=
the token after slash ="0rntx\\"=
the second output (mymemmove) is the correct one
the output of this when using other compiler is:
using PellesC memmove
the token is ="0rntx\"=
MyPtr ="= Len=1
the token after poke is ="0rntx\""=
ptr after poke is=""=
the token after slash ="0rntx\\"=
now using my memmove
the token is ="0rntx\"=
MyPtr ="= Len=1
the token after poke is ="0rntx\""=
ptr after poke is=""=
the token after slash ="0rntx\\"=
both outputs identical as expected
this is a bigggggg bug for me, since pellesC is my main compiler,
please fix this as soon as possible, and let me know