Hylafax Developers Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-devel] Re: Problem with fxStr [] operator and crackArg



Hi,

The faxd/faxQueueApp.c++ crackArgv function was one of the ones that had to 
be changed to compile with gcc 2.95(The fxStr class defined both const 
char* operator and char* operator which is broken as they conflict).

The old 4.0pl2 version:
static void
crackArgv(fxStr& s)
{
     char* cp = s;
     u_int l = s.length()+1;             // +1 for \0
     do {
         while (*cp && !isspace(*cp))
             cp++;
         if (*cp == '\0')
             break;
         *cp++ = '\0';
         char* tp = cp;
         while (isspace(*tp))
             tp++;
         if (tp > cp)
             memcpy(cp, tp, l-(tp - (char*) s));
     } while (*cp != '\0');
     s.resize(cp - (char*) s);
}

The current version(quickly hacked by me with no testing ;-):
static void
crackArgv(fxStr& s)
{
     int i = 0;
     do {
         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 (s[i] != '\0');
     s.resize(i);
}

The quickest fix i think would be to change it to the following(roughly):
static void
crackArgv(fxStr& s)
{
     int i = 0;
     do {
         while (i < s.length() && !isspace(s[i])) i++;
         if (i < s.length()) {
             s[i++] = '\0';
             int j = i;
             while (isspace(s[j])) j++;
             if (j > i) {
                 s.remove(i, j - i);
             }
     } while (i < s.length());
     s.resize(i);
}

(this assumes the fxStr::length() function handles embedding 0's within the 
string strtok() style).

PS The above is off the top of my head and might not work.

PPS I find the fxStr class extremely difficult to use, every other C/C++ 
project i have worked on has used char arrays, or the ansi string class or 
the MS CString thing to represent a string.

- Robert




Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services