From c994a9a25e1af4ba4270aaf5b8cbb4ce93ac840d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Sun, 7 Sep 2008 10:55:16 +0000 Subject: [PATCH] fix some msvc64bit warnings Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3217 --- src/dos/cdrom_aspi_win32.cpp | 8 ++++---- src/dos/cdrom_image.cpp | 12 ++++++------ src/dos/dos.cpp | 8 ++++---- src/dos/dos_classes.cpp | 17 ++++++----------- src/dos/dos_execute.cpp | 6 +++--- src/dos/dos_files.cpp | 12 +++++++----- src/dos/dos_ioctl.cpp | 5 +++-- src/dos/dos_misc.cpp | 30 +++++++++++++++++------------- src/dos/dos_mscdex.cpp | 10 +++++----- src/dos/dos_programs.cpp | 6 +++--- src/dos/drive_iso.cpp | 14 +++++++++----- src/dos/drive_local.cpp | 8 ++++---- src/dos/drives.cpp | 10 ++++++---- src/gui/render_simple.h | 6 ++++-- src/ints/ems.cpp | 6 +++--- src/ints/int10_vesa.cpp | 4 ++-- src/libs/gui_tk/gui_tk.cpp | 8 ++++---- src/libs/gui_tk/gui_tk.h | 26 +++++++++++++++----------- src/misc/programs.cpp | 22 +++++++++++----------- src/misc/setup.cpp | 4 ++-- src/shell/shell.cpp | 18 +++++++++--------- src/shell/shell_cmds.cpp | 11 +++++++---- src/shell/shell_misc.cpp | 22 +++++++++++----------- 23 files changed, 145 insertions(+), 128 deletions(-) diff --git a/src/dos/cdrom_aspi_win32.cpp b/src/dos/cdrom_aspi_win32.cpp index 4f389461..47bac693 100644 --- a/src/dos/cdrom_aspi_win32.cpp +++ b/src/dos/cdrom_aspi_win32.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: cdrom_aspi_win32.cpp,v 1.19 2008-08-06 18:32:34 c2woody Exp $ */ +/* $Id: cdrom_aspi_win32.cpp,v 1.20 2008-09-07 10:55:14 c2woody Exp $ */ #if defined (WIN32) @@ -224,9 +224,9 @@ bool CDROM_Interface_Aspi::GetVendor(BYTE HA_num, BYTE SCSI_Id, BYTE SCSI_Lun, c return false; } else { safe_strncpy(szBuffer,szBuffer+8,26); - int len = strlen(szBuffer); - for (int i=0; i #include @@ -65,7 +65,7 @@ bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, int seek, int count) int CDROM_Interface_Image::BinaryFile::getLength() { file->seekg(0, ios::end); - int length = file->tellg(); + int length = (int)file->tellg(); if (file->fail()) return -1; return length; } @@ -170,7 +170,7 @@ bool CDROM_Interface_Image::SetDevice(char* path, int forceCD) // print error message on dosbox console char buf[MAX_LINE_LENGTH]; snprintf(buf, MAX_LINE_LENGTH, "Could not load image file: %s\n", path); - Bit16u size = strlen(buf); + Bit16u size = (Bit16u)strlen(buf); DOS_WriteFile(STDOUT, (Bit8u*)buf, &size); return false; } @@ -185,7 +185,7 @@ bool CDROM_Interface_Image::GetUPC(unsigned char& attr, char* upc) bool CDROM_Interface_Image::GetAudioTracks(int& stTrack, int& end, TMSF& leadOut) { stTrack = 1; - end = tracks.size() - 1; + end = (int)(tracks.size() - 1); FRAMES_TO_MSF(tracks[tracks.size() - 1].start + 150, &leadOut.min, &leadOut.sec, &leadOut.fr); return true; } @@ -639,7 +639,7 @@ bool CDROM_Interface_Image::GetCueFrame(int &frames, istream &in) bool CDROM_Interface_Image::GetCueString(string &str, istream &in) { - int pos = in.tellg(); + int pos = (int)in.tellg(); in >> str; if (str[0] == '\"') { if (str[str.size() - 1] == '\"') { diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 82b5d312..d5260132 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos.cpp,v 1.112 2008-05-28 09:53:31 qbix79 Exp $ */ +/* $Id: dos.cpp,v 1.113 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -645,7 +645,7 @@ static Bitu DOS_21Handler(void) { break; case 0x47: /* CWD Get current directory */ if (DOS_GetCurrentDir(reg_dl,name1)) { - MEM_BlockWrite(SegPhys(ds)+reg_si,name1,strlen(name1)+1); + MEM_BlockWrite(SegPhys(ds)+reg_si,name1,(Bitu)(strlen(name1)+1)); reg_ax=0x0100; CALLBACK_SCF(false); } else { @@ -821,7 +821,7 @@ static Bitu DOS_21Handler(void) { MEM_StrCopy(SegPhys(ds)+reg_dx,name1,DOSNAMEBUF); if (DOS_CreateTempFile(name1,&handle)) { reg_ax=handle; - MEM_BlockWrite(SegPhys(ds)+reg_dx,name1,strlen(name1)+1); + MEM_BlockWrite(SegPhys(ds)+reg_dx,name1,(Bitu)(strlen(name1)+1)); CALLBACK_SCF(false); } else { reg_ax=dos.errorcode; @@ -870,7 +870,7 @@ static Bitu DOS_21Handler(void) { case 0x60: /* Canonicalize filename or path */ MEM_StrCopy(SegPhys(ds)+reg_si,name1,DOSNAMEBUF); if (DOS_Canonicalize(name1,name2)) { - MEM_BlockWrite(SegPhys(es)+reg_di,name2,strlen(name2)+1); + MEM_BlockWrite(SegPhys(es)+reg_di,name2,(Bitu)(strlen(name2)+1)); CALLBACK_SCF(false); } else { reg_ax=dos.errorcode; diff --git a/src/dos/dos_classes.cpp b/src/dos/dos_classes.cpp index 81364b6e..85e829e5 100644 --- a/src/dos/dos_classes.cpp +++ b/src/dos/dos_classes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_classes.cpp,v 1.54 2008-01-21 21:26:49 qbix79 Exp $ */ +/* $Id: dos_classes.cpp,v 1.55 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -25,12 +25,6 @@ #include "dos_inc.h" #include "support.h" -/* - Work in progress, making classes for handling certain internal memory structures in dos - This should make it somewhat easier for porting to other endian machines and make - dos work a bit easier. -*/ - void DOS_ParamBlock::Clear(void) { memset(&exec,0,sizeof(exec)); @@ -345,12 +339,13 @@ void DOS_DTA::SetupSearch(Bit8u _sdrive,Bit8u _sattr,char * pattern) { char * find_ext; find_ext=strchr(pattern,'.'); if (find_ext) { - Bitu size=find_ext-pattern;if (size>8) size=8; + Bitu size=(Bitu)(find_ext-pattern); + if (size>8) size=8; MEM_BlockWrite(pt+offsetof(sDTA,sname),pattern,size); find_ext++; - MEM_BlockWrite(pt+offsetof(sDTA,sext),find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext)); + MEM_BlockWrite(pt+offsetof(sDTA,sext),find_ext,(strlen(find_ext)>3) ? 3 : (Bitu)strlen(find_ext)); } else { - MEM_BlockWrite(pt+offsetof(sDTA,sname),pattern,(strlen(pattern) > 8) ? 8 : strlen(pattern)); + MEM_BlockWrite(pt+offsetof(sDTA,sname),pattern,(strlen(pattern) > 8) ? 8 : (Bitu)strlen(pattern)); } } diff --git a/src/dos/dos_execute.cpp b/src/dos/dos_execute.cpp index ee646230..62f5f455 100644 --- a/src/dos/dos_execute.cpp +++ b/src/dos/dos_execute.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_execute.cpp,v 1.63 2007-11-18 10:30:12 c2woody Exp $ */ +/* $Id: dos_execute.cpp,v 1.64 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -201,7 +201,7 @@ static bool MakeEnv(char * name,Bit16u * segment) { envwrite+=2; char namebuf[DOS_PATHLENGTH]; if (DOS_Canonicalize(name,namebuf)) { - MEM_BlockWrite(envwrite,namebuf,strlen(namebuf)+1); + MEM_BlockWrite(envwrite,namebuf,(Bitu)(strlen(namebuf)+1)); return true; } else return false; } diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index f5651495..9abfb119 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_files.cpp,v 1.98 2008-08-06 18:32:34 c2woody Exp $ */ +/* $Id: dos_files.cpp,v 1.99 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -153,7 +153,7 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) { } - lastdir=strlen(fullname); + lastdir=(Bit32u)strlen(fullname); if (lastdir!=0) strcat(fullname,"\\"); char * ext=strchr(tempdir,'.'); @@ -814,9 +814,11 @@ static void DTAExtendName(char * const name,char * const filename,char * const e *find=0; } else ext[0]=0; strcpy(filename,name); - Bitu i; - for (i=strlen(name);i<8;i++) filename[i]=' ';filename[8]=0; - for (i=strlen(ext);i<3;i++) ext[i]=' ';ext[3]=0; + size_t i; + for (i=strlen(name);i<8;i++) filename[i]=' '; + filename[8]=0; + for (i=strlen(ext);i<3;i++) ext[i]=' '; + ext[3]=0; } static void SaveFindResult(DOS_FCB & find_fcb) { diff --git a/src/dos/dos_ioctl.cpp b/src/dos/dos_ioctl.cpp index 04c808a9..5b402383 100644 --- a/src/dos/dos_ioctl.cpp +++ b/src/dos/dos_ioctl.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_ioctl.cpp,v 1.32 2008-05-25 17:24:59 c2woody Exp $ */ +/* $Id: dos_ioctl.cpp,v 1.33 2008-09-07 10:55:14 c2woody Exp $ */ #include #include "dosbox.h" @@ -152,7 +152,8 @@ bool DOS_IOCTL(void) { char const* find_ext=strchr(bufin,'.'); if (find_ext) { - Bitu size=find_ext-bufin;if (size>8) size=8; + Bitu size=(Bitu)(find_ext-bufin); + if (size>8) size=8; memcpy(buffer,bufin,size); find_ext++; memcpy(buffer+size,find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext)); diff --git a/src/dos/dos_misc.cpp b/src/dos/dos_misc.cpp index e695f7f8..f203c720 100644 --- a/src/dos/dos_misc.cpp +++ b/src/dos/dos_misc.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_misc.cpp,v 1.19 2008-08-06 18:32:34 c2woody Exp $ */ +/* $Id: dos_misc.cpp,v 1.20 2008-09-07 10:55:14 c2woody Exp $ */ #include "dosbox.h" #include "callback.h" @@ -120,22 +120,26 @@ static bool DOS_MultiplexFunctions(void) { nlen-=(extlen+1); if (nlen>8) nlen=8; - for (Bitu i=0; i3) extlen=3; - for (Bitu i=0; i8) nlen=8; - for (Bitu i=0; i #include @@ -666,10 +666,10 @@ bool CMscdex::GetDirectoryEntry(Bit16u drive, bool copyFlag, PhysPt pathname, Ph upcase(searchName); char* searchPos = searchName; - //strip of tailing . (XCOM APOCALIPSE) - int searchlen = strlen(searchName); - if(searchlen > 1 && strcmp(searchName,"..")) - if(searchName[searchlen-1] =='.') searchName[searchlen-1] = 0; + //strip of tailing . (XCOM APOCALYPSE) + size_t searchlen = strlen(searchName); + if (searchlen > 1 && strcmp(searchName,"..")) + if (searchName[searchlen-1] =='.') searchName[searchlen-1] = 0; //LOG(LOG_MISC,LOG_ERROR)("MSCDEX: Get DirEntry : Find : %s",searchName); // read vtoc diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 5478a55f..2e1d4f44 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_programs.cpp,v 1.86 2008-08-06 18:32:34 c2woody Exp $ */ +/* $Id: dos_programs.cpp,v 1.87 2008-09-07 10:55:14 c2woody Exp $ */ #include "dosbox.h" #include @@ -678,7 +678,7 @@ public: FILE *tfile = getFSFile("system.rom", &sz1, &sz2, true); if (tfile!=NULL) { fseek(tfile, 0x3000L, SEEK_SET); - Bit32u drd=fread(rombuf, 1, 0xb000, tfile); + Bit32u drd=(Bit32u)fread(rombuf, 1, 0xb000, tfile); if (drd==0xb000) { for(i=0;i<0xb000;i++) phys_writeb(0xf3000+i,rombuf[i]); } @@ -1075,7 +1075,7 @@ public: } // find all file parameters, assuming that all option parameters have been removed - while(cmd->FindCommand(paths.size() + 2, temp_line) && temp_line.size()) { + while(cmd->FindCommand((unsigned int)(paths.size() + 2), temp_line) && temp_line.size()) { struct stat test; if (stat(temp_line.c_str(),&test)) { diff --git a/src/dos/drive_iso.cpp b/src/dos/drive_iso.cpp index 6d088a16..d7ae555a 100644 --- a/src/dos/drive_iso.cpp +++ b/src/dos/drive_iso.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_iso.cpp,v 1.23 2008-05-24 18:50:39 c2woody Exp $ */ +/* $Id: drive_iso.cpp,v 1.24 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -510,8 +510,10 @@ int isoDrive :: readDirEntry(isoDirEntry *de, Bit8u *data) // remove any file version identifiers as there are some cdroms that don't have them strreplace((char*)de->ident, ';', 0); // if file has no extension remove the trailing dot - int tmp = strlen((char*)de->ident); - if (tmp > 0 && de->ident[tmp - 1] == '.') de->ident[tmp - 1] = 0; + size_t tmp = strlen((char*)de->ident); + if (tmp > 0) { + if (de->ident[tmp - 1] == '.') de->ident[tmp - 1] = 0; + } } const char* dotpos = strchr((char*)de->ident, '.'); if (dotpos!=NULL) { @@ -554,8 +556,10 @@ bool isoDrive :: lookup(isoDirEntry *de, const char *path) if (IS_DIR(de->fileFlags)) { // remove the trailing dot if present - int nameLength = strlen(name); - if (nameLength > 0 && name[nameLength - 1] == '.') name[nameLength - 1] = 0; + size_t nameLength = strlen(name); + if (nameLength > 0) { + if (name[nameLength - 1] == '.') name[nameLength - 1] = 0; + } // look for the current path element int dirIterator = GetDirIterator(de); diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index 117de89d..74eae3a7 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_local.cpp,v 1.76 2007-11-01 12:15:34 qbix79 Exp $ */ +/* $Id: drive_local.cpp,v 1.77 2008-09-07 10:55:14 c2woody Exp $ */ #include #include @@ -443,7 +443,7 @@ localDrive::localDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors bool localFile::Read(Bit8u * data,Bit16u * size) { if (last_action==WRITE) fseek(fhandle,ftell(fhandle),SEEK_SET); last_action=READ; - *size=fread(data,1,*size,fhandle); + *size=(Bit16u)fread(data,1,*size,fhandle); /* Fake harddrive motion. Inspector Gadget with soundblaster compatible */ /* Same for Igor */ /* hardrive motion => unmask irq 2. Only do it when it's masked as unmasking is realitively heavy to emulate */ @@ -460,7 +460,7 @@ bool localFile::Write(Bit8u * data,Bit16u * size) { } else { - *size=fwrite(data,1,*size,fhandle); + *size=(Bit16u)fwrite(data,1,*size,fhandle); return true; } } diff --git a/src/dos/drives.cpp b/src/dos/drives.cpp index 7cd1cb93..c33ad5a7 100644 --- a/src/dos/drives.cpp +++ b/src/dos/drives.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drives.cpp,v 1.13 2008-01-21 21:25:17 qbix79 Exp $ */ +/* $Id: drives.cpp,v 1.14 2008-09-07 10:55:14 c2woody Exp $ */ #include "dosbox.h" #include "dos_system.h" @@ -40,7 +40,8 @@ bool WildFileCmp(const char * file, const char * wild) find_ext=strrchr(file,'.'); if (find_ext) { - Bitu size=find_ext-file;if (size>8) size=8; + Bitu size=(Bitu)(find_ext-file); + if (size>8) size=8; memcpy(file_name,file,size); find_ext++; memcpy(file_ext,find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext)); @@ -50,7 +51,8 @@ bool WildFileCmp(const char * file, const char * wild) upcase(file_name);upcase(file_ext); find_ext=strrchr(wild,'.'); if (find_ext) { - Bitu size=find_ext-wild;if (size>8) size=8; + Bitu size=(Bitu)(find_ext-wild); + if (size>8) size=8; memcpy(wild_name,wild,size); find_ext++; memcpy(wild_ext,find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext)); diff --git a/src/gui/render_simple.h b/src/gui/render_simple.h index 84b50333..94bddd17 100644 --- a/src/gui/render_simple.h +++ b/src/gui/render_simple.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: render_simple.h,v 1.6 2008-09-07 10:55:15 c2woody Exp $ */ + #if defined (SCALERLINEAR) static void conc4d(SCALERNAME,SBPP,DBPP,L)(const void *s) { #else @@ -91,7 +93,7 @@ static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { } #if defined(SCALERLINEAR) #if (SCALERHEIGHT > 1) - Bitu copyLen = (Bit8u*)line1 - (Bit8u*)WC[0]; + Bitu copyLen = (Bitu)((Bit8u*)line1 - (Bit8u*)WC[0]); BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch ,WC[0], copyLen ); #endif #if (SCALERHEIGHT > 2) diff --git a/src/ints/ems.cpp b/src/ints/ems.cpp index 06e3a2a9..440eaf77 100644 --- a/src/ints/ems.cpp +++ b/src/ints/ems.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: ems.cpp,v 1.57 2008-08-06 18:32:35 c2woody Exp $ */ +/* $Id: ems.cpp,v 1.58 2008-09-07 10:55:15 c2woody Exp $ */ #include #include @@ -437,7 +437,7 @@ static Bit8u EMM_PartialPageMapping(void) { return EMM_RestoreMappingTable(); break; case 0x02: /* Get Partial Page Map Array Size */ - reg_al=2+reg_bx*(2+sizeof(EMM_Mapping)); + reg_al=(Bit8u)(2+reg_bx*(2+sizeof(EMM_Mapping))); break; default: LOG(LOG_MISC,LOG_ERROR)("EMS:Call %2X Subfunction %2X not supported",reg_ah,reg_al); @@ -1237,7 +1237,7 @@ public: /* Add a little hack so it appears that there is an actual ems device installed */ char const* emsname="EMMXXXX0"; if(!emsnameseg) emsnameseg=DOS_GetMemory(2); //We have 32 bytes - MEM_BlockWrite(PhysMake(emsnameseg,0xa),emsname,strlen(emsname)+1); + MEM_BlockWrite(PhysMake(emsnameseg,0xa),emsname,(Bitu)(strlen(emsname)+1)); /* Copy the callback piece into the beginning, and set the interrupt vector to it*/ char buf[16]; diff --git a/src/ints/int10_vesa.cpp b/src/ints/int10_vesa.cpp index 6f90ffd7..d4cca91d 100644 --- a/src/ints/int10_vesa.cpp +++ b/src/ints/int10_vesa.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: int10_vesa.cpp,v 1.36 2008-05-10 17:33:28 c2woody Exp $ */ +/* $Id: int10_vesa.cpp,v 1.37 2008-09-07 10:55:15 c2woody Exp $ */ #include #include @@ -484,7 +484,7 @@ void INT10_SetupVESA(void) { phys_writew(PhysMake(0xc000,int10.rom.used),0xffff); int10.rom.used+=2; int10.rom.oemstring=RealMake(0xc000,int10.rom.used); - Bitu len=strlen(string_oem)+1; + Bitu len=(Bitu)(strlen(string_oem)+1); for (i=0;i text.size()-start) len = text.size()-start; + if (len > text.size()-start) len = (Size)(text.size()-start); len += start; Size wordstart = start; @@ -859,7 +859,7 @@ bool Input::keyDown(const Key &key) start_sel = end_sel = pos; } else { start_sel = 0; - pos = end_sel = text.size(); + pos = end_sel = (Size)text.size(); } break; case 24: @@ -905,7 +905,7 @@ bool Input::keyDown(const Key &key) case Key::End: if (multi) { while (pos < text.size() && f->toSpecial(text[pos]) != Font::LF) pos++; - } else pos = text.size(); + } else pos = (Size)text.size(); break; case Key::Backspace: if (!key.shift && start_sel != end_sel) clearSelection(); diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index fd18a21f..3d5f0e2d 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -102,7 +102,7 @@ * along with this program. If not, see */ -/* $Id: gui_tk.h,v 1.4 2008-08-09 19:42:26 qbix79 Exp $ */ +/* $Id: gui_tk.h,v 1.5 2008-09-07 10:55:15 c2woody Exp $ */ #ifndef GUI__TOOLKIT_H #define GUI__TOOLKIT_H @@ -435,7 +435,7 @@ template void NativeString::getString(String &dest, const S } template STR* NativeString::getNative(const String &src) { - Size strlen = src.size(); + Size strlen = (Size)src.size(); STR* dest = new STR[strlen+1]; dest[strlen] = 0; for (; strlen > 0; strlen--) dest[strlen-1] = src[strlen-1]; @@ -447,12 +447,12 @@ template <> class NativeString { protected: friend class String; static void getString(String &dest, const std::string *src) { - Size strlen = src->length(); + Size strlen = (Size)src->length(); dest.resize(strlen); for (Size i = 0; i< strlen; i++) dest[i] = (*src)[i]; } static std::string* getNative(const String &src) { - Size strlen = src.size(); + Size strlen = (Size)src.size(); std::string* dest = new std::string(); for (Size i = 0; i < strlen; i++) dest->append(1,src[i]); src.addNative(new String::NativeObject(dest)); @@ -466,12 +466,12 @@ template <> class NativeString { protected: friend class String; static void getString(String &dest, const std::string &src) { - Size strlen = src.length(); + Size strlen = (Size)src.length(); dest.resize(strlen); for (Size i = 0; i< strlen; i++) dest[i] = src[i]; } static std::string& getNative(const String &src) { - Size strlen = src.size(); + Size strlen = (Size)src.size(); std::string* dest = new std::string(); for (Size i = 0; i < strlen; i++) dest->append(1,src[i]); src.addNative(new String::NativeObject(dest)); @@ -1133,7 +1133,11 @@ protected: /// Draw \p len characters to a drawable at the current position, starting at string position \p start. /** This can be used to provide kerning. */ - virtual void drawString(Drawable *d, const String &s, Size start, Size len) const { if (len > s.size()-start) len = s.size()-start; len += start; while (start < len) drawChar(d,s[start++]); } + virtual void drawString(Drawable *d, const String &s, Size start, Size len) const { + if (len > s.size()-start) len = (Size)(s.size()-start); + len += start; + while (start < len) drawChar(d,s[start++]); + } public: /// Return a font with the given name (case-sensitive). @@ -1173,7 +1177,7 @@ public: /** Can be used to provide kerning. */ virtual int getWidth(const String &s, Size start = 0, Size len = (Size)-1) const { int width = 0; - if (start+len > s.size()) len = s.size()-start; + if (start+len > s.size()) len = (Size)(s.size()-start); while (len--) width += getWidth(s[start++]); return width; } @@ -1506,7 +1510,7 @@ public: String c = getClipboard(); clearSelection(); text.insert(text.begin()+pos,c.begin(),c.end()); - start_sel = end_sel = pos += c.size(); + start_sel = end_sel = pos += (Size)c.size(); } /// get character position corresponding to coordinates @@ -1852,7 +1856,7 @@ public: else if (key.special == Key::Escape) { setVisible(false); return true; } else return true; if (items[selected].size() == 0 && items.size() > 1) return keyDown(key); - if (selected < 0) selected = items.size()-1; + if (selected < 0) selected = (int)(items.size()-1); if (selected >= (int)items.size()) selected = 0; return true; } @@ -1988,7 +1992,7 @@ public: if (selected >= 0 && !menus[selected]->isVisible()) oldselected = -1; if (selected >= 0) menus[selected]->setVisible(false); if (x < 0 || x >= lastx) return true; - for (selected = menus.size()-1; menus[selected]->getX() > x; selected--) {}; + for (selected = (int)(menus.size()-1); menus[selected]->getX() > x; selected--) {}; if (oldselected == selected) selected = -1; else menus[selected]->setVisible(true); return true; diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index ada79052..59d08d88 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: programs.cpp,v 1.32 2008-07-26 19:06:26 qbix79 Exp $ */ +/* $Id: programs.cpp,v 1.33 2008-09-07 10:55:15 c2woody Exp $ */ #include #include @@ -126,12 +126,12 @@ void Program::WriteOut(const char * format,...) { vsnprintf(buf,2047,format,msg); va_end(msg); - Bit16u size = strlen(buf); + Bit16u size = (Bit16u)strlen(buf); DOS_WriteFile(STDOUT,(Bit8u *)buf,&size); } void Program::WriteOut_NoParsing(const char * format) { - Bit16u size = strlen(format); + Bit16u size = (Bit16u)strlen(format); DOS_WriteFile(STDOUT,(Bit8u *)format,&size); } @@ -145,7 +145,7 @@ bool Program::GetEnvStr(const char * entry,std::string & result) { do { MEM_StrCopy(env_read,env_string,1024); if (!env_string[0]) return false; - env_read+=strlen(env_string)+1; + env_read += (PhysPt)(strlen(env_string)+1); char* equal = strchr(env_string,'='); if (!equal) continue; /* replace the = with \0 to get the length */ @@ -167,7 +167,7 @@ bool Program::GetEnvNum(Bitu num,std::string & result) { MEM_StrCopy(env_read,env_string,1024); if (!env_string[0]) break; if (!num) { result=env_string;return true;} - env_read+=strlen(env_string)+1; + env_read += (PhysPt)(strlen(env_string)+1); num--; } while (1); return false; @@ -191,12 +191,12 @@ bool Program::SetEnv(const char * entry,const char * new_string) { do { MEM_StrCopy(env_read,env_string,1024); if (!env_string[0]) break; - env_read+=strlen(env_string)+1; + env_read += (PhysPt)(strlen(env_string)+1); if (!strchr(env_string,'=')) continue; /* Remove corrupt entry? */ if ((strncasecmp(entry,env_string,strlen(entry))==0) && env_string[strlen(entry)]=='=') continue; - MEM_BlockWrite(env_write,env_string,strlen(env_string)+1); - env_write+=strlen(env_string)+1; + MEM_BlockWrite(env_write,env_string,(Bitu)(strlen(env_string)+1)); + env_write += (PhysPt)(strlen(env_string)+1); } while (1); /* TODO Maybe save the program name sometime. not really needed though */ /* Save the new entry */ @@ -205,8 +205,8 @@ bool Program::SetEnv(const char * entry,const char * new_string) { for (std::string::iterator it = bigentry.begin(); it != bigentry.end(); ++it) *it = toupper(*it); sprintf(env_string,"%s=%s",bigentry.c_str(),new_string); // sprintf(env_string,"%s=%s",entry,new_string); //oldcode - MEM_BlockWrite(env_write,env_string,strlen(env_string)+1); - env_write+=strlen(env_string)+1; + MEM_BlockWrite(env_write,env_string,(Bitu)(strlen(env_string)+1)); + env_write += (PhysPt)(strlen(env_string)+1); } /* Clear out the final piece of the environment */ mem_writed(env_write,0); diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index fc9021dc..0347a3c6 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: setup.cpp,v 1.50 2008-08-06 18:32:35 c2woody Exp $ */ +/* $Id: setup.cpp,v 1.51 2008-09-07 10:55:15 c2woody Exp $ */ #include "dosbox.h" #include "cross.h" @@ -872,7 +872,7 @@ bool CommandLine::GetStringRemain(std::string & value) { unsigned int CommandLine::GetCount(void) { - return cmds.size(); + return (unsigned int)cmds.size(); } CommandLine::CommandLine(int argc,char const * const argv[]) { diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index d7032b92..744c9952 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.cpp,v 1.93 2008-09-06 14:47:15 c2woody Exp $ */ +/* $Id: shell.cpp,v 1.94 2008-09-07 10:55:16 c2woody Exp $ */ #include #include @@ -99,7 +99,7 @@ void AutoexecObject::CreateAutoexec(void) { } sprintf((autoexec_data+auto_len),"%s\r\n",(*it).c_str()); } - if(first_shell) VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,strlen(autoexec_data)); + if(first_shell) VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,(Bit32u)strlen(autoexec_data)); } AutoexecObject::~AutoexecObject(){ @@ -430,7 +430,7 @@ public: } } nomount: - VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,strlen(autoexec_data)); + VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,(Bit32u)strlen(autoexec_data)); } }; @@ -598,14 +598,14 @@ void SHELL_Init() { /* Setup environment */ PhysPt env_write=PhysMake(env_seg,0); - MEM_BlockWrite(env_write,path_string,strlen(path_string)+1); - env_write+=strlen(path_string)+1; - MEM_BlockWrite(env_write,comspec_string,strlen(comspec_string)+1); - env_write+=strlen(comspec_string)+1; + MEM_BlockWrite(env_write,path_string,(Bitu)(strlen(path_string)+1)); + env_write += (PhysPt)(strlen(path_string)+1); + MEM_BlockWrite(env_write,comspec_string,(Bitu)(strlen(comspec_string)+1)); + env_write += (PhysPt)(strlen(comspec_string)+1); mem_writeb(env_write++,0); mem_writew(env_write,1); env_write+=2; - MEM_BlockWrite(env_write,full_name,strlen(full_name)+1); + MEM_BlockWrite(env_write,full_name,(Bitu)(strlen(full_name)+1)); DOS_PSP psp(psp_seg); psp.MakeNew(0); @@ -629,7 +629,7 @@ void SHELL_Init() { psp.SetEnvironment(env_seg); /* Set the command line for the shell start up */ CommandTail tail; - tail.count=strlen(init_line); + tail.count=(Bit8u)strlen(init_line); strcpy(tail.buffer,init_line); MEM_BlockWrite(PhysMake(psp_seg,128),&tail,128); diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index eabb056c..6842b258 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_cmds.cpp,v 1.83 2008-08-11 12:54:57 qbix79 Exp $ */ +/* $Id: shell_cmds.cpp,v 1.84 2008-09-07 10:55:16 c2woody Exp $ */ #include "dosbox.h" #include "shell.h" @@ -413,7 +413,7 @@ void DOS_Shell::CMD_DIR(char * args) { char buffer[CROSS_LEN]; args = trim(args); - Bit32u argLen = strlen(args); + size_t argLen = strlen(args); if (argLen == 0) { strcpy(args,"*.*"); //no arguments. } else { @@ -481,7 +481,10 @@ void DOS_Shell::CMD_DIR(char * args) { if (attr & DOS_ATTR_DIRECTORY) { if (optW) { WriteOut("[%s]",name); - for (Bitu i=14-strlen(name);i>0;i--) WriteOut(" "); + size_t namelen = strlen(name); + if ((namelen>=0) && (namelen<=14)) { + for (Bitu i=14-(Bitu)namelen;i>0;i--) WriteOut(" "); + } } else { WriteOut("%-8s %-3s %-16s %02d-%02d-%04d %2d:%02d\n",name,ext,"",day,month,year,hour,minute); } @@ -1003,7 +1006,7 @@ void DOS_Shell::CMD_CHOICE(char * args){ } while (!c || !(ptr = strchr(rem,(optS?c:toupper(c))))); c = optS?c:toupper(c); DOS_WriteFile (STDOUT,&c, &n); - dos.return_code = ptr-rem+1; + dos.return_code = (Bit8u)(ptr-rem+1); } void DOS_Shell::CMD_ATTRIB(char *args){ diff --git a/src/shell/shell_misc.cpp b/src/shell/shell_misc.cpp index f2dc58b3..224f0956 100644 --- a/src/shell/shell_misc.cpp +++ b/src/shell/shell_misc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_misc.cpp,v 1.52 2008-03-02 11:13:47 qbix79 Exp $ */ +/* $Id: shell_misc.cpp,v 1.53 2008-09-07 10:55:16 c2woody Exp $ */ #include #include @@ -78,7 +78,7 @@ void DOS_Shell::InputCommand(char * line) { line[str_index ++] = c; DOS_WriteFile(STDOUT,&c,&n); } - str_len = str_index = it_history->length(); + str_len = str_index = (Bitu)it_history->length(); size = CMD_MAXLINE - str_index - 2; line[str_len] = 0; } @@ -124,7 +124,7 @@ void DOS_Shell::InputCommand(char * line) { outc(8); outc(' '); outc(8); } strcpy(line, it_history->c_str()); - len = it_history->length(); + len = (Bit16u)it_history->length(); str_len = str_index = len; size = CMD_MAXLINE - str_index - 2; DOS_WriteFile(STDOUT, (Bit8u *)line, &len); @@ -153,7 +153,7 @@ void DOS_Shell::InputCommand(char * line) { outc(8); outc(' '); outc(8); } strcpy(line, it_history->c_str()); - len = it_history->length(); + len = (Bit16u)it_history->length(); str_len = str_index = len; size = CMD_MAXLINE - str_index - 2; DOS_WriteFile(STDOUT, (Bit8u *)line, &len); @@ -224,15 +224,15 @@ void DOS_Shell::InputCommand(char * line) { if (p_completion_start) { p_completion_start ++; - completion_index = str_len - strlen(p_completion_start); + completion_index = (Bit16u)(str_len - strlen(p_completion_start)); } else { p_completion_start = line; completion_index = 0; } char *path; - if ((path = strrchr(line+completion_index,'\\'))) completion_index = path-line+1; - if ((path = strrchr(line+completion_index,'/'))) completion_index = path-line+1; + if ((path = strrchr(line+completion_index,'\\'))) completion_index = (Bit16u)(path-line+1); + if ((path = strrchr(line+completion_index,'/'))) completion_index = (Bit16u)(path-line+1); // build the completion list char mask[DOS_PATHLENGTH]; @@ -295,7 +295,7 @@ void DOS_Shell::InputCommand(char * line) { } strcpy(&line[completion_index], it_completion->c_str()); - len = it_completion->length(); + len = (Bit16u)it_completion->length(); str_len = str_index = completion_index + len; size = CMD_MAXLINE - str_index - 2; DOS_WriteFile(STDOUT, (Bit8u *)it_completion->c_str(), &len); @@ -448,7 +448,7 @@ bool DOS_Shell::Execute(char * name,char * args) { block.Clear(); //Add a filename RealPt file_name=RealMakeSeg(ss,reg_sp+0x20); - MEM_BlockWrite(Real2Phys(file_name),fullname,strlen(fullname)+1); + MEM_BlockWrite(Real2Phys(file_name),fullname,(Bitu)(strlen(fullname)+1)); /* HACK: Store full commandline for mount and imgmount */ full_arguments.assign(line); @@ -458,7 +458,7 @@ bool DOS_Shell::Execute(char * name,char * args) { cmdtail.count = 0; memset(&cmdtail.buffer,0,126); //Else some part of the string is unitialized (valgrind) if (strlen(line)>126) line[126]=0; - cmdtail.count=strlen(line); + cmdtail.count=(Bit8u)strlen(line); memcpy(cmdtail.buffer,line,strlen(line)); cmdtail.buffer[strlen(line)]=0xd; /* Copy command line in stack block too */