more context

This commit is contained in:
mimic
2020-03-13 17:57:09 +01:00
parent 5f7aeb85db
commit b3fc64f455
30 changed files with 26286 additions and 22 deletions
@@ -106,9 +106,9 @@ public class HierarchicalRegrouperForC {
}
private HierarchicalActionSet purifyActionSet(HierarchicalActionSet actionSet){
HierarchicalActionSet hierarchicalActionSet = removeBlocks(actionSet);
hierarchicalActionSet = removeIFthenBlocks(hierarchicalActionSet);
hierarchicalActionSet = removeParentForSingle(hierarchicalActionSet);
hierarchicalActionSet = removeParentNode(hierarchicalActionSet);
// hierarchicalActionSet = removeIFthenBlocks(hierarchicalActionSet);
// hierarchicalActionSet = removeParentForSingle(hierarchicalActionSet);
// hierarchicalActionSet = removeParentNode(hierarchicalActionSet);
return hierarchicalActionSet;
// return actionSet;
}
@@ -154,6 +154,7 @@ public class HierarchicalRegrouperForC {
Predicate<HierarchicalActionSet> predicate = x->NodeMap_new.getKeysByValue(NodeMap_new.StatementMap,x.getAstNodeType()).size() == 1 ;
Predicate<HierarchicalActionSet> predicate1 = x->!x.getAstNodeType().equals("block");
Predicate<HierarchicalActionSet> predicate2 = x->!x.getAstNodeType().equals("then");
// Predicate<HierarchicalActionSet> predicate3 = p->p.getAction().getName().equals(subActions.get(0).getAction().getName()));
private HierarchicalActionSet removeBlocks(HierarchicalActionSet actionSet){
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
@@ -162,20 +163,28 @@ public class HierarchicalRegrouperForC {
Action action = actionSet.getAction();
if (subActions.size() == 1){
HierarchicalActionSet subaction = subActions.get(0);
if(!postOrder(subaction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
// if(!postOrder(subaction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
// return actionSet;
// }
List<HierarchicalActionSet> collect = postOrder(subaction).stream().filter(predicate.and(predicate1.and(predicate2))).collect(Collectors.toList());
if(collect.size() == 0){
return actionSet;
}
boolean b = collect.stream().anyMatch(p -> p.getAction().getName().equals(subActions.get(0).getAction().getName()));
if(!b){
return actionSet;
}
Action action1 = subaction.getAction();
//else,then,block
if(action.getClass().equals(action1.getClass()) && action.getName().equals("UPD")) {
List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subaction.getAstNodeType());
if (keysByValue != null && keysByValue.size() == 1) {
// List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subaction.getAstNodeType());
// if (keysByValue != null && keysByValue.size() == 1) {
subaction.setParent(null);
return removeBlocks(subaction);
}
// }
// if(areRelatedActions(action,action1)) {
// if (subaction.getAstNodeType().equals("block")) {//|| subaction.getAstNodeType().equals("then") || subaction.getAstNodeType().equals("else")){
// List<HierarchicalActionSet> subSubActions = subaction.getSubActions();
@@ -601,15 +601,16 @@ public class TestInputCases {
"------UPD call@@PyString_FromString \"\" @TO@ PySequence_GetSlice pattern 0 0 @AT@ 52073 @LENGTH@ 22\n" +
"---------UPD name@@PyString_FromString @TO@ PySequence_GetSlice @AT@ 52073 @LENGTH@ 19\n" +
"---------UPD argument_list@@\"\" @TO@ pattern 0 0 @AT@ 52092 @LENGTH@ 2\n" +
"------------INS argument@@pattern @TO@ argument_list@@\"\" @AT@ 51091 @LENGTH@ 7\n" +
"---------------INS expr@@pattern @TO@ argument@@pattern @AT@ 51091 @LENGTH@ 7\n" +
"------------------INS name@@pattern @TO@ expr@@pattern @AT@ 51091 @LENGTH@ 7\n" +
"------------INS argument@@0 @TO@ argument_list@@\"\" @AT@ 51100 @LENGTH@ 1\n" +
"---------------INS expr@@0 @TO@ argument@@0 @AT@ 51100 @LENGTH@ 1\n" +
"------------------INS literal:number@@0 @TO@ expr@@0 @AT@ 51100 @LENGTH@ 1\n" +
"------------INS argument@@0 @TO@ argument_list@@\"\" @AT@ 51103 @LENGTH@ 1\n" +
"---------------INS expr@@0 @TO@ argument@@0 @AT@ 51103 @LENGTH@ 1\n" +
"------------------INS literal:number@@0 @TO@ expr@@0 @AT@ 51103 @LENGTH@ 1\n" +
"------------UPD argument@@\"\" @TO@ 0 @AT@ 52093 @LENGTH@ 2\n" +
"---------------UPD expr@@\"\" @TO@ 0 @AT@ 52093 @LENGTH@ 2\n" +
"------------------UPD literal:string@@\"\" @TO@ 0 @AT@ 52093 @LENGTH@ 2\n");
"------------UPD argument@@\"\" @TO@ pattern @AT@ 52093 @LENGTH@ 2\n" +
"---------------UPD expr@@\"\" @TO@ pattern @AT@ 52093 @LENGTH@ 2\n" +
"------------------INS name@@pattern @TO@ expr@@\"\" @AT@ 51091 @LENGTH@ 7\n" +
"------------------DEL literal:string@@\"\" @AT@ 52093 @LENGTH@ 2\n");
}
@Test
public void test_cpython_03897e_8fcc8e() throws IOException {
@@ -865,9 +866,9 @@ public class TestInputCases {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("cpython_719f5f_dcc6ef_Objects#intobject.c");//wrong
Assert.assertEquals(hierarchicalActionSets.size(),1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@long d m if i_divmod x y & d & m < 0 return NULL newintobject m @TO@ long d m if i_divmod x y & d & m < 0 return NULL return newintobject m @AT@ 4993 @LENGTH@ 63\n" +
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@long d long m if i_divmod x y & d & m < 0 return NULL newintobject m @TO@ long d long m if i_divmod x y & d & m < 0 return NULL return newintobject m @AT@ 4993 @LENGTH@ 68\n" +
"---DEL expr_stmt@@newintobject m @AT@ 5056 @LENGTH@ 14\n" +
"---INS return@@return newintobject m @TO@ block@@long d m if i_divmod x y & d & m < 0 return NULL newintobject m @AT@ 5112 @LENGTH@ 21\n" +
"---INS return@@return newintobject m @TO@ block@@long d long m if i_divmod x y & d & m < 0 return NULL newintobject m @AT@ 5112 @LENGTH@ 21\n" +
"------MOV expr@@newintobject m @TO@ return@@return newintobject m @AT@ 5056 @LENGTH@ 14\n");
}
@Test
@@ -1017,7 +1018,7 @@ public class TestInputCases {
public void test_php_src_a10e77_634012() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("php-src_a10e77_634012_ext#phar#tar.c");//
Assert.assertEquals(hierarchicalActionSets.size(),1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS if@@if entry . filename_len == UINT_MAX if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (invalid entry size)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE @TO@ block@@last_was_longlink = 1 entry . filename_len = entry . uncompressed_filesize entry . filename = pemalloc entry . filename_len + 1 myphar -> is_persistent read = php_stream_read fp entry . filename entry . filename_len if read != entry . filename_len efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE entry . filename ][entry . filename_len = '\\0' size = ( ( size + 511 ) & ~ 511 ) - size php_stream_seek fp size SEEK_CUR if ( uint ) php_stream_tell fp > totalsize efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE read = php_stream_read fp buf buf if read != buf efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE continue; @AT@ 11511 @LENGTH@ 211\n" +
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS if@@if entry . filename_len == UINT_MAX if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (invalid entry size)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE @TO@ block@@last_was_longlink = 1 entry . filename_len = entry . uncompressed_filesize entry . filename = pemalloc entry . filename_len + 1 myphar -> is_persistent read = php_stream_read fp entry . filename entry . filename_len if read != entry . filename_len efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE entry . filename ][entry . filename_len = '\\0' size = ( ( size + 511 ) & ~ 511 ) - size php_stream_seek fp size SEEK_CUR if ( uint ) php_stream_tell fp > totalsize efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE read = php_stream_read fp buf sizeof buf if read != sizeof buf efree entry . filename if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (truncated)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE continue; @AT@ 11511 @LENGTH@ 211\n" +
"---INS condition@@entry . filename_len == UINT_MAX @TO@ if@@if entry . filename_len == UINT_MAX if error spprintf error 4096 \"phar error: \\\"%s\\\" is a corrupted tar file (invalid entry size)\" fname php_stream_close fp phar_destroy_phar_data myphar TSRMLS_CC return FAILURE @AT@ 11511 @LENGTH@ 32\n" +
"------INS expr@@entry . filename_len == UINT_MAX @TO@ condition@@entry . filename_len == UINT_MAX @AT@ 11512 @LENGTH@ 32\n" +
"---------INS name@@entry . filename_len @TO@ expr@@entry . filename_len == UINT_MAX @AT@ 11512 @LENGTH@ 20\n" +
@@ -1183,7 +1184,36 @@ public class TestInputCases {
}
@Test
public void test_php_src_e76cf8_39753f() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("php-src_e76cf8_39753f_Zend#zend.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
}
@Test
public void test_cpython_f62026_71eb864() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("cpython_f62026_71eb864_Python#ceval.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
}
@Test
public void test_cpython_df0d00_1254d7() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("cpython_df0d00_1254d7_Python#ceval.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
}
@Test
public void test_cpython_6a619f_46ab6d() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("cpython_6a619f_46ab6d_Modules#posixmodule.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
}
@Test
public void test_gzip_051ed8_8b83dc() throws IOException {
//null pointer
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("gzip_051ed8_8b83dc_gzip.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
}
public List<HierarchicalActionSet> getHierarchicalActionSets(String s) throws IOException {
Properties appProps = new Properties();
@@ -1200,7 +1230,7 @@ public class TestInputCases {
EDiffHunkParser parser = new EDiffHunkParser();
// srcMLPath = "/usr/local/bin/srcml";
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
return hierarchicalActionSets;
}catch (NullPointerException n){
@@ -468,8 +468,7 @@ public class TestRealCases {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("31-B-136044-136045.c");
Assert.assertEquals(hierarchicalActionSets.size(),1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV if@@if flag puts ans + 1 else printf \"No solution\\n\" @TO@ block@@long i l flag 0 tot 0 gets str + 1 l = strlen str + 1 if str ][1 == '@' || str ][l == '@' end for i = 1 i <= l - 2 i ++ if str ][i == '@' && ( str ][i + 1 == '@' || str ][i + 2 == '@' ) end for i = 1 i <= l i ++ if flag && str ][i + 1 == '@' ans ][++ tot = ',' if str ][i == '@' flag = 1 ans ][++ tot = str ][i if flag puts ans + 1 else printf \"No solution\\n\" end return 0 @AT@ 937 @LENGTH@ 48\n");
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV if@@if flag puts ans + 1 else printf \"No solution\\n\" @TO@ block@@long i long l long flag 0 long tot 0 gets str + 1 l = strlen str + 1 if str ][1 == '@' || str ][l == '@' end for i = 1 i <= l - 2 i ++ if str ][i == '@' && ( str ][i + 1 == '@' || str ][i + 2 == '@' ) end for i = 1 i <= l i ++ if flag && str ][i + 1 == '@' ans ][++ tot = ',' if str ][i == '@' flag = 1 ans ][++ tot = str ][i if flag puts ans + 1 else printf \"No solution\\n\" end return 0 @AT@ 937 @LENGTH@ 48\n");
}
@Test
@@ -754,6 +753,117 @@ public class TestRealCases {
"------------------------------INS name@@[rear @TO@ expr@@[rear @AT@ 1850 @LENGTH@ 5\n" +
"------------UPD operator@@++ @TO@ += @AT@ 1874 @LENGTH@ 2\n");
}
@Test
public void test_496_A_15303159_15303846() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("496-A-15303159-15303846.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS expr_stmt@@max = 0 @TO@ block@@for j = 0 j < n - 1 j ++ if i == j + 1 && max < a ][j + 2 - a ][j max = a ][j + 2 - a ][j elseif if max < a ][j + 1 - a ][j max = a ][j + 1 - a ][j b ][i = max @AT@ 155 @LENGTH@ 7\n" +
"---INS expr@@max = 0 @TO@ expr_stmt@@max = 0 @AT@ 155 @LENGTH@ 7\n" +
"------INS name@@max @TO@ expr@@max = 0 @AT@ 155 @LENGTH@ 3\n" +
"------INS operator@@= @TO@ expr@@max = 0 @AT@ 158 @LENGTH@ 1\n" +
"------INS literal:number@@0 @TO@ expr@@max = 0 @AT@ 159 @LENGTH@ 1\n");
}
@Test
public void test_430_B_10625991_10626001() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("430-B-10625991-10626001.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS else@@else break; @TO@ if@@if A ][start == A ][end && ( start && A ][start - 1 == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 4 , start -= 2 , end += 2 elseif if ( A ][start == A ][end ) && ( start && A ][start - 1 == A ][end ) count2 = 3 , start -= 2 , end += 1 elseif if ( A ][start == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 3 , start -= 1 , end += 2 @AT@ 803 @LENGTH@ 11\n" +
"---INS block@@break; @TO@ else@@else break; @AT@ 803 @LENGTH@ 6\n" +
"------INS break@@break; @TO@ block@@break; @AT@ 803 @LENGTH@ 6\n");
}
@Test
public void test_60_A_510615_510619() throws IOException {
//wrong
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("60-A-510615-510619.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS else@@else break; @TO@ if@@if A ][start == A ][end && ( start && A ][start - 1 == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 4 , start -= 2 , end += 2 elseif if ( A ][start == A ][end ) && ( start && A ][start - 1 == A ][end ) count2 = 3 , start -= 2 , end += 1 elseif if ( A ][start == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 3 , start -= 1 , end += 2 @AT@ 803 @LENGTH@ 11\n" +
"---INS block@@break; @TO@ else@@else break; @AT@ 803 @LENGTH@ 6\n" +
"------INS break@@break; @TO@ block@@break; @AT@ 803 @LENGTH@ 6\n");
}
@Test
public void test_509_B_11349359_11354327() throws IOException {
//wrong//
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("509-B-11349359-11354327.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD ternary@@j < min 1 else j - min + 1 @TO@ j <= min 1 else j - min @AT@ 368 @LENGTH@ 26\n" +
"---UPD condition@@j < min @TO@ j <= min @AT@ 368 @LENGTH@ 7\n" +
"------UPD expr@@j < min @TO@ j <= min @AT@ 368 @LENGTH@ 7\n" +
"---------UPD operator@@< @TO@ <= @AT@ 369 @LENGTH@ 1\n" +
"---UPD else@@else j - min + 1 @TO@ else j - min @AT@ 380 @LENGTH@ 16\n" +
"------UPD expr@@j - min + 1 @TO@ j - min @AT@ 380 @LENGTH@ 11\n" +
"---------DEL operator@@+ @AT@ 385 @LENGTH@ 1\n" +
"---------DEL literal:number@@1 @AT@ 386 @LENGTH@ 1\n");
}
@Test
public void test_6_C_12776326_12776346() throws IOException {
//wrong//
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("6-C-12776326-12776346.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if n == 1 printf \"1 0\\n\" @TO@ if n == 1 printf \"1 0\\n\" return 0 @AT@ 83 @LENGTH@ 24\n" +
"---UPD then@@printf \"1 0\\n\" @TO@ printf \"1 0\\n\" return 0 @AT@ 94 @LENGTH@ 14\n" +
"------UPD block@@printf \"1 0\\n\" @TO@ printf \"1 0\\n\" return 0 @AT@ 94 @LENGTH@ 14\n" +
"---------MOV return@@return 0 @TO@ block@@printf \"1 0\\n\" @AT@ 111 @LENGTH@ 8\n");
}
@Test
public void test_494_A_10139010_10139025() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("494-A-10139010-10139025.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if sum == 0 && h > 0 flag = 0 @TO@ if ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 flag = 0 @AT@ 298 @LENGTH@ 29\n" +
"---UPD condition@@sum == 0 && h > 0 @TO@ ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 @AT@ 298 @LENGTH@ 17\n" +
"------UPD expr@@sum == 0 && h > 0 @TO@ ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 @AT@ 299 @LENGTH@ 17\n" +
"---------INS operator@@( @TO@ expr@@sum == 0 && h > 0 @AT@ 299 @LENGTH@ 1\n" +
"---------INS operator@@) @TO@ expr@@sum == 0 && h > 0 @AT@ 313 @LENGTH@ 1\n" +
"---------INS operator@@|| @TO@ expr@@sum == 0 && h > 0 @AT@ 315 @LENGTH@ 2\n" +
"---------INS name@@sum @TO@ expr@@sum == 0 && h > 0 @AT@ 318 @LENGTH@ 3\n" +
"---------INS operator@@- @TO@ expr@@sum == 0 && h > 0 @AT@ 321 @LENGTH@ 1\n" +
"---------INS name@@h @TO@ expr@@sum == 0 && h > 0 @AT@ 322 @LENGTH@ 1\n" +
"---------INS operator@@+ @TO@ expr@@sum == 0 && h > 0 @AT@ 323 @LENGTH@ 1\n" +
"---------INS literal:number@@1 @TO@ expr@@sum == 0 && h > 0 @AT@ 324 @LENGTH@ 1\n" +
"---------INS operator@@<= @TO@ expr@@sum == 0 && h > 0 @AT@ 325 @LENGTH@ 2\n" +
"---------INS literal:number@@0 @TO@ expr@@sum == 0 && h > 0 @AT@ 327 @LENGTH@ 1\n");
}
@Test
public void test_248_B_3757114_3757122() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("248-B-3757114-3757122.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"---UPD expr@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"------UPD call@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"---------UPD argument_list@@\"%3d\\n\" suf ][n % P @TO@ \"%.*d\\n\" 3 suf ][n % P @AT@ 341 @LENGTH@ 19\n" +
"------------UPD argument@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"---------------UPD expr@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"------------------UPD literal:string@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"------------INS argument@@3 @TO@ argument_list@@\"%3d\\n\" suf ][n % P @AT@ 352 @LENGTH@ 1\n" +
"---------------INS expr@@3 @TO@ argument@@3 @AT@ 352 @LENGTH@ 1\n" +
"------------------INS literal:number@@3 @TO@ expr@@3 @AT@ 352 @LENGTH@ 1\n");
}
//codeflaws_31-B-14288247-14288278.c
@Test
public void test_31_B_14288247_14288278() throws IOException {
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("31-B-14288247-14288278.c");
Assert.assertEquals(hierarchicalActionSets.size(), 1);
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"---UPD expr@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"------UPD call@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
"---------UPD argument_list@@\"%3d\\n\" suf ][n % P @TO@ \"%.*d\\n\" 3 suf ][n % P @AT@ 341 @LENGTH@ 19\n" +
"------------UPD argument@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"---------------UPD expr@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"------------------UPD literal:string@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
"------------INS argument@@3 @TO@ argument_list@@\"%3d\\n\" suf ][n % P @AT@ 352 @LENGTH@ 1\n" +
"---------------INS expr@@3 @TO@ argument@@3 @AT@ 352 @LENGTH@ 1\n" +
"------------------INS literal:number@@3 @TO@ expr@@3 @AT@ 352 @LENGTH@ 1\n");
}
public List<HierarchicalActionSet> getHierarchicalActionSets(String s) throws IOException {
Properties appProps = new Properties();
appProps.load(new FileInputStream("src/main/resource/app.properties"));
@@ -1,11 +1,10 @@
portDumps = 6399
numOfWorkers = 14
hunkLimit = 10
hunkLimit = 1
patchSize = 50
#projectList = libtiff,php-src,cpython,wireshark,gzip,gmp,lighttpd1.4,lighttpd2
projectList = codeflaws
projectList = libtiff,php-src,cpython,wireshark,gzip,gmp,lighttpd1.4,lighttpd2
#inputPath = /Users/anilkoyuncu/projects/gumInputLinux
#inputPath = /Users/anil.koyuncu/projects/fixminer/fixminer-data/gumInputLinux
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
scanf ("%d", &n);
if (n < 3)
printf ("-1\n");
else if (n == 3)
printf ("210\n");
else {
int i;
printf ("1");
for (i = 0; i < n-4; ++i)
printf ("0");
printf ("%3d\n", suf[n % P]);
}
exit (EXIT_SUCCESS);
return 0;
}
@@ -0,0 +1,26 @@
#include <stdio.h>
int main(int argc, char *argv[]) {
char *p,*q,s[201];
scanf("%s\n",s);
int ms=0;
for (p=s,q=p-2;*p;p++) {
if (*p=='@')
if (p-q<3) break;
else q=p;
ms=1;
}
int first=1;
if (*p||*(p-1)=='@'||!ms) printf("No solution\n");
else {
for (p=s+1,q=s;*p;p++,q++) {
if (*p=='@') {
if (!first) printf(",");
first=0;
}
printf("%c",*q);
}
printf("%s\n",q);
}
return 0;
}
@@ -0,0 +1,43 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,k,x,i,max=0,start,end;
scanf("%d%d%d",&n,&k,&x);
int A[n],consecutive[n-1],count=0,count2=0,temp,temp2,tempcount;
for(i=0;i<n;i++)
scanf("%d",&A[i]);
for(i=0;i<n-1;i++)
{
if(A[i]==A[i+1] && A[i]== x)
consecutive[count++]=i;
}
//printf("%d\n",count );
for(i=0;i<count;i++)
{
start=consecutive[i];
end=consecutive[i]+1;
start--;
end++;
tempcount=2;
while(start!=-1 && end != n)
{
count2=0;
if(A[start]==A[end] && (start && A[start-1]==A[end]) && (end!=n-1 && A[start]==A[end+1]))
count2=4,start-=2,end+=2;
else if((A[start]== A[end])&&(start && A[start-1]==A[end]))
count2=3,start-=2,end+=1;
else if((A[start]==A[end])&&(end!=n-1 && A[start]==A[end+1]))
count2=3,start-=1,end+=2;
else
;
if(count2>=3)
tempcount=tempcount+count2;
}
if(tempcount>max)
max=tempcount;
}
printf("%d\n",max );
return 0;
}
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[]){
int flag,sum,max,sum1,i,j,k,l,n,m,h;
char c[100000];
scanf("%s",c);
n = strlen(c);
h=0;
flag=1;
for(i=0;i<n;i++){
if(c[i]=='#'){
h++;
max=i;
}
else if(c[i]=='(')
sum++;
else if(c[i]==')')
sum--;
}
if(sum==0 && h>0)
flag=0;
sum1=0;
if(flag==0)
printf("-1\n");
else{
for(i=0;i<n;i++){
if(c[i]=='(')
sum1++;
else if(c[i]=='#'){
if(i!=max)
sum1--;
else
sum1 = sum1 - (sum-h+1);
}
else if(c[i]==')')
sum1--;
else ;
if(sum1<0){
printf("-1\n");
flag=0;
break;
}
else;
}
if(flag==1)
for(i=0;i<n;i++)
if(c[i]=='#'){
if(i!=max)
printf("1\n");
else
printf("%d\n",sum-h+1);
}
}
return 0;
}
@@ -0,0 +1,24 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,a[200],i,max=0,j,b[100];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=1;i<n-1;i++){
for(j=0;j<n-1;j++){
if(i==j+1&&max<a[j+2]-a[j])
max=a[j+2]-a[j];
else if(max<a[j+1]-a[j])
max=a[j+1]-a[j];
else;
}
b[i]=max;
}
max=b[1];
for(i=1;i<n-1;i++)
if(max>b[i])
max=b[i];
printf("%d",max);
return 0;
}
@@ -0,0 +1,27 @@
#include<stdio.h>
int arr[52000],i,j,n,m,max=-31231212,min=1123132;
int main(int argc, char *argv[]){
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++){
scanf("%d",&arr[i]);
if(arr[i]<min)
min = arr[i];
if(arr[i]>max)
max = arr[i];
}
if(max - min > m){
puts("NO");
return 0;
}
puts("YES");
for(i=1;i<=n;i++) {
for(j=1;j<=arr[i];j++)
printf("%d ",j<min ? 1 : j-min+1);
puts("");
}
return 0;
}
@@ -0,0 +1,67 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,i,j;
scanf("%d",&n);
if(n==1)
printf("1 0\n"); return 0;
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int cna=0,cnb=0;
int t1=0,t2=0;
i=0;
j=n-1;
cna++; cnb++;
t1+=arr[0];
t2+=arr[n-1];
//printf("%d %d %d %d\n\n",t1,t2,i,j);
while((i+1)!=j)
{
if(t1<t2)
{
i++;
cna++;
t1+=arr[i];
}
else if(t2<t1)
{
j--;
cnb++;
t2+=arr[j];
}
else if(t2==t1 && (i+2)!=j)
{
j--;
cnb++;
t2+=arr[j];
i++;
cna++;
t1+=arr[i];
}
if((i+2)==j && t2==t1)
{
cna++;
t1+=arr[i];
break;
}
//printf("%d %d %d %d\n",t1,t2,i,j);
}
printf("%d %d\n",cna,cnb);
return 0;
}
@@ -0,0 +1,33 @@
#include<math.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define oo 1000000000
#define pi 3.14159265359
#define zero(a) (abb(a)<=1e-7)
#define lowbit(a) ((a)&(-(a)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abb(a) ((a)>0?(a):(-(a)))
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))
char a[111],b[111],c[111],d[111];
int main(int argc, char *argv[])
{
int m,t,x=1,y;
scanf("%d%d",&y,&m);
while (m--)
{
scanf("%s%s%s%s%d",a+1,b+1,c+1,d+1,&t);
if (c[1]=='l')
y=min(y,t-1);
else
x=max(x,t+1);
printf("%d\n",(y>=x)?y-x+1:-1);
}
return 0;
}
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
scanf ("%d", &n);
if (n < 3)
printf ("-1\n");
else if (n == 3)
printf ("210\n");
else {
int i;
printf ("1");
for (i = 0; i < n-4; ++i)
printf ("0");
printf ("%.*d\n", 3, suf[n % P]);
}
exit (EXIT_SUCCESS);
return 0;
}
@@ -0,0 +1,27 @@
#include <stdio.h>
int main(int argc, char *argv[]) {
char *p,*q,s[201];
scanf("%s\n",s);
int ms=0;
for (p=s,q=p-2;*p;p++) {
if (*p=='@') {
if (p-q<3) break;
else q=p;
ms=1;
}
}
int first=1;
if (*p||*(p-1)=='@'||!ms) printf("No solution\n");
else {
for (p=s+1,q=s;*p;p++,q++) {
if (*p=='@') {
if (!first) printf(",");
first=0;
}
printf("%c",*q);
}
printf("%s\n",q);
}
return 0;
}
@@ -0,0 +1,44 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,k,x,i,max=0,start,end;
scanf("%d%d%d",&n,&k,&x);
int A[n],consecutive[n-1],count=0,count2=0,temp,temp2,tempcount;
for(i=0;i<n;i++)
scanf("%d",&A[i]);
for(i=0;i<n-1;i++)
{
if(A[i]==A[i+1] && A[i]== x)
consecutive[count++]=i;
}
//printf("%d\n",count );
for(i=0;i<count;i++)
{
start=consecutive[i];
end=consecutive[i]+1;
start--;
end++;
tempcount=2;
while(start!=-1 && end != n)
{
count2=0;
if(A[start]==A[end] && (start && A[start-1]==A[end]) && (end!=n-1 && A[start]==A[end+1]))
count2=4,start-=2,end+=2;
else if((A[start]== A[end])&&(start && A[start-1]==A[end]))
count2=3,start-=2,end+=1;
else if((A[start]==A[end])&&(end!=n-1 && A[start]==A[end+1]))
count2=3,start-=1,end+=2;
else
break;
if(count2>=3)
tempcount=tempcount+count2;
}
if(tempcount>max)
max=tempcount;
}
printf("%d\n",max );
return 0;
}
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[]){
int flag,sum,max,sum1,i,j,k,l,n,m,h;
char c[100000];
scanf("%s",c);
n = strlen(c);
h=0;
flag=1;
for(i=0;i<n;i++){
if(c[i]=='#'){
h++;
max=i;
}
else if(c[i]=='(')
sum++;
else if(c[i]==')')
sum--;
}
if((sum==0 && h>0) || sum-h+1<=0)
flag=0;
sum1=0;
if(flag==0)
printf("-1\n");
else{
for(i=0;i<n;i++){
if(c[i]=='(')
sum1++;
else if(c[i]=='#'){
if(i!=max)
sum1--;
else
sum1 = sum1 - (sum-h+1);
}
else if(c[i]==')')
sum1--;
else ;
if(sum1<0){
printf("-1\n");
flag=0;
break;
}
else;
}
if(flag==1)
for(i=0;i<n;i++)
if(c[i]=='#'){
if(i!=max)
printf("1\n");
else
printf("%d\n",sum-h+1);
}
}
return 0;
}
@@ -0,0 +1,25 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,a[200],i,max=0,j,b[100];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=1;i<n-1;i++){
max=0;
for(j=0;j<n-1;j++){
if(i==j+1&&max<a[j+2]-a[j])
max=a[j+2]-a[j];
else if(max<a[j+1]-a[j])
max=a[j+1]-a[j];
else;
}
b[i]=max;
}
max=b[1];
for(i=1;i<n-1;i++)
if(max>b[i])
max=b[i];
printf("%d",max);
return 0;
}
@@ -0,0 +1,27 @@
#include<stdio.h>
int arr[52000],i,j,n,m,max=-31231212,min=1123132;
int main(int argc, char *argv[]){
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++){
scanf("%d",&arr[i]);
if(arr[i]<min)
min = arr[i];
if(arr[i]>max)
max = arr[i];
}
if(max - min > m){
puts("NO");
return 0;
}
puts("YES");
for(i=1;i<=n;i++) {
for(j=1;j<=arr[i];j++)
printf("%d ",j<=min ? 1 : j-min);
puts("");
}
return 0;
}
@@ -0,0 +1,70 @@
#include<stdio.h>
int main(int argc, char *argv[])
{
int n,i,j;
scanf("%d",&n);
if(n==1)
{
printf("1 0\n"); return 0;
}
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int cna=0,cnb=0;
int t1=0,t2=0;
i=0;
j=n-1;
cna++; cnb++;
t1+=arr[0];
t2+=arr[n-1];
//printf("%d %d %d %d\n\n",t1,t2,i,j);
while((i+1)!=j)
{
if(t1<t2)
{
i++;
cna++;
t1+=arr[i];
}
else if(t2<t1)
{
j--;
cnb++;
t2+=arr[j];
}
else if(t2==t1 && (i+2)!=j)
{
j--;
cnb++;
t2+=arr[j];
i++;
cna++;
t1+=arr[i];
}
if((i+2)==j && t2==t1)
{
cna++;
t1+=arr[i];
break;
}
//printf("%d %d %d %d\n",t1,t2,i,j);
}
printf("%d %d\n",cna,cnb);
return 0;
}
@@ -0,0 +1,33 @@
#include<math.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define oo 1000000000
#define pi 3.14159265359
#define zero(a) (abb(a)<=1e-7)
#define lowbit(a) ((a)&(-(a)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abb(a) ((a)>0?(a):(-(a)))
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))
char a[111],b[111],c[111],d[111];
int main(int argc, char *argv[])
{
int m,t,x=1,y;
scanf("%d%d",&y,&m);
while (m--)
{
scanf("%s%s%s%s%d",a+1,b+1,c+1,d+1,&t);
if (c[1]=='l')
y=min(y,t-1);
else
x=max(x,t+1);
}
printf("%d\n",(y>=x)?y-x+1:-1);
return 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff