Pastey (std/text.e) - format function patch

--- text.e-ori	2015-01-11 22:39:43.819905851 +0100
+++ text.e	2015-01-11 22:58:55.695413520 +0100
@@ -1439,7 +1439,9 @@
 	object envsym
 	object envvar
 	integer ep
-	
+    integer pflag
+	integer count
+
 	if atom(arg_list) then
 		arg_list = {arg_list}
 	end if
@@ -1677,7 +1679,7 @@
 						
 					elsif integer(arg_list[argn]) 
 					-- for consistent formatting, we need to test in case of 64-bit euphoria
-					and arg_list[argn] <= 0x3fff_fff 
+					and arg_list[argn] <= 0x3fff_ffff 
 					and arg_list[argn] >= -0x4000_0000 then
 						if istext then
 							argtext = {and_bits(0xFFFF_FFFF, math:abs(arg_list[argn]))}
@@ -1687,12 +1689,17 @@
 							
 						elsif binout = 1 then
 							argtext = stdseq:reverse( convert:int_to_bits(arg_list[argn], 32)) + '0'
-							for ib = 1 to length(argtext) do
-								if argtext[ib] = '1' then
-									argtext = argtext[ib .. $]
-									exit
+							if zfill != 0 and width > 0 then
+								if width > length(argtext) then
+									argtext = repeat('0', width - length(argtext)) & argtext
 								end if
-							end for
+							else
+								count = 1
+								while count < length(argtext) and argtext[count] = '0' do
+									count += 1
+								end while
+								argtext = argtext[count .. $]
+							end if
 
 						elsif hexout = 0 then
 							argtext = sprintf("%d", arg_list[argn])
@@ -1847,8 +1854,8 @@
 							ep = match("e+0", argtext)
 						end while
 					end if
-	    			currargv = arg_list[argn]
-    			end if
+					currargv = arg_list[argn]
+				end if
 
 
     			if length(argtext) > 0 then
@@ -1871,21 +1878,35 @@
 					if atom(currargv) then
 						if find('e', argtext) = 0 then
 							-- Only applies to non-scientific notation.
+							pflag = 0
+							if msign and currargv < 0 then
+								pflag = 1
+							end if										
+
 							if decs != -1 then
 								pos = find('.', argtext)
 								if pos then
 									if decs = 0 then
 										argtext = argtext [1 .. pos-1 ]
 									else
-										pos = length(argtext) - pos
+										pos = length(argtext) - pos - pflag
 										if pos > decs then
 											argtext = argtext[ 1 .. $ - pos + decs ]
 										elsif pos < decs then
-											argtext = argtext & repeat('0', decs - pos)
+											argtext = argtext[ 1 .. $ - pflag ] & repeat('0', decs - pos)
+											if pflag then
+												argtext = argtext[1 .. $ - 1] & '.' & repeat('0', decs) & ')'
+											else
+												argtext = argtext & '.' & repeat('0', decs)
+											end if
 										end if
 									end if
 								elsif decs > 0 then
-									argtext = argtext & '.' & repeat('0', decs)
+									if pflag then
+										argtext = argtext[1 .. $ - 1] & '.' & repeat('0', decs) & '9'
+									else
+										argtext = argtext & '.' & repeat('0', decs)
+									end if
 								end if
 							end if
 

1. Comment by cargoan Jan 11, 2015

two first lines should be changed from

--- text.e-ori	2015-01-11 22:39:43.819905851 +0100 
+++ text.e	2015-01-11 22:58:55.695413520 +0100 
to

--- text.e	2015-01-11 22:39:43.819905851 +0100 
+++ text.e-new	2015-01-11 22:58:55.695413520 +0100 

for apply patch to text.e include file.