{"action":"created","comment":{"url":"https://api.github.com/repos/google/shaderc/pulls/comments/50709226","id":50709226,"diff_hunk":"@@ -176,24 +185,43 @@ int main(int argc, char** argv) {\n         std::cerr << \"glslc: error: argument to '-D' is missing\" << std::endl;\n       } else {\n         const string_piece argument = arg.substr(2);\n-        size_t name_length = argument.find_first_of('=');\n-        const string_piece name = argument.substr(0, name_length);\n-        if (name.starts_with(\"GL_\")) {\n+        // Get the exact length of the macro string.\n+        size_t equal_sign_loc = argument.find_first_of('=');\n+        size_t name_length = equal_sign_loc != shaderc_util::string_piece::npos\n+                                 ? equal_sign_loc\n+                                 : arg.size() - strlen(\"-D\");\n+        const string_piece name_piece = argument.substr(0, name_length);\n+        size_t argument_length = argument.size() - (argument.back() == '=' ? 1 : 0);\n+        if (name_piece.starts_with(\"GL_\")) {\n           std::cerr\n               << \"glslc: error: names beginning with 'GL_' cannot be defined: \"\n               << arg << std::endl;\n           return 1;\n         }\n-        if (name.find(\"__\") != string_piece::npos) {\n+        if (name_piece.find(\"__\") != string_piece::npos) {\n           std::cerr\n               << \"glslc: warning: names containing consecutive underscores \"\n                  \"are reserved: \"\n               << arg << std::endl;\n         }\n+\n+        // We have to insert a null terminator at the end of name, as we are\n+        // using libshaderc's API instead of libshaderc_util's. Libshaderc API\n+        // assumes a const char* string, while libshaderc_util assume a\n+        // string_piece one. The original implementation doesn't append '\\0' but\n+        // works fine with libshaderc_util because it has 'end_' property. But\n+        // libshaderc api doesn't know that so the macro 'name' will include the\n+        // 'value' if we don't insert '\\0'.\n+\n+        macro_names.emplace_back(std::string(name_piece.data(), name_length));","path":"glslc/src/main.cc","position":92,"original_position":92,"commit_id":"64aa624046ab914960d896d119e6f20f1f06e42e","original_commit_id":"64aa624046ab914960d896d119e6f20f1f06e42e","user":{"login":"dekimir","id":1635074,"avatar_url":"https://avatars.githubusercontent.com/u/1635074?v=3","gravatar_id":"","url":"https://api.github.com/users/dekimir","html_url":"https://github.com/dekimir","followers_url":"https://api.github.com/users/dekimir/followers","following_url":"https://api.github.com/users/dekimir/following{/other_user}","gists_url":"https://api.github.com/users/dekimir/gists{/gist_id}","starred_url":"https://api.github.com/users/dekimir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekimir/subscriptions","organizations_url":"https://api.github.com/users/dekimir/orgs","repos_url":"https://api.github.com/users/dekimir/repos","events_url":"https://api.github.com/users/dekimir/events{/privacy}","received_events_url":"https://api.github.com/users/dekimir/received_events","type":"User","site_admin":false},"body":"Delete `std::string`.","created_at":"2016-01-25T15:39:25Z","updated_at":"2016-01-25T15:39:25Z","html_url":"https://github.com/google/shaderc/pull/100#discussion_r50709226","pull_request_url":"https://api.github.com/repos/google/shaderc/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/google/shaderc/pulls/comments/50709226"},"html":{"href":"https://github.com/google/shaderc/pull/100#discussion_r50709226"},"pull_request":{"href":"https://api.github.com/repos/google/shaderc/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/google/shaderc/pulls/100","id":56937919,"html_url":"https://github.com/google/shaderc/pull/100","diff_url":"https://github.com/google/shaderc/pull/100.diff","patch_url":"https://github.com/google/shaderc/pull/100.patch","issue_url":"https://api.github.com/repos/google/shaderc/issues/100","number":100,"state":"open","locked":false,"title":"Port glslc to use libshaderc' compilation interface","user":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"body":"1. Replace shader_stage.cc/.h with shader_kind.cc/.h, also replaced the tests for it\r\n2. FileCompiler now inherits from shaderc::Compiler. It delegates an shaderc::CompilerOptions object to set modes, etc. \r\n3. Add disassembly_ and preprocessing_only_ flags to FileCompiler, as libshaderc is not supposed to maintain states.\r\n4. Add a vector of string in main() to hold the macro definitions.\r\n5. Updated the CMakeList.txt, glslc now depends on shaderc.\r\n6. Modified FileIncluder uses libshaderc_util::FileFinder. But it only keeps the latest response, data needs to be copied to underlying glslang.\r\n7. FileCompiler now is using std::cerr as the error stream.","created_at":"2016-01-22T20:32:19Z","updated_at":"2016-01-25T15:39:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50454fc95a266bb7fd31c3e7dd5d3bc6a0ca8ff2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/shaderc/pulls/100/commits","review_comments_url":"https://api.github.com/repos/google/shaderc/pulls/100/comments","review_comment_url":"https://api.github.com/repos/google/shaderc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/shaderc/issues/100/comments","statuses_url":"https://api.github.com/repos/google/shaderc/statuses/64aa624046ab914960d896d119e6f20f1f06e42e","head":{"label":"Qining:port_glslc_to_libshaderc","ref":"port_glslc_to_libshaderc","sha":"64aa624046ab914960d896d119e6f20f1f06e42e","user":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"repo":{"id":48245210,"name":"shaderc","full_name":"Qining/shaderc","owner":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Qining/shaderc","description":"A collection of tools, libraries and tests for shader compilation.","fork":true,"url":"https://api.github.com/repos/Qining/shaderc","forks_url":"https://api.github.com/repos/Qining/shaderc/forks","keys_url":"https://api.github.com/repos/Qining/shaderc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Qining/shaderc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Qining/shaderc/teams","hooks_url":"https://api.github.com/repos/Qining/shaderc/hooks","issue_events_url":"https://api.github.com/repos/Qining/shaderc/issues/events{/number}","events_url":"https://api.github.com/repos/Qining/shaderc/events","assignees_url":"https://api.github.com/repos/Qining/shaderc/assignees{/user}","branches_url":"https://api.github.com/repos/Qining/shaderc/branches{/branch}","tags_url":"https://api.github.com/repos/Qining/shaderc/tags","blobs_url":"https://api.github.com/repos/Qining/shaderc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Qining/shaderc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Qining/shaderc/git/refs{/sha}","trees_url":"https://api.github.com/repos/Qining/shaderc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Qining/shaderc/statuses/{sha}","languages_url":"https://api.github.com/repos/Qining/shaderc/languages","stargazers_url":"https://api.github.com/repos/Qining/shaderc/stargazers","contributors_url":"https://api.github.com/repos/Qining/shaderc/contributors","subscribers_url":"https://api.github.com/repos/Qining/shaderc/subscribers","subscription_url":"https://api.github.com/repos/Qining/shaderc/subscription","commits_url":"https://api.github.com/repos/Qining/shaderc/commits{/sha}","git_commits_url":"https://api.github.com/repos/Qining/shaderc/git/commits{/sha}","comments_url":"https://api.github.com/repos/Qining/shaderc/comments{/number}","issue_comment_url":"https://api.github.com/repos/Qining/shaderc/issues/comments{/number}","contents_url":"https://api.github.com/repos/Qining/shaderc/contents/{+path}","compare_url":"https://api.github.com/repos/Qining/shaderc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Qining/shaderc/merges","archive_url":"https://api.github.com/repos/Qining/shaderc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Qining/shaderc/downloads","issues_url":"https://api.github.com/repos/Qining/shaderc/issues{/number}","pulls_url":"https://api.github.com/repos/Qining/shaderc/pulls{/number}","milestones_url":"https://api.github.com/repos/Qining/shaderc/milestones{/number}","notifications_url":"https://api.github.com/repos/Qining/shaderc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Qining/shaderc/labels{/name}","releases_url":"https://api.github.com/repos/Qining/shaderc/releases{/id}","deployments_url":"https://api.github.com/repos/Qining/shaderc/deployments","created_at":"2015-12-18T16:31:32Z","updated_at":"2015-12-18T16:31:32Z","pushed_at":"2016-01-23T07:14:49Z","git_url":"git://github.com/Qining/shaderc.git","ssh_url":"git@github.com:Qining/shaderc.git","clone_url":"https://github.com/Qining/shaderc.git","svn_url":"https://github.com/Qining/shaderc","homepage":"","size":473,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"ec10670bed39f870ce6dc41960423622adc25304","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":40277133,"name":"shaderc","full_name":"google/shaderc","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/shaderc","description":"A collection of tools, libraries and tests for shader compilation.","fork":false,"url":"https://api.github.com/repos/google/shaderc","forks_url":"https://api.github.com/repos/google/shaderc/forks","keys_url":"https://api.github.com/repos/google/shaderc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/shaderc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/shaderc/teams","hooks_url":"https://api.github.com/repos/google/shaderc/hooks","issue_events_url":"https://api.github.com/repos/google/shaderc/issues/events{/number}","events_url":"https://api.github.com/repos/google/shaderc/events","assignees_url":"https://api.github.com/repos/google/shaderc/assignees{/user}","branches_url":"https://api.github.com/repos/google/shaderc/branches{/branch}","tags_url":"https://api.github.com/repos/google/shaderc/tags","blobs_url":"https://api.github.com/repos/google/shaderc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/shaderc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/shaderc/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/shaderc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/shaderc/statuses/{sha}","languages_url":"https://api.github.com/repos/google/shaderc/languages","stargazers_url":"https://api.github.com/repos/google/shaderc/stargazers","contributors_url":"https://api.github.com/repos/google/shaderc/contributors","subscribers_url":"https://api.github.com/repos/google/shaderc/subscribers","subscription_url":"https://api.github.com/repos/google/shaderc/subscription","commits_url":"https://api.github.com/repos/google/shaderc/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/shaderc/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/shaderc/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/shaderc/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/shaderc/contents/{+path}","compare_url":"https://api.github.com/repos/google/shaderc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/shaderc/merges","archive_url":"https://api.github.com/repos/google/shaderc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/shaderc/downloads","issues_url":"https://api.github.com/repos/google/shaderc/issues{/number}","pulls_url":"https://api.github.com/repos/google/shaderc/pulls{/number}","milestones_url":"https://api.github.com/repos/google/shaderc/milestones{/number}","notifications_url":"https://api.github.com/repos/google/shaderc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/shaderc/labels{/name}","releases_url":"https://api.github.com/repos/google/shaderc/releases{/id}","deployments_url":"https://api.github.com/repos/google/shaderc/deployments","created_at":"2015-08-06T01:17:42Z","updated_at":"2016-01-23T08:33:16Z","pushed_at":"2016-01-23T07:14:50Z","git_url":"git://github.com/google/shaderc.git","ssh_url":"git@github.com:google/shaderc.git","clone_url":"https://github.com/google/shaderc.git","svn_url":"https://github.com/google/shaderc","homepage":"","size":526,"stargazers_count":142,"watchers_count":142,"language":"C++","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":6,"forks":15,"open_issues":6,"watchers":142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/shaderc/pulls/100"},"html":{"href":"https://github.com/google/shaderc/pull/100"},"issue":{"href":"https://api.github.com/repos/google/shaderc/issues/100"},"comments":{"href":"https://api.github.com/repos/google/shaderc/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/google/shaderc/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/google/shaderc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/shaderc/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/google/shaderc/statuses/64aa624046ab914960d896d119e6f20f1f06e42e"}}}}