Changeset 170:bef543dec5c3
- Timestamp:
- 02/22/08 18:56:35
(8 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
Fix for LEDataStream unread
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r48 |
r170 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 94 | 94 | */ |
|---|
| 95 | 95 | override public int read(byte b[], int off, int len) { |
|---|
| 96 | | int read = 0, count; |
|---|
| 97 | | while (read !is len && (count = readData(b, off, len - read)) !is -1) { |
|---|
| | 96 | int read_ = 0, count; |
|---|
| | 97 | while (read_ !is len && (count = readData(b, off, len - read_)) !is -1) { |
|---|
| 98 | 98 | off += count; |
|---|
| 99 | | read += count; |
|---|
| | 99 | read_ += count; |
|---|
| 100 | 100 | } |
|---|
| 101 | | position += read; |
|---|
| 102 | | if (read is 0 && read !is len) return -1; |
|---|
| 103 | | return read; |
|---|
| | 101 | position += read_; |
|---|
| | 102 | if (read_ is 0 && read_ !is len) return -1; |
|---|
| | 103 | return read_; |
|---|
| 104 | 104 | } |
|---|
| 105 | 105 | |
|---|
| … | … | |
| 144 | 144 | |
|---|
| 145 | 145 | int inCopied = host.read( buffer, newOffset, len - cacheCopied ); |
|---|
| 146 | | if( inCopied is -1 ) inCopied = -1; |
|---|
| 147 | 146 | if (inCopied > 0 ) return inCopied + cacheCopied; |
|---|
| 148 | 147 | if (cacheCopied is 0) return inCopied; |
|---|
| … | … | |
| 156 | 155 | public int readInt() { |
|---|
| 157 | 156 | byte[4] buf = void; |
|---|
| 158 | | host.read(buf); |
|---|
| | 157 | read(buf); |
|---|
| 159 | 158 | return ((((((buf[3] & 0xFF) << 24) | |
|---|
| 160 | 159 | (buf[2] & 0xFF)) << 16) | |
|---|
| … | … | |
| 169 | 168 | public short readShort() { |
|---|
| 170 | 169 | byte[2] buf = void; |
|---|
| 171 | | host.read(buf); |
|---|
| | 170 | read(buf); |
|---|
| 172 | 171 | return cast(short)(((buf[1] & 0xFF) << 8) | (buf[0] & 0xFF)); |
|---|
| 173 | 172 | } |
|---|