Are there alternate implementations of GNU getline interface?

后端 未结 5 1225
醉酒成梦
醉酒成梦 2020-11-28 09:48

The experiment I am currently working uses a software base with a complicated source history and no well defined license. It would be a considerable amount of work to ration

5条回答
  •  悲&欢浪女
    2020-11-28 10:07

    Use these portable versions from NetBSD: getdelim() and getline()

    These come from libnbcompat in pkgsrc, and have a BSD license at the top of each file. You need both because getline() calls getdelim(). Fetch the latest versions of both files. See the BSD license at the top of each file. Modify the files to fit into your program: you might need to declare getline() and getdelim() in one of your header files, and modify both files to include your header instead of the nbcompat headers.

    This version of getdelim() is portable because it calls fgetc(). For contrast, a getdelim() from a libc (like BSD libc or musl libc) would probably use private features of that libc, so it would not work across platforms.

    In the years since POSIX 2008 specified getline(), more Unixish platforms have added the getline() function. It is rare that getline() is missing, but it can still happen on old platforms. A few people try to bootstrap NetBSD pkgsrc on old platforms (like PowerPC Mac OS X), so they want libnbcompat to provide missing POSIX functions like getline().

提交回复
热议问题