Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 55522 - sys-apps/which has a bug in --read-functions processing
Summary: sys-apps/which has a bug in --read-functions processing
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-29 02:12 UTC by Brian Harring (RETIRED)
Modified: 2006-03-09 16:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Harring (RETIRED) gentoo-dev 2004-06-29 02:12:23 UTC
taken from eutils.eclass as of 06/29/04:

have_NPTL() {
        cat > ${T}/test-nptl.c <<-"END"
              #define _XOPEN_SOURCE
                #include <unistd.h>
                #include <stdio.h>

                int main()
                {
                  char buf[255];
                  char *str = buf;

                  confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255);
                  if (NULL != str) {
                    printf("%s\n", str);
                    if (NULL != strstr(str, "NPTL"))
                      return 0;
                  }

                  return 1;
                }
        END

        einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ... "
        if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null
        then
                echo "yes"
                einfon "Checking what PTHREADS implementation we have ... "
                if ${T}/nptl
                then
                        return 0
                else
                        return 1
                fi
        else
                echo "no"
        fi

        return 1
}

source /${PORTDIR}/eclass/eutils; declare -f | which --read-functions have_NPTL results in

int main()
{
  char buf[255];
  char *str = buf;

  confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255);
  if (NULL != str) {
    printf("%s\n", str);
    if (NULL != strstr(str, "NPTL"))
      return 0;
  }

  return 1;
}

Which isn't valid bash (and was a pita to track down) :)

The issue is how declare is outputting the code-

have_NPTL () 
{ 
    cat >${T}/test-nptl.c  <<-'END'
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdio.h>

int main()
{
  char buf[255];
  char *str = buf;

  confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255);
  if (NULL != str) {
    printf("%s\n", str);
    if (NULL != strstr(str, "NPTL"))
      return 0;
  }

  return 1;
}
END

    einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ... ";
    if gcc -o ${T}/nptl ${T}/test-nptl.c >&/dev/null; then
        echo "yes";
        einfon "Checking what PTHREADS implementation we have ... ";
        if ${T}/nptl; then
            return 0;
        else
            return 1;
        fi;
    else
        echo "no";
    fi;
    return 1
}

I'm guessing which is just hunting for the function definition '^[^ ] \(\)[[:space:]]{\n', and then matching till '^}$', which isn't valid (or at least is an unexepected 'feature').

Work around is type has_NPTL which has it's own issues in isolating the function.
Comment 1 Brian Harring (RETIRED) gentoo-dev 2004-06-29 19:12:18 UTC
Haven't tested it w/ v2.12, but 2.16 I've verified as failing.
Comment 2 SpanKY gentoo-dev 2004-10-14 19:52:45 UTC
e-mailed upstream ... the problem lays in the code block in which.c around line ~550
Comment 3 Brian Harring (RETIRED) gentoo-dev 2006-03-09 16:30:13 UTC
bugs going no where, wrote filter-env to get around this...