www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - std.stdio.write, writeln, fwrite, fwriteln

reply "Lionello Lunesu" <lionello lunesu.remove.com> writes:
This is for the cout lovers out there:

I like writefln, but many times it's doing too much. I often forget to print
strings explicitly using "%s", to prevent errors in the (rare) case the
string contains %-characters. That's why I've added write, writeln, fwrite,
fwriteln to std\stdio.d

Attached the changed files from DMD 0.178 (including ddoc). (I have no idea
what flags to pass to diff to get the usual diff output; do tell)

Changes:
* std.format.doFormat has an optional 4th parameter "bool parse" that
determines whether strings should be parsed for %-characters. It defaults to
'true' (for compatibility).
* std.stdio.writefx has an optional 5th parameter "bool parse". Ditto.
* std.stdio.write, writeln, fwrite, fwriteln call writefx with parse=false,
which in turn calls doFormat with parse=false.

Because the signature of doFormat and writefx has changed, you'll have
linker errors when linking to old obj/libs. Since we're <1.0 I thought it
would not be a problem. If it is, I'll have to make new functions doFormat2,
writefx2 (or so) and make the old doFormat, writefx call those new
functions.

By the way: since the "parse" flag is tested early on, printing strings with
write,writeln will probably be slightly faster as well.

Also: I hereby release my changes to the public domain.

L.


begin 666 std.zip

M; /^#P

MKSLXJ(67]S GB:(2WDFV6JM>%PZ +,L 8BNF2)(2F0>A2 W],B$AC2H'E\4R

MA %^,^$;%UM48#F00F$0BH4D2>Z!I9F0"N,LU[H:YA^68$.[;?&"A%+D/^OW
MSGSZ?GI\N19+D0]F*IIIL3JS5$1%0AO]D29FM K.3SLTPVZ18R$QR-$&K5"Q

MV6)V-9Y^&%FQQU[W4?MH>]F2;9SIZDN4.6MY85S!(LX*%2YX(L*_/"3T83(]


MB8-)X[M:H ]7]QF=\EA<WP"1JR*E7.5]8_% $S(E^[ 4( %.RX1Q>AP3S-C1
M,FPD>JQD037"+F A&1HA>N3J9%HT;*:X9!'UM/=A!8:2]TU#X 89"[,%8F9&
M0E*2 LY,+QN<8<T2!792*G(%";VE":KAM$F"+*D'G4.X)I*$>OG &JK_!$80
M)Z[3%!<+92+ML!B\=JAOCS'"3 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`
M`````````0` ````U 0``&9O<FUA="YD4$L%! `````"``(`:P```*(H````
!````
`
end
Dec 28 2006
next sibling parent "Lionello Lunesu" <lionello lunesu.remove.com> writes:
I forgot to mention:

To test, overwrite the files in dmd/src/phobos/std/ and recompile Phobos.
(follow the instructions from 
http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/CompilePhobos )

Copy the resulting phobos.lib to dmd/lib/, overwriting the phobos.lib that's 
already there.

And an example:

#import std.stdio;
#void main() {



Prints:
test 23 is %s 5

L. 
Dec 28 2006
prev sibling next sibling parent reply "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
Lionello Lunesu wrote:
 This is for the cout lovers out there:
 
 I like writefln, but many times it's doing too much. I often forget to print
 strings explicitly using "%s", to prevent errors in the (rare) case the
 string contains %-characters. That's why I've added write, writeln, fwrite,
 fwriteln to std\stdio.d
How about the converse read* functions? Andrei
Dec 28 2006
parent reply "Lionello Lunesu" <lionello lunesu.remove.com> writes:
"Andrei Alexandrescu (See Website For Email)" 
<SeeWebsiteForEmail erdani.org> wrote in message 
news:45941A78.50908 erdani.org...
 Lionello Lunesu wrote:
 This is for the cout lovers out there:

 I like writefln, but many times it's doing too much. I often forget to 
 print
 strings explicitly using "%s", to prevent errors in the (rare) case the
 string contains %-characters. That's why I've added write, writeln, 
 fwrite,
 fwriteln to std\stdio.d
How about the converse read* functions?
I didn't know they existed? Ah wait, they don't! I see, std.stdio is actually only std-output : ) L.
Dec 28 2006
next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Lionello Lunesu wrote:

How about the converse read* functions?
I didn't know they existed? Ah wait, they don't! I see, std.stdio is actually only std-output : )
They exist, but only for std.stream (din) There is also an "unFormat" implementation there (in vreadf). --anders
Dec 28 2006
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
Lionello Lunesu wrote:
 "Andrei Alexandrescu (See Website For Email)" 
 <SeeWebsiteForEmail erdani.org> wrote in message 
 news:45941A78.50908 erdani.org...
 Lionello Lunesu wrote:
 This is for the cout lovers out there:

 I like writefln, but many times it's doing too much. I often forget to 
 print
 strings explicitly using "%s", to prevent errors in the (rare) case the
 string contains %-characters. That's why I've added write, writeln, 
 fwrite,
 fwriteln to std\stdio.d
How about the converse read* functions?
I didn't know they existed? Ah wait, they don't! I see, std.stdio is actually only std-output : )
Yup, they don't exist, though std.stream does have read functions. As an alternative, I've put a copy of the readf/unFormat routines I wrote ages ago online here: http://www.invisibleduck.org/~sean/code/stdio.d http://www.invisibleduck.org/~sean/code/unformat.d http://www.invisibleduck.org/~sean/code/utf.d They convert everything to dchar internally during processing and this may not be a terribly optimal decision (though given my limited understanding of Unicode at the time it seemed the most prudent approach), but the code may be useful regardless, as it's a complete implementation of the C99 scanf function with some additions for D. The utf changes are necessary to preserve the one-char putback guarantee that C requires, though things admittedly get a bit weird with a single Unicode char being represented by up to four bytes. Sean
Dec 28 2006
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Sean Kelly wrote:

 As an alternative, I've put a copy of the readf/unFormat routines I wrote 
 ages ago online here:
 
 http://www.invisibleduck.org/~sean/code/stdio.d
 http://www.invisibleduck.org/~sean/code/unformat.d
 http://www.invisibleduck.org/~sean/code/utf.d
Just for the archives: the ugly workarounds I did at http://www.algonet.se/~afb/d/stdio/ turned out to be just because Mac OS X 10.3 / GCC 3.3 doesn't support templates fully, and GDC uses that for the TypeInfo... For Mac OS X 10.4 / GCC 4.0, it should be working OK ? (DMDScript is also broken on the old, for same reason) --anders
Dec 28 2006
parent reply Sean Kelly <sean f4.ca> writes:
Anders F Björklund wrote:
 Sean Kelly wrote:
 
 As an alternative, I've put a copy of the readf/unFormat routines I 
 wrote ages ago online here:

 http://www.invisibleduck.org/~sean/code/stdio.d
 http://www.invisibleduck.org/~sean/code/unformat.d
 http://www.invisibleduck.org/~sean/code/utf.d
Just for the archives: the ugly workarounds I did at http://www.algonet.se/~afb/d/stdio/ turned out to be just because Mac OS X 10.3 / GCC 3.3 doesn't support templates fully, and GDC uses that for the TypeInfo...
Thanks for pointing this out. I couldn't remember why the workarounds were necessary.
 For Mac OS X 10.4 / GCC 4.0, it should be working OK ?
I hope so. Aside from some inline asm issues, I haven't seen anything DMD can compile that the new GDC cannot. Sean
Dec 28 2006
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Sean Kelly wrote:

 ... because Mac OS X 10.3 / GCC 3.3 doesn't support
 templates fully, and GDC uses that for the TypeInfo...
Thanks for pointing this out. I couldn't remember why the workarounds were necessary.
I've worked on a back-port from Apple's GCC (which *does* support one-only linkage) to FSF GCC 3.3 (which doesn't), but haven't been able to get it out of the crashing stage. Then again, Intel Macs has made it (10.3) obsolete anyway. --anders PS. http://www.algonet.se/~afb/d/gcc-3.3.6-linkonce.patch (If you can make it work, please follow up to D.gnu!)
Dec 28 2006
prev sibling next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Lionello Lunesu wrote:

 I like writefln, but many times it's doing too much. I often forget to print
 strings explicitly using "%s", to prevent errors in the (rare) case the
 string contains %-characters. That's why I've added write, writeln, fwrite,
 fwriteln to std\stdio.d
I hope that you have better luck with your patch than I did with mine... http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=15627
 Attached the changed files from DMD 0.178 (including ddoc). (I have no idea
 what flags to pass to diff to get the usual diff output; do tell)
diff -u
 Because the signature of doFormat and writefx has changed, you'll have
 linker errors when linking to old obj/libs. Since we're <1.0 I thought it
 would not be a problem. If it is, I'll have to make new functions doFormat2,
 writefx2 (or so) and make the old doFormat, writefx call those new
 functions.
I hope so. Secretly I also hope that readf / unFormat will make it too ? (see http://www.digitalmars.com/d/archives/digitalmars/D/21692.html) --anders
Dec 28 2006
parent "Lionello Lunesu" <lionello lunesu.remove.com> writes:
"Anders F Björklund" <afb algonet.se> wrote in message 
news:en166e$1lou$1 digitaldaemon.com...
 I hope that you have better luck with your patch than I did with mine...

 http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=15627
I figured it had to be done before : S Maybe 'yet another patch' will convince Walter that this is badly needed : )
 Attached the changed files from DMD 0.178 (including ddoc). (I have no 
 idea
 what flags to pass to diff to get the usual diff output; do tell)
diff -u
Thanks.. Why isn't that the default, I wonder.
 I hope so. Secretly I also hope that readf / unFormat will make it too ?
 (see http://www.digitalmars.com/d/archives/digitalmars/D/21692.html)
Hey Andrei! Check that out : ) My wish for the new year will be Phobos being hosted on dsource. L.
Dec 28 2006
prev sibling parent "Lionello Lunesu" <lionello lunesu.remove.com> writes:
The diff -u against files from 0.178.

This patch also solves the following bug in doFormat:
(a bug that has nothing to do with write/writeln, but is easily solvable 
because of them)

#import std.stdio;
#void main() {




C:\dmd>dmd -run bug
[Error: std.format

This happens because doFormat is called recursively, once for each of the 
elements of the array. This means that there should never be any parsing for 
string elements, since there'll never be any 2nd argument to be formatted.

Because the new doFormat takes the extra "bool parse" parameter, the fix is 
simple: invoke doFormat with parse set to false.

L. 


begin 666 write.patch
M+2TM(%QD;60N,3<X7&1M9%QS<F-<<&AO8F]S7'-T9%PO9F]R;6%T+F0),C P
M-BTQ,BTR,R R,#HT



M87)G=6UE;G1S(#T 07)R87D ;V8 5'EP94EN9F\G<RP ;VYE(&9O<B!E86-H
M(&%R9W5M96YT('1O(&)E(&9O<FUA='1E9"X-"B  * EA<F=P='( /2!0;VEN
M=', =&\ =F%R:6%D:6, 87)G=6UE;G0 ;&ES="X-"BL * EP87)S92 ]($)O
M;VQE86XN(%1H92!D969A=6QT(&]F('1R=64 =VEL;"!P87)S92!S=')I;F=S
M(&9O<B H)$D 9F]R;6%T('-P96-I9FEC871I;VYS*2X-"B  * T*(" J(%1H
M<F]W<SH-"B  * E-:7-M871C:&5D(&%R9W5M96YT<R!A;F0 9F]R;6%T<R!R




M(&EN="!J.PT**W9O:60 9&]&;W)M870H=F]I9"!D96QE9V%T92AD8VAA<BD 
M<'5T8RP 5'EP94EN9F];72!A<F=U;65N=',L('9A7VQI<W0 87)G<'1R+"!B
M;V]L('!A<G-E(#UT

M-R! 0 T*( D ('!U=&,H)ULG*3L-"B )("!S:7IE7W0 ='-I>F4 /2!T:2YT
M<VEZ92 I.PT*( D ('=H:6QE("AL96XM+2D >PT*+0D ("  9&]&;W)M870H







M(&=O=&\ 3&5R<F]R.PT*( EM(#T 8V%S="A-86YG;&4I=&DN8VQA<W-I;F9O

M("AM(#T
M;F=L92!M,B ](&-A<W0H36%N9VQE*71I+F-L87-S:6YF;RYN86UE6S$P73L-
M"B )("  (&-H87);72  9FUT.PD)"2\O(&9O<FUA="!S=')I;F<-"BTM+2!<
M9&UD+C$W.%QD;61<<W)C7'!H;V)O<UQS=&1<+W-T9&EO+F0),C P-BTQ,BTR
M,R R,#HT
M-BTQ,BTR." R,#HT

M('T-"B -"BUV;VED('=R:71E9G H1DE,12H 9G L(%1Y<&5);F9O6UT 87)G
M=6UE;G1S+"!V;VED*B!A<F=P='(L(&EN="!N97=L:6YE/69A;'-E*0T**W9O
M:60 =W)I=&5F>"A&24Q%*B!F<"P 5'EP94EN9F];72!A<F=U;65N=',L('9O
M:60J(&%R9W!T<BP 8F]O;"!N97=L:6YE/69A;'-E+"!B;V]L('!A<G-E/71R


M( D ("  ?0T*( T*+0D ("  <W1D+F9O<FUA="YD;T9O<FUA=" F<'5T8RP 
M87)G=6UE;G1S+"!A<F=P='(I.PT**PD ("  <W1D+F9O<FUA="YD;T9O<FUA
M=" F<'5T8RP 87)G=6UE;G1S+"!A<F=P='(L('!A<G-E*3L-"B )("  (&EF


M( T*+0D ("  <W1D+F9O<FUA="YD;T9O<FUA=" F<'5T8W<L(&%R9W5M96YT
M<RP 87)G<'1R*3L-"BL)("  ('-T9"YF;W)M870N9&]&;W)M870H)G!U=&-W
M+"!A<F=U;65N=',L(&%R9W!T<BP <&%R<V4I.PT*( D ("  :68 *&YE=VQI

M,"PT-R! 0 T*( T*(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