[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Starting the final call for features for 1.7

From: Oliver Kiddle
Subject: Re: [Nmh-workers] Starting the final call for features for 1.7
Date: Tue, 27 Sep 2016 12:16:20 +0200

On 23 Sep, Ken Hornstein wrote:
> I think that we are starting to get close to being ready for a 1.7

The latest code in git is failing to build on Solaris because it
relies on getline(3). getline was a GNU extension that has now been
added to recent POSIX specifications but may still be lacking on
older systems that predate that.

Could we perhaps include a configure test and a fallback implementation
such as the one below (it is a public domain implementation tweaked
to use mh_xmalloc etc)?

I'm not quite sure which file would be appropriate for this to be
included in. sbr/utils.c seemed a reasonable choice but one of the
test cases also depends on getline and my automake knowledge was not
sufficient to work out how to handle the dependencies for that without
listing loads of object files. I also can't work out how to run the
tests by the way. make test doesn't work and the README file provides no
indication of how to run them.



ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
    int c;
    size_t alloced = 0;
    char *linebuf;

    if (*lineptr == NULL) {
        alloced = 256;
        linebuf = mh_xmalloc(sizeof(char) * alloced);
    } else {
        linebuf = *lineptr;
        alloced = *n;
    ssize_t linelen = 0;

    do {
        c = fgetc(stream);
        if (c == EOF) {
        if (linelen >= alloced) {
            alloced += (alloced + 1)/2;
            linebuf = mh_xrealloc(linebuf, sizeof(char) * alloced);
        *(linebuf + linelen) = (unsigned char)c;
    } while (c != '\n');

    if (linelen == 0) {
        if (linebuf && !*lineptr) {
            linebuf = NULL;
        linelen = -1;
        *n = alloced;
    } else {
        if (linebuf) {
            linebuf[linelen] = '\0';
        *n = alloced;
        *lineptr = linebuf;

    return linelen;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]