Skip to content

Commit

Permalink
[#13] Minor source code improvements (Part 205: Cumulative minor impr…
Browse files Browse the repository at this point in the history
…ovements)
  • Loading branch information
tomas-nestorovic committed Nov 14, 2022
1 parent 4e89011 commit a8b323c
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Main/Main.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<CompileAsManaged>false</CompileAsManaged>
<BufferSecurityCheck>false</BufferSecurityCheck>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<AdditionalOptions>/QIfist /Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
<OmitFramePointers>true</OmitFramePointers>
<CallingConvention>StdCall</CallingConvention>
<FloatingPointExceptions>false</FloatingPointExceptions>
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Greaseweazle.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
} driver;
const BYTE fddId;
const Utils::CCallocPtr<BYTE> dataBuffer;
#pragma pack(1);
#pragma pack(1)
struct{
BYTE major, minor, isMainFirmware, maxCmd;
DWORD sampleFrequency;
Expand Down
6 changes: 3 additions & 3 deletions Main/src/KryoFluxBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@


struct TIndexPulse sealed{
DWORD posInStreamData;
int posInStreamData;
DWORD sampleCounter;
DWORD indexCounter;
};
Expand Down Expand Up @@ -365,7 +365,7 @@ badFormat: ::SetLastError(ERROR_BAD_FORMAT);
DWORD sampleCounter=0, totalSampleCounter=0; // delta and absolute sample counters
PLogTime buffer=result.GetBuffer(),pLogTime=buffer;
BYTE nearestIndexPulse=0;
DWORD nearestIndexPulsePos= nIndexPulses>0 ? indexPulses[0].posInStreamData : INT_MAX;
int nearestIndexPulsePos= nIndexPulses>0 ? indexPulses[0].posInStreamData : INT_MAX;
for( PCBYTE pis=inStreamData,pLastInStreamData=pis+inStreamDataLength; pis<pLastInStreamData; ){
const BYTE header=*pis++;
// . extracting flux from the KryoFlux "in-Stream" data (pre-processed in ctor)
Expand Down Expand Up @@ -399,7 +399,7 @@ badFormat: ::SetLastError(ERROR_BAD_FORMAT);
result.AddIndexTime( (LONGLONG)TIME_SECOND(1)*indexSampleCounter/SampleClockDefault ); // temporary 64-bit precision even on 32-bit machines
else // custom Sample-Clock, involving floating-point number computation
result.AddIndexTime( (double)TIME_SECOND(1)*indexSampleCounter/sck ); // temporary 64-bit precision even on 32-bit machines
nearestIndexPulsePos= ++nearestIndexPulse<nIndexPulses ? indexPulses[nearestIndexPulse].posInStreamData : -1;
nearestIndexPulsePos= ++nearestIndexPulse<nIndexPulses ? indexPulses[nearestIndexPulse].posInStreamData : INT_MAX;
}
// . adding the flux into the Buffer
totalSampleCounter+=sampleCounter;
Expand Down
2 changes: 1 addition & 1 deletion Main/src/SpectrumDos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define FORMAT_ADDITIONAL_COUNT 2

#define TAPE_EXTENSION _T(".tap")
#define TAPE_FILTER _T("Tape (*") TAPE_EXTENSION _T(")|*") TAPE_EXTENSION
#define TAPE_FILTER _T("Tape (*") TAPE_EXTENSION _T(")|*") TAPE_EXTENSION _T("|")

CDos::TCmdResult CSpectrumDos::ProcessCommand(WORD cmd){
// returns the Result of processing a DOS-related command
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ namespace Utils{
static constexpr TCHAR RangeSign='-'; // "minus"
static constexpr TCHAR Delimiters[]={ ',', ';', RangeSign, '\0' }; // valid integer delimiters, INCLUDING RangeSign

bool CRideDialog::GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,UINT nIntsMin,UINT nIntsMax) const{
bool CRideDialog::GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,int nIntsMin,int nIntsMax) const{
// True <=> item with the specified ID contains list of integer values (grammar bellow), otherwise False
// - elimination of white spaces from the content
TCHAR buf[16384], *pEnd=buf;
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ namespace Utils{
void SetDlgItemSingleCharUsingFont(WORD id,WCHAR singleChar,LPCTSTR fontFace,int fontPointSize) const;
void PopulateDlgComboBoxWithSequenceOfNumbers(WORD cbId,BYTE iStartValue,LPCTSTR strStartValueDesc,BYTE iEndValue,LPCTSTR strEndValueDesc) const;
void ConvertDlgButtonToSplitButton(WORD id,PCSplitButtonAction pAction,BYTE nActions) const;
bool GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,UINT nIntsMin=0,UINT nIntsMax=INT_MAX) const;
bool GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,int nIntsMin=0,int nIntsMax=INT_MAX) const;
void SetDlgItemIntList(WORD id,const CIntList &list) const;
};

Expand Down
1 change: 0 additions & 1 deletion PropGrid/PropGrid.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<FloatingPointExceptions>false</FloatingPointExceptions>
Expand Down
4 changes: 2 additions & 2 deletions PropGrid/src/Editor_Enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
uValue.longValue=0;
::memcpy( &uValue, value.buffer, valueSize );
WCHAR desc[STRING_LENGTH_MAX+1];
__drawString__( __getValueDescW__( value.param, uValue, desc, sizeof(desc)/sizeof(WCHAR) ), -1,
__drawString__( __getValueDescW__( value.param, uValue, desc, ARRAYSIZE(desc) ), -1,
pdis
);
}
Expand Down Expand Up @@ -87,7 +87,7 @@
// string Value
WCHAR descW[100];
ComboBox_SetItemData( hComboBox,
::SendMessageW( hComboBox, CB_ADDSTRING, 0, (LPARAM)__getValueDescW__(value.param,uValue,descW,sizeof(descW)/sizeof(WCHAR)) ),
::SendMessageW( hComboBox, CB_ADDSTRING, 0, (LPARAM)__getValueDescW__(value.param,uValue,descW,ARRAYSIZE(descW)) ),
uValue.longValue
);
}
Expand Down
2 changes: 1 addition & 1 deletion PropGrid/src/Editor_Hyperlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if (wideChar)
::lstrcpyW(buf+1,(LPCWSTR)value.buffer);
else
::MultiByteToWideChar( CP_ACP, 0, (LPCSTR)value.buffer,-1, buf+1,sizeof(buf)/sizeof(WCHAR)-1 );
::MultiByteToWideChar( CP_ACP, 0, (LPCSTR)value.buffer,-1, buf+1,ARRAYSIZE(buf)-1 );
return ::CreateWindowW( WC_LINK,
buf,
EDITOR_STYLE,
Expand Down
2 changes: 1 addition & 1 deletion PropGrid/src/Editor_Integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// True <=> Editor's current Value is acceptable, otherwise False
const HWND hEdit=TEditor::pSingleShown->hMainCtrl;
TCHAR buf[16];
const int nChars=::GetWindowText( hEdit, buf, sizeof(buf)/sizeof(TCHAR) );
const int nChars=::GetWindowText( hEdit, buf, ARRAYSIZE(buf) );
static_assert( PropGrid::Integer::HEXADECIMAL==1, "PropGrid::Integer::HEXADECIMAL==1" );
const int i=_tcstol( buf, nullptr, 10+6*(features&PropGrid::Integer::HEXADECIMAL) );
const bool outOfRange= features&PropGrid::Integer::HEXADECIMAL
Expand Down
6 changes: 3 additions & 3 deletions PropGrid/src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
HANDLE WINAPI PropGrid::AddPropertyA(HWND hPropGrid,HANDLE category,LPCSTR name,PValue value,PCEditor editor,PCustomParam param){
// creates, adds into PropertyGrid, and returns a new ValueItem with given Name and Value
WCHAR bufW[200];
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) );
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) );
return AddPropertyW( hPropGrid, category, bufW, value, editor, param );
}

Expand All @@ -70,7 +70,7 @@
HANDLE WINAPI PropGrid::AddDisabledPropertyA(HWND hPropGrid,HANDLE category,LPCSTR name,PValue value,PCEditor editor,PCustomParam param){
// creates, adds into PropertyGrid, and returns a new ValueItem with given Name and Value
WCHAR bufW[200];
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) );
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) );
return AddDisabledPropertyW( hPropGrid, category, bufW, value, editor, param );
}

Expand All @@ -92,7 +92,7 @@
HANDLE WINAPI PropGrid::AddCategoryA(HWND hPropGrid,HANDLE category,LPCSTR name,bool initiallyExpanded){
// creates, adds into PropertyGrid, and returns a new CategoryItem with given Name
WCHAR bufW[200];
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) );
::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) );
return AddCategoryW( hPropGrid, category, bufW, initiallyExpanded );
}

Expand Down
1 change: 0 additions & 1 deletion Tdi/Tdi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<StructMemberAlignment>Default</StructMemberAlignment>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
<FloatingPointExceptions>false</FloatingPointExceptions>
<DisableSpecificWarnings>4482;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
Expand Down
4 changes: 2 additions & 2 deletions Tdi/src/Tdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
: tabId(_tabId) {
data.mask = TCIF_PARAM | TCIF_TEXT;
data.pszText=caption;
data.cchTextMax=sizeof(caption)/sizeof(TCHAR);
data.cchTextMax=ARRAYSIZE(caption);
TabCtrl_GetItem(hTdi,_tabId,&data);
TabCtrl_GetItemRect(hTdi,_tabId,&targetArea);
}
Expand Down Expand Up @@ -189,7 +189,7 @@
TCHAR tmpCaption[80];
tmp.mask = TCIF_PARAM | TCIF_TEXT;
tmp.pszText=tmpCaption;
tmp.cchTextMax=sizeof(tmpCaption)/sizeof(TCHAR);
tmp.cchTextMax=ARRAYSIZE(tmpCaption);
TabCtrl_GetItem( hTdi, iTargetTab, &tmp );
TabCtrl_SetItem( hTdi, iTargetTab, &pDraggedTabInfo->data );
TabCtrl_SetItem( hTdi, pDraggedTabInfo->tabId, &tmp );
Expand Down

0 comments on commit a8b323c

Please sign in to comment.