Changeset 3008


Ignore:
Timestamp:
2002-02-27T11:55:28+13:00 (22 years ago)
Author:
jrm21
Message:

According to the c++ standard, we can't use a UCArray::iterator interchangeably
with char *, which caused errors with gcc3. We now get the address of the
character whenever we need to convert from iterator to char*.

Location:
trunk/gsdl/src/mgpp/text
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/mgpp/text/GSDLQueryLex.cpp

    r2693 r3008  
    3939
    4040  // this version of end is used in unitool
    41   UCArray::const_iterator endMinus1 = end-1;
     41  //  UCArray::const_iterator endMinus1 = end-1;
     42  const unsigned char* endMinus1 = &(*end)-1;
    4243
    4344  int charLen;
    4445  unsigned short c; // one character lookahead
    45   charLen = parse_utf8_char (here, endMinus1, &c);
     46  charLen = parse_utf8_char (&*here, endMinus1, &c);
    4647
    4748  // check for positive or negative
     
    4950  if (c == '+') {
    5051    AddNChar (here, el.text, charLen);
    51     charLen = parse_utf8_char (here, endMinus1, &c);
     52    charLen = parse_utf8_char (&*here, endMinus1, &c);
    5253  } else if (c == '-') {
    5354    neg = true;
    5455    AddNChar (here, el.text, charLen);
    55     charLen = parse_utf8_char (here, endMinus1, &c);
     56    charLen = parse_utf8_char (&*here, endMinus1, &c);
    5657  }
    5758
     
    6465    el.num = el.num*10 + c - '0';
    6566    AddNChar (here, el.text, charLen);
    66     charLen = parse_utf8_char (here, endMinus1, &c);
     67    charLen = parse_utf8_char (&*here, endMinus1, &c);
    6768  }
    6869
     
    7879
    7980  // this version of end is used in unitool
    80   UCArray::const_iterator endMinus1 = end-1;
     81  //UCArray::const_iterator endMinus1 = end-1;
     82  const unsigned char* endMinus1 = &(*end)-1;
    8183
    8284  int charLen=0;
    8385  int length=0;
    8486  unsigned short c; // one character lookahead
    85   charLen = parse_utf8_char (here, endMinus1, &c);
     87  charLen = parse_utf8_char (&*here, endMinus1, &c);
    8688
    8789  // read in number part
     
    9496    AddNChar (here, el.text, charLen);
    9597    length += charLen;
    96     charLen = parse_utf8_char (here, endMinus1, &c);
     98    charLen = parse_utf8_char (&*here, endMinus1, &c);
    9799  }
    98100  // check the next character -if it is a letter, then have a term, not an integer
     
    110112    AddNChar (here, el.text, charLen);
    111113    length += charLen;
    112     charLen = parse_utf8_char (here, endMinus1, &c);
     114    charLen = parse_utf8_char (&*here, endMinus1, &c);
    113115  }
    114116
     
    118120               UCArray::const_iterator end,
    119121               UCArray &text) {
    120   UCArray::const_iterator endMinus1 = end-1;
    121   here = ParseIndexWord (here, endMinus1, text);
     122  //UCArray::const_iterator endMinus1 = end-1;
     123  const unsigned char* endMinus1 = &(*end)-1;
     124  const unsigned char* new_here = ParseIndexWord (&*here, endMinus1, text);
     125  here += (new_here - &*here); // advance iterator by number of chars advanced
    122126  return !text.empty();
    123127}
     
    133137 
    134138  // this version of end is used in unitool
    135   UCArray::const_iterator endMinus1 = end-1;
    136  
     139  //UCArray::const_iterator endMinus1 = end-1;
     140  const unsigned char* endMinus1 = &(*end)-1;
     141
    137142  // ignore all white space
    138143  int charLen;
    139144  unsigned short c; // one character lookahead
    140   charLen = parse_utf8_char (here, endMinus1, &c);
     145  charLen = parse_utf8_char (&*here, endMinus1, &c);
    141146  while (here != end && is_unicode_space (c)) {
    142147    here += charLen;
    143     charLen = parse_utf8_char (here, endMinus1, &c);
     148    charLen = parse_utf8_char (&*here, endMinus1, &c);
    144149  }
    145150  if (here == end) return false;
  • trunk/gsdl/src/mgpp/text/Terms.cpp

    r2468 r3008  
    244244  // convert the word to an "mg word"
    245245  mgWord[0] = term.size();
    246   memcpy ((char *)&mgWord[1], (const char *)term.begin(), term.size());
     246  memcpy ((char *)&mgWord[1], &(term[0]), term.size());
    247247 
    248248  // stem the word
  • trunk/gsdl/src/mgpp/text/UCArray.cpp

    r2468 r3008  
    4141  int i = 0;
    4242  while (here != end) {
    43     cstr[i] = (char)*here;
     43    cstr[i] = text[i];
    4444    here++; i++;
    4545  }
     
    253253  fputc (sufLen, f);
    254254  if (ferror(f) != 0) return false;
    255   return (fwrite ((char *)a.begin()+preLen, sizeof (char), sufLen, f) == sufLen);
     255  char* tmp=GetCStr(a);
     256  int ret=(fwrite (tmp+preLen, sizeof (char), sufLen, f) == sufLen);
     257  delete (tmp);
     258  return (ret);
    256259}
    257260
  • trunk/gsdl/src/mgpp/text/UCArray.h

    r2468 r3008  
    2424
    2525// need this to avoid bizarre compiler problems under VC++ 6.0
    26 #if defined (__WIN32__) && !defined (GSDL_USE_IOS_H)
     26#if !defined (GSDL_NAMESPACE_BROKEN) && !defined (GSDL_USE_IOS_H)
    2727# include <iostream>
    2828using namespace std;
  • trunk/gsdl/src/mgpp/text/ivf.pass1.cpp

    r2468 r3008  
    272272  if (!wordLevelIndex && !inFrag) return;
    273273
    274   const unsigned char *textHere = el.text.begin();
    275   const unsigned char *textEnd = el.text.end() - 1;
     274  const unsigned char *textHere = &(el.text[0]);
     275  const unsigned char *textEnd = &(el.text[el.text.size() - 1]);
    276276  UCArray word;
    277277 
  • trunk/gsdl/src/mgpp/text/ivf.pass2.cpp

    r2468 r3008  
    804804  if (!wordLevelIndex && !inFrag) return;
    805805
    806   const unsigned char *textHere = el.text.begin();
    807   const unsigned char *textEnd = el.text.end() - 1;
     806  const unsigned char *textHere = &(el.text[0]);
     807  const unsigned char *textEnd = &(el.text[el.text.size() - 1]);
    808808  unsigned char mgWord[MAXSTEMLEN + 1];
    809809 
  • trunk/gsdl/src/mgpp/text/mgpp_perf_hash_build.cpp

    r2557 r3008  
    9393   
    9494    *pool++ = wordEl.el.size();
    95     memcpy ((char *) pool, (const char *) wordEl.el.begin(), wordEl.el.size());
     95    memcpy ((char *) pool, &(wordEl.el[0]), wordEl.el.size());
    9696    //cerr << pool<<"   " <<starts[i]<<endl;
    9797    pool += wordEl.el.size();
  • trunk/gsdl/src/mgpp/text/mgpp_stem_idx.cpp

    r2557 r3008  
    7676    // convert the word to an "mg word"
    7777    mgWord[0] = wordEl.el.size();
    78     memcpy((char *)&mgWord[1], (const char *)wordEl.el.begin(), wordEl.el.size());
     78    memcpy((char *)&mgWord[1], &(wordEl.el[0]), wordEl.el.size());
    7979
    8080    // stem the word
  • trunk/gsdl/src/mgpp/text/text.pass1.cpp

    r2698 r3008  
    269269    docLen += textLen;
    270270
    271     retValue = process_text_element ((*here).text.begin(), textLen);
     271    retValue = process_text_element (&(here->text[0]), textLen);
    272272    if (retValue != COMPALLOK) return retValue;
    273273   
  • trunk/gsdl/src/mgpp/text/text.pass2.cpp

    r2541 r3008  
    384384    // compress the text
    385385    if (compress_text (textOutBuf,
    386                (*here).text.begin(),
     386               &(here->text[0]),
    387387               (*here).text.size(),
    388388               whichWordType,
Note: See TracChangeset for help on using the changeset viewer.