| 906 | } |
| 907 | |
| 908 | static std::string getStringString(const char* src) { |
| 909 | if (src == NULL) { |
| 910 | return "NULL"; |
| 911 | } |
| 912 | |
| 913 | std::string str(src); |
| 914 | |
| 915 | if (str.length() > 6000) { |
| 916 | str = str.substr(0, 6000).append("..."); |
| 917 | } |
| 918 | |
| 919 | size_t found = 0; |
| 920 | while (true) { |
| 921 | found = str.find_first_of("\n\r\t\"", found); |
| 922 | if (found == std::string::npos) { |
| 923 | break; |
| 924 | } |
| 925 | char subst[] = {'\\', '\0', '\0'}; |
| 926 | switch (str[found]) { |
| 927 | case '\n': |
| 928 | subst[1] = 'n'; |
| 929 | break; |
| 930 | case '\r': |
| 931 | subst[1] = 'r'; |
| 932 | break; |
| 933 | case '\t': |
| 934 | subst[1] = 't'; |
| 935 | break; |
| 936 | case '\"': |
| 937 | subst[1] = '\"'; |
| 938 | break; |
| 939 | default: |
| 940 | ++found; |
| 941 | continue; |
| 942 | } |
| 943 | str.replace(found, 1, subst); |
| 944 | found += 2; |
| 945 | } |
| 946 | |
| 947 | str.insert(size_t(0), size_t(1), '\"').append(1, '\"'); |
| 948 | return str; |
| 949 | } |
| 950 | |
| 951 | static std::string getProgramSourceString(const char** strings, const size_t* lengths, |
| 952 | cl_uint count) { |
no test coverage detected