| 232 | | FLOCK(args[0]); |
|---|
| 233 | | scope(exit) FUNLOCK(args[0]); |
|---|
| 234 | | foreach (arg; args[1 .. $]) |
|---|
| 235 | | { |
|---|
| 236 | | final s = to!(string)(arg); |
|---|
| 237 | | size_t written = void; |
|---|
| 238 | | version(linux) |
|---|
| 239 | | { |
|---|
| 240 | | written = fwrite_unlocked(s.ptr, |
|---|
| 241 | | s[0].sizeof, s.length, args[0]); |
|---|
| 242 | | } |
|---|
| 243 | | else |
|---|
| 244 | | { |
|---|
| 245 | | // TODO: figure out unlocked bulk writes on Windows |
|---|
| 246 | | written = std.c.stdio.fwrite(s.ptr, |
|---|
| 247 | | s[0].sizeof, s.length, args[0]); |
|---|
| 248 | | } |
|---|
| 249 | | if (written != s.length) |
|---|
| 250 | | { |
|---|
| 251 | | StdioException(); |
|---|
| 252 | | } |
|---|
| 253 | | } |
|---|
| 254 | | } |
|---|
| | 231 | alias stdout target; |
|---|
| | 232 | static const first = 0; |
|---|
| | 233 | } |
|---|
| | 234 | writef(target, "", args[first .. $]); |
|---|
| 362 | | static if (!isSomeString!(T[1])) |
|---|
| 363 | | { |
|---|
| 364 | | // compatibility hack |
|---|
| 365 | | return writef(args[0], "", args[1 .. $]); |
|---|
| 366 | | } |
|---|
| 367 | | else |
|---|
| 368 | | { |
|---|
| 369 | | w.backend = args[0]; |
|---|
| 370 | | FLOCK(w.backend); |
|---|
| 371 | | scope(exit) FUNLOCK(w.backend); |
|---|
| 372 | | std.format.formattedWrite(w, args[1 .. $]); |
|---|
| 373 | | } |
|---|
| | 332 | alias stdout target; |
|---|
| | 333 | static const first = 0; |
|---|
| | 334 | } |
|---|
| | 335 | w.backend = target; |
|---|
| | 336 | FLOCK(w.backend); |
|---|
| | 337 | scope(exit) FUNLOCK(w.backend); |
|---|
| | 338 | static if (!isSomeString!(T[first])) |
|---|
| | 339 | { |
|---|
| | 340 | // compatibility hack |
|---|
| | 341 | std.format.formattedWrite(w, "", args[first .. $]); |
|---|
| | 342 | } |
|---|
| | 343 | else |
|---|
| | 344 | { |
|---|
| | 345 | std.format.formattedWrite(w, args[first .. $]); |
|---|
| 401 | | //writef(args, '\n'); |
|---|
| 402 | | // Duplicate code so we don't duplicate the stack; replace with macro l8r |
|---|
| 403 | | FileWriter!(char) w; |
|---|
| 404 | | static const errorMessage = |
|---|
| 405 | | "You must pass a formatting string as the first" |
|---|
| 406 | | " argument to writefln. If no formatting is needed," |
|---|
| 407 | | " you may want to use writeln."; |
|---|
| 408 | | static if (!is(typeof(args[0]) : FILE*)) |
|---|
| 409 | | { |
|---|
| 410 | | static if (!isSomeString!(T[0])) |
|---|
| 411 | | { |
|---|
| 412 | | // compatibility hack |
|---|
| 413 | | return writef(stdout, "", args, '\n'); |
|---|
| 414 | | } |
|---|
| 415 | | else |
|---|
| 416 | | { |
|---|
| 417 | | w.backend = stdout; |
|---|
| 418 | | FLOCK(w.backend); |
|---|
| 419 | | scope(exit) FUNLOCK(w.backend); |
|---|
| 420 | | std.format.formattedWrite(w, args, '\n'); |
|---|
| 421 | | } |
|---|
| 422 | | } |
|---|
| 423 | | else |
|---|
| 424 | | { |
|---|
| 425 | | static if (!isSomeString!(T[1])) |
|---|
| 426 | | { |
|---|
| 427 | | // compatibility hack |
|---|
| 428 | | return writef(args[0], "", args[1 .. $], '\n'); |
|---|
| 429 | | } |
|---|
| 430 | | else |
|---|
| 431 | | { |
|---|
| 432 | | w.backend = args[0]; |
|---|
| 433 | | FLOCK(w.backend); |
|---|
| 434 | | scope(exit) FUNLOCK(w.backend); |
|---|
| 435 | | std.format.formattedWrite(w, args[1 .. $], '\n'); |
|---|
| 436 | | } |
|---|
| 437 | | } |
|---|
| | 373 | writef(args, '\n'); |
|---|