| 27 | |
| 28 | |
| 29 | def get_includes(code): |
| 30 | includes = (('alloca','alloca.h'), |
| 31 | ('NULL','cstddef'), |
| 32 | ('size_t','cstddef'), |
| 33 | ('free','cstdlib'), |
| 34 | ('malloc','cstdlib'), |
| 35 | ('realloc','cstdlib'), |
| 36 | ('memcpy','cstring'), |
| 37 | ('stdin','cstdio'), |
| 38 | ('strcat','cstring'), |
| 39 | ('strchr','cstring'), |
| 40 | ('strcpy','cstring'), |
| 41 | ('strlen','cstring'), |
| 42 | ('strncat','cstring'), |
| 43 | ('strncpy','cstring'), |
| 44 | ('std::cout','iostream'), |
| 45 | ('std::pair','utility'), |
| 46 | ('std::shared_ptr','memory'), |
| 47 | ('std::string','string'), |
| 48 | ('std::unique_ptr','memory'), |
| 49 | ('std::vector','vector')) |
| 50 | |
| 51 | ret = '' |
| 52 | |
| 53 | for i in includes: |
| 54 | if i[0] in code: |
| 55 | include_header = '#include <%s>' % i[1] |
| 56 | if include_header not in ret: |
| 57 | ret += include_header + '\n' |
| 58 | |
| 59 | return ret |
| 60 | |
| 61 | |
| 62 | def tweak_expected(expected, start_code): |