source: patches/make-3.82-fixes-1.patch@ 58375318

systemd
Last change on this file since 58375318 was d87123b, checked in by William Harrington <kb0iic@…>, 11 years ago

Add make 3.82 fixes patch for upstream changes.

  • Property mode set to 100644
File size: 9.4 KB
  • expand.c

    Submitted By:            William Harrington at <kb0iic at cross-lfs dot org>
    Date:                    2013-08-01
    Initial Package Version: 3.82
    Upstream Status:         Fixed Upstream
    Origin:                  Upstream
    Description:             Several bug fixes from upstream git
    
    diff -Naur make-3.82.orig/expand.c make-3.82/expand.c
    old new  
    197197{
    198198  struct variable *v;
    199199  const char *p, *p1;
    200   char *abuf = NULL;
     200  char *save;
    201201  char *o;
    202202  unsigned int line_offset;
    203203
     
    212212      return (variable_buffer);
    213213    }
    214214
    215   /* If we want a subset of the string, allocate a temporary buffer for it.
    216      Most of the functions we use here don't work with length limits.  */
    217   if (length > 0 && string[length] != '\0')
    218     {
    219       abuf = xmalloc(length+1);
    220       memcpy(abuf, string, length);
    221       abuf[length] = '\0';
    222       string = abuf;
    223     }
    224   p = string;
     215  /* We need a copy of STRING: due to eval, it's possible that it will get
     216     freed as we process it (it might be the value of a variable that's reset
     217     for example).  Also having a nil-terminated string is handy.  */
     218  save = length < 0 ? xstrdup (string) : xstrndup (string, length);
     219  p = save;
    225220
    226221  while (1)
    227222    {
     
    411406      ++p;
    412407    }
    413408
    414   if (abuf)
    415     free (abuf);
     409  free (save);
    416410
    417411  variable_buffer_output (o, "", 1);
    418412  return (variable_buffer + line_offset);
  • function.c

    diff -Naur make-3.82.orig/function.c make-3.82/function.c
    old new  
    706706  const char *word_iterator = argv[0];
    707707  char buf[20];
    708708
    709   while (find_next_token (&word_iterator, (unsigned int *) 0) != 0)
     709  while (find_next_token (&word_iterator, NULL) != 0)
    710710    ++i;
    711711
    712712  sprintf (buf, "%d", i);
     
    11331133
    11341134  /* Find the maximum number of words we'll have.  */
    11351135  t = argv[0];
    1136   wordi = 1;
    1137   while (*t != '\0')
     1136  wordi = 0;
     1137  while ((p = find_next_token (&t, NULL)) != 0)
    11381138    {
    1139       char c = *(t++);
    1140 
    1141       if (! isspace ((unsigned char)c))
    1142         continue;
    1143 
     1139      ++t;
    11441140      ++wordi;
    1145 
    1146       while (isspace ((unsigned char)*t))
    1147         ++t;
    11481141    }
    11491142
    1150   words = xmalloc (wordi * sizeof (char *));
     1143  words = xmalloc ((wordi == 0 ? 1 : wordi) * sizeof (char *));
    11511144
    11521145  /* Now assign pointers to each string in the array.  */
    11531146  t = argv[0];
  • make-3.82

    diff -Naur make-3.82.orig/job.c make-3.82/job.c
    old new  
    2929
    3030#include <string.h>
    3131
     32#if defined(__linux__) /* defined (HAVE_LINUX_BINFMTS_H) && defined (HAVE_SYS_USER_H) */
     33#include <sys/user.h>
     34#include <unistd.h>
     35#ifndef PAGE_SIZE
     36#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
     37#endif
     38#include <linux/binfmts.h>
     39#endif
     40
    3241/* Default shell to use.  */
    3342#ifdef WINDOWS32
    3443#include <windows.h>
     
    27912800       argument list.  */
    27922801
    27932802    unsigned int shell_len = strlen (shell);
     2803#ifdef MAX_ARG_STRLEN
     2804    static char eval_line[] = "eval\\ \\\"set\\ x\\;\\ shift\\;\\ ";
     2805#define ARG_NUMBER_DIGITS 5
     2806#define EVAL_LEN (sizeof(eval_line)-1 + shell_len + 4 \
     2807                 + (7 + ARG_NUMBER_DIGITS) * 2 * line_len / (MAX_ARG_STRLEN - 2))
     2808#else
     2809#define EVAL_LEN 0
     2810#endif
     2811    char *args_ptr;
    27942812    unsigned int line_len = strlen (line);
    27952813    unsigned int sflags_len = strlen (shellflags);
    27962814    char *command_ptr = NULL; /* used for batch_mode_shell mode */
     
    28662884      }
    28672885
    28682886    new_line = alloca (shell_len + 1 + sflags_len + 1
    2869                              + (line_len*2) + 1);
     2887                             + (line_len*2) + 1 + EVAL_LEN);
    28702888    ap = new_line;
    28712889    memcpy (ap, shell, shell_len);
    28722890    ap += shell_len;
     
    28752893    ap += sflags_len;
    28762894    *(ap++) = ' ';
    28772895    command_ptr = ap;
     2896
     2897#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
     2898    if (unixy_shell && line_len > MAX_ARG_STRLEN)
     2899      {
     2900        unsigned j;
     2901        memcpy (ap, eval_line, sizeof (eval_line) - 1);
     2902        ap += sizeof (eval_line) - 1;
     2903        for (j = 1; j <= 2 * line_len / (MAX_ARG_STRLEN - 2); j++)
     2904          ap += sprintf (ap, "\\$\\{%u\\}", j);
     2905        *ap++ = '\\';
     2906        *ap++ = '"';
     2907        *ap++ = ' ';
     2908        /* Copy only the first word of SHELL to $0.  */
     2909        for (p = shell; *p != '\0'; ++p)
     2910          {
     2911            if (isspace ((unsigned char)*p))
     2912              break;
     2913            *ap++ = *p;
     2914          }
     2915        *ap++ = ' ';
     2916      }
     2917#endif
     2918    args_ptr = ap;
     2919
    28782920    for (p = line; *p != '\0'; ++p)
    28792921      {
    28802922        if (restp != NULL && *p == '\n')
     
    29222964          }
    29232965#endif
    29242966        *ap++ = *p;
     2967
     2968#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
     2969        if (unixy_shell && line_len > MAX_ARG_STRLEN && (ap - args_ptr > MAX_ARG_STRLEN - 2))
     2970          {
     2971            *ap++ = ' ';
     2972            args_ptr = ap;
     2973          }
     2974#endif
    29252975      }
    29262976    if (ap == new_line + shell_len + sflags_len + 2)
    29272977      /* Line was empty.  */
  • make-3.82

    diff -Naur make-3.82.orig/main.c make-3.82/main.c
    old new  
    11381138     a macro and some compilers (MSVC) don't like conditionals in macros.  */
    11391139  {
    11401140    const char *features = "target-specific order-only second-expansion"
    1141                            " else-if shortest-stem undefine"
     1141                           " else-if shortest-stem undefine oneshell"
    11421142#ifndef NO_ARCHIVES
    11431143                           " archives"
    11441144#endif
     
    20932093            const char *pv = define_makeflags (1, 1);
    20942094            char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1);
    20952095            sprintf (p, "MAKEFLAGS=%s", pv);
    2096             putenv (p);
     2096            putenv (allocated_variable_expand (p));
    20972097          }
    20982098
    20992099          if (ISDB (DB_BASIC))
  • make-3.82

    diff -Naur make-3.82.orig/read.c make-3.82/read.c
    old new  
    29042904      const char *name;
    29052905      const char **nlist = 0;
    29062906      char *tildep = 0;
     2907      int globme = 1;
    29072908#ifndef NO_ARCHIVES
    29082909      char *arname = 0;
    29092910      char *memname = 0;
     
    30283029            {
    30293030              /* This looks like the first element in an open archive group.
    30303031                 A valid group MUST have ')' as the last character.  */
    3031               const char *e = p + nlen;
     3032              const char *e = p;
    30323033              do
    30333034                {
    30343035                  e = next_token (e);
     
    30843085         Go to the next item in the string.  */
    30853086      if (flags & PARSEFS_NOGLOB)
    30863087        {
    3087           NEWELT (concat (2, prefix, tp));
     3088          NEWELT (concat (2, prefix, tmpbuf));
    30883089          continue;
    30893090        }
    30903091
    30913092      /* If we get here we know we're doing glob expansion.
    30923093         TP is a string in tmpbuf.  NLEN is no longer used.
    30933094         We may need to do more work: after this NAME will be set.  */
    3094       name = tp;
     3095      name = tmpbuf;
    30953096
    30963097      /* Expand tilde if applicable.  */
    3097       if (tp[0] == '~')
     3098      if (tmpbuf[0] == '~')
    30983099        {
    3099           tildep = tilde_expand (tp);
     3100          tildep = tilde_expand (tmpbuf);
    31003101          if (tildep != 0)
    31013102            name = tildep;
    31023103        }
     
    31123113        }
    31133114#endif /* !NO_ARCHIVES */
    31143115
    3115       switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
    3116         {
    3117         case GLOB_NOSPACE:
    3118           fatal (NILF, _("virtual memory exhausted"));
    3119 
    3120         case 0:
    3121           /* Success.  */
    3122           i = gl.gl_pathc;
    3123           nlist = (const char **)gl.gl_pathv;
    3124           break;
    3125 
    3126         case GLOB_NOMATCH:
    3127           /* If we want only existing items, skip this one.  */
    3128           if (flags & PARSEFS_EXISTS)
    3129             {
    3130               i = 0;
    3131               break;
    3132             }
    3133           /* FALLTHROUGH */
    3134 
    3135         default:
    3136           /* By default keep this name.  */
     3116      /* glob() is expensive: don't call it unless we need to.  */
     3117      if (!(flags & PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
     3118        {
     3119          globme = 0;
    31373120          i = 1;
    31383121          nlist = &name;
    3139           break;
    3140         }
     3122        }
     3123      else
     3124        switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
     3125          {
     3126          case GLOB_NOSPACE:
     3127            fatal (NILF, _("virtual memory exhausted"));
     3128
     3129          case 0:
     3130            /* Success.  */
     3131            i = gl.gl_pathc;
     3132            nlist = (const char **)gl.gl_pathv;
     3133            break;
     3134
     3135          case GLOB_NOMATCH:
     3136            /* If we want only existing items, skip this one.  */
     3137            if (flags & PARSEFS_EXISTS)
     3138              {
     3139                i = 0;
     3140                break;
     3141              }
     3142            /* FALLTHROUGH */
     3143
     3144          default:
     3145            /* By default keep this name.  */
     3146            i = 1;
     3147            nlist = &name;
     3148            break;
     3149          }
    31413150
    31423151      /* For each matched element, add it to the list.  */
    31433152      while (i-- > 0)
     
    31523161            else
    31533162              {
    31543163                /* We got a chain of items.  Attach them.  */
    3155                 (*newp)->next = found;
     3164                if (*newp)
     3165                  (*newp)->next = found;
     3166                else
     3167                  *newp = found;
    31563168
    31573169                /* Find and set the new end.  Massage names if necessary.  */
    31583170                while (1)
     
    31743186#endif /* !NO_ARCHIVES */
    31753187          NEWELT (concat (2, prefix, nlist[i]));
    31763188
    3177       globfree (&gl);
     3189      if (globme)
     3190        globfree (&gl);
    31783191
    31793192#ifndef NO_ARCHIVES
    31803193      if (arname)
Note: See TracBrowser for help on using the repository browser.