{"action":"created","comment":{"url":"https://api.github.com/repos/adah1972/libunibreak/pulls/comments/88922763","pull_request_review_id":9479110,"id":88922763,"diff_hunk":"@@ -0,0 +1,219 @@\n+/*\n+ * Grapheme breaking in a Unicode sequence.  Designed to be used in a\n+ * generic text renderer.\n+ *\n+ * Copyright (C) 2016 Andreas Röver <roever at users dot sf dot net>\n+ *\n+ * This software is provided 'as-is', without any express or implied\n+ * warranty.  In no event will the author be held liable for any damages\n+ * arising from the use of this software.\n+ *\n+ * Permission is granted to anyone to use this software for any purpose,\n+ * including commercial applications, and to alter it and redistribute\n+ * it freely, subject to the following restrictions:\n+ *\n+ * 1. The origin of this software must not be misrepresented; you must\n+ *    not claim that you wrote the original software.  If you use this\n+ *    software in a product, an acknowledgement in the product\n+ *    documentation would be appreciated but is not required.\n+ * 2. Altered source versions must be plainly marked as such, and must\n+ *    not be misrepresented as being the original software.\n+ * 3. This notice may not be removed or altered from any source\n+ *    distribution.\n+ *\n+ * The main reference is Unicode Standard Annex 29 (UAX #29):\n+ *      <URL:http://unicode.org/reports/tr29>\n+ *\n+ * When this library was designed, this annex was at Revision 29, for\n+ * Unicode 9.0.0:\n+ *\n+ * The Unicode Terms of Use are available at\n+ *      <URL:http://www.unicode.org/copyright.html>\n+ */\n+\n+/**\n+ * @file    graphemebreak.c\n+ *\n+ * Implementation of the grapheme breaking algorithm as described in Unicode\n+ * Standard Annex 29.\n+ *\n+ * @version 1.0, 2016\n+ * @author  Andreas Roever\n+ */\n+\n+#include \"unibreakdef.h\"\n+#include \"graphemebreak.h\"\n+#include \"graphemebreakdata.c\"\n+#include \"stdbool.h\"\n+\n+#define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0]))\n+\n+/**\n+ * Initializes the wordbreak internals.  It currently does nothing, but\n+ * it may in the future.\n+ */\n+void init_graphemebreak(void)\n+{\n+}\n+\n+/**\n+ * Gets the grapheme breaking class of a character.\n+ *\n+ * @param ch   character to check\n+ * @return     the grapheme breaking class if found; \\c GBP_Other otherwise\n+ */\n+static enum GraphemeBreakClass get_char_gb_class(utf32_t ch)\n+{\n+    int min = 0;\n+    int max = ARRAY_LEN(gb_prop_default) - 1;\n+    int mid;\n+\n+    do\n+    {\n+        mid = (min + max) / 2;\n+\n+        if (ch < gb_prop_default[mid].start)\n+            max = mid - 1;\n+        else if (ch > gb_prop_default[mid].end)\n+            min = mid + 1;\n+        else\n+            return gb_prop_default[mid].prop;\n+    }\n+    while (min <= max);\n+\n+    return GBP_Other;\n+}\n+\n+/**\n+ * Sets the grapheme breaking information for a generic input string.\n+ *\n+ * @param[in]  s             input string\n+ * @param[in]  len           length of the input\n+ * @param[out] brks          pointer to the output breaking data, containing\n+ *                           #GRAPHEMEBREAK_BREAK or #GRAPHEMEBREAK_NOBREAK\n+ * @param[in] get_next_char  function to get the next UTF-32 character\n+ */\n+static void set_graphemebreaks(\n+        const void *s,\n+        size_t len,\n+        char *brks,\n+        get_next_char_t get_next_char)\n+{\n+    size_t posNext = 0;\n+    bool rule10Left = false; // is the left side of rule 10 fulfilled?\n+    bool EvenRegionalIndicators = true; // is the number of preceeding GBP_RegionalIndicator characters even\n+\n+    utf32_t ch = get_next_char(s, len, &posNext);\n+    enum GraphemeBreakClass a = get_char_gb_class(ch);\n+\n+    ch = get_next_char(s, len, &posNext);\n+    while (ch != EOS)\n+    {\n+        enum GraphemeBreakClass b = get_char_gb_class(ch);\n+\n+        if (a == GBP_E_Base || a == GBP_E_Base_GAZ)\n+          rule10Left = true;\n+        else if (a != GBP_Extend)\n+          rule10Left = false;\n+\n+        if (a == GBP_Regional_Indicator)\n+          EvenRegionalIndicators = !EvenRegionalIndicators;\n+        else\n+          EvenRegionalIndicators = true;\n+\n+        if (a == GBP_CR && b == GBP_LF)\n+            *brks = GRAPHEMEBREAK_NOBREAK;            // Rule: GB3","path":"src/graphemebreak.c","position":125,"original_position":125,"commit_id":"68f953ea542e5960f4251bb4ea59cc31f2c2b961","original_commit_id":"68f953ea542e5960f4251bb4ea59cc31f2c2b961","user":{"login":"roever","id":4319511,"avatar_url":"https://avatars.githubusercontent.com/u/4319511?v=3","gravatar_id":"","url":"https://api.github.com/users/roever","html_url":"https://github.com/roever","followers_url":"https://api.github.com/users/roever/followers","following_url":"https://api.github.com/users/roever/following{/other_user}","gists_url":"https://api.github.com/users/roever/gists{/gist_id}","starred_url":"https://api.github.com/users/roever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roever/subscriptions","organizations_url":"https://api.github.com/users/roever/orgs","repos_url":"https://api.github.com/users/roever/repos","events_url":"https://api.github.com/users/roever/events{/privacy}","received_events_url":"https://api.github.com/users/roever/received_events","type":"User","site_admin":false},"body":"my output would use one output per unicode character, so no \"inside\" is needed... but you are right, as your output uses one value per \"string-element\"... this would be an inconsistent output.","created_at":"2016-11-21T15:49:54Z","updated_at":"2016-11-21T15:49:54Z","html_url":"https://github.com/adah1972/libunibreak/pull/18#discussion_r88922763","pull_request_url":"https://api.github.com/repos/adah1972/libunibreak/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/comments/88922763"},"html":{"href":"https://github.com/adah1972/libunibreak/pull/18#discussion_r88922763"},"pull_request":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/adah1972/libunibreak/pulls/18","id":94489737,"html_url":"https://github.com/adah1972/libunibreak/pull/18","diff_url":"https://github.com/adah1972/libunibreak/pull/18.diff","patch_url":"https://github.com/adah1972/libunibreak/pull/18.patch","issue_url":"https://api.github.com/repos/adah1972/libunibreak/issues/18","number":18,"state":"open","locked":false,"title":"grapheme-break algorithm","user":{"login":"roever","id":4319511,"avatar_url":"https://avatars.githubusercontent.com/u/4319511?v=3","gravatar_id":"","url":"https://api.github.com/users/roever","html_url":"https://github.com/roever","followers_url":"https://api.github.com/users/roever/followers","following_url":"https://api.github.com/users/roever/following{/other_user}","gists_url":"https://api.github.com/users/roever/gists{/gist_id}","starred_url":"https://api.github.com/users/roever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roever/subscriptions","organizations_url":"https://api.github.com/users/roever/orgs","repos_url":"https://api.github.com/users/roever/repos","events_url":"https://api.github.com/users/roever/events{/privacy}","received_events_url":"https://api.github.com/users/roever/received_events","type":"User","site_admin":false},"body":"Here is a first try at implementing the grapheme break algorithm... open for criticism....","created_at":"2016-11-19T18:03:28Z","updated_at":"2016-11-21T15:49:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c4744411810aec196a03c73c6e6da5cef1e356a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/adah1972/libunibreak/pulls/18/commits","review_comments_url":"https://api.github.com/repos/adah1972/libunibreak/pulls/18/comments","review_comment_url":"https://api.github.com/repos/adah1972/libunibreak/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adah1972/libunibreak/issues/18/comments","statuses_url":"https://api.github.com/repos/adah1972/libunibreak/statuses/68f953ea542e5960f4251bb4ea59cc31f2c2b961","head":{"label":"roever:master","ref":"master","sha":"68f953ea542e5960f4251bb4ea59cc31f2c2b961","user":{"login":"roever","id":4319511,"avatar_url":"https://avatars.githubusercontent.com/u/4319511?v=3","gravatar_id":"","url":"https://api.github.com/users/roever","html_url":"https://github.com/roever","followers_url":"https://api.github.com/users/roever/followers","following_url":"https://api.github.com/users/roever/following{/other_user}","gists_url":"https://api.github.com/users/roever/gists{/gist_id}","starred_url":"https://api.github.com/users/roever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roever/subscriptions","organizations_url":"https://api.github.com/users/roever/orgs","repos_url":"https://api.github.com/users/roever/repos","events_url":"https://api.github.com/users/roever/events{/privacy}","received_events_url":"https://api.github.com/users/roever/received_events","type":"User","site_admin":false},"repo":{"id":74225451,"name":"libunibreak","full_name":"roever/libunibreak","owner":{"login":"roever","id":4319511,"avatar_url":"https://avatars.githubusercontent.com/u/4319511?v=3","gravatar_id":"","url":"https://api.github.com/users/roever","html_url":"https://github.com/roever","followers_url":"https://api.github.com/users/roever/followers","following_url":"https://api.github.com/users/roever/following{/other_user}","gists_url":"https://api.github.com/users/roever/gists{/gist_id}","starred_url":"https://api.github.com/users/roever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roever/subscriptions","organizations_url":"https://api.github.com/users/roever/orgs","repos_url":"https://api.github.com/users/roever/repos","events_url":"https://api.github.com/users/roever/events{/privacy}","received_events_url":"https://api.github.com/users/roever/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/roever/libunibreak","description":"The libunibreak library","fork":true,"url":"https://api.github.com/repos/roever/libunibreak","forks_url":"https://api.github.com/repos/roever/libunibreak/forks","keys_url":"https://api.github.com/repos/roever/libunibreak/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roever/libunibreak/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roever/libunibreak/teams","hooks_url":"https://api.github.com/repos/roever/libunibreak/hooks","issue_events_url":"https://api.github.com/repos/roever/libunibreak/issues/events{/number}","events_url":"https://api.github.com/repos/roever/libunibreak/events","assignees_url":"https://api.github.com/repos/roever/libunibreak/assignees{/user}","branches_url":"https://api.github.com/repos/roever/libunibreak/branches{/branch}","tags_url":"https://api.github.com/repos/roever/libunibreak/tags","blobs_url":"https://api.github.com/repos/roever/libunibreak/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roever/libunibreak/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roever/libunibreak/git/refs{/sha}","trees_url":"https://api.github.com/repos/roever/libunibreak/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roever/libunibreak/statuses/{sha}","languages_url":"https://api.github.com/repos/roever/libunibreak/languages","stargazers_url":"https://api.github.com/repos/roever/libunibreak/stargazers","contributors_url":"https://api.github.com/repos/roever/libunibreak/contributors","subscribers_url":"https://api.github.com/repos/roever/libunibreak/subscribers","subscription_url":"https://api.github.com/repos/roever/libunibreak/subscription","commits_url":"https://api.github.com/repos/roever/libunibreak/commits{/sha}","git_commits_url":"https://api.github.com/repos/roever/libunibreak/git/commits{/sha}","comments_url":"https://api.github.com/repos/roever/libunibreak/comments{/number}","issue_comment_url":"https://api.github.com/repos/roever/libunibreak/issues/comments{/number}","contents_url":"https://api.github.com/repos/roever/libunibreak/contents/{+path}","compare_url":"https://api.github.com/repos/roever/libunibreak/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roever/libunibreak/merges","archive_url":"https://api.github.com/repos/roever/libunibreak/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roever/libunibreak/downloads","issues_url":"https://api.github.com/repos/roever/libunibreak/issues{/number}","pulls_url":"https://api.github.com/repos/roever/libunibreak/pulls{/number}","milestones_url":"https://api.github.com/repos/roever/libunibreak/milestones{/number}","notifications_url":"https://api.github.com/repos/roever/libunibreak/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roever/libunibreak/labels{/name}","releases_url":"https://api.github.com/repos/roever/libunibreak/releases{/id}","deployments_url":"https://api.github.com/repos/roever/libunibreak/deployments","created_at":"2016-11-19T17:57:37Z","updated_at":"2016-11-19T17:57:38Z","pushed_at":"2016-11-19T18:00:55Z","git_url":"git://github.com/roever/libunibreak.git","ssh_url":"git@github.com:roever/libunibreak.git","clone_url":"https://github.com/roever/libunibreak.git","svn_url":"https://github.com/roever/libunibreak","homepage":null,"size":356,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"adah1972:master","ref":"master","sha":"d5b4b98dc000f690691594e517aef29412addf9a","user":{"login":"adah1972","id":2137834,"avatar_url":"https://avatars.githubusercontent.com/u/2137834?v=3","gravatar_id":"","url":"https://api.github.com/users/adah1972","html_url":"https://github.com/adah1972","followers_url":"https://api.github.com/users/adah1972/followers","following_url":"https://api.github.com/users/adah1972/following{/other_user}","gists_url":"https://api.github.com/users/adah1972/gists{/gist_id}","starred_url":"https://api.github.com/users/adah1972/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adah1972/subscriptions","organizations_url":"https://api.github.com/users/adah1972/orgs","repos_url":"https://api.github.com/users/adah1972/repos","events_url":"https://api.github.com/users/adah1972/events{/privacy}","received_events_url":"https://api.github.com/users/adah1972/received_events","type":"User","site_admin":false},"repo":{"id":5385649,"name":"libunibreak","full_name":"adah1972/libunibreak","owner":{"login":"adah1972","id":2137834,"avatar_url":"https://avatars.githubusercontent.com/u/2137834?v=3","gravatar_id":"","url":"https://api.github.com/users/adah1972","html_url":"https://github.com/adah1972","followers_url":"https://api.github.com/users/adah1972/followers","following_url":"https://api.github.com/users/adah1972/following{/other_user}","gists_url":"https://api.github.com/users/adah1972/gists{/gist_id}","starred_url":"https://api.github.com/users/adah1972/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adah1972/subscriptions","organizations_url":"https://api.github.com/users/adah1972/orgs","repos_url":"https://api.github.com/users/adah1972/repos","events_url":"https://api.github.com/users/adah1972/events{/privacy}","received_events_url":"https://api.github.com/users/adah1972/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adah1972/libunibreak","description":"The libunibreak library","fork":false,"url":"https://api.github.com/repos/adah1972/libunibreak","forks_url":"https://api.github.com/repos/adah1972/libunibreak/forks","keys_url":"https://api.github.com/repos/adah1972/libunibreak/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adah1972/libunibreak/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adah1972/libunibreak/teams","hooks_url":"https://api.github.com/repos/adah1972/libunibreak/hooks","issue_events_url":"https://api.github.com/repos/adah1972/libunibreak/issues/events{/number}","events_url":"https://api.github.com/repos/adah1972/libunibreak/events","assignees_url":"https://api.github.com/repos/adah1972/libunibreak/assignees{/user}","branches_url":"https://api.github.com/repos/adah1972/libunibreak/branches{/branch}","tags_url":"https://api.github.com/repos/adah1972/libunibreak/tags","blobs_url":"https://api.github.com/repos/adah1972/libunibreak/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adah1972/libunibreak/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adah1972/libunibreak/git/refs{/sha}","trees_url":"https://api.github.com/repos/adah1972/libunibreak/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adah1972/libunibreak/statuses/{sha}","languages_url":"https://api.github.com/repos/adah1972/libunibreak/languages","stargazers_url":"https://api.github.com/repos/adah1972/libunibreak/stargazers","contributors_url":"https://api.github.com/repos/adah1972/libunibreak/contributors","subscribers_url":"https://api.github.com/repos/adah1972/libunibreak/subscribers","subscription_url":"https://api.github.com/repos/adah1972/libunibreak/subscription","commits_url":"https://api.github.com/repos/adah1972/libunibreak/commits{/sha}","git_commits_url":"https://api.github.com/repos/adah1972/libunibreak/git/commits{/sha}","comments_url":"https://api.github.com/repos/adah1972/libunibreak/comments{/number}","issue_comment_url":"https://api.github.com/repos/adah1972/libunibreak/issues/comments{/number}","contents_url":"https://api.github.com/repos/adah1972/libunibreak/contents/{+path}","compare_url":"https://api.github.com/repos/adah1972/libunibreak/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adah1972/libunibreak/merges","archive_url":"https://api.github.com/repos/adah1972/libunibreak/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adah1972/libunibreak/downloads","issues_url":"https://api.github.com/repos/adah1972/libunibreak/issues{/number}","pulls_url":"https://api.github.com/repos/adah1972/libunibreak/pulls{/number}","milestones_url":"https://api.github.com/repos/adah1972/libunibreak/milestones{/number}","notifications_url":"https://api.github.com/repos/adah1972/libunibreak/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adah1972/libunibreak/labels{/name}","releases_url":"https://api.github.com/repos/adah1972/libunibreak/releases{/id}","deployments_url":"https://api.github.com/repos/adah1972/libunibreak/deployments","created_at":"2012-08-12T03:40:50Z","updated_at":"2016-10-26T10:49:19Z","pushed_at":"2016-11-19T18:03:28Z","git_url":"git://github.com/adah1972/libunibreak.git","ssh_url":"git@github.com:adah1972/libunibreak.git","clone_url":"https://github.com/adah1972/libunibreak.git","svn_url":"https://github.com/adah1972/libunibreak","homepage":null,"size":433,"stargazers_count":37,"watchers_count":37,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":4,"forks":9,"open_issues":4,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/18"},"html":{"href":"https://github.com/adah1972/libunibreak/pull/18"},"issue":{"href":"https://api.github.com/repos/adah1972/libunibreak/issues/18"},"comments":{"href":"https://api.github.com/repos/adah1972/libunibreak/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adah1972/libunibreak/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/adah1972/libunibreak/statuses/68f953ea542e5960f4251bb4ea59cc31f2c2b961"}}}}
{"actor":{"display_login":"roever"}}