------------------------------------
|CS472a Assignment 2 script Readme |
------------------------------------

1> naming constraints:

a number means a line number. e.g. 10 means line 10
'T' means True, 'F' means False
'if' means if decision
'elseif' means else if decision
'for' means for loop decision
'while' means while loop decision
'case' means case in switch function

'10 if T' means if decision in line 10 is True

2> when running the script, may have to press enter to let 
the script go on since concordance display message such as 
help in pages.
 
----------------------------------
************************************
*******test concordance.cc**********
************************************
118 if T,argc<2 T;129 if T,argc<4 T
====================================
118 if F, argc<2 F, 129 if F, argc<4 F
124 elseif T, argv[1]=-? T, others F
====================================
118 if F, argc<2 F, 129 if F, argc<4 F
124 elseif T, argv[1]=-h T, others F
====================================
118 if F, argc<2 F, 129 if F, argc<4 F
124 elseif T, argv[1]=--help T, others F
====================================
118 if F, argc<2 F, 129 if F, argc<4 F
124 elseif F
====================================
146 if T, 147 if T, 148 for T,F, 150 for T,F, 155 for T,F, 156 if T
====================================
146 if T, 147 if T, 155 for T,F, 156 if F
429 if T
====================================
146 if T, 147 if F, 155 for T,F
165 for T,F, 166 T, 167 if F, 169 else if F, 171 else if T, 175 if F
180 case T, 183 case F, 186 case F, 189 case F
countType is s. 502 if T, 503 elseif F, 504 elseif F, 506 if T, 507 elseif F, 508 elseif F
511 if T, 512 elseif F, 513 elseif F
====================================
argc>2 F, 146 if F
165 for T,F, 166 F 
180 case F, 183 case F, 186 case F, 189 case T
383 if F
390 if T
429 if F
====================================
165 for T,F, 166 T, 167 if T, 169 else if F, 171 else if F, 175 if F
180 case F, 183 case F, 186 case T, 189 case F
165 for T,F, 166 T, 167 if F, 169 else if F, 171 else if F, 175 if T
countType is p. 502 if F, 503 elseif T, 504 elseif F, 506 if F, 507 elseif T, 508 elseif F
511 if F, 512 elseif T, 513 elseif F
====================================
165 for T,F, 166 T, 167 if F, 169 else if T, 171 else if F, 175 if F
180 case F, 183 case T, 186 case F, 189 case F
countType is l. 502 if F, 503 elseif F, 504 elseif T, 506 if F, 507 elseif F, 508 elseif T
511 if F, 512 elseif F, 513 elseif T
there is no a white spece as form feed in input file and countType is not p
467 else if F, inbuffer[n]=FF is F, countType = p is F
inbuffer is not '>' ,countType is not s, isNum is not true
469 else if F, inbuffer[n]='>' is not T, countType = s is not T, isNum is not T
if not quiet mode, 481 if T, 496 if T, 526 if T
====================================
a file can't be read; 383 if T
====================================
390 if F
====================================
443 while, 436 for, 438 if F, 447 F
====================================
there is a white spece as line feed in input file and countType is l
464 if T, inbuffer[n]=LF is T, countType = l is T
====================================
there is no a white spece as line feed in input file and countType is not l
464 if F, inbuffer[n]=LF is F, countType = l is F
====================================
there is a white spece as form feed in input file and countType is p
467 else if T, inbuffer[n]=FF is T, countType = p is T
====================================
inbuffer is '>' ,countType is s, isNum is true
469 else if T, inbuffer[n]='>' is T, countType = s is T, isNum is T
====================================
if quiet mode, 481 if F, 496 if F, 526 if F
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       
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       
Word::~Word(void)              word.cc        145  1 / 1       1 /     2 =  50%
Word::incWord(unsigned int)    word.cc        238  1 / 1       1 /     2 =  50%
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%
saveConFile(c...ist&,BOOLEAN)  ...rdance.cc   491  1 / 1      17 /    20 =  85%
WordList::add...unsigned int)  word.cc        455  1 / 1      19 /    22 =  86%
main(int,char**)               ...rdance.cc   110  1 / 1      43 /    49 =  87%
parse(char*,c...har*,BOOLEAN)  ...rdance.cc   371  1 / 1      60 /    62 =  96%
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       
instructions(void)             ...rdance.cc   263  1 / 1       0 /     0       
saveAlphabetF...tor&,BOOLEAN)  ...rdance.cc   520  1 / 1       2 /     2 = 100%
isAlphaDiacritic(int)          concutils.cc   128  1 / 1      24 /    24 = 100%
ateof(FILE*)                   concutils.cc   174  1 / 1       2 /     2 = 100%
lowerCaseString(char*)         concutils.cc   192  1 / 1       2 /     2 = 100%
getFilenameOnly(char*)         concutils.cc   216  1 / 1       6 /     6 = 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                                                37%     209 /   446 =  46%
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      }
  ...
TF      148           for (n=0;argv[1][n]!=':';n++);//move past the colon
        149           n++;
TF      150a          for (ndx=0;
  -->t  150b                     ndx<12&&
  tf    150c                             argv[1][n];ndx++,n++){
        151              numBfr[ndx]=argv[1][n];
        152           }
        153
        154        numBfr[ndx]='\0';
TF      155a       for (n=0;
  -->t  155b                n<12&&
  tf    155c                      numBfr[n];n++) //check to be surethere is a n
-->F    156           if (!isdigit(numBfr[n])){
        157              cerr << "\n\nSYNTAX ERROR on command line: switch -[pv
        158              exit(1);
        159           }
  ...
X       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
  ...
        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
  ...
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])||
  ...
        501
TF      502     if(ctType=='s')      confile << "Initial stanza of file was sta
TF      503     else if(ctType=='p') confile << "Initial page of file was page
-->T    504     else if(ctType=='l') confile << "Initial line of file was line
        505
TF      506     if(ctType=='s')        confile << "Last stanza of file was stan
TF      507     else if(ctType=='p')   confile << "Last page of file was page "
-->T    508     else if(ctType=='l')   confile << "Last line of file was line "
        509
        510     confile << "Word           Number of";
TF      511     if(ctType=='s') confile << "   Stanza number\n";
TF      512     else if(ctType=='p') confile << "   Page number\n";
-->T    513     else if(ctType=='l') confile << "   Line number\n";
        514     confile << "Len  Word:         uses:   Locations:\n";
        515     confile << wl;
        516  }
  ...
        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:
  ...
        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;
  ...
        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);
  ...
