{"action":"created","comment":{"url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments/46691409","id":46691409,"diff_hunk":"@@ -86,58 +92,210 @@ static Key *createUnescapedKey(Key *key, const char *name)\n \telektraFree (localString);\n \treturn key;\n }\n-static int iniKeyToElektraKey (void *vhandle, const char *section, const char *name, const char *value, unsigned short toMeta, unsigned short lineContinuation)\n+static void setSectionNumber(Key *parentKey, Key *key, KeySet *ks)\n {\n-\tstatic long lastIndex = 0;\n-\tCallbackHandle *handle = (CallbackHandle *)vhandle;\n-\tKey *appendKey = keyDup (handle->parentKey);\n-\tif (section)\n+\tif(!strcmp(keyBaseName(key), INTERNAL_ROOT_SECTION))\n+\t{\n+\t\tKey *tmpKey = keyDup(key);\n+\t\tkeySetMeta(tmpKey, \"ini/section\", \"0\");\n+\t\tkeySetMeta(key, \"ini/section\", \"0\");\n+\t\tkeySetString(tmpKey, 0);\n+\t\tksAppendKey(ks, tmpKey);\n+\t\tkeyDel(tmpKey);\n+\t\treturn;\n+\t}\n+\n+\tKey *lookupKey = keyDup(key);\n+\tKey *lastKey = keyDup(lookupKey);\n+\n+\twhile(1)\n \t{\n-\t\tif (*section != '\\0')\n+\t\tif(!strcmp(keyName(lookupKey), keyName(parentKey)))\n+\t\t{\n+\t\t\tif(keyGetMeta(parentKey, \"ini/lastSection\"))\n+\t\t\t{\n+\t\t\t\tlong previousSection = atol(keyString(keyGetMeta(parentKey, \"ini/lastSection\")));\n+\t\t\t\t++previousSection;\n+\t\t\t\tchar buffer[21]; //20 digits (long) + \\0\n+\t\t\t\tsnprintf(buffer, sizeof(buffer), \"%ld\", previousSection);\n+\t\t\t\tkeySetMeta(parentKey, \"ini/lastSection\", buffer);\n+\t\t\t\tkeySetMeta(key, \"ini/section\", buffer);\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\tkeySetMeta(parentKey, \"ini/lastSection\", \"1\");\n+\t\t\t\tkeySetMeta(parentKey, \"ini/section\", \"0\");\n+\t\t\t\tkeySetMeta(key, \"ini/section\", \"1\");\n+\t\t\t}\n+\t\t\tkeySetMeta(lastKey, \"ini/section\", keyString(keyGetMeta(key, \"ini/section\")));\n+\t\t\tksAppendKey(ks, lastKey);\n+\t\t\tbreak;\n+\t\t}\n+\t\tif(keyGetMeta(ksLookup(ks, lookupKey, KDB_O_NONE), \"ini/section\"))\n \t\t{\n-\t\t\tappendKey = createUnescapedKey(appendKey, section);\n+\t\t\tkeySetMeta(key, \"ini/section\", keyString(keyGetMeta(ksLookup(ks, lookupKey, KDB_O_NONE), \"ini/section\")));\n+\t\t\tbreak;\n \t\t}\n-\t\tKey *sectionKey = ksLookup(handle->result, appendKey, KDB_O_NONE);\n-\t\tif (sectionKey)\n+\t\tkeySetName(lastKey, keyName(lookupKey));\n+\t\tkeyAddName(lookupKey, \"..\");\n+\t}\n+\tkeyDel(lookupKey);\n+\tkeyDel(lastKey);\n+}\n+\n+static void setOrderNumber(Key *parentKey, Key *key)\n+{\n+\tint order = atol(keyString(keyGetMeta(parentKey, \"order\")));\n+\t++order;\n+\tchar buffer[10];\n+\tsnprintf(buffer, sizeof(buffer), \"%09d\", order);\n+\tkeySetMeta(key, \"order\", buffer);\n+\tkeySetMeta(parentKey, \"order\", buffer);\n+}\n+\n+static void insertNewKeyIntoExistendOrder(Key *key, KeySet *ks)\n+{\n+\tif(keyGetMeta(ksLookup(ks, key, KDB_O_NONE), \"order\"))\n+\t\treturn;\n+\tksRewind(ks);\t\n+\tKey *curKey;\n+\tKey *prevKey = NULL;\n+\twhile((curKey = ksNext(ks)) != NULL)\n+\t{\n+\t\tif(!strcmp(keyName(curKey), keyName(key)))\n \t\t{\n-\t\t\tif (!(keyGetMeta(sectionKey, \"order\")))\n+\t\t\tconst char *oldOrder = \"000000001\";","path":"src/plugins/ini/ini.c","position":120,"original_position":120,"commit_id":"dc572a116e5f99153d63e8092b60d3b4bfeaa36d","original_commit_id":"dc572a116e5f99153d63e8092b60d3b4bfeaa36d","user":{"login":"markus2330","id":7949075,"avatar_url":"https://avatars.githubusercontent.com/u/7949075?v=3","gravatar_id":"","url":"https://api.github.com/users/markus2330","html_url":"https://github.com/markus2330","followers_url":"https://api.github.com/users/markus2330/followers","following_url":"https://api.github.com/users/markus2330/following{/other_user}","gists_url":"https://api.github.com/users/markus2330/gists{/gist_id}","starred_url":"https://api.github.com/users/markus2330/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markus2330/subscriptions","organizations_url":"https://api.github.com/users/markus2330/orgs","repos_url":"https://api.github.com/users/markus2330/repos","events_url":"https://api.github.com/users/markus2330/events{/privacy}","received_events_url":"https://api.github.com/users/markus2330/received_events","type":"User","site_admin":false},"body":"use array syntax","created_at":"2015-12-04T15:14:55Z","updated_at":"2015-12-04T15:14:55Z","html_url":"https://github.com/ElektraInitiative/libelektra/pull/405#discussion_r46691409","pull_request_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405","_links":{"self":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments/46691409"},"html":{"href":"https://github.com/ElektraInitiative/libelektra/pull/405#discussion_r46691409"},"pull_request":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405"}}},"pull_request":{"url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405","id":51999914,"html_url":"https://github.com/ElektraInitiative/libelektra/pull/405","diff_url":"https://github.com/ElektraInitiative/libelektra/pull/405.diff","patch_url":"https://github.com/ElektraInitiative/libelektra/pull/405.patch","issue_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/405","number":405,"state":"open","locked":false,"title":"Enhanced ini 2","user":{"login":"tom-wa","id":13944659,"avatar_url":"https://avatars.githubusercontent.com/u/13944659?v=3","gravatar_id":"","url":"https://api.github.com/users/tom-wa","html_url":"https://github.com/tom-wa","followers_url":"https://api.github.com/users/tom-wa/followers","following_url":"https://api.github.com/users/tom-wa/following{/other_user}","gists_url":"https://api.github.com/users/tom-wa/gists{/gist_id}","starred_url":"https://api.github.com/users/tom-wa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tom-wa/subscriptions","organizations_url":"https://api.github.com/users/tom-wa/orgs","repos_url":"https://api.github.com/users/tom-wa/repos","events_url":"https://api.github.com/users/tom-wa/events{/privacy}","received_events_url":"https://api.github.com/users/tom-wa/received_events","type":"User","site_admin":false},"body":"TODO: \r\nwrite a README\r\nadhere coding guidline","created_at":"2015-11-27T14:27:10Z","updated_at":"2015-12-04T15:14:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea6e29e9c429d0099e0dceebe493a35aa3acbf38","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405/commits","review_comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405/comments","review_comment_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/405/comments","statuses_url":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/dc572a116e5f99153d63e8092b60d3b4bfeaa36d","head":{"label":"tom-wa:enhanced_ini_2","ref":"enhanced_ini_2","sha":"dc572a116e5f99153d63e8092b60d3b4bfeaa36d","user":{"login":"tom-wa","id":13944659,"avatar_url":"https://avatars.githubusercontent.com/u/13944659?v=3","gravatar_id":"","url":"https://api.github.com/users/tom-wa","html_url":"https://github.com/tom-wa","followers_url":"https://api.github.com/users/tom-wa/followers","following_url":"https://api.github.com/users/tom-wa/following{/other_user}","gists_url":"https://api.github.com/users/tom-wa/gists{/gist_id}","starred_url":"https://api.github.com/users/tom-wa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tom-wa/subscriptions","organizations_url":"https://api.github.com/users/tom-wa/orgs","repos_url":"https://api.github.com/users/tom-wa/repos","events_url":"https://api.github.com/users/tom-wa/events{/privacy}","received_events_url":"https://api.github.com/users/tom-wa/received_events","type":"User","site_admin":false},"repo":{"id":42685319,"name":"libelektra","full_name":"tom-wa/libelektra","owner":{"login":"tom-wa","id":13944659,"avatar_url":"https://avatars.githubusercontent.com/u/13944659?v=3","gravatar_id":"","url":"https://api.github.com/users/tom-wa","html_url":"https://github.com/tom-wa","followers_url":"https://api.github.com/users/tom-wa/followers","following_url":"https://api.github.com/users/tom-wa/following{/other_user}","gists_url":"https://api.github.com/users/tom-wa/gists{/gist_id}","starred_url":"https://api.github.com/users/tom-wa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tom-wa/subscriptions","organizations_url":"https://api.github.com/users/tom-wa/orgs","repos_url":"https://api.github.com/users/tom-wa/repos","events_url":"https://api.github.com/users/tom-wa/events{/privacy}","received_events_url":"https://api.github.com/users/tom-wa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tom-wa/libelektra","description":"Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database.","fork":true,"url":"https://api.github.com/repos/tom-wa/libelektra","forks_url":"https://api.github.com/repos/tom-wa/libelektra/forks","keys_url":"https://api.github.com/repos/tom-wa/libelektra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tom-wa/libelektra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tom-wa/libelektra/teams","hooks_url":"https://api.github.com/repos/tom-wa/libelektra/hooks","issue_events_url":"https://api.github.com/repos/tom-wa/libelektra/issues/events{/number}","events_url":"https://api.github.com/repos/tom-wa/libelektra/events","assignees_url":"https://api.github.com/repos/tom-wa/libelektra/assignees{/user}","branches_url":"https://api.github.com/repos/tom-wa/libelektra/branches{/branch}","tags_url":"https://api.github.com/repos/tom-wa/libelektra/tags","blobs_url":"https://api.github.com/repos/tom-wa/libelektra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tom-wa/libelektra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tom-wa/libelektra/git/refs{/sha}","trees_url":"https://api.github.com/repos/tom-wa/libelektra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tom-wa/libelektra/statuses/{sha}","languages_url":"https://api.github.com/repos/tom-wa/libelektra/languages","stargazers_url":"https://api.github.com/repos/tom-wa/libelektra/stargazers","contributors_url":"https://api.github.com/repos/tom-wa/libelektra/contributors","subscribers_url":"https://api.github.com/repos/tom-wa/libelektra/subscribers","subscription_url":"https://api.github.com/repos/tom-wa/libelektra/subscription","commits_url":"https://api.github.com/repos/tom-wa/libelektra/commits{/sha}","git_commits_url":"https://api.github.com/repos/tom-wa/libelektra/git/commits{/sha}","comments_url":"https://api.github.com/repos/tom-wa/libelektra/comments{/number}","issue_comment_url":"https://api.github.com/repos/tom-wa/libelektra/issues/comments{/number}","contents_url":"https://api.github.com/repos/tom-wa/libelektra/contents/{+path}","compare_url":"https://api.github.com/repos/tom-wa/libelektra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tom-wa/libelektra/merges","archive_url":"https://api.github.com/repos/tom-wa/libelektra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tom-wa/libelektra/downloads","issues_url":"https://api.github.com/repos/tom-wa/libelektra/issues{/number}","pulls_url":"https://api.github.com/repos/tom-wa/libelektra/pulls{/number}","milestones_url":"https://api.github.com/repos/tom-wa/libelektra/milestones{/number}","notifications_url":"https://api.github.com/repos/tom-wa/libelektra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tom-wa/libelektra/labels{/name}","releases_url":"https://api.github.com/repos/tom-wa/libelektra/releases{/id}","created_at":"2015-09-17T22:27:25Z","updated_at":"2015-10-26T05:20:40Z","pushed_at":"2015-11-29T20:29:45Z","git_url":"git://github.com/tom-wa/libelektra.git","ssh_url":"git@github.com:tom-wa/libelektra.git","clone_url":"https://github.com/tom-wa/libelektra.git","svn_url":"https://github.com/tom-wa/libelektra","homepage":"","size":29752,"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":"ElektraInitiative:master","ref":"master","sha":"f140a6825ad872f982043beb076a337a92bf2004","user":{"login":"ElektraInitiative","id":7949092,"avatar_url":"https://avatars.githubusercontent.com/u/7949092?v=3","gravatar_id":"","url":"https://api.github.com/users/ElektraInitiative","html_url":"https://github.com/ElektraInitiative","followers_url":"https://api.github.com/users/ElektraInitiative/followers","following_url":"https://api.github.com/users/ElektraInitiative/following{/other_user}","gists_url":"https://api.github.com/users/ElektraInitiative/gists{/gist_id}","starred_url":"https://api.github.com/users/ElektraInitiative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElektraInitiative/subscriptions","organizations_url":"https://api.github.com/users/ElektraInitiative/orgs","repos_url":"https://api.github.com/users/ElektraInitiative/repos","events_url":"https://api.github.com/users/ElektraInitiative/events{/privacy}","received_events_url":"https://api.github.com/users/ElektraInitiative/received_events","type":"Organization","site_admin":false},"repo":{"id":21063580,"name":"libelektra","full_name":"ElektraInitiative/libelektra","owner":{"login":"ElektraInitiative","id":7949092,"avatar_url":"https://avatars.githubusercontent.com/u/7949092?v=3","gravatar_id":"","url":"https://api.github.com/users/ElektraInitiative","html_url":"https://github.com/ElektraInitiative","followers_url":"https://api.github.com/users/ElektraInitiative/followers","following_url":"https://api.github.com/users/ElektraInitiative/following{/other_user}","gists_url":"https://api.github.com/users/ElektraInitiative/gists{/gist_id}","starred_url":"https://api.github.com/users/ElektraInitiative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElektraInitiative/subscriptions","organizations_url":"https://api.github.com/users/ElektraInitiative/orgs","repos_url":"https://api.github.com/users/ElektraInitiative/repos","events_url":"https://api.github.com/users/ElektraInitiative/events{/privacy}","received_events_url":"https://api.github.com/users/ElektraInitiative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ElektraInitiative/libelektra","description":"Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database.","fork":false,"url":"https://api.github.com/repos/ElektraInitiative/libelektra","forks_url":"https://api.github.com/repos/ElektraInitiative/libelektra/forks","keys_url":"https://api.github.com/repos/ElektraInitiative/libelektra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElektraInitiative/libelektra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElektraInitiative/libelektra/teams","hooks_url":"https://api.github.com/repos/ElektraInitiative/libelektra/hooks","issue_events_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/events{/number}","events_url":"https://api.github.com/repos/ElektraInitiative/libelektra/events","assignees_url":"https://api.github.com/repos/ElektraInitiative/libelektra/assignees{/user}","branches_url":"https://api.github.com/repos/ElektraInitiative/libelektra/branches{/branch}","tags_url":"https://api.github.com/repos/ElektraInitiative/libelektra/tags","blobs_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/{sha}","languages_url":"https://api.github.com/repos/ElektraInitiative/libelektra/languages","stargazers_url":"https://api.github.com/repos/ElektraInitiative/libelektra/stargazers","contributors_url":"https://api.github.com/repos/ElektraInitiative/libelektra/contributors","subscribers_url":"https://api.github.com/repos/ElektraInitiative/libelektra/subscribers","subscription_url":"https://api.github.com/repos/ElektraInitiative/libelektra/subscription","commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElektraInitiative/libelektra/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElektraInitiative/libelektra/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElektraInitiative/libelektra/contents/{+path}","compare_url":"https://api.github.com/repos/ElektraInitiative/libelektra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElektraInitiative/libelektra/merges","archive_url":"https://api.github.com/repos/ElektraInitiative/libelektra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElektraInitiative/libelektra/downloads","issues_url":"https://api.github.com/repos/ElektraInitiative/libelektra/issues{/number}","pulls_url":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls{/number}","milestones_url":"https://api.github.com/repos/ElektraInitiative/libelektra/milestones{/number}","notifications_url":"https://api.github.com/repos/ElektraInitiative/libelektra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElektraInitiative/libelektra/labels{/name}","releases_url":"https://api.github.com/repos/ElektraInitiative/libelektra/releases{/id}","created_at":"2014-06-21T08:01:04Z","updated_at":"2015-11-21T17:00:36Z","pushed_at":"2015-12-02T10:16:39Z","git_url":"git://github.com/ElektraInitiative/libelektra.git","ssh_url":"git@github.com:ElektraInitiative/libelektra.git","clone_url":"https://github.com/ElektraInitiative/libelektra.git","svn_url":"https://github.com/ElektraInitiative/libelektra","homepage":"","size":29942,"stargazers_count":21,"watchers_count":21,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":56,"forks":18,"open_issues":56,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405"},"html":{"href":"https://github.com/ElektraInitiative/libelektra/pull/405"},"issue":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/405"},"comments":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/issues/405/comments"},"review_comments":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405/comments"},"review_comment":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/pulls/405/commits"},"statuses":{"href":"https://api.github.com/repos/ElektraInitiative/libelektra/statuses/dc572a116e5f99153d63e8092b60d3b4bfeaa36d"}}}}