{"action":"closed","number":8,"pull_request":{"url":"https://api.github.com/repos/judah/terminfo/pulls/8","id":46906069,"html_url":"https://github.com/judah/terminfo/pull/8","diff_url":"https://github.com/judah/terminfo/pull/8.diff","patch_url":"https://github.com/judah/terminfo/pull/8.patch","issue_url":"https://api.github.com/repos/judah/terminfo/issues/8","number":8,"state":"closed","locked":false,"title":"Subject: Remove use of cur_term global struct","user":{"login":"mimi1vx","id":931039,"avatar_url":"https://avatars.githubusercontent.com/u/931039?v=3","gravatar_id":"","url":"https://api.github.com/users/mimi1vx","html_url":"https://github.com/mimi1vx","followers_url":"https://api.github.com/users/mimi1vx/followers","following_url":"https://api.github.com/users/mimi1vx/following{/other_user}","gists_url":"https://api.github.com/users/mimi1vx/gists{/gist_id}","starred_url":"https://api.github.com/users/mimi1vx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimi1vx/subscriptions","organizations_url":"https://api.github.com/users/mimi1vx/orgs","repos_url":"https://api.github.com/users/mimi1vx/repos","events_url":"https://api.github.com/users/mimi1vx/events{/privacy}","received_events_url":"https://api.github.com/users/mimi1vx/received_events","type":"User","site_admin":false},"body":"From: Scott Bahling sbahling@suse.com\r\nDate: 2015-10-04\r\n\r\nWith the move to ncurses6, it has been decided by the openSUSE\r\ndeveloper to build the library in threaded mode only. In threaded\r\nmode, the global variables are protected and not exported.\r\n\r\nghc-terminfo was accessing (reading and writing) the cur_term\r\nglobal so it doesn't work with the openSUSE threaded ncurses6\r\nlibrary. This is an attempt to remove the need to access cur_term\r\nand rely only on the low-level functions.\r\n\r\nFirst, cur_term was being set to a null pointer in order to force\r\nncurses setupterm() to return new struct instead of a copy of the\r\ncurrent when the terminal name is the same. Actually (and unfortunately)\r\nsetupterm() does not return the struct but rather set the global cur_term.\r\nReading the ncurses code, and the NEWS file, it appears that the\r\nbehavior of setupterm() had been changed quite some time ago, and no\r\nlonger returns a copy of the struct (internal 'reuse' option) (NEWS 20041127).\r\nThe code seems to confirm this, so setting cur_term to a null pointer\r\nshouldn't really be required - we remove poke cur_term!\r\n\r\nThat's great, but the we still have the problem that setupterm() doesn't\r\nreturn the terminal struct that is required later to setup the\r\ncleanup routine of the Terminal type (del_curterm cterm). The only\r\nfunction that appears to return the cur_term pointer is set_curterm()\r\nwhich has the side effect of overwriting the current pointer in the\r\nprocess :/  So, we call set_curterm() with a null pointer, retrieving\r\nthe former, cur_term pointer for our use in the cterm instance, and\r\nthen call set_curterm() again with the former pointer to set it\r\nback again.... whew! Having looked at the ncurses set_curterm() code\r\nit seems it handles a null pointer in the way we would need.\r\n\r\nLater in the withCurTerm function we use virtually the same trick\r\nto relieve the need to peek into the cur_term global. I'm not so\r\nsure if this is Haskell correct code though.\r\n\r\nSomeone with more Haskell programming knowledge than me should review\r\nthis patch. It still needs to be tested as well.","created_at":"2015-10-06T13:59:15Z","updated_at":"2015-12-13T22:15:33Z","closed_at":"2015-12-13T22:15:33Z","merged_at":null,"merge_commit_sha":"8dcd972a13b72382a049d816b0c1a40f8751ba6f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/judah/terminfo/pulls/8/commits","review_comments_url":"https://api.github.com/repos/judah/terminfo/pulls/8/comments","review_comment_url":"https://api.github.com/repos/judah/terminfo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/judah/terminfo/issues/8/comments","statuses_url":"https://api.github.com/repos/judah/terminfo/statuses/68674ed51d94bdee6ea3ea10c1494352c8143da2","head":{"label":"mimi1vx:master","ref":"master","sha":"68674ed51d94bdee6ea3ea10c1494352c8143da2","user":{"login":"mimi1vx","id":931039,"avatar_url":"https://avatars.githubusercontent.com/u/931039?v=3","gravatar_id":"","url":"https://api.github.com/users/mimi1vx","html_url":"https://github.com/mimi1vx","followers_url":"https://api.github.com/users/mimi1vx/followers","following_url":"https://api.github.com/users/mimi1vx/following{/other_user}","gists_url":"https://api.github.com/users/mimi1vx/gists{/gist_id}","starred_url":"https://api.github.com/users/mimi1vx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimi1vx/subscriptions","organizations_url":"https://api.github.com/users/mimi1vx/orgs","repos_url":"https://api.github.com/users/mimi1vx/repos","events_url":"https://api.github.com/users/mimi1vx/events{/privacy}","received_events_url":"https://api.github.com/users/mimi1vx/received_events","type":"User","site_admin":false},"repo":{"id":43628768,"name":"terminfo","full_name":"mimi1vx/terminfo","owner":{"login":"mimi1vx","id":931039,"avatar_url":"https://avatars.githubusercontent.com/u/931039?v=3","gravatar_id":"","url":"https://api.github.com/users/mimi1vx","html_url":"https://github.com/mimi1vx","followers_url":"https://api.github.com/users/mimi1vx/followers","following_url":"https://api.github.com/users/mimi1vx/following{/other_user}","gists_url":"https://api.github.com/users/mimi1vx/gists{/gist_id}","starred_url":"https://api.github.com/users/mimi1vx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimi1vx/subscriptions","organizations_url":"https://api.github.com/users/mimi1vx/orgs","repos_url":"https://api.github.com/users/mimi1vx/repos","events_url":"https://api.github.com/users/mimi1vx/events{/privacy}","received_events_url":"https://api.github.com/users/mimi1vx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mimi1vx/terminfo","description":"Haskell bindings to the terminfo API.","fork":true,"url":"https://api.github.com/repos/mimi1vx/terminfo","forks_url":"https://api.github.com/repos/mimi1vx/terminfo/forks","keys_url":"https://api.github.com/repos/mimi1vx/terminfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mimi1vx/terminfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mimi1vx/terminfo/teams","hooks_url":"https://api.github.com/repos/mimi1vx/terminfo/hooks","issue_events_url":"https://api.github.com/repos/mimi1vx/terminfo/issues/events{/number}","events_url":"https://api.github.com/repos/mimi1vx/terminfo/events","assignees_url":"https://api.github.com/repos/mimi1vx/terminfo/assignees{/user}","branches_url":"https://api.github.com/repos/mimi1vx/terminfo/branches{/branch}","tags_url":"https://api.github.com/repos/mimi1vx/terminfo/tags","blobs_url":"https://api.github.com/repos/mimi1vx/terminfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mimi1vx/terminfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mimi1vx/terminfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/mimi1vx/terminfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mimi1vx/terminfo/statuses/{sha}","languages_url":"https://api.github.com/repos/mimi1vx/terminfo/languages","stargazers_url":"https://api.github.com/repos/mimi1vx/terminfo/stargazers","contributors_url":"https://api.github.com/repos/mimi1vx/terminfo/contributors","subscribers_url":"https://api.github.com/repos/mimi1vx/terminfo/subscribers","subscription_url":"https://api.github.com/repos/mimi1vx/terminfo/subscription","commits_url":"https://api.github.com/repos/mimi1vx/terminfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/mimi1vx/terminfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/mimi1vx/terminfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/mimi1vx/terminfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/mimi1vx/terminfo/contents/{+path}","compare_url":"https://api.github.com/repos/mimi1vx/terminfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mimi1vx/terminfo/merges","archive_url":"https://api.github.com/repos/mimi1vx/terminfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mimi1vx/terminfo/downloads","issues_url":"https://api.github.com/repos/mimi1vx/terminfo/issues{/number}","pulls_url":"https://api.github.com/repos/mimi1vx/terminfo/pulls{/number}","milestones_url":"https://api.github.com/repos/mimi1vx/terminfo/milestones{/number}","notifications_url":"https://api.github.com/repos/mimi1vx/terminfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mimi1vx/terminfo/labels{/name}","releases_url":"https://api.github.com/repos/mimi1vx/terminfo/releases{/id}","created_at":"2015-10-04T07:37:54Z","updated_at":"2015-10-04T07:37:54Z","pushed_at":"2015-10-06T13:54:20Z","git_url":"git://github.com/mimi1vx/terminfo.git","ssh_url":"git@github.com:mimi1vx/terminfo.git","clone_url":"https://github.com/mimi1vx/terminfo.git","svn_url":"https://github.com/mimi1vx/terminfo","homepage":null,"size":153,"stargazers_count":0,"watchers_count":0,"language":"Haskell","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":"judah:master","ref":"master","sha":"1b5ab01452eaa6c21de7174ad4312a017a13d0ab","user":{"login":"judah","id":49143,"avatar_url":"https://avatars.githubusercontent.com/u/49143?v=3","gravatar_id":"","url":"https://api.github.com/users/judah","html_url":"https://github.com/judah","followers_url":"https://api.github.com/users/judah/followers","following_url":"https://api.github.com/users/judah/following{/other_user}","gists_url":"https://api.github.com/users/judah/gists{/gist_id}","starred_url":"https://api.github.com/users/judah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judah/subscriptions","organizations_url":"https://api.github.com/users/judah/orgs","repos_url":"https://api.github.com/users/judah/repos","events_url":"https://api.github.com/users/judah/events{/privacy}","received_events_url":"https://api.github.com/users/judah/received_events","type":"User","site_admin":false},"repo":{"id":14018195,"name":"terminfo","full_name":"judah/terminfo","owner":{"login":"judah","id":49143,"avatar_url":"https://avatars.githubusercontent.com/u/49143?v=3","gravatar_id":"","url":"https://api.github.com/users/judah","html_url":"https://github.com/judah","followers_url":"https://api.github.com/users/judah/followers","following_url":"https://api.github.com/users/judah/following{/other_user}","gists_url":"https://api.github.com/users/judah/gists{/gist_id}","starred_url":"https://api.github.com/users/judah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judah/subscriptions","organizations_url":"https://api.github.com/users/judah/orgs","repos_url":"https://api.github.com/users/judah/repos","events_url":"https://api.github.com/users/judah/events{/privacy}","received_events_url":"https://api.github.com/users/judah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/judah/terminfo","description":"Haskell bindings to the terminfo API.","fork":false,"url":"https://api.github.com/repos/judah/terminfo","forks_url":"https://api.github.com/repos/judah/terminfo/forks","keys_url":"https://api.github.com/repos/judah/terminfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/judah/terminfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/judah/terminfo/teams","hooks_url":"https://api.github.com/repos/judah/terminfo/hooks","issue_events_url":"https://api.github.com/repos/judah/terminfo/issues/events{/number}","events_url":"https://api.github.com/repos/judah/terminfo/events","assignees_url":"https://api.github.com/repos/judah/terminfo/assignees{/user}","branches_url":"https://api.github.com/repos/judah/terminfo/branches{/branch}","tags_url":"https://api.github.com/repos/judah/terminfo/tags","blobs_url":"https://api.github.com/repos/judah/terminfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/judah/terminfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/judah/terminfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/judah/terminfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/judah/terminfo/statuses/{sha}","languages_url":"https://api.github.com/repos/judah/terminfo/languages","stargazers_url":"https://api.github.com/repos/judah/terminfo/stargazers","contributors_url":"https://api.github.com/repos/judah/terminfo/contributors","subscribers_url":"https://api.github.com/repos/judah/terminfo/subscribers","subscription_url":"https://api.github.com/repos/judah/terminfo/subscription","commits_url":"https://api.github.com/repos/judah/terminfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/judah/terminfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/judah/terminfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/judah/terminfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/judah/terminfo/contents/{+path}","compare_url":"https://api.github.com/repos/judah/terminfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/judah/terminfo/merges","archive_url":"https://api.github.com/repos/judah/terminfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/judah/terminfo/downloads","issues_url":"https://api.github.com/repos/judah/terminfo/issues{/number}","pulls_url":"https://api.github.com/repos/judah/terminfo/pulls{/number}","milestones_url":"https://api.github.com/repos/judah/terminfo/milestones{/number}","notifications_url":"https://api.github.com/repos/judah/terminfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/judah/terminfo/labels{/name}","releases_url":"https://api.github.com/repos/judah/terminfo/releases{/id}","created_at":"2013-10-31T13:49:51Z","updated_at":"2014-12-30T06:35:43Z","pushed_at":"2015-12-01T07:43:10Z","git_url":"git://github.com/judah/terminfo.git","ssh_url":"git@github.com:judah/terminfo.git","clone_url":"https://github.com/judah/terminfo.git","svn_url":"https://github.com/judah/terminfo","homepage":null,"size":75,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/judah/terminfo/pulls/8"},"html":{"href":"https://github.com/judah/terminfo/pull/8"},"issue":{"href":"https://api.github.com/repos/judah/terminfo/issues/8"},"comments":{"href":"https://api.github.com/repos/judah/terminfo/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/judah/terminfo/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/judah/terminfo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/judah/terminfo/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/judah/terminfo/statuses/68674ed51d94bdee6ea3ea10c1494352c8143da2"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":2,"review_comments":0,"commits":1,"additions":11,"deletions":19,"changed_files":1}}