Changed: Use of CFile::createEmptyFile

Changed: #142 Replace atoi and sscanf by fromString when it's possible
This commit is contained in:
kervala 2011-05-29 13:57:08 +02:00
parent 2d12ef943d
commit bc994d4bec

View file

@ -969,14 +969,12 @@ void force_exception_frame(...) {std::cout.flush();}
static void exceptionTranslator(unsigned, EXCEPTION_POINTERS *pexp) static void exceptionTranslator(unsigned, EXCEPTION_POINTERS *pexp)
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file = fopen ("exception_catched", "wb"); CFile::createEmptyFile(getLogDirectory() + "exception_catched");
fclose (file);
#endif #endif
if (pexp->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) if (pexp->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT)
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file2 = fopen ("breakpointed", "wb"); CFile::createEmptyFile(getLogDirectory() + "breakpointed");
fclose (file2);
#endif #endif
return; return;
} }
@ -1684,11 +1682,15 @@ NLMISC_CATEGORISED_COMMAND(nel, writeaccess, "write a uint8 value in an invalid
uint8 *adr = (uint8*)0; uint8 *adr = (uint8*)0;
if(args.size() >= 1) if(args.size() >= 1)
#ifdef HAVE_X86_64 #ifdef HAVE_X86_64
adr = (uint8*)(uint64)atoi(args[0].c_str()); uint64 addr64;
NLMISC::fromString(args[0], addr64);
adr = (uint8*)addr64;
#else #else
adr = (uint8*)atoi(args[0].c_str()); uint32 addr32;
NLMISC::fromString(args[0], addr32);
adr = (uint8*)addr32;
#endif #endif
if(args.size() >= 2) val = (uint8)atoi(args[1].c_str()); if(args.size() >= 2) NLMISC::fromString(args[1], val);
*adr = val; *adr = val;
return true; return true;
} }
@ -1699,9 +1701,13 @@ NLMISC_CATEGORISED_COMMAND(nel, readaccess, "read a uint8 value in an invalid ad
uint8 *adr = (uint8*)0; uint8 *adr = (uint8*)0;
if(args.size() == 1) if(args.size() == 1)
#ifdef HAVE_X86_64 #ifdef HAVE_X86_64
adr = (uint8*)(uint64)atoi(args[0].c_str()); uint64 addr64;
NLMISC::fromString(args[0], addr64);
adr = (uint8*)addr64;
#else #else
adr = (uint8*)atoi(args[0].c_str()); uint32 addr32;
NLMISC::fromString(args[0], addr32);
adr = (uint8*)addr32;
#endif #endif
val = *adr; val = *adr;
log.displayNL("value is %hu", (uint16)val); log.displayNL("value is %hu", (uint16)val);