Changeset 40a3e1a in tol


Ignore:
Timestamp:
May 27, 2009, 7:28:05 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
1308348
Parents:
830be0c
Message:

Fixing control of CRLF

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1042 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/bbasic/txtalgeb.cpp

    r830be0c r40a3e1a  
    15211521}
    15221522
     1523#define READ_CRLF_AS_LF
     1524
    15231525
    15241526//--------------------------------------------------------------------
    … …  
    15431545  length_ = 0;
    15441546  BChar ch  = ' ';
     1547  bool untilIsLF = until=='\n';
    15451548  for(;(length_<=maxChars)&&(ch!=until)&&(ch!='\0')&&(!is.eof()); length_++)
    15461549  {
    15471550    is.get(ch);
     1551#   ifdef READ_CRLF_AS_LF
     1552    if(untilIsLF && (ch == '\r')&&(!is.eof()))
     1553    {
     1554      is.get(ch);
     1555      if(ch!='\n') { is.unget(); ch = '\r'; }
     1556    }
     1557#   endif
    15481558    buffer_[length_] = ch;
    15491559  }
    … …  
    15741584  }
    15751585  length_ = 0;
    1576   BChar ch  = ' ';
     1586  BChar ch  = ' ', c;
     1587  bool untilIsLF = until=='\n';
    15771588  for(;(length_<=maxChars)&&(ch!=until)&&(ch!='\0')&&(!feof(file)); length_++)
    15781589  {
    15791590    ch = fgetc(file);
     1591#   ifdef READ_CRLF_AS_LF
     1592    if(untilIsLF && (ch == '\r')&&(!feof(file)))
     1593    {
     1594      ch = fgetc(file);
     1595      if(ch!='\n') { ungetc(c, file); ch = '\r'; }
     1596    }
     1597#   endif
    15801598    buffer_[length_] = ch;
    15811599  }
    … …  
    15831601  if(ch=='\0')  { length_--; }
    15841602  buffer_[length_] = '\0';
    1585 
    15861603}
    15871604
    … …  
    16631680  txt.ReallocateBuffer(size);
    16641681  BInt n=-1;
     1682  char ch;
    16651683  do
    16661684  {
    … …  
    16721690      txt.ReallocateBuffer(size);
    16731691    }
    1674     txt.PutChar(n,(BChar)is.get());
     1692    ch = (BChar)is.get();
     1693#   ifdef READ_CRLF_AS_LF
     1694    if((ch == '\r')&&(!is.eof()))
     1695    {
     1696      ch = is.get();
     1697      if(ch!='\n') { is.unget(); ch = '\r'; }
     1698    }
     1699#   endif
     1700    txt.PutChar(n,ch);
    16751701  }
    16761702  while(!(is.eof()) && (txt.String()[n]!=end));
Note: See TracChangeset for help on using the changeset viewer.