Hylafax Developers Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[hylafax-devel] Ummmm.... repost of crackArgv patch
Hi,
Way back in March, I posted a patch for crackArgv.
What is currently in the CVS doesn't bear much relation to what I posted...
Here is my post again...
--
Steve Williams, Calgary, Alberta, Canada
Genie Computer Systems Inc.
steve@genie96.com
"A man doesn't begin to attain wisdom until he recognizes that he is
no longer indispensable."
- Admiral Richard E. Byrd ( 1888-1957 )
--------------------------------------------------------------------------------
Hi,
A little closer examination & C 101 ( array indices start at 0 - DUH ),
would indicate that fxStr is fine, and that crackArgv was broken, and
that the ASSERT was totally correct!!
So, a new crackArgv using the length() method rather than looking for
null byte..
Using this, I have a functional, running, backwards compatable faxq
process running.... YEAH!!!
So, can some other eyeballs look at this new routine, and if it's OK,
log the changes to the CVS...
static void
crackArgv(fxStr& s)
{
int i = 0;
do {
while ( (i < s.length()) && !isspace(s[i]))
i++;
if ( i == s.length() ) break; /* read to the end of string, quit */
s[i++] = '\0'; /* null terminate to isspace */
int j = i; /* check for multiple whitespace */
while (j < s.length() && isspace(s[j]))
j++;
if (j > i) {
s.remove(i, j - i);
}
} while (i < s.length() );
s.resize(i);
}
----------------------------------------------------------------------
--- faxQueueApp.c++ Mon Mar 6 23:21:04 2000
+++ faxQueueApp.c++.org Mon Mar 6 23:19:28 2000
@@ -2699,26 +2699,20 @@
}
}
-
static void
crackArgv(fxStr& s)
{
int i = 0;
do {
- while ( (i < s.length()) && !isspace(s[i]))
- i++;
- if ( i == s.length() ) break; /* read to the end of string, quit */
-
- s[i++] = '\0'; /* not end, null terminate to isspace */
-
- int j = i; /* check for multiple whitespace */
- while (j < s.length() && isspace(s[j]))
- j++;
-
- if (j > i) { /* and remove it if there is any */
+ while (s[i] && !isspace(s[i])) i++;
+ if (s[i] == '\0') break;
+ s[i++] = '\0';
+ int j = i;
+ while (isspace(s[j])) j++;
+ if (j > i) {
s.remove(i, j - i);
}
- } while (i < s.length() );
+ } while (s[i] != '\0');
s.resize(i);
}
----------------------------------------------------------------------
--
Steve Williams, Calgary, Alberta, Canada
Genie Computer Systems Inc.
steve@genie96.com
"A man doesn't begin to attain wisdom until he recognizes that he is
no longer indispensable."
- Admiral Richard E. Byrd ( 1888-1957 )
____________________ HylaFAX(tm) Developers Mailing List ____________________
To unsub: mail -s unsubscribe hylafax-devel-request@hylafax.org < /dev/null