.
D 2015-09-09T22:39:26.717
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment I\snoticed\sthat\smakesearch()\scontains\sa\sminor\sbug\sthat\soften\scauses\sit\sto\sclone\sa\ssuccessor\sof\sthe\s"pre"\sstate\stwice\snot\sonce.\s\sAFAICT\sthe\sextra\sstate\sis\sunreachable\sand\sthus\sthere\sis\sno\svisible\seffect,\sbut\sit's\sstill\sa\swaste\sof\sresources.\r\n\r\nThe\sproblem\soccurs\swhen\sthe\sfirst\sstate\sseen\sby\sthe\s"make\sa\slist\sof\sthe\sstates"\ssearch\sis\sseen\stwice\sbecause\sthere\sare\stwo\sarcs\sfrom\sthe\s"pre"\sstate\sto\sthe\ssame\sstate.\s\sThe\sfirst\stime,\swe\sdo\r\n\r\ns->tmp\s=\sslist;\r\nslist\s=\ss;\r\n\r\nbut\ssince\sslist\swas\spreviously\sNULL,\ss->tmp\sdoesn't\schange.\s\sThe\ssecond\stime,\sthe\stest\sfor\ss->tmp\s==\sNULL\smistakenly\sthinks\swe\shadn't\svisited\sthis\sstate,\sso\sit\sdoes\sthat\sagain.\s\sNow\swe\shave\sslist\spointing\sto\sa\sstate\swhose\stmp\sfield\salso\spoints\sto\sitself,\sso\swe'll\svisit\sit\stwice\sin\sthe\s"do\sthe\ssplits"\sloop.\s\sThe\ssecond\svisit\smakes\sa\ssecond\sclone\sof\sthis\sstate,\sbut\ssince\swe\salready\sfreed\sall\sthe\sstate's\sinarcs\sfrom\splaces\sother\sthan\spre,\sthe\ssecond\sclone\sreceives\sno\sinarcs\sand\sis\suseless.\r\n\r\nThe\sproblem\scan\sbe\sseen\sto\sexist\sby\sadding\sa\sdumpnfa()\scall\safter\sthe\scall\sto\smakesearch().\r\nOn\sa\stest\scase\slike\sregexp\s{b*b}\s{a},\sthis\sprintout\sresults:\r\n\r\n\r\nfinal\scleanup:\r\npre\s1,\spost\s0,\sbos\s[2],\sbol\s[3],\seos\s[4],\seol\s[5]\r\n0@\tno\sout\sarcs\r\n1>\t[0]->3\t[1]->3\t[2]->3\t[3]->3\r\n2.\t[0]->0\t[1]->0\t[4]->0\t[5]->0\r\n3.\t[1]->3\t[1]->2\r\nmax\s5\r\n#\s1(\s1):\sb\r\n#\s2(ps):\s\r\n#\s3(ps):\s\r\n#\s4(ps):\s\r\n#\s5(ps):\s\r\n\r\nafter\smakesearch:\r\npre\s1,\spost\s0,\sbos\s[2],\sbol\s[3],\seos\s[4],\seol\s[5]\r\n0@\tno\sout\sarcs\r\n1>\t[0]->3\t[1]->3\t[2]->3\t[3]->3\t[0]->1\r\n\t[1]->1\t[2]->1\t[3]->1\r\n2.\t[0]->0\t[1]->0\t[4]->0\t[5]->0\r\n3.\t[1]->2\t[1]->4\r\n4.\t[1]->2\t[1]->4\r\n5.\t[1]->4\t[1]->2\r\nmax\s5\r\n#\s1(\s1):\sb\r\n#\s2(ps):\s\r\n#\s3(ps):\s\r\n#\s4(ps):\s\r\n#\s5(ps):\s\r\n\r\nNotice\sthe\slack\sof\sways\sto\sreach\sstate\s5.\r\n\r\nI\sthink\sthe\sfix\sis\ssimple:\sthe\stest\r\n\r\nif\s(b\s!=\sNULL\s&&\ss->tmp\s==\sNULL)\r\n\r\nneeds\sto\sbe\r\n\r\nif\s(b\s!=\sNULL\s&&\ss->tmp\s==\sNULL\s&&\ss\s!=\sslist)
J foundin 8.6.4
J is_private 0
J login tgl
J priority 5\sMedium
J private_contact 26864b65f1c6ce8bda86f87ed9c554e19ac0390d
J resolution None
J severity Minor
J status Open
J submitter tgl
J subsystem 43.\sRegexp
J title makesearch()\scan\screate\sa\suseless\sstate
J type Bug
K d7ea9f9853e8438db20f38c27bd657ecb2d48438
U tgl
Z 1c98da86fc4a81563fb17fe90c8e0c3d