======== tc 1=======================
============ tc 2======================
============== tc 3============
Function                       Source        Line  FnCov           C/D Coverage
-----------------------------  ------------------  -----  ---------------------
diactolower(int)               concutils.cc   227  0 / 1       0 /    39 =   0%
isAlDiaNum(int)                concutils.cc   141  0 / 1       0 /    28 =   0%
WordList::addWord(Word*)       word.cc        538  0 / 1       0 /    22 =   0%
strcomp(char*,char*)           concutils.cc   259  0 / 1       0 /    16 =   0%
Word::saveWord(FILE*)          word.cc        251  0 / 1       0 /    16 =   0%
Word::operator=(Word&)         word.cc        214  0 / 1       0 /    12 =   0%
WordList::delWord(char*)       word.cc        619  0 / 1       0 /    12 =   0%
operator>>(istream&,Word&)     word.cc        293  0 / 1       0 /     6 =   0%
WordList::findWord(char*)      word.cc        651  0 / 1       0 /     6 =   0%
WordList::findWord(Word*)      word.cc        664  0 / 1       0 /     6 =   0%
CharCtVector:...Vector(FILE*)  alphalst.cc    160  0 / 1       0 /     4 =   0%
Word::operator=(char*)         word.cc        200  0 / 1       0 /     4 =   0%
Word::printWord(void)          word.cc        350  0 / 1       0 /     4 =   0%
WordList::Wor...st WordList&)  word.cc        396  0 / 1       0 /     4 =   0%
WordList::delList(void)        word.cc        425  0 / 1       0 /     4 =   0%
WordList::saveWordList(FILE*)  word.cc        677  0 / 1       0 /     4 =   0%
WordList::loadWordList(FILE*)  word.cc        690  0 / 1       0 /     4 =   0%
WordList::ope...r=(WordList&)  word.cc        703  0 / 1       0 /     4 =   0%
CharCt::operator==(CharCt&)    alphalst.cc     85  0 / 1       0 /     2 =   0%
CharCt::operator<(CharCt&)     alphalst.cc     90  0 / 1       0 /     2 =   0%
CharCt::operator>(CharCt&)     alphalst.cc     95  0 / 1       0 /     2 =   0%
CharCtVector:...harCtVector&)  alphalst.cc    152  0 / 1       0 /     2 =   0%
CharCtVector:...Vector(FILE*)  alphalst.cc    169  0 / 1       0 /     2 =   0%
ateof(istream&)                concutils.cc   158  0 / 1       0 /     2 =   0%
upperCaseString(char*)         concutils.cc   204  0 / 1       0 /     2 =   0%
Word::Word(const Word&)        word.cc        125  0 / 1       0 /     2 =   0%
Word::loadWord(FILE*)          word.cc        273  0 / 1       0 /     2 =   0%
CharCt::operator=(CharCt&)     alphalst.cc     69  0 / 1       0 /     0       
CharCt::saveChar(FILE*)        alphalst.cc    100  0 / 1       0 /     0       
CharCt::loadChar(FILE*)        alphalst.cc    107  0 / 1       0 /     0       
operator>>(istream&,CharCt&)   alphalst.cc    114  0 / 1       0 /     0       
CharCt::CharC...ed char,long)  alphalst.h      68  0 / 1       0 /     0       
CharCt::CharCt(const CharCt&)  alphalst.h      69  0 / 1       0 /     0       
CharCt::getCh...r(void) const  alphalst.h      70  0 / 1       0 /     0       
CharCt::setCh...er(char,long)  alphalst.h      71  0 / 1       0 /     0       
CharCt::setCh...ed char,long)  alphalst.h      72  0 / 1       0 /     0       
CharCt::getPe...e(void) const  alphalst.h      75  0 / 1       0 /     0       
instructions(void)             ...rdance.cc   263  0 / 1       0 /     0       
outOfMem(void)                 ...rdance.cc   532  0 / 1       0 /     0       
Locus::Locus(const Locus&)     word.cc         62  0 / 1       0 /     0       
Locus::saveLoc(FILE*)          word.cc         74  0 / 1       0 /     0       
Locus::loadLoc(FILE*)          word.cc         79  0 / 1       0 /     0       
Locus::operator=(Locus&)       word.cc         84  0 / 1       0 /     0       
Locus::operat...unsigned int)  word.cc         91  0 / 1       0 /     0       
operator<<(ostream&,Locus&)    word.cc         98  0 / 1       0 /     0       
operator>>(istream&,Locus&)    word.cc        104  0 / 1       0 /     0       
WordList::WordList(Word*)      word.cc        370  0 / 1       0 /     0       
WordList::WordList(Word&)      word.cc        379  0 / 1       0 /     0       
WordList::Wor...unsigned int)  word.cc        388  0 / 1       0 /     0       
WordList::iterb(void)          word.cc        447  0 / 1       0 /     0       
Locus::Locus(void)             word.h          70  0 / 1       0 /     0       
Locus::setLoc(unsigned int)    word.h          76  0 / 1       0 /     0       
Locus::getLocAdd(void)         word.h          77  0 / 1       0 /     0       
Locus::setNxt(Locus*)          word.h          78  0 / 1       0 /     0       
Locus::getThis(void)           word.h          80  0 / 1       0 /     0       
Word::Word(void)               word.h         107  0 / 1       0 /     0       
Word::getLen(void) const       word.h         112  0 / 1       0 /     0       
Word::getUse(void) const       word.h         113  0 / 1       0 /     0       
Word::getPrv(void) const       word.h         114  0 / 1       0 /     0       
Word::getLoci(void) const      word.h         116  0 / 1       0 /     0       
Word::getTail(void) const      word.h         117  0 / 1       0 /     0       
Word::incWord(void)            word.h         122  0 / 1       0 /     0       
WordList::get...s(void) const  word.h         152  0 / 1       0 /     0       
WordList::getHead(void)        word.h         153  0 / 1       0 /     0       
saveConFile(c...ist&,BOOLEAN)  ...rdance.cc   491  1 / 1       4 /    20 =  20%
main(int,char**)               ...rdance.cc   110  1 / 1      17 /    49 =  34%
saveAlphabetF...tor&,BOOLEAN)  ...rdance.cc   520  1 / 1       1 /     2 =  50%
Word::~Word(void)              word.cc        145  1 / 1       1 /     2 =  50%
Word::incWord(unsigned int)    word.cc        238  1 / 1       1 /     2 =  50%
isAlphaDiacritic(int)          concutils.cc   128  1 / 1      14 /    24 =  58%
operator<<(ostream&,Word&)     word.cc        316  1 / 1       4 /     6 =  66%
Word::addLocus(Locus*)         word.cc        152  1 / 1       6 /     8 =  75%
CharCtVector:...entages(void)  alphalst.cc    193  1 / 1       3 /     4 =  75%
operator<<(os...harCtVector&)  alphalst.cc    207  1 / 1       3 /     4 =  75%
Word::delLoci(void)            word.cc        183  1 / 1       3 /     4 =  75%
operator<<(os...m&,WordList&)  word.cc        726  1 / 1       3 /     4 =  75%
parse(char*,c...har*,BOOLEAN)  ...rdance.cc   371  1 / 1      47 /    62 =  75%
getFilenameOnly(char*)         concutils.cc   216  1 / 1       5 /     6 =  83%
WordList::add...unsigned int)  word.cc        455  1 / 1      19 /    22 =  86%
CharCt::operator=(char&)       alphalst.cc     77  1 / 1       0 /     0       
operator<<(ostream&,CharCt&)   alphalst.cc    121  1 / 1       2 /     2 = 100%
CharCtVector:...tVector(void)  alphalst.cc    144  1 / 1       2 /     2 = 100%
CharCtVector::incChar(int)     alphalst.cc    177  1 / 1       4 /     4 = 100%
CharCtVector::operator[](int)  alphalst.cc    201  1 / 1       0 /     0       
CharCt::CharCt(void)           alphalst.h      67  1 / 1       0 /     0       
CharCt::incChar(void)          alphalst.h      73  1 / 1       0 /     0       
CharCt::getUse(void) const     alphalst.h      74  1 / 1       0 /     0       
CharCt::setPercent(float)      alphalst.h      76  1 / 1       0 /     0       
copyright(void)                ...rdance.cc   246  1 / 1       0 /     0       
ateof(FILE*)                   concutils.cc   174  1 / 1       2 /     2 = 100%
lowerCaseString(char*)         concutils.cc   192  1 / 1       2 /     2 = 100%
Locus::Locus(unsigned int)     word.cc         68  1 / 1       0 /     0       
Word::Word(ch...unsigned int)  word.cc        115  1 / 1       0 /     0       
WordList::~WordList(void)      word.cc        413  1 / 1       2 /     2 = 100%
WordList::iterf(void)          word.cc        439  1 / 1       0 /     0       
Locus::getLoc(void) const      word.h          75  1 / 1       0 /     0       
Locus::getNxt(void)            word.h          79  1 / 1       0 /     0       
Word::getWord(void) const      word.h         111  1 / 1       0 /     0       
Word::getNxt(void) const       word.h         115  1 / 1       0 /     0       
WordList::WordList(void)       word.h         145  1 / 1       0 /     0       
WordList::set...tToHead(void)  word.h         154  1 / 1       0 /     0       
-----------------------------  ------------------  -----  ---------------------
Total                                                36%     145 /   446 =  32%
alphalst.cc:
  ...
         66
         67  //*****  class CharCt functions* *********************************
         68
-->      69  CharCt &CharCt::operator = (CharCt &cc)
         70  {
         71     character=cc.getCharacter();
         72     useAmt=cc.getUse();
  ...
         82     return *this;
         83  }
         84
-->      85  int CharCt::operator == (CharCt &cc)
         86  {
-->      87     return character==cc.getCharacter() ? 1 : 0;
         88  }
         89
-->      90  int CharCt::operator < (CharCt &cc)
         91  {
-->      92     return character < cc.getCharacter() ? 1 : 0;
         93  }
         94
-->      95  int CharCt::operator > (CharCt &cc)
         96  {
-->      97     return character > cc.getCharacter() ? 1 : 0;
         98  }
         99
-->     100  void CharCt::saveChar(FILE *fp)
        101  {
        102     fwrite(&character,sizeof(char),1,fp);
        103     fwrite(&useAmt,sizeof(long),1,fp);
        104     fwrite(&percentUse,sizeof(float),1,fp);
        105  }
        106
-->     107  void CharCt::loadChar(FILE *fp)
        108  {
        109     fread(&character,sizeof(char),1,fp);
        110     fread(&useAmt,sizeof(long),1,fp);
        111     fread(&percentUse,sizeof(float),1,fp);
        112  }
        113
-->     114  istream &operator>>(istream &is,CharCt &cc)
        115  {
        116     is >> cc.character;
        117     cc.useAmt=1;
  ...
        149     }
        150  }
        151
-->     152  CharCtVector::CharCtVector(CharCtVector &ccv)
        153     :totAlphaNums(0)
        154  {
-->     155     for (int n=0;n<ALPHABETLEN;n++){
        156        charVector[n].setCharacter(ccv[n].getCharacter(),ccv[n].getU
        157     }
        158  }
        159
-->     160  void CharCtVector::saveVector(FILE *fp)
        161  {
-->     162     if (totAlphaNums>0)doPercentages();
        163     fwrite(&totAlphaNums,sizeof(long),1,fp);
-->     164     for (int n=0;n<ALPHABETLEN;n++){
        165        charVector[n].saveChar(fp);
        166     }
        167  }
        168
-->     169  void CharCtVector::loadVector(FILE *fp)
        170  {
        171     fread(&totAlphaNums,sizeof(long),1,fp);
-->     172     for (int n=0;n<ALPHABETLEN;n++){
        173        charVector[n].loadChar(fp);
        174     }
        175  }
  ...
        192
X       193  void CharCtVector::doPercentages(void)  //set percentages of total
        194  {
-->T    195     if (totAlphaNums>0)
TF      196        for (int n=0;n<ALPHABETLEN;n++){
        197           charVector[n].setPercent(charVector[n].getUse()/float(tot
        198        }
  ...
        206
X       207  ostream &operator<<(ostream &os,CharCtVector &ccv)
        208  {
-->T    209     if (ccv.totAlphaNums>0)ccv.doPercentages();
TF      210     for (int n=0;n<ALPHABETLEN;n++){
        211        os << ccv[n] << endl;
        212     }
  ...
alphalst.h:
  ...
         65          float percentUse; //percentage of total characters used
         66
X        67          CharCt(void):character('\0'),useAmt(0),percentUse(0.0){}
-->      68          CharCt(unsigned char ch,long use=0) :character(ch),useAmt(
-->      69          CharCt(const CharCt &cc):character(cc.getCharacter()),useA
-->      70          unsigned char getCharacter(void) const { return character;
-->      71          void setCharacter(char ch, long use=0) { character = (unsi
-->      72          void setCharacter(unsigned char ch, long use=0) { characte
X        73          void incChar(void){useAmt++;}
X        74          long getUse(void) const { return useAmt; }
-->      75          float getPercentUse(void) const { return percentUse; }
X        76          void setPercent(float pct){percentUse=pct;}
         77          CharCt &operator = (CharCt &cc);
         78          CharCt &operator = (char &ch);
  ...
concordance.cc:
  ...
        115
        116      copyright();
        117
-->F    118      if (argc<2){   //if only appname is called, provide instructio
        119         instructions();
        120         return 0;
        121      }
        122
        123      //if help is asked for, provide instructions
-->F    124a     else if(
  -->f  124b             strcmp(argv[1],"-?")==0||
  -->f  124c                                      strcmp(argv[1],"-h")==0||
  -->f  124d                                                               strc
        125         instructions();
        126         return 0;
        127      }
        128
-->T    129      if (argc<4){   //no outfile name given on command line: set as
        130         outfile=0;
        131      }
        132      else{ //otherwise use the name of the outfile given by operato
  ...
        143  #ifdef OS_UNIX //this block is set to handle command line switches
        144     enum CtType{UNINDICATED,PAGE,LINE,STANZA}; //command line switc
        145        CtType countType=UNINDICATED;
-->T    146     if (argc > 2){    //operator has included switches (segfaulted
-->F    147        if (strstr(argv[1],"n:")){ //determine starting p/line/v num
-->     148           for (n=0;argv[1][n]!=':';n++);//move past the colon
        149           n++;
-->     150a          for (ndx=0;
  -->   150b                     ndx<12&&
  -->   150c                             argv[1][n];ndx++,n++){
        151              numBfr[ndx]=argv[1][n];
        152           }
        153
        154        numBfr[ndx]='\0';
-->     155a       for (n=0;
  -->   155b                n<12&&
  -->   155c                      numBfr[n];n++) //check to be surethere is a n
-->     156           if (!isdigit(numBfr[n])){
        157              cerr << "\n\nSYNTAX ERROR on command line: switch -[pv
        158              exit(1);
        159           }
  ...
        164
TF      165     for(n=1; n < argc; n++){
TF      166        if(strstr(argv[n],"-")){    //if the arg is a switch...
-->F    167           if(strstr(argv[n],"p"))
        168              countType=PAGE;
-->F    169           else if(strstr(argv[n],"l"))
        170              countType=LINE;
-->T    171           else if(strstr(argv[n],"s"))
        172              countType=STANZA;
        173           else
        174              countType=PAGE;
-->F    175           if(strstr(argv[n],"q"))
        176              QuietFlag=ON;
        177        }
        178     }
  ...
X       180        case STANZA:
        181           parse(argv[2],'s',outfile,QuietFlag);
        182           break;
-->     183        case LINE:
        184           parse(argv[2],'l',outfile,QuietFlag);
        185           break;
-->     186        case PAGE:
        187           parse(argv[2],'p',outfile,QuietFlag);
        188           break;
-->     189        case UNINDICATED:
        190           parse(argv[2],'p',outfile,QuietFlag);
        191           break;
-->     192        }
        193     }
        194
        195     else parse(argv[1],'p',outfile,QuietFlag);  //default choice if
  ...
        260
        261  // print usage instructions on screen:
        262  #ifdef OS_UNIX
-->     263  void instructions(void)
        264  {
        265      cout << "\nUSAGE:\n"
        266        << "concordance [-p[q][n:num] or -l[q][n:num]] or -s[q][num]
  ...
        380     CharCtVector ccv; //character counter
        381     WordList wl;   //the concordance: the linked list of words and
        382
-->F    383     if((fp=fopen(fname,"rb"))==0){   //open file to be concordanced
        384        cerr << "Couldn't open file" << fname << endl;
        385        perror("File opening error");
        386        assert (fp);   //make sure it opened OK
        387     }
        388
        389      //Set up filenames for output .wds & .abc results files:
-->T    390     if (ofname==0){   //if operator hasn't provided an output file
        391        filenameBfr=new char[(fnlen=strlen(fname)+EXTENSIONLEN)];
        392        assert(filenameBfr!=0);
        393        strcpy(filenameBfr,fname);  //use the filename of file to be
  ...
        426        << "\n                                     (1 line of dots =
        427  #endif
        428  #ifdef OS_UNIX
-->T    429     if(!quiet)cout << "\n\nMaking Condordance. Depending on file le
        430  #endif
        431     unsigned char inbuffer[FILESEGMENT];  //holding buffer for read
        432
  ...
TF      436a       for (unsigned int n=0;
  tf    436b                             n<FILESEGMENT&&
  tf    436c                                            n<charsRead&&
  -->t  436d                                                         char(inbuf
        437           ccv.incChar(inbuffer[n]);
TF      438a          if (
  tf    438b              isAlphaDiacritic(inbuffer[n])||
  ...
        440              wordBfr[wordNdx++]=inbuffer[n];
TF      441a             if (
  tf    441b                 isdigit(inbuffer[n])&&
  -->t  441c                                       !isWord)isNum=YES; //if inbu
TF      442              else if (!isWord){
        443                 isWord=YES;  //if a digit has a letter included, in
        444                 isNum=NO;    //added along with &&(inbuffer[n]!='>'
  ...
TF      447a          else if (
  tf    447b                   wordFlag&&!(
  tf    447c                               inbuffer[n]=='>'&&
  -->t  447d                                                 isNum)){ //inbuffe
        448              wordBfr[wordNdx]='\0';  //NULL end the word in wordBfr
        449              wl.addWord(wordBfr,locNum);  //add the word to the con
        450              fileLoc=ftell(fp); //note location in file
  ...
        461           if (inbuffer[n] == CR && countType == 'l') //if whitespac
        462  #endif
        463  #ifdef OS_UNIX
-->F    464a          if (
  tf    464b              inbuffer[n] == LF &&
  -->f  464c                                   countType == 'l') //if whitespac
        465  #endif
        466              locNum++; //increment locnum as line number on carriag
-->F    467a          else if (
  -->f  467b                   inbuffer[n] == FF &&
  -->   467c                                        countType == 'p') //if whit
        468              locNum++; //increment locnum as page number on formfee
TF      469a          else if (
  tf    469b                   inbuffer[n] == '>' &&
  -->t  469c                                         countType == 's' &&
  -->t  469d                                                             isNum)
        470              wordBfr[wordNdx]='\0';  //end the string
        471              locNum=atoi(wordBfr);   //put the number into location
        472              wordNdx=isWord=wordFlag=isNum=0; //start with new word
  ...
        478     saveConFile(fname,conFn,countType,wl,quiet); //save the list of
        479     saveAlphabetFile(fname,alphaFn,ccv,quiet);   //save the alphabe
        480
-->T    481     if(!quiet)
        482        cout << "\n\nConcordancing completed.  For concordance file,
        483        << "usage file, see " << alphaFn << "\n\n";
        484
  ...
        493  {
        494     ofstream confile(conFn);
        495     assert(confile!=0);
-->T    496     if(!quiet)cout << "\n\nSaving concordance file " << conFn << ",
        497     confile << "Concordance for file: " << origFn << "\n\n";
        498     confile << "Note: Concordancer considers a word a set of alphan
        499     confile << "      bounded by whitespace at each end of the set.
        500     confile << "Total number of words in file: " << wordCount << "\
        501
-->T    502     if(ctType=='s')      confile << "Initial stanza of file was sta
-->     503     else if(ctType=='p') confile << "Initial page of file was page
-->     504     else if(ctType=='l') confile << "Initial line of file was line
        505
-->T    506     if(ctType=='s')        confile << "Last stanza of file was stan
-->     507     else if(ctType=='p')   confile << "Last page of file was page "
-->     508     else if(ctType=='l')   confile << "Last line of file was line "
        509
        510     confile << "Word           Number of";
-->T    511     if(ctType=='s') confile << "   Stanza number\n";
-->     512     else if(ctType=='p') confile << "   Page number\n";
-->     513     else if(ctType=='l') confile << "   Line number\n";
        514     confile << "Len  Word:         uses:   Locations:\n";
        515     confile << wl;
        516  }
  ...
        522     ofstream alphafile(alphaFn);
        523     assert(alphafile!=0);
        524
-->T    525     if(!quiet)cout << "\n\nSaving alphabet count file " << alphaFn
        526     alphafile << ccv;
        527  }
        528
        529
        530
        531  //out of memory message to display on screen in parser:
-->     532  void outOfMem(void)
        533  {
        534     cerr << "\n\nERROR: You have insufficient memory to continue ma
        535          << "document.  It will be necessary for you to shorten the
  ...
concutils.cc:
  ...
  tf    131a    (c>='A'&&
  tf    131b             c<='Z')||
  tf    132a    (c>='a'&&
  -->t  132b             c<='z')||
  -->f  133a    (c>=128&&
  -->   133b             c<=154)||
  -->f  134a    (c>=160&&
  -->   134b             c<=165)||
  -->f  135a    (c>=224&&
  -->   135b             c<=235))
        136     ? YES : NO;
        137  }
        138
        139
        140  //OK returns non-0 if c is an alphanumeric or diacritical alphanum
-->     141  BOOLEAN isAlDiaNum(int c)
        142  {
-->     143a    return (
  -->   143b            (c=='\'')||
  -->   144a    (c>='0'&&
  -->   144b             c<='9')||
  -->   145a    (c>='A'&&
  -->   145b             c<='Z')||
  -->   146a    (c>='a'&&
  -->   146b             c<='z')||
  -->   147a    (c>=128&&
  -->   147b             c<=154)||
  -->   148a    (c>=160&&
  -->   148b             c<=165)||
  -->   149a    (c>=224&&
  -->   149b             c<=235))
        150     ? YES : NO;
        151  }
        152
  ...
        155
        156  //OK tell if at end of fstream file on input:
        157  //overloaded
-->     158  int ateof(istream &instream)
        159  {
        160     long floc = instream.tellg();
        161     instream.seekg(floc+2);
-->     162     if(instream.peek() == EOF){
        163        return EOF;
        164     }
        165     else{
  ...
        201  }
        202
        203  //upper cases a null ended c string:
-->     204  char *upperCaseString(char *stringToLc)
        205  {
-->     206     for (int n=0;*(stringToLc+n)!='\0';n++){
        207        *(stringToLc+n)=toupper(*(stringToLc+n));
        208     }
        209     return stringToLc;
  ...
        217  {
        218     int n;
TF      219a    for (n=0;
  -->t  219b             *(fname+n)!='\0'&&
  tf    219c                               *(fname+n)!='.';n++);
        220     *(fname+n)='\0';  //add the null ending to the string
        221  }
  ...
        224
        225  //this function returns a lowercased alphadiacritical or the origi
        226  //character entered if not an alphadiacritical.
-->     227  int diactolower(int ch)
        228  {
-->     229a    if (!(
  -->   229b          ch>='A'||
  -->   229c                   ch<='Z'||
  -->   229d                            ch>='a'||
  -->   229e                                     ch<='z'||
  -->   230a        ch>=128||
  -->   230b                 ch<=154||
  -->   230c                          ch>=160||
  -->   230d                                   ch<=165))return ch;
-->     231a    else if (
  -->   231b             ch>='A'&&
  -->   231c                      ch<='Z')return ch+'a'-'A';
-->     232a    else if (
  -->   232b             ch>='a'&&
  -->   232c                      ch<='z')return ch;
        233     else{
        234        switch(ch){
-->     235           case '':
        236              return '';
-->     237           case '':
        238              return '';
-->     239           case '':
        240              return '';
-->     241           case '':
        242              return '';
-->     243           case '':
        244              return '';
-->     245           case '':
        246              return '';
-->     247           case '':
        248              return '';
-->     249           case '':
        250              return '';
-->     251           default :
        252              return ch;
        253        }
        254     }
  ...
        256
        257  //**************************************************************
        258  //determine if strings are equal by subtracting string 2 from stri
-->     259  int strcomp(char *str1,char *str2)
        260  {
        261     int n;
        262
-->     263a    for (n = 0;
  -->   263b                *(str1+n)!='\0'&&
  -->   263c                                 *(str2+n)!='\0' ; n++){
        264        int val;
-->     265        if ((val=(*(str1+n))-(*(str2+n)))==0);
-->     266        else if (val<0)return val;
-->     267        else if (val>0)return val;
        268     }
        269     //determine if one string is longer than the other:
-->     270     if (str1[n]==str2[n])return 0;
-->     271     else if (str1[n]>str2[n])return str1[n];
        272     else return -str2[n];
        273  }
        274
  ...
word.cc:
  ...
         59
         60  //****   class Locus functions ***********************************
         61
-->      62  Locus::Locus(const Locus &lc)       //X(const X&) constructor
         63  {
         64     loc = lc.getLoc();
         65     nxt=this;   //temporarily point it at itself
  ...
         71     nxt=this;   //temporarily point it at itself
         72  }
         73
-->      74  void Locus::saveLoc(FILE *fp) //save locus to file
         75  {
         76     fwrite(&loc,sizeof(unsigned int),1,fp);
         77  }
         78
-->      79  void Locus::loadLoc(FILE *fp) //read a locus from file
         80  {
         81     fread(&loc,sizeof(unsigned int),1,fp);
         82  }
         83
-->      84  Locus &Locus::operator=(Locus &lc)
         85  {
         86     loc = lc.getLoc();
         87     //nxt=this;     for the moment, leave nxt as it is
         88     return *this;
         89  }
         90
-->      91  Locus &Locus::operator=(unsigned int lc)
         92  {
         93     loc = lc;
         94     //nxt=this;     for the moment, leave nxt as it is
         95     return *this;
         96  }
         97
-->      98  ostream &operator<<(ostream &os,Locus &lc)
         99  {
        100     os << lc.loc;
        101     return os;
        102  }
        103
-->     104  istream &operator>>(istream &is,Locus &lc)
        105  {
        106     is >> lc.loc; //in;
        107     return is;
  ...
        122     assert(loci!=0);
        123  }
        124
-->     125  Word::Word(const Word &wrd)
        126     :wordLen(wrd.getLen()),useAmt(wrd.getUse()),loci(0),tail(0),prv
        127  {
        128     word=new char[wordLen];
  ...
        130     strcpy(word,wrd.getWord());
        131
        132     Locus *newLoc,*walker=wrd.getLoci(); //create a new locus list
-->     133     while (walker!=walker->nxt) {
        134        newLoc=new Locus;   //copy the list of locations
        135        assert(newLoc!=0);
        136        *newLoc=*walker;
  ...
        144
X       145  Word::~Word(void)
        146  {
-->T    147     if (word) delete [] word;
        148     delLoci();
        149  }
        150
        151  //add a locus to the locus list:
X       152  void Word::addLocus(Locus *lcp) //add a locus to the word
        153  {
-->F    154     if (!loci){ //if no list yet (NULL loci = no list)
        155        loci=tail=lcp;   //locus is head of list
        156        return;
        157     }
        158
        159     Locus *walker=loci; //pointer to walk through list - was at top
TF      160     while (walker!=walker->nxt) { //go to the end of the list
-->F    161        if (walker->getLoc()==lcp->getLoc()){
        162           delete lcp; //unneeded - location already present
        163           return;  //if locus is already recorded, don't record;
        164        }
  ...
        182  //removes locus list
X       183  void Word::delLoci(void)
        184  {
-->T    185     if (loci){
        186        Locus *delLocus,*walker=loci;
        187
TF      188        while (walker!=walker->nxt) {   //delete the list of loci
  ...
        197
        198  //copies a char string into Word and sets its use to 1
        199  //does NOT set locus!
-->     200  Word &Word::operator=(char *wrd)
        201  {
-->     202     if (word)delete [] word;
        203     word=new char[wordLen=(strlen(wrd)+1)];
        204     assert(word!=0);
        205     strcpy(word,lowerCaseString(wrd));
        206     useAmt=1;
-->     207     if (loci)delLoci();
        208     tail=loci=0;  //no loci!!
        209     return *this;
        210  }
        211
        212  //note that the use of this function requires
        213  //adding the word to a list in order to set prv and nxt!
-->     214  Word &Word::operator=(Word &wrd)  //set a word to another word
        215  {
        216     wordLen=wrd.getLen();
-->     217     if (word)delete [] word;
        218     word=new char[wordLen];
        219     assert(word!=0);
        220     strcpy(word,wrd.getWord());
        221     useAmt=wrd.getUse();
-->     222     if (loci)delLoci();
        223     Locus *newloc,*prv=0,*walker=wrd.getLoci(); //write the locatio
-->     224     if (walker){
-->     225a       for (unsigned int n=0;
  -->   225b                             n<useAmt&&
  -->   225c                                       prv!=walker;n++){
        226           prv=walker;
        227           newloc=new Locus(walker->getLoc());
        228           addLocus(newloc);
  ...
        237
X       238  void Word::incWord(unsigned int locus)  //increment the number of
        239  {                               //and add a new location to the li
-->T    240     if (word){
        241        useAmt++;
        242        Locus *newLoc=new Locus(locus);
        243        assert(newLoc!=0);
  ...
        248     }
        249  }
        250
-->     251  void Word::saveWord(FILE *fp)   //save a word to disk
        252  {
-->     253a    if(
  -->   253b       !wordLen||
  -->   253c                 !word)return; //on an empty word, don't write
        254     fwrite(&wordLen,sizeof(wordLen),1,fp); //write the length
        255     fwrite(word,wordLen,1,fp); //write the word to the stream
        256     fwrite(&useAmt,sizeof(useAmt),1,fp);   //write the usage (also
        257
-->     258     if(!loci){  //if there is no locus list, write a unsigned int 0
        259        unsigned int substitute=0;
        260        fwrite(&substitute,sizeof(unsigned int),1,fp);
        261        return;
        262     }
        263     Locus *prv=0,*walker=loci; //write the location list
-->     264     if (walker){
-->     265a       for (unsigned int n=0;
  -->   265b                             n<useAmt&&
  -->   265c                                       prv!=walker;n++){
        266           prv=walker;
        267           fwrite(walker->getLocAdd(),sizeof(unsigned int),1,fp);
        268           walker=walker->getNxt();
  ...
        270     }
        271  }
        272
-->     273  Word *Word::loadWord(FILE *fp)   //load a word from disk
        274  {
        275     fread(&wordLen,sizeof(wordLen),1,fp); //read the length
        276     word = new char[wordLen];
  ...
        280
        281     Locus *inloc;  //read in the location list
        282     unsigned int lloc;
-->     283     for (unsigned int n=0;n<useAmt;n++){
        284        fread(&lloc,sizeof(lloc),1,fp);
        285        inloc=new Locus(lloc);
        286        addLocus(inloc);
  ...
        290
        291  //note that this function is non-functional for reading
        292  //information in from a file as saved by operator << !!!
-->     293  istream &operator>>(istream &is,Word &wrd)
        294  {
-->     295     if (wrd.word)delete [] wrd.word;  //delete the word in the form
-->     296     if(wrd.loci)wrd.delLoci();        //delete the loci in the form
        297
        298     is >> wrd.wordLen;
        299     wrd.word = new char[wrd.wordLen];
  ...
        303
        304     Locus *inloc;
        305     unsigned int lloc;
-->     306     for(unsigned int n=0;n<wrd.useAmt;n++){
        307        is >> lloc;
        308        inloc=new Locus(lloc);
        309        assert(inloc!=0);
  ...
        315  //added spaces and endls to set up for read in - check if it works
X       316  ostream &operator<<(ostream &os,Word &wrd)
        317  {
-->T    318     if(wrd.word){    //output nothing if the word is empty
        319        os.width(2);
        320        os << wrd.wordLen-1;
        321        os << ' ';
  ...
        331        os << " - ";
        332
        333        Locus *walker=wrd.loci;
-->F    334        if(!wrd.loci){ //if there is no locus list, write a unsigned
        335           unsigned int substitute=0;
        336           os << substitute << endl;
        337           return os;
  ...
        347     return os;
        348  }
        349
-->     350  void Word::printWord(void)
        351  {
        352     cout << word << ", # of uses: "<< useAmt << ", and locations";
        353     Locus *walker=loci;
-->     354     if(loci){
-->     355        while (walker!=walker->getNxt()){
        356           cout << ", " << walker->getLoc();
        357           walker=walker->getNxt();
        358        }
  ...
        367
        368  SORTORDER WordList::sortOrder=ascending;
        369
-->     370  WordList::WordList(Word *wrd) //wordlist receiving a word as point
        371     :numWords(1)
        372  {
        373     current = head = tail = new Word;
  ...
        376     head->nxt=head->prv=head;  //point word at itself indicating en
        377  }
        378
-->     379  WordList::WordList(Word &wrd) //wordlist receiving a word as ref
        380     :numWords(1)
        381  {
        382     current = head = tail = new Word;
  ...
        385     head->nxt=head->prv=head;
        386  }
        387
-->     388  WordList::WordList(char *wrd,unsigned int loc) //wordlist receivin
        389     :numWords(1)
        390  {
        391     current = head = tail = new Word(wrd,loc);
  ...
        393     head->nxt=head->prv=head;
        394  }
        395
-->     396  WordList::WordList(const WordList &wl) //copy constructor
        397     :numWords(wl.getNumWords())
        398  {
        399     Word *newWord,*walker = wl.head;
-->     400     if (walker){
-->     401        while (walker!=walker->nxt) {
        402           newWord = new Word(*walker);
        403           assert (newWord!=0);
        404           addWord(newWord);
  ...
        422     delete walker; //delete the last one of the list
        423  }
        424
-->     425  void WordList::delList(void)
        426  {
-->     427     if (!head)return;
        428     current=head;
        429     Word *delWord;
-->     430     while ((delWord=iterf())!=delWord->nxt) {
        431        delete delWord;
        432     }
        433     delete delWord;
  ...
        444  }
        445
        446  //iterates wordlist.current backward.  Always returns present curr
-->     447  Word *WordList::iterb(void)
        448  {
        449     Word *holder=current;
        450     current=current->prv;
  ...
        472              return OK;
        473           }
TF      474           else if(strcasecmp(wrd,walker->getWord())<0){//if new wor
-->T    475              if(walker==head){   //make newWord the new head
        476                 walker->prv=newWord;
        477                 newWord->prv=newWord;
        478                 newWord->nxt=walker;
  ...
        491           }
        492           //else if(strcasecmp(wrd,walker->getWord())>0&&strcasecmp
TF      493a          else if(
  -->t  493b                  strcasecmp(wrd,walker->getWord())>0&&
  tf    493c                                                       strcasecmp(w
        494              newWord->nxt=walker->nxt;
        495              walker->nxt->prv=newWord;
  ...
        506           return OK;
        507        }
TF      508        else if(strcasecmp(wrd,walker->getWord())<0){//if new word <
-->T    509           if(walker==head){   //make newWord the new head
        510              walker->prv=newWord;
        511              newWord->prv=newWord;
        512              newWord->nxt=walker;
  ...
        535     }
        536  }
        537
-->     538  int WordList::addWord(Word *wrd)
        539  {
        540     Word *newWord=new Word(*wrd);
        541     assert(newWord!=0);
-->     542     if (!head){
        543        current = tail = head = new Word(*wrd);
        544        assert(head!=0);
        545        head->nxt=head->prv=head;
  ...
        548     }
        549     else{
        550        Word *walker=head;
-->     551        while (walker!=walker->nxt) {
-->     552           if (strcasecmp(wrd->getWord(),walker->getWord())==0){//if
        553              walker->incWord(); //add the new location to the word
        554              return OK;
        555           }
-->     556           else if(strcasecmp(wrd->getWord(),walker->getWord())<0){
-->     557              if(walker==head){   //make newWord the new head
        558                 walker->prv=newWord;
        559                 newWord->prv=newWord;
        560                 newWord->nxt=walker;
  ...
        571                 return OK;
        572              }
        573           }
-->     574a          else if(
  -->   574b                  strcasecmp(wrd->getWord(),walker->getWord())>0&&
  -->   574c                                                                  s
        575              newWord->nxt=walker->nxt;
        576              walker->nxt->prv=newWord;
        577              newWord->prv=walker;
  ...
        581           }
        582           else walker = walker->nxt;
        583        }
-->     584        if (strcasecmp(wrd->getWord(),walker->getWord())==0){//if sa
        585           walker->incWord(); //add the new location to the word in
        586           return OK;
        587        }
-->     588        else if(strcasecmp(wrd->getWord(),walker->getWord())<0){//if
-->     589           if(walker==head){   //make newWord the new head
        590              walker->prv=newWord;
        591              newWord->prv=newWord;
        592              newWord->nxt=walker;
  ...
        616  }
        617
        618
-->     619  void WordList::delWord(char *wrd)   //find a word and remove it fr
        620  {
        621     Word *wordToDel; //word to be deleted
        622
-->     623     if ((wordToDel=this->findWord(wrd))!=0){
-->     624a       if (
  -->   624b           wordToDel==head&&
  -->   624c                            head==head->nxt){ //at head & no list
        625           head=tail=current=0; //NULL all pointers
        626           numWords=0;
        627           delete wordToDel;
        628        }
-->     629        else if(wordToDel==head){
        630           head=head->nxt;          //set next record as head
        631           head->nxt->prv=head->nxt;  //and point it at itself
        632           numWords--;
        633           delete wordToDel;
        634        }
-->     635        else if (wordToDel==tail){
        636           wordToDel->prv->nxt=wordToDel->prv; //point previous Word
        637           tail=wordToDel->prv; //make previous Word tail
        638           current = tail;
  ...
        648     }
        649  }
        650
-->     651  Word *WordList::findWord(char *wrd) //find a word, given a char st
        652  {
        653     current = head;
        654     Word *walker;
-->     655     while ((walker=iterf())!=walker->nxt) {
-->     656        if (strcasecmp(walker->getWord(),wrd)==0)
        657           return walker;
        658     }
-->     659     if (strcasecmp(walker->getWord(),wrd)==0)  //check last record
        660        return walker;
        661     else return 0; //NULL returned on not found
        662  }
        663
-->     664  Word *WordList::findWord(Word *wrd) //find a word, given a Word.
        665  {
        666     current = head;
        667     Word *walker;
-->     668     while ((walker=iterf())!=walker->nxt) {
-->     669        if (strcasecmp(walker->getWord(),wrd->getWord())==0)
        670           return walker;
        671     }
-->     672     if (strcasecmp(walker->getWord(),wrd->getWord())==0)
        673        return walker;
        674     else return 0; //NULL returned on not found
        675  }
        676
-->     677  void WordList::saveWordList(FILE *fp)  //save a list to disk
        678  {
        679     Word *svWord;
-->     680     if (!head) return;
        681     else{
        682        fwrite(&numWords,sizeof(long),1,fp);
        683        current=head;
-->     684        while ((svWord=iterf())!=svWord->nxt) {
        685           svWord->saveWord(fp);
        686        }
        687     }  svWord->saveWord(fp);
        688  }
        689
-->     690  void WordList::loadWordList(FILE *fp)  //load a list from disk
        691  {
        692     long numWordsToLoad;
        693     fread(&numWordsToLoad,sizeof(long),1,fp);
-->     694     if (numWordsToLoad>0){
-->     695        for (int ct=0;ct<numWordsToLoad;ct++){
        696           Word *inWord  = new Word;
        697           assert(inWord!=0);
        698           addWord(inWord->loadWord(fp));
  ...
        700     }
        701  }
        702
-->     703  WordList &WordList::operator=(WordList &wl)  //copy a list into an
        704  {
        705     delList();
        706     Word *newWord,*walker = wl.head;
-->     707     if (walker){
-->     708        while (walker!=walker->nxt) {
        709           newWord = new Word(*walker);
        710           assert (newWord!=0);
        711           addWord(newWord);
  ...
        725
X       726  ostream &operator<<(ostream &os,WordList &wl) //output a WordList
        727  {
-->T    728     if (wl.head){
        729        wl.setCurrentToHead();
        730        Word *walker=wl.iterf();
TF      731        while (walker!=walker->getNxt()) {
  ...
word.h:
  ...
         67     unsigned int loc;   //unsigned int containing a line location
         68     Locus *nxt; //pointer to the next Locus-singly linked list
         69
-->      70     Locus(void):loc(0),nxt(this){}   //default constructor - point
         71     Locus(const Locus &lc);       //X(const X&) constructor
         72     Locus(unsigned int lc);               //constructor receiving a
         73     Locus &operator=(Locus &lc);
         74     Locus &operator=(unsigned int lc);
X        75     unsigned int getLoc(void) const {return loc;} //return a line n
-->      76     void setLoc(unsigned int lc){loc = lc;} //set the location
-->      77     unsigned int *getLocAdd(void) {return &loc;} //return line numb
-->      78     void setNxt(Locus *lp){nxt=lp;}  //set the nxt pointer
X        79     Locus *getNxt(void){return nxt;} //return the pointer to the ne
-->      80     Locus *getThis(void){return this;} //return the pointer to this
         81     void saveLoc(FILE *fp); //save locus to file
         82     void loadLoc(FILE *fp); //read a locus from file
         83     friend ostream &operator<<(ostream &os,Locus &lc);
  ...
        104
        105     void addLocus(Locus *lcp); //add a locus to the word
        106     void delLoci(void); //delete the locus list
-->     107     Word(void):word(0),wordLen(0),useAmt(0),loci(0),tail(0),prv(0),
        108     Word(char *wrd,unsigned int lc,unsigned int numUses=1);  //args
        109     Word(const Word &wrd);
        110     ~Word(void);
X       111     char *getWord(void) const {return word;}
-->     112     int  getLen(void) const {return wordLen;}
-->     113     unsigned int getUse(void) const {return useAmt;}
-->     114     Word *getPrv(void) const {return prv;}
X       115     Word *getNxt(void) const {return nxt;}
-->     116     Locus *getLoci(void) const { return loci; }
-->     117     Locus *getTail(void) const { return tail; }
        118     void printWord(void);  //put word on screen in formatted manner
        119     Word &operator=(Word &wrd);  //set a word to another word
        120     Word &operator=(char *wrd);  //set a word to an instance of 1 w
        121     void incWord(unsigned int locus);  //increment the number of ti
-->     122     void incWord(void){incWord(0);} //increment a word without addi
        123     void saveWord(FILE *fp);   //save a word to disk
        124     Word *loadWord(FILE *fp);   //load a word from disk
        125     friend istream &operator>>(istream &is,Word &wrd);
  ...
        149     WordList(const WordList &wl); //copy constructor
        150     ~WordList(void);
        151     void delList(void);
-->     152     long getNumWords(void) const {return numWords;}
-->     153     Word *getHead(void){return head;}
X       154     void setCurrentToHead(void){current=head;}
        155     Word *iterf(void); //iterators
        156     Word *iterb(void);
  ...
