[prev in list] [next in list] [prev in thread] [next in thread]
List: ros-diffs
Subject: [ros-diffs] [turner] 17591: Fixed a bug in tab complete when there
From: <turner () svn ! reactos ! com>
Date: 2005-08-29 18:25:57
Message-ID: 000001c5acc7$194886a0$6b01a8c0 () PENELOPE
[Download RAW message or body]
Fixed a bug in tab complete when there was only one " and it was in the
middle or end of the string. Also changed used more optimized code
removing " and removed all _tcsncmp(..,..,1).
Modified: trunk/reactos/subsys/system/cmd/filecomp.c
_____
Modified: trunk/reactos/subsys/system/cmd/filecomp.c
--- trunk/reactos/subsys/system/cmd/filecomp.c 2005-08-29 14:24:38 UTC
(rev 17590)
+++ trunk/reactos/subsys/system/cmd/filecomp.c 2005-08-29 18:25:54 UTC
(rev 17591)
@@ -396,7 +396,7 @@
nQuotes++;
/* Find the prefix and suffix */
- if(nQuotes % 2 && nQuotes)
+ if(nQuotes % 2 && nQuotes > 1)
{
/* Odd number of quotes. Just start from the last " */
/* THis is the way MS does it, and is an easy way out */
@@ -468,7 +468,7 @@
bInside = !bInside;
if(str[i] == _T(' ') && !bInside)
SBreak = i;
- if((!_tcsncmp(&str[i], _T(" "),1) || !_tcsncmp(&str[i],
_T("\\"),1)) && !bInside)
+ if((str[i] == _T(' ') || str[i] == _T('\\')) &&
!bInside)
PBreak = i;
}
@@ -477,7 +477,7 @@
_tcscpy(szSuffix,&strIN[SBreak]);
strIN[PBreak] = _T('\0');
_tcscpy(szPrefix,strIN);
- if(!_tcsncmp(&szPrefix[_tcslen(szPrefix) - 2],_T("\""),1))
+ if(szPrefix[_tcslen(szPrefix) - 2] == _T('\"'))
{
/* need to remove the " right before a \ at the end to
allow the next stuff to stay inside one set of quotes
@@ -535,7 +535,6 @@
INT FileListSize = 0;
/* Used for loops */
INT i;
- INT ii;
/* Editable string of what was passed in */
TCHAR str[MAX_PATH];
/* Keeps track of what element was last selected */
@@ -573,13 +572,12 @@
no quote at the END of the full name */
FindPrefixAndSuffix(str,szPrefix,szBaseWord);
/* Strip quotes */
- for(i = 0; i < _tcslen(szBaseWord); i++)
+ while(i < _tcslen(szBaseWord)+1)
{
- if(!_tcsncmp(&szBaseWord[i], _T("\""),1))
- {
- for(ii = i; ii < (_tcslen(szBaseWord));
ii++)
- szBaseWord[ii] = szBaseWord[ii +
1];
- }
+ if(szBaseWord[i] == _T('\"'))
+ memmove(&szBaseWord[i],&szBaseWord[i +
1], _tcslen(&szBaseWord[i]) * sizeof(TCHAR));
+ else
+ i++;
}
/* clear it out */
@@ -691,8 +689,8 @@
LastSpace = i;
}
- /* insert the space and move things around */
- if(_tcsncmp(&szPrefix[LastSpace + 1],_T("\""),1) &&
LastSpace != -1)
+ /* insert the quoation and move things around */
+ if(szPrefix[LastSpace + 1] == _T('\"') && LastSpace !=
-1)
{
/* add another char or you will lose a null char
ending */
_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) -
1],1);
[Attachment #3 (text/html)]
<html>
<head>
<style>
<!--
body { background-color:#ffffff }
.file { border:1px solid #eeeeee; margin-top:1em; margin-bottom:1em }
.pathname { font-family:monospace; float:right }
.fileheader { margin-bottom:.5em }
.diff { margin:0 }
.tasklist { padding:4px; border:1px dashed #000000; margin-top:1em }
.tasklist ul { margin-top:0; margin-bottom:0 }
tr.alt { background-color:#eeeeee }
#added { background-color:#ddffdd }
#addedchars { background-color:#99ff99; font-weight:bolder }
tr.alt #added { background-color:#ccf7cc }
#removed { background-color:#ffdddd }
#removedchars { background-color:#ff9999; font-weight:bolder }
tr.alt #removed { background-color:#f7cccc }
#info { color:#888888 }
#context { background-color:#eeeeee }
td {padding-left:.3em; padding-right:.3em }
tr.head { border-bottom-width:1px; border-bottom-style:solid }
tr.head td { padding:0; padding-top:.2em }
.task { background-color:#ffff00 }
.comment { padding:4px; border:1px dashed #000000; background-color:#ffffdd }
.error { color:red }
hr { border-width:0px; height:2px; background:black }
-->
</style>
</head>
<body>
<pre class="comment">Fixed a bug in tab complete when there was only one " and \
it was in the middle or end of the string. Also changed used more optimized \
code removing " and removed all _tcsncmp(..,..,1).</pre><pre class="diff" \
id="context">Modified: trunk/reactos/subsys/system/cmd/filecomp.c </pre><hr /><div \
class="file"> <div class="fileheader"><big><b>Modified: \
trunk/reactos/subsys/system/cmd/filecomp.c</b></big></div> <pre class="diff"><small \
id="info">--- trunk/reactos/subsys/system/cmd/filecomp.c 2005-08-29 14:24:38 UTC (rev \
17590)
+++ trunk/reactos/subsys/system/cmd/filecomp.c 2005-08-29 18:25:54 UTC (rev 17591)
@@ -396,7 +396,7 @@
</small></pre><pre class="diff" id="context"> nQuotes++;
/* Find the prefix and suffix */
</pre><pre class="diff" id="removed">- if(nQuotes % 2 && nQuotes)
</pre><pre class="diff" id="added">+ if(nQuotes % 2 && nQuotes<span \
id="addedchars"> > 1</span>) </pre><pre class="diff" id="context"> {
/* Odd number of quotes. Just start from the last " */
/* THis is the way MS does it, and is an easy way out */
@@ -468,7 +468,7 @@
</pre><pre class="diff" id="context"> bInside = !bInside;
if(str[i] == _T(' ') && !bInside)
SBreak = i;
</pre><pre class="diff" id="removed">- if((<span \
id="removedchars">!_tcsncmp(&str[i], _T(" "),1) || \
!_tcsncmp(&str[i], _T("\\"),1</span>)) && !bInside) </pre><pre \
class="diff" id="added">+ if((<span id="addedchars">str[i] == _T(' ') || str[i] == \
_T('\\'</span>)) && !bInside) </pre><pre class="diff" id="context"> PBreak \
= i;
}
@@ -477,7 +477,7 @@
</pre><pre class="diff" id="context"> _tcscpy(szSuffix,&strIN[SBreak]);
strIN[PBreak] = _T('\0');
_tcscpy(szPrefix,strIN);
</pre><pre class="diff" id="removed">- if(<span \
id="removedchars">!_tcsncmp(&szPrefix[_tcslen(szPrefix) - \
2],_T("\""),1</span>)) </pre><pre class="diff" id="added">+ if(<span \
id="addedchars">szPrefix[_tcslen(szPrefix) - 2] == _T('\"'</span>)) </pre><pre \
class="diff" id="context"> { /* need to remove the " right before a \ at the \
end to allow the next stuff to stay inside one set of quotes
@@ -535,7 +535,6 @@
</pre><pre class="diff" id="context"> INT FileListSize = 0;
/* Used for loops */
INT i;
</pre><pre class="diff" id="removed">- INT ii;
</pre><pre class="diff" id="context"> /* Editable string of what was passed in */
TCHAR str[MAX_PATH];
/* Keeps track of what element was last selected */
@@ -573,13 +572,12 @@
</pre><pre class="diff" id="context"> no quote at the END of the full name */
FindPrefixAndSuffix(str,szPrefix,szBaseWord);
/* Strip quotes */
</pre><pre class="diff" id="removed">- <span id="removedchars">for(i = 0; i < \
_tcslen(szBaseWord); i++</span>) </pre><pre class="diff" id="added">+ <span \
id="addedchars">while(i < _tcslen(szBaseWord)+1</span>) </pre><pre class="diff" \
id="context"> { </pre><pre class="diff" \
id="removed">- if(!_tcsncmp(&szBaseWord[i], \
_T("\""),1))
- {
- for(ii = i; ii < (_tcslen(szBaseWord)); ii++)
- szBaseWord[ii] = szBaseWord[ii + 1];
- <span id="removedchars">}</span>
</pre><pre class="diff" id="added">+ <span id="addedchars">if(szBaseWord[i] == \
_T('\"'))</span> + memmove(&szBaseWord[i],&szBaseWord[i + 1], \
_tcslen(&szBaseWord[i]) * sizeof(TCHAR)); + else
+ i++;
</pre><pre class="diff" id="context"> }
/* clear it out */
@@ -691,8 +689,8 @@
</pre><pre class="diff" id="context"> LastSpace = i;
}
</pre><pre class="diff" id="removed">- /* insert the space and move things around */
- <span id="removedchars">if(_tcsncmp(&szPrefix[LastSpace + \
1],_T("\""),1) && LastSpace != -1)</span> </pre><pre \
class="diff" id="added">+ <span id="addedchars">/* insert the quoation and move \
things around */</span> + if(szPrefix[LastSpace + 1] == _T('\"') && \
LastSpace != -1) </pre><pre class="diff" id="context"> {
/* add another char or you will lose a null char ending */
_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);
</pre>
</div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic