Mercurial > projects > ldc
comparison lphobos/std/stream.d @ 662:88e23f8c2354
Applied downs' latest Phobos patch
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 06 Oct 2008 21:40:33 +0200 |
parents | 373489eeaf90 |
children |
comparison
equal
deleted
inserted
replaced
661:99f32e967746 | 662:88e23f8c2354 |
---|---|
1137 version (Win32) { | 1137 version (Win32) { |
1138 count = _vsnprintf(p, psize, f, args_copy); | 1138 count = _vsnprintf(p, psize, f, args_copy); |
1139 if (count != -1) | 1139 if (count != -1) |
1140 break; | 1140 break; |
1141 psize *= 2; | 1141 psize *= 2; |
1142 p = cast(char*) alloca(psize); | 1142 p = cast(char*) /*alloca*/malloc(psize); |
1143 } else version (Unix) { | 1143 } else version (Unix) { |
1144 count = vsnprintf(p, psize, f, args_copy); | 1144 count = vsnprintf(p, psize, f, args_copy); |
1145 if (count == -1) | 1145 if (count == -1) |
1146 psize *= 2; | 1146 psize *= 2; |
1147 else if (count >= psize) | 1147 else if (count >= psize) |
1148 psize = count + 1; | 1148 psize = count + 1; |
1149 else | 1149 else |
1150 break; | 1150 break; |
1151 p = cast(char*) alloca(psize); | 1151 p = cast(char*) /*alloca*/malloc(psize); |
1152 } else | 1152 } else |
1153 throw new Exception("unsupported platform"); | 1153 throw new Exception("unsupported platform"); |
1154 } | 1154 } |
1155 writeString(p[0 .. count]); | 1155 writeString(p[0 .. count]); |
1156 return count; | 1156 return count; |
1776 In = 1, | 1776 In = 1, |
1777 Out = 2, | 1777 Out = 2, |
1778 OutNew = 6, // includes FileMode.Out | 1778 OutNew = 6, // includes FileMode.Out |
1779 Append = 10 // includes FileMode.Out | 1779 Append = 10 // includes FileMode.Out |
1780 } | 1780 } |
1781 | |
1782 version(linux) version = Unix; | |
1781 | 1783 |
1782 version (Win32) { | 1784 version (Win32) { |
1783 private import std.c.windows.windows; | 1785 private import std.c.windows.windows; |
1784 extern (Windows) { | 1786 extern (Windows) { |
1785 void FlushFileBuffers(HANDLE hFile); | 1787 void FlushFileBuffers(HANDLE hFile); |
2230 * The EndianStream reads and writes binary data (non-getc functions) in a | 2232 * The EndianStream reads and writes binary data (non-getc functions) in a |
2231 * one-to-one | 2233 * one-to-one |
2232 * manner with the source stream so the source stream's position and state will be | 2234 * manner with the source stream so the source stream's position and state will be |
2233 * kept in sync with the EndianStream if only non-getc functions are called. | 2235 * kept in sync with the EndianStream if only non-getc functions are called. |
2234 */ | 2236 */ |
2235 class EndianStream : FilterStream { | 2237 /// This causes a crash in -O2 |
2238 /+class EndianStream : FilterStream { | |
2236 | 2239 |
2237 Endian endian; /// Endianness property of the source stream. | 2240 Endian endian; /// Endianness property of the source stream. |
2238 | 2241 |
2239 /*** | 2242 /*** |
2240 * Create the endian stream for the source stream source with endianness end. | 2243 * Create the endian stream for the source stream source with endianness end. |
2508 assert( em.getc() == 'l' ); | 2511 assert( em.getc() == 'l' ); |
2509 assert( em.getc() == 'l' ); | 2512 assert( em.getc() == 'l' ); |
2510 em.position(0); | 2513 em.position(0); |
2511 } | 2514 } |
2512 } | 2515 } |
2516 +/ | |
2513 | 2517 |
2514 /*** | 2518 /*** |
2515 * Parameterized subclass that wraps an array-like buffer with a stream | 2519 * Parameterized subclass that wraps an array-like buffer with a stream |
2516 * interface. | 2520 * interface. |
2517 * | 2521 * |