Changeset 11419


Ignore:
Timestamp:
12/05/08 22:58:19 (12 years ago)
Author:
ehuelsmann
Message:

Make one variable out of reader and pushbackReader: they need to point to the exact same stream anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/open-external-format/src/org/armedbear/lisp/Stream.java

    r11417 r11419  
    6868
    6969  // Character input.
    70   private Reader reader;
    71   private PushbackReader pushbackReader;
     70  private PushbackReader reader;
    7271  protected int offset;
    7372  protected int lineNumber;
     
    9089  }
    9190
    92   static final private Symbol keywordDefault = Packages.internKeyword("DEFAULT");
     91  static final protected Symbol keywordDefault = Packages.internKeyword("DEFAULT");
    9392 
    9493  static final private Symbol keywordCodePage = Packages.internKeyword("CODE-PAGE");
     
    107106  protected LispObject externalFormat = LispObject.NIL;
    108107  protected String encoding = null;
     108  protected char lastChar = 0;
    109109 
    110110  // Binary input.
     
    145145              new InputStreamReader(inputStream);
    146146          }
    147         pushbackReader = new PushbackReader(new BufferedReader(inputStreamReader),
    148               2);
    149   initAsCharacterInputStream(pushbackReader);
     147        initAsCharacterInputStream(new BufferedReader(inputStreamReader));
    150148      }
    151149    else
     
    205203  protected void initAsCharacterInputStream(Reader reader)
    206204  {
    207     this.reader = reader;
     205    if (! (reader instanceof PushbackReader))
     206        this.reader = new PushbackReader(reader, 2);
     207    else
     208        this.reader = (PushbackReader)reader;
     209   
    208210    isInputStream = true;
    209211    isCharacterStream = true;
     
    18241826    try
    18251827      {
    1826         pushbackReader.unread(n);
     1828        reader.unread(n);
    18271829        --offset;
    18281830        if (n == eolChar)
     
    18751877      {
    18761878        if (c == '\n') {
    1877     if (eolStyle == EolStyle.CRLF)
    1878               writer.write("\r\n");
    1879           else
    1880               writer.write(eolChar);
    1881          
     1879    if (eolStyle == EolStyle.CRLF && lastChar != '\r')
     1880              writer.write('\r');
     1881
     1882          writer.write(eolChar);
     1883          lastChar = eolChar;
    18821884          writer.flush();
    18831885          charPos = 0;
    18841886        } else {
    18851887          writer.write(c);
     1888          lastChar = c;
    18861889          ++charPos;
    18871890        }
     
    19161919            // writing the space between newlines as chunks.
    19171920            _writeChar(chars[i]);
    1918          
    1919         } else
     1921          return;
     1922        }
     1923       
    19201924        writer.write(chars, start, end - start);
    1921        
     1925        lastChar = chars[end-1];
    19221926        int index = -1;
    19231927        for (int i = end; i-- > start;)
     
    21382142        writer.write(sw.toString());
    21392143        writer.write('\n');
     2144        lastChar = '\n';
    21402145        writer.flush();
    21412146        charPos = 0;
Note: See TracChangeset for help on using the changeset viewer.