Re: text.e bugs?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Please! Ignore this patch.

I put later other with the amendments and 64 bits support.

And more

include std/text.e 
 
 
puts(1, format("Fmt A: [(,,:018.2] Fmt B: [,,:018.2]  Raw: []",     { 1267.4,  1267.4,  1267.4}) & 10)  
puts(1, format("Fmt A: [(,,:018.2] Fmt B: [,,:018.2]  Raw: []",     {-1267.4, -1267.4, -1267.4}) & 10)  
puts(1, format("Fmt A: [+(,,:018.2] Fmt B: [+,,:018.2]  Raw: []",   { 1267.4,  1267.4,  1267.4}) & 10)  
puts(1, format("Fmt A: [+(,,:018.2] Fmt B: [+,,:018.2]  Raw: []\n", {-1267.4, -1267.4, -1267.4}) & 10)  
 
 
puts(1, format("Fmt A: [z,,:18] Fmt B: [,,:018.2]  Raw: []",   { 1267.4,  1267.4,  1267.4}) & 10)  
puts(1, format("Fmt A: [z,,:18] Fmt B: [,,:018.2]  Raw: []",   {-1267.4, -1267.4, -1267.4}) & 10)  
puts(1, format("Fmt A: [+z,,:18] Fmt B: [+,,:018.2]  Raw: []", { 1267.4,  1267.4,  1267.4}) & 10)  
puts(1, format("Fmt A: [+z,,:18] Fmt B: [+,,:018.2]  Raw: []", {-1267.4, -1267.4, -1267.4}) & 10)  

[$]: eui ~/prutext.ex  
Fmt A: 000000000001267.40 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: 00000000001267.40) Fmt B: 000000000001267.40  Raw: -1267.4 
Fmt A: 000000000001267.40 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: 00000000001267.40) Fmt B: 000000000001267.40  Raw: -1267.4 
 
Fmt A: 0000000000001267.4 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: -000000000001267.4 Fmt B: 000000000001267.40  Raw: -1267.4 
Fmt A: +000000000001267.4 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: -000000000001267.4 Fmt B: 000000000001267.40  Raw: -1267.4 
 
[$]: cd $EUINC/std; diff -u text.e  text.e.new | patch; eutest "$EUDIR/tests/t_text.e"; 
patching file text.e 
 
interpreting /home/cargoan/euphoria-LINUX-4.1.0/tests/t_text.e: 
 
Test results summary: 
Files (run: 1) (failed: 0) (100% success) 
 
[$]: eui ~/prutext.ex  
Fmt A: 000000000001267.40 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: (0000000001267.40) Fmt B: -00000000001267.40  Raw: -1267.4 
Fmt A: +00000000001267.40 Fmt B: +00000000001267.40  Raw: 1267.4 
Fmt A: (0000000001267.40) Fmt B: -00000000001267.40  Raw: -1267.4 
 
Fmt A: 0000000000001267.4 Fmt B: 000000000001267.40  Raw: 1267.4 
Fmt A: -000000000001267.4 Fmt B: -00000000001267.40  Raw: -1267.4 
Fmt A: +000000000001267.4 Fmt B: +00000000001267.40  Raw: 1267.4 
Fmt A: -000000000001267.4 Fmt B: -00000000001267.40  Raw: -1267.4 

patch:

--- text.e	2015-01-14 09:02:11.151693000 +0100 
+++ text.e	2015-01-14 08:53:20.514693000 +0100 
@@ -1441,7 +1441,9 @@ 
 	integer ep 
 	integer pflag 
 	integer count 
-	 
+	sequence fmt 
+	atom argval 
+		 
 	if atom(arg_list) then 
 		arg_list = {arg_list} 
 	end if 
@@ -1548,7 +1550,7 @@ 
 	    				end if 
 	    				width = width * 10 + pos - 1 
 	    				if width = 0 then 
-	    					zfill = '0' 
+	    					zfill = 1 
 	    				end if 
 	    			end while 
  
@@ -1760,7 +1762,19 @@ 
 									end if 
 								end if 
 							else 
-								argtext = trim(sprintf("%15.15g", arg_list[argn])) 
+								argval = arg_list[argn] 
+								if argval < 0 then 
+								   argval = -argval 
+								end if 
+								if decs < 0 then 
+									fmt = "%.15g" 
+								elsif argval >= 1e15 or 
+									  argval < 1e-4 then 
+									fmt = sprintf("%%.%de", decs) 
+								else 
+									fmt = sprintf("%%.%df", decs) 
+								end if 
+								argtext = trim(sprintf(fmt, arg_list[argn])) 
 								-- Remove any leading 0 after e+ 
 								while ep != 0 with entry do 
 									argtext = remove(argtext, ep+2) 
@@ -1770,7 +1784,11 @@ 
 								if zfill != 0 and width > 0 then 
 									if width > length(argtext) then 
 										if argtext[1] = '-' then 
-											argtext = '-' & repeat('0', width - length(argtext)) & argtext[2..$] 
+											if msign then 
+												argtext = '-' & repeat('0', width - length(argtext) - 1) & argtext[2..$] 
+											else 
+												argtext = '-' & repeat('0', width - length(argtext)) & argtext[2..$] 
+											end if 
 										else 
 											argtext = repeat('0', width - length(argtext)) & argtext 
 										end if 
@@ -1790,7 +1808,7 @@ 
 											argtext = '(' & argtext[2..$] & ')' 
 										else 
 											if argtext[2] = '0' then 
-												argtext = '(' & argtext[3..$] & ')' 
+												argtext = '(' & argtext[2..$] & ')' 
 											else 
 												argtext = argtext[2..$] & ')' 
 											end if 
 
 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu