[pure-lang-svn] SF.net SVN: pure-lang: [126] pure/trunk/test/test011.log
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-24 19:27:19
|
Revision: 126 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=126&view=rev Author: agraef Date: 2008-05-24 12:27:27 -0700 (Sat, 24 May 2008) Log Message: ----------- Fix scanf %n conversion. Modified Paths: -------------- pure/trunk/test/test011.log Modified: pure/trunk/test/test011.log =================================================================== --- pure/trunk/test/test011.log 2008-05-24 19:26:54 UTC (rev 125) +++ pure/trunk/test/test011.log 2008-05-24 19:27:27 UTC (rev 126) @@ -778,67 +778,49 @@ state 0: #0 <var> state 1 state 1: #0 -} end; do_fscanf _/*0:001*/ ret/*0:01*/ _/*0:1*/ = throw (this_cant_happen ret/*0:01*/) { +} end; do_fscanf _/*0:001*/ (_/*0:0101*/,ret/*0:011*/) _/*0:1*/ = throw (this_cant_happen ret/*0:011*/) { rule #0: do_fscanf fp (nread,ret) (scanf_format_spec t s) = nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_fscanf_int fp s buf; "g" = pure_fscanf_double fp s buf; "s" = pure_fscanf_string fp s buf; "p" = pure_fscanf_pointer fp s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret end rule #1: do_fscanf fp (nread,ret) (scanf_format_str s) = nread+res,ret when res = pure_fscanf fp s; ret = if res>=0 then ret else throw (scanf_error ret) end - rule #2: do_fscanf _ ret _ = throw (this_cant_happen ret) + rule #2: do_fscanf _ (_,ret) _ = throw (this_cant_happen ret) state 0: #0 #1 #2 <var> state 1 state 1: #0 #1 #2 - <var> state 2 - <app> state 4 - state 2: #2 - <var> state 3 - state 3: #2 + <app> state 2 + state 2: #0 #1 #2 + <app> state 3 + state 3: #0 #1 #2 + , state 4 state 4: #0 #1 #2 <var> state 5 - <app> state 8 - state 5: #2 + state 5: #0 #1 #2 <var> state 6 - state 6: #2 + state 6: #0 #1 #2 <var> state 7 + <app> state 8 state 7: #2 state 8: #0 #1 #2 <var> state 9 - , state 13 + <app> state 11 + scanf_format_str state 18 state 9: #2 <var> state 10 state 10: #2 - <var> state 11 - state 11: #2 + state 11: #0 #2 <var> state 12 + scanf_format_spec state 15 state 12: #2 - state 13: #0 #1 #2 + <var> state 13 + state 13: #2 <var> state 14 - state 14: #0 #1 #2 - <var> state 15 - state 15: #0 #1 #2 + state 14: #2 + state 15: #0 #2 <var> state 16 - <app> state 17 - state 16: #2 - state 17: #0 #1 #2 - <var> state 18 - <app> state 20 - scanf_format_str state 27 - state 18: #2 + state 16: #0 #2 + <var> state 17 + state 17: #0 #2 + state 18: #1 #2 <var> state 19 - state 19: #2 - state 20: #0 #2 - <var> state 21 - scanf_format_spec state 24 - state 21: #2 - <var> state 22 - state 22: #2 - <var> state 23 - state 23: #2 - state 24: #0 #2 - <var> state 25 - state 25: #0 #2 - <var> state 26 - state 26: #0 #2 - state 27: #1 #2 - <var> state 28 - state 28: #1 #2 + state 19: #1 #2 }; guestimate format/*0:1*/ = n/*0:01*/,format/*0:1*/ when 1,0,_/*0:1101*/,1,s/*0:1111*/ = regex "^%([0-9]*)" REG_EXTENDED format/*0:1*/ 0; n/*0:01*/,format/*0:1*/ = if null s/*0:1111*/ then 1025,"%1024"+tail format/*1:1*/ else eval s/*0:1111*/+1,format/*1:1*/ { rule #0: n,format = if null s then 1025,"%1024"+tail format else eval s+1,format state 0: #0 @@ -1168,10 +1150,10 @@ state 0: #0 <var> state 1 state 1: #0 -} end; do_sscanf (_/*0:0101*/,ret/*0:011*/) _/*0:1*/ = throw (this_cant_happen ret/*0:011*/) { +} end; do_sscanf (_/*0:0101*/,_/*0:01101*/,ret/*0:0111*/) _/*0:1*/ = throw (this_cant_happen ret/*0:0111*/) { rule #0: do_sscanf (u,nread,ret) (scanf_format_spec t s) = u,nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_sscanf_int u s buf; "g" = pure_sscanf_double u s buf; "s" = pure_sscanf_string u s buf; "p" = pure_sscanf_pointer u s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret; u = drop res u end rule #1: do_sscanf (u,nread,ret) (scanf_format_str s) = u,nread+res,ret when res = pure_sscanf u s; ret = if res>=0 then ret else throw (scanf_error ret); u = drop res u end - rule #2: do_sscanf (_,ret) _ = throw (this_cant_happen ret) + rule #2: do_sscanf (_,_,ret) _ = throw (this_cant_happen ret) state 0: #0 #1 #2 <app> state 1 state 1: #0 #1 #2 @@ -1181,60 +1163,42 @@ state 3: #0 #1 #2 <var> state 4 state 4: #0 #1 #2 - <var> state 5 - <app> state 7 - state 5: #2 - <var> state 6 - state 6: #2 + <app> state 5 + state 5: #0 #1 #2 + <app> state 6 + state 6: #0 #1 #2 + , state 7 state 7: #0 #1 #2 <var> state 8 - <app> state 11 - state 8: #2 + state 8: #0 #1 #2 <var> state 9 - state 9: #2 + state 9: #0 #1 #2 <var> state 10 + <app> state 11 state 10: #2 state 11: #0 #1 #2 <var> state 12 - , state 16 + <app> state 14 + scanf_format_str state 21 state 12: #2 <var> state 13 state 13: #2 - <var> state 14 - state 14: #2 + state 14: #0 #2 <var> state 15 + scanf_format_spec state 18 state 15: #2 - state 16: #0 #1 #2 + <var> state 16 + state 16: #2 <var> state 17 - state 17: #0 #1 #2 - <var> state 18 - state 18: #0 #1 #2 + state 17: #2 + state 18: #0 #2 <var> state 19 - <app> state 20 - state 19: #2 - state 20: #0 #1 #2 - <var> state 21 - <app> state 23 - scanf_format_str state 30 - state 21: #2 + state 19: #0 #2 + <var> state 20 + state 20: #0 #2 + state 21: #1 #2 <var> state 22 - state 22: #2 - state 23: #0 #2 - <var> state 24 - scanf_format_spec state 27 - state 24: #2 - <var> state 25 - state 25: #2 - <var> state 26 - state 26: #2 - state 27: #0 #2 - <var> state 28 - state 28: #0 #2 - <var> state 29 - state 29: #0 #2 - state 30: #1 #2 - <var> state 31 - state 31: #1 #2 + state 22: #1 #2 } end; readline prompt/*0:1*/::string = cstring$c_readline prompt/*0:1*/; fnmatch pat/*0:001*/::string s/*0:01*/::string flags/*0:1*/::int = c_fnmatch pat/*0:001*/ s/*0:01*/ flags/*0:1*/==0; @@ -1980,7 +1944,7 @@ state 1: #0 } { - rule #0: fscanf fp format::string = tuple$reverse ret when _,ret = catch error_handler (foldl (do_fscanf fp) (0,[])$scanf_split_format format) end with error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)); error_handler x = throw x; check_buf buf = throw scanf_malloc_error if null buf; check_buf buf = buf; do_fscanf fp (nread,ret) (scanf_format_spec t s) = nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_fscanf_int fp s buf; "g" = pure_fscanf_double fp s buf; "s" = pure_fscanf_string fp s buf; "p" = pure_fscanf_pointer fp s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret end; do_fscanf fp (nread,ret) (scanf_format_str s) = nread+res,ret when res = pure_fscanf fp s; ret = if res>=0 then ret else throw (scanf_error ret) end; do_fscanf _ ret _ = throw (this_cant_happen ret); guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end end + rule #0: fscanf fp format::string = tuple$reverse ret when _,ret = catch error_handler (foldl (do_fscanf fp) (0,[])$scanf_split_format format) end with error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)); error_handler x = throw x; check_buf buf = throw scanf_malloc_error if null buf; check_buf buf = buf; do_fscanf fp (nread,ret) (scanf_format_spec t s) = nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_fscanf_int fp s buf; "g" = pure_fscanf_double fp s buf; "s" = pure_fscanf_string fp s buf; "p" = pure_fscanf_pointer fp s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret end; do_fscanf fp (nread,ret) (scanf_format_str s) = nread+res,ret when res = pure_fscanf fp s; ret = if res>=0 then ret else throw (scanf_error ret) end; do_fscanf _ (_,ret) _ = throw (this_cant_happen ret); guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end end state 0: #0 <var> state 1 state 1: #0 @@ -2006,7 +1970,7 @@ state 4: #0 } { - rule #0: sscanf s::string format::string = tuple$reverse ret when _,_,ret = catch error_handler (foldl do_sscanf (s,0,[])$scanf_split_format format) end with error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)); error_handler x = throw x; check_buf buf = throw scanf_malloc_error if null buf; check_buf buf = buf; guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end; do_sscanf (u,nread,ret) (scanf_format_spec t s) = u,nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_sscanf_int u s buf; "g" = pure_sscanf_double u s buf; "s" = pure_sscanf_string u s buf; "p" = pure_sscanf_pointer u s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret; u = drop res u end; do_sscanf (u,nread,ret) (scanf_format_str s) = u,nread+res,ret when res = pure_sscanf u s; ret = if res>=0 then ret else throw (scanf_error ret); u = drop res u end; do_sscanf (_,ret) _ = throw (this_cant_happen ret) end + rule #0: sscanf s::string format::string = tuple$reverse ret when _,_,ret = catch error_handler (foldl do_sscanf (s,0,[])$scanf_split_format format) end with error_handler (scanf_error ret) = throw (scanf_error (tuple$reverse ret)); error_handler x = throw x; check_buf buf = throw scanf_malloc_error if null buf; check_buf buf = buf; guestimate format = n,format when 1,0,_,1,s = regex "^%([0-9]*)" REG_EXTENDED format 0; n,format = if null s then 1025,"%1024"+tail format else eval s+1,format end; do_sscanf (u,nread,ret) (scanf_format_spec t s) = u,nread+res,ret when size,s = if t=="s" then guestimate s else 16,s; buf = check_buf (calloc size 1); res = case t of "n" = pure_fscanf_int fp s buf; "d" = pure_sscanf_int u s buf; "g" = pure_sscanf_double u s buf; "s" = pure_sscanf_string u s buf; "p" = pure_sscanf_pointer u s buf; _ = throw (this_cant_happen ret) end; res = if res>=0 then res else throw (scanf_error ret) when _ = free buf end; val = case t of "n" = nread+get_int buf; "d" = get_int buf; "g" = get_double buf; "s" = cstring buf; "p" = get_pointer buf; _ = throw (this_cant_happen ret) end; _ = if t=="s" then () else free buf; ret = val:ret; u = drop res u end; do_sscanf (u,nread,ret) (scanf_format_str s) = u,nread+res,ret when res = pure_sscanf u s; ret = if res>=0 then ret else throw (scanf_error ret); u = drop res u end; do_sscanf (_,_,ret) _ = throw (this_cant_happen ret) end state 0: #0 <var>::string state 1 state 1: #0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |