Changeset 7731


Ignore:
Timestamp:
2004-07-08T15:59:21+12:00 (20 years ago)
Author:
jrm21
Message:

gcc 3 is more strict about signed vs unsigned chars... and get() wants a
signed one. fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/cfgread.cpp

    r7705 r7731  
    112112
    113113  text_t curvalue;
    114   unsigned char c1;
     114  char c1;
    115115  filein.get(c1);
    116116
     
    136136     
    137137    bool inquote=false;
    138     unsigned char quotemark='"';
    139     unsigned char preceding; // 1-char state to allow \" and \'
     138    char quotemark='"';
     139    char preceding; // 1-char state to allow \" and \'
    140140    // see if this is a quoted phrase
    141141    if (c1=='\'' || c1=='\"') { // starts with a quote
     
    169169      // see if current byte is part of a multibyte char (utf-8 only!)
    170170      unsigned short int c; // text_t uses 16bit unicode
    171       if (c1 < 0x80) {
    172     c=c1;
    173       } else if (c1 >= 0xc0 && c1 <= 0xdf) {
     171      unsigned char uc1=(unsigned)c1;
     172      if (uc1 < 0x80) {
     173    c=uc1;
     174      } else if (uc1 >= 0xc0 && uc1 <= 0xdf) {
    174175    // 2-byte utf-8
    175176    unsigned char c2;
    176177    // two byte character
    177     if (!filein.eof()) filein.get(c2);
    178     c = ((c1 & 0x1f) << 6) + (c2 & 0x3f);
    179       } else if (c1 >= 0xe0 && c1 <= 0xef) {
     178    if (!filein.eof()) filein.get((char)c2); // get takes a signed char
     179    c = ((uc1 & 0x1f) << 6) + (c2 & 0x3f);
     180      } else if (uc1 >= 0xe0 && uc1 <= 0xef) {
    180181    // 3-byte character
    181182    unsigned char c2, c3;
    182     if (!filein.eof()) filein.get(c2);
    183     if (!filein.eof()) filein.get(c3);
    184     c = ((c1 & 0xf) << 12) + ((c2 & 0x3f) << 6) + (c3 & 0x3f);
     183    if (!filein.eof()) filein.get((char)c2);
     184    if (!filein.eof()) filein.get((char)c3);
     185    c = ((uc1 & 0xf) << 12) + ((c2 & 0x3f) << 6)
     186      + (c3 & 0x3f);
    185187      } // we don't do group2/plane0 (4,5,6-byte utf-8)
    186188
Note: See TracChangeset for help on using the changeset viewer.