Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 584052 | Differences between
and this patch

Collapse All | Expand All

(-)libgpg-error-1.22/src/mkheader.c.old (-26 / +45 lines)
Lines 17-22 Link Here
17
#include <string.h>
17
#include <string.h>
18
#include <errno.h>
18
#include <errno.h>
19
#include <unistd.h>
19
#include <unistd.h>
20
#include <regex.h>
20
21
21
#define PGM "mkheader"
22
#define PGM "mkheader"
22
23
Lines 64-109 Link Here
64
}
65
}
65
66
66
67
67
/* Return a malloced string with TRIPLET.  If TRIPLET has an alias
68
/* Return a malloced string with TRIPLET.  The TRIPLET should conform 
68
   return that instead.  In general build-aux/config.sub should do the
69
 * to the hostnames in the header file names in src/syscfg.  Assume 
69
   aliasing but some returned triplets are anyway identical and thus we
70
 * build-aux/config.sub correctly validates the names and try to map it 
70
   use this function to map it to the canonical form.  */
71
 * to a header hostname.  */
71
static char *
72
static char *
72
canon_host_triplet (const char *triplet)
73
canon_host_triplet (const char *triplet)
73
{
74
{
74
  struct {
75
  struct {
75
    const char *name;
76
    const char *pattern;
76
    const char *alias;
77
    const char *host;
77
  } tbl[] = {
78
  } tbl[] = {
78
    {"i486-pc-linux-gnu", "i686-pc-linux-gnu" },
79
    {"^aarch64.*apple.*", "aarch64-apple-darwin"},
79
    {"i586-pc-linux-gnu" },
80
    {"^aarch64.*", "aarch64-apple-darwin"},
80
    {"i486-pc-gnu", "i686-pc-gnu"},
81
    {"^alpha.*", "alpha-unknown-linux-gnu"},
81
    {"i586-pc-gnu"},
82
    {"^arm.*apple.*", "arm-apple-darwin"},
82
    {"i486-pc-kfreebsd-gnu", "i686-pc-kfreebsd-gnu"},
83
    {"^arm.*android.*", "arm-unknown-linux-androideabi"},
83
    {"i586-pc-kfreebsd-gnu"},
84
    {"^arm.*gnueabihf.*", "arm-unknown-linux-gnueabihf"},
84
    {"x86_64-pc-linux-gnuhardened1", "x86_64-pc-linux-gnu" },
85
    {"^armv6.*musl.*", "armv6-unknown-linux-musleabihf"},
85
    {"powerpc-unknown-linux-gnuspe", "powerpc-unknown-linux-gnu" },
86
    {"^arm.*musl.*", "armv5-unknown-linux-musleabi"},
87
    {"^arm.*", "arm-unknown-linux-gnueabi"},
88
    {"^hppa.*", "hppa-unknown-linux-gnu"},
89
    {"^i[3-6]86.*freebsd.*", "i686-pc-kfreebsd-gnu"},
90
    {"^i[3-6]86.*linux.*", "i686-pc-linux-gnu"},
91
    {"^i[3-6]86.*", "i686-pc-gnu"},
92
    {"^m68.*", "m68k-unknown-linux-gnu"},
93
    {"^mingw.*", "mingw32"},
94
    {"^mips64el.*", "mips64el-unknown-linux-gnuabi64"},
95
    {"^mipsel.*", "mipsel-unknown-linux-gnu"},
96
    {"^mips.*", "mips-unknown-linux-gnu"},
97
    {"^nios2.*", "nios2-unknown-linux-gnu"},
98
    {"^or1k.*", "or1k-unknown-linux-gnu"},
99
    {"^powerpc64le.*", "powerpc64le-unknown-linux-gnu"},
100
    {"^powerpc64.*", "powerpc64-unknown-linux-gnu"},
101
    {"^powerpc.*", "powerpc-unknown-linux-gnu"},
102
    {"^s390.*", "s390x-ibm-linux-gnu"},
103
    {"^sh.*", "sh4-unknown-linux-gnu"},
104
    {"^sparc64.*", "sparc64-unknown-linux-gnu"},
105
    {"^sparc.*", "sparc-unknown-linux-gnu"},
106
    {"^x86_64.*freebsd.*", "x86_64-pc-kfreebsd-gnu"},
107
    {"^x86_64.*musl.*", "x86_64-pc-linux-musl"},
108
    {"^x86_64.*x32.*", "x86_64-pc-linux-gnux32"},
109
    {"^x86_64.*", "x86_64-pc-linux-gnu"},
86
110
87
    { NULL }
111
    { NULL }
88
  };
112
  };
89
  int i;
113
  regex_t regtest;
90
  const char *lastalias = NULL;
114
  const char *lasthost = NULL;
91
115
92
  for (i=0; tbl[i].name; i++)
116
  for (int i=0; tbl[i].pattern; i++)
93
    {
117
    {
94
      if (tbl[i].alias)
118
      lasthost = tbl[i].host;
95
        lastalias = tbl[i].alias;
119
      if (regcomp(&regtest, tbl[i].pattern, REG_NOSUB) == 0)
96
      if (!strcmp (tbl[i].name, triplet))
120
        if (regexec(&regtest, triplet, 0, NULL, 0) == 0)
97
        {
121
          return xstrdup (lasthost);
98
          if (!lastalias)
99
            break; /* Ooops: first entry has no alias.  */
100
          return xstrdup (lastalias);
101
        }
102
    }
122
    }
103
  return xstrdup (triplet);
123
  return xstrdup (triplet);
104
}
124
}
105
125
106
107
/* Parse the supplied config.h file and extract required info.
126
/* Parse the supplied config.h file and extract required info.
108
   Returns 0 on success.  */
127
   Returns 0 on success.  */
109
static int
128
static int

Return to bug 584052