{"action":"created","issue":{"url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/233","repository_url":"https://api.github.com/repos/fuzzball-muck/fuzzball","labels_url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/233/labels{/name}","comments_url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/233/comments","events_url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/233/events","html_url":"https://github.com/fuzzball-muck/fuzzball/issues/233","id":386067994,"node_id":"MDU6SXNzdWUzODYwNjc5OTQ=","number":233,"title":"The strcpyn function","user":{"login":"nyanster","id":31562770,"node_id":"MDQ6VXNlcjMxNTYyNzcw","avatar_url":"https://avatars1.githubusercontent.com/u/31562770?v=4","gravatar_id":"","url":"https://api.github.com/users/nyanster","html_url":"https://github.com/nyanster","followers_url":"https://api.github.com/users/nyanster/followers","following_url":"https://api.github.com/users/nyanster/following{/other_user}","gists_url":"https://api.github.com/users/nyanster/gists{/gist_id}","starred_url":"https://api.github.com/users/nyanster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nyanster/subscriptions","organizations_url":"https://api.github.com/users/nyanster/orgs","repos_url":"https://api.github.com/users/nyanster/repos","events_url":"https://api.github.com/users/nyanster/events{/privacy}","received_events_url":"https://api.github.com/users/nyanster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-30T07:23:02Z","updated_at":"2018-12-01T04:41:44Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"While examining prochelp.c again, I saw a function defined called strcpyn.  It's used in a lot of files.  In fbstrings.c and resolver.c there's a comment explaining\r\n\"Like strncpy, except it guarantees null termination of the result string.\"\r\n(the comment has a typo in resolver.c but is otherwise the same)\r\nI find it confusing that strcpyn is defined and used when strncpy already exists, and strncpy is already in the C standard.  It's much easier, documentation-wise, to use standard functions, since I was able to read a man page on strncpy.  This is something I value as a C newb though, with my own needs.  But there's quite possibly a valid reason for strcpyn to exist, and I'm just not seeing it.  So I want to know what you guys think.\r\n[demodiff.txt](https://github.com/fuzzball-muck/fuzzball/files/2632380/demodiff.txt)\r\nI've attached a demonstration diff that shows it really does behave the same.  prochelp still worked after this diff.\r\nShould strcpyn be replaced with the strncpy line + null termination line when it occurs in code?\r\nOr should it be left as is?  If left as is, should it be left with its own implementation, or should its implementation be replaced in the way my demonstration diff shows?"},"comment":{"url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/comments/443399255","html_url":"https://github.com/fuzzball-muck/fuzzball/issues/233#issuecomment-443399255","issue_url":"https://api.github.com/repos/fuzzball-muck/fuzzball/issues/233","id":443399255,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzM5OTI1NQ==","user":{"login":"nyanster","id":31562770,"node_id":"MDQ6VXNlcjMxNTYyNzcw","avatar_url":"https://avatars1.githubusercontent.com/u/31562770?v=4","gravatar_id":"","url":"https://api.github.com/users/nyanster","html_url":"https://github.com/nyanster","followers_url":"https://api.github.com/users/nyanster/followers","following_url":"https://api.github.com/users/nyanster/following{/other_user}","gists_url":"https://api.github.com/users/nyanster/gists{/gist_id}","starred_url":"https://api.github.com/users/nyanster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nyanster/subscriptions","organizations_url":"https://api.github.com/users/nyanster/orgs","repos_url":"https://api.github.com/users/nyanster/repos","events_url":"https://api.github.com/users/nyanster/events{/privacy}","received_events_url":"https://api.github.com/users/nyanster/received_events","type":"User","site_admin":false},"created_at":"2018-12-01T04:41:44Z","updated_at":"2018-12-01T04:41:44Z","author_association":"CONTRIBUTOR","body":"Oh. >w<  Good thing to know.  Thank you so much!!\r\nI was inappropriately copying part of an example in the strncpy manual page, then:\r\nhttps://www.freebsd.org/cgi/man.cgi?query=strncpy\r\nI applied similar printf lines to prochelp.c's strcpyn and found the same results you show. I wonder what I'm misunderstanding about the man page's example...\r\nI see though. It's good to know about strlen."}}
{"actor":{"display_login":"nyanster"}}