[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Fwd: [TSVN][PATCH]C++ standard compliant loop header scopes

From: Joseph Galbraith <galb_at_vandyke.com>
Date: 2005-08-19 23:12:15 CEST

Stefan Fuhrmann wrote:
> Index: TortoiseMerge/BaseView.cpp
> ===================================================================
> --- TortoiseMerge/BaseView.cpp (revision 4159)
> +++ TortoiseMerge/BaseView.cpp (working copy)
> @@ -1091,7 +1091,7 @@
> int nLength = nCount;
>
> int nTabCount = 0;
> - for (i=0; i<nLength; i++)
> + for (int i=0; i<nLength; i++)
> {
> if (pszChars[i] == _T('\t'))
> nTabCount ++;
> @@ -1101,7 +1101,7 @@
> int nCurPos = 0;
> if (nTabCount > 0 || m_bViewWhitespace)
> {
> - for (i=0; i<nLength; i++)
> + for (int i=0; i<nLength; i++)
> {
> if (pszChars[i] == _T('\t'))
> {

These look good to me.

(Forget my earlier comment about a previous declaration of i.)

> Index: TortoiseMerge/MainFrm.cpp
> ===================================================================
> --- TortoiseMerge/MainFrm.cpp (revision 4159)
> +++ TortoiseMerge/MainFrm.cpp (working copy)
> @@ -1050,7 +1050,8 @@
> CString left;
> CString right;
> CString bottom;
> - for (int i=m_nSearchIndex; i<m_pwndLeftView->m_arDiffLines->GetCount(); i++)
> + int i = 0;
> + for (i=m_nSearchIndex; i<m_pwndLeftView->m_arDiffLines->GetCount(); i++)
> {
> left = m_pwndLeftView->m_arDiffLines->GetAt(i);
> if ((m_pwndRightView)&&(m_pwndRightView->m_arDiffLines))

This looks correct to me.

> Index: TortoiseProc/RepositoryTree.cpp
> ===================================================================
> --- TortoiseProc/RepositoryTree.cpp (revision 4159)
> +++ TortoiseProc/RepositoryTree.cpp (working copy)
> @@ -144,7 +144,8 @@
> }
> // insert other columns text
> CString temp;
> - for (int col=1; col<GetActiveSubItemCount()-1; col++)
> + int col = 0;
> + for (col=1; col<GetActiveSubItemCount()-1; col++)
> {
> if (AfxExtractSubString(temp, folder, col, '\t'))
> SetItemText(GetItemIndex(hItem), col, temp);

It looks like this one is just taking advantage of the fact
that col == GetActiveSubItemCount()-1 coming out of the
loop.

An alternative to this change would be to change
the code beneath it to use GetActiveSubItemCount() - 1
directly.

I'm not sure which is preferable. I do believe that the
patch as written is correct.

> @@ -200,7 +201,8 @@
>
> // insert other columns text
> CString temp;
> - for (int col=1; col<GetActiveSubItemCount()-1; col++)
> + int col = 0;
> + for (col=1; col<GetActiveSubItemCount()-1; col++)
> {
> if (AfxExtractSubString(temp, file, col, '\t'))
> SetItemText(GetItemIndex(hItem), col, temp);

Ditto on this change.

> Index: Utils/HistoryCombo.cpp
> ===================================================================
> --- Utils/HistoryCombo.cpp (revision 4159)
> +++ Utils/HistoryCombo.cpp (working copy)
> @@ -190,7 +190,7 @@
> regkey = m_arEntries.GetAt(n);
> }
> //remove items exceeding the max number of history items
> - for (n = nMax; ; n++)
> + for (int n = nMax; ; n++)
> {
> CString sKey;
> sKey.Format(_T("%s\\%s%d"), (LPCTSTR)m_sSection, (LPCTSTR)m_sKeyPrefix, n);

This change looks correct to me.

The patch is much smaller than I expected. I know
Stephan will review it anyway as he applies it, but
hopefully having another set of eyes on it has helped.

Thanks,

Joseph

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Fri Aug 19 23:07:45 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.