Ignore:
Timestamp:
Sep 15, 2006, 7:09:38 AM (19 years ago)
Author:
bird
Message:

Untested merge with GNU Make v3.81 (vendor/gnumake/2005-05-16 -> vendor/gnumake/current).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/expand.c

    r281 r503  
    11/* Variable expansion functions for GNU Make.
    2 Copyright (C) 1988, 89, 91, 92, 93, 95 Free Software Foundation, Inc.
     2Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     4Foundation, Inc.
    35This file is part of GNU Make.
    46
    5 GNU Make is free software; you can redistribute it and/or modify
    6 it under the terms of the GNU General Public License as published by
    7 the Free Software Foundation; either version 2, or (at your option)
    8 any later version.
    9 
    10 GNU Make is distributed in the hope that it will be useful,
    11 but WITHOUT ANY WARRANTY; without even the implied warranty of
    12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13 GNU General Public License for more details.
    14 
    15 You should have received a copy of the GNU General Public License
    16 along with GNU Make; see the file COPYING.  If not, write to
    17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18 Boston, MA 02111-1307, USA.  */
     7GNU Make is free software; you can redistribute it and/or modify it under the
     8terms of the GNU General Public License as published by the Free Software
     9Foundation; either version 2, or (at your option) any later version.
     10
     11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     13A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     14
     15You should have received a copy of the GNU General Public License along with
     16GNU Make; see the file COPYING.  If not, write to the Free Software
     17Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
    1918
    2019#include "make.h"
     
    2726#include "variable.h"
    2827#include "rule.h"
     28
     29/* Initially, any errors reported when expanding strings will be reported
     30   against the file where the error appears.  */
     31const struct floc **expanding_var = &reading_file;
    2932
    3033/* The next two describe the variable output buffer.
     
    98101{
    99102  char *value;
     103  const struct floc *this_var;
     104  const struct floc **saved_varp;
    100105  struct variable_set_list *save = 0;
    101106  int set_reading = 0;
    102107
     108  /* Don't install a new location if this location is empty.
     109     This can happen for command-line variables, builtin variables, etc.  */
     110  saved_varp = expanding_var;
     111  if (v->fileinfo.filenm)
     112    {
     113      this_var = &v->fileinfo;
     114      expanding_var = &this_var;
     115    }
     116
     117  /* If we have no other file-reading context, use the variable's context. */
     118  if (!reading_file)
     119    {
     120      set_reading = 1;
     121      reading_file = &v->fileinfo;
     122    }
     123
    103124  if (v->expanding)
    104125    {
    105126      if (!v->exp_count)
    106127        /* Expanding V causes infinite recursion.  Lose.  */
    107         fatal (reading_file,
     128        fatal (*expanding_var,
    108129               _("Recursive variable `%s' references itself (eventually)"),
    109130               v->name);
     
    115136      save = current_variable_set_list;
    116137      current_variable_set_list = file->variables;
    117     }
    118 
    119   /* If we have no other file-reading context, use the variable's context. */
    120   if (!reading_file)
    121     {
    122       set_reading = 1;
    123       reading_file = &v->fileinfo;
    124138    }
    125139
     
    133147  if (set_reading)
    134148    reading_file = 0;
     149
    135150  if (file)
    136151    current_variable_set_list = save;
     152
     153  expanding_var = saved_varp;
    137154
    138155  return value;
     
    208225      p1 = strchr (p, '$');
    209226
    210       o = variable_buffer_output (o, p, p1 != 0 ? p1 - p : strlen (p) + 1);
     227      o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1);
    211228
    212229      if (p1 == 0)
     
    249266            if (end == 0)
    250267              /* Unterminated variable reference.  */
    251               fatal (reading_file, _("unterminated variable reference"));
     268              fatal (*expanding_var, _("unterminated variable reference"));
    252269            p1 = lindex (beg, end, '$');
    253270            if (p1 != 0)
     
    375392          /* A $ followed by a random char is a variable reference:
    376393             $a is equivalent to $(a).  */
    377           {
    378             /* We could do the expanding here, but this way
    379                avoids code repetition at a small performance cost.  */
    380             char name[5];
    381             name[0] = '$';
    382             name[1] = '(';
    383             name[2] = *p;
    384             name[3] = ')';
    385             name[4] = '\0';
    386             p1 = allocated_variable_expand (name);
    387             o = variable_buffer_output (o, p1, strlen (p1));
    388             free (p1);
    389           }
     394          o = reference_variable (o, p, 1);
    390395
    391396          break;
     
    503508    buf = variable_buffer_output (buf, " ", 1);
    504509
    505   return variable_buffer_output (buf, v->value, strlen (v->value));
     510  /* Either expand it or copy it, depending.  */
     511  if (! v->recursive)
     512    return variable_buffer_output (buf, v->value, strlen (v->value));
     513
     514  buf = variable_expand_string (buf, v->value, strlen (v->value));
     515  return (buf + strlen (buf));
    506516}
    507517
     
    510520allocated_variable_append (const struct variable *v)
    511521{
    512   char *val, *retval;
     522  char *val;
    513523
    514524  /* Construct the appended variable value.  */
     
    526536  variable_buffer_length = olen;
    527537
    528   /* Now expand it and return that.  */
    529 
    530   retval = allocated_variable_expand (val);
    531 
    532   free (val);
    533   return retval;
     538  return val;
    534539}
    535540
Note: See TracChangeset for help on using the changeset viewer.