patches/glibc/2.7/250-sh-chop-linux-version.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jan 17 23:06:02 2010 +0100 (2010-01-17)
changeset 1740 c57458bb354d
permissions -rw-r--r--
configure: do not require hg when configuring in an hg clone

When configuring in an hg clone, we need hg to compute the version string.
It can happen that users do not have Mercurial (eg. if they got a snapshot
rather that they did a full clone). In this case, we can still run, of
course, so simply fill the version string with a sufficiently explicit
value, that does not require hg. The date is a good candidate.
     1 --- glibc-2.7/sysdeps/unix/sysv/linux/dl-osinfo.h.orig	2007-09-15 23:54:08.000000000 +0100
     2 +++ glibc-2.7/sysdeps/unix/sysv/linux/dl-osinfo.h	2008-08-20 09:26:26.000000000 +0100
     3 @@ -83,6 +83,10 @@
     4    int parts;
     5    char *cp;
     6    struct utsname uts;
     7 +  int dotsfound = 0;
     8 +  int versionindex = 0;
     9 +  char *choppoint;
    10 +
    11  
    12    /* Try the uname system call.  */
    13    if (__uname (&uts))
    14 @@ -102,8 +106,34 @@
    15    else
    16      buf = uts.release;
    17  
    18 +  /* We are only interested in the first three kernel numbers, so */
    19 +  /* chop off anything past that: */
    20 +
    21 +  choppoint = buf;
    22 +  while (1)
    23 +    {
    24 +      versionindex++;
    25 +      if (versionindex == 63) break;
    26 +      if (*choppoint == '.') dotsfound++;
    27 +      choppoint++;
    28 +      if (dotsfound == 2)
    29 +      {
    30 +        if (*choppoint == '0' || *choppoint == '1'
    31 +          || *choppoint == '2' || *choppoint == '3'
    32 +          || *choppoint == '4' || *choppoint == '5'
    33 +          || *choppoint == '6' || *choppoint == '7'
    34 +          || *choppoint == '8' || *choppoint == '9')
    35 +          continue;
    36 +        else
    37 +          {
    38 +            *choppoint = 0;
    39 +            break;
    40 +          }
    41 +      }
    42 +    }
    43 +
    44    /* Now convert it into a number.  The string consists of at most
    45 -     three parts.  */
    46 +     three parts.  Now it does, anyway.  ;-)  */
    47    version = 0;
    48    parts = 0;
    49    cp = buf;