/[m4]/m4/m4/macro.c
ViewVC logotype

Diff of /m4/m4/macro.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by gary, Wed Jun 18 16:21:54 2003 UTC revision 1.28 by gary, Thu Jun 19 14:51:04 2003 UTC
# Line 61  expand_token (m4 *context, struct obstac Line 61  expand_token (m4 *context, struct obstac
61                m4__token_type type, m4_symbol_value *token)                m4__token_type type, m4_symbol_value *token)
62  {  {
63    m4_symbol *symbol;    m4_symbol *symbol;
64    char *text = xstrdup (VALUE_TEXT (token));    char *text = xstrdup (m4_get_symbol_value_text (token));
65    
66    switch (type)    switch (type)
67      {                           /* TOKSW */      {                           /* TOKSW */
# Line 84  expand_token (m4 *context, struct obstac Line 84  expand_token (m4 *context, struct obstac
84    
85          symbol = m4_symbol_lookup (M4SYMTAB, textp);          symbol = m4_symbol_lookup (M4SYMTAB, textp);
86          if (symbol == NULL          if (symbol == NULL
87              || SYMBOL_TYPE (symbol) == M4_SYMBOL_VOID              || symbol->value->type == M4_SYMBOL_VOID
88              || (SYMBOL_TYPE (symbol) == M4_SYMBOL_FUNC              || (symbol->value->type == M4_SYMBOL_FUNC
89                  && BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_BLIND_ARGS_BIT)                  && BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_BLIND_ARGS_BIT)
90                  && !M4_IS_OPEN (m4_peek_input ())))                  && !M4_IS_OPEN (m4_peek_input ())))
91            {            {
# Line 123  expand_argument (m4 *context, struct obs Line 123  expand_argument (m4 *context, struct obs
123    const char *current_file = m4_current_file;    const char *current_file = m4_current_file;
124    int current_line = m4_current_line;    int current_line = m4_current_line;
125    
126    VALUE_TYPE (argp) = M4_SYMBOL_VOID;    argp->type = M4_SYMBOL_VOID;
127    
128    /* Skip leading white space.  */    /* Skip leading white space.  */
129    do    do
# Line 137  expand_argument (m4 *context, struct obs Line 137  expand_argument (m4 *context, struct obs
137        switch (type)        switch (type)
138          {                       /* TOKSW */          {                       /* TOKSW */
139          case M4_TOKEN_SIMPLE:          case M4_TOKEN_SIMPLE:
140            text = VALUE_TEXT (&token);            text = m4_get_symbol_value_text (&token);
141            if ((M4_IS_COMMA (*text) || M4_IS_CLOSE (*text)) && paren_level == 0)            if ((M4_IS_COMMA (*text) || M4_IS_CLOSE (*text)) && paren_level == 0)
142              {              {
143    
# Line 145  expand_argument (m4 *context, struct obs Line 145  expand_argument (m4 *context, struct obs
145                obstack_1grow (obs, '\0');                obstack_1grow (obs, '\0');
146                text = obstack_finish (obs);                text = obstack_finish (obs);
147    
148                if (VALUE_TYPE (argp) == M4_SYMBOL_VOID)                if (argp->type == M4_SYMBOL_VOID)
149                  {                  {
150                    VALUE_TYPE (argp) = M4_SYMBOL_TEXT;                    m4_set_symbol_value_text (argp, text);
                   VALUE_TEXT (argp) = text;  
151                  }                  }
152                return (boolean) (M4_IS_COMMA (*VALUE_TEXT (&token)));                return (boolean) (M4_IS_COMMA (*m4_get_symbol_value_text (&token)));
153              }              }
154    
155            if (M4_IS_OPEN (*text))            if (M4_IS_OPEN (*text))
# Line 215  ERROR: Recursion limit of %d exceeded, u Line 214  ERROR: Recursion limit of %d exceeded, u
214    macro_call_id++;    macro_call_id++;
215    my_call_id = macro_call_id;    my_call_id = macro_call_id;
216    
217    traced = (boolean) ((debug_level & M4_DEBUG_TRACE_ALL) || SYMBOL_TRACED (symbol));    traced = (boolean) ((debug_level & M4_DEBUG_TRACE_ALL)
218                          || m4_get_symbol_traced (symbol));
219    
220    obstack_init (&argptr);    obstack_init (&argptr);
221    obstack_init (&arguments);    obstack_init (&arguments);
# Line 261  collect_arguments (m4 *context, const ch Line 261  collect_arguments (m4 *context, const ch
261    
262    groks_macro_args = BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_MACRO_ARGS_BIT);    groks_macro_args = BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_MACRO_ARGS_BIT);
263    
264    VALUE_TYPE (&token) = M4_SYMBOL_TEXT;    m4_set_symbol_value_text (&token, (char *) name);
   VALUE_TEXT (&token) = (char *) name;  
265    tokenp = (m4_symbol_value *) obstack_copy (arguments, (void *) &token,    tokenp = (m4_symbol_value *) obstack_copy (arguments, (void *) &token,
266                                        sizeof (token));                                        sizeof (token));
267    obstack_grow (argptr, (void *) &tokenp, sizeof (tokenp));    obstack_grow (argptr, (void *) &tokenp, sizeof (tokenp));
# Line 275  collect_arguments (m4 *context, const ch Line 274  collect_arguments (m4 *context, const ch
274          {          {
275            more_args = expand_argument (context, arguments, &token);            more_args = expand_argument (context, arguments, &token);
276    
277            if (!groks_macro_args && VALUE_TYPE (&token) == M4_SYMBOL_FUNC)            if (!groks_macro_args && m4_is_symbol_value_func (&token))
278              {              {
279                VALUE_TYPE (&token) = M4_SYMBOL_TEXT;                m4_set_symbol_value_text (&token, "");
               VALUE_TEXT (&token) = "";  
280              }              }
281            tokenp = (m4_symbol_value *)            tokenp = (m4_symbol_value *)
282              obstack_copy (arguments, (void *) &token, sizeof (token));              obstack_copy (arguments, (void *) &token, sizeof (token));
# Line 299  void Line 297  void
297  m4_call_macro (m4_symbol *symbol, m4 *context, struct obstack *expansion,  m4_call_macro (m4_symbol *symbol, m4 *context, struct obstack *expansion,
298                 int argc, m4_symbol_value **argv)                 int argc, m4_symbol_value **argv)
299  {  {
300    switch (SYMBOL_TYPE (symbol))    if (m4_is_symbol_text (symbol))
301      {      {
     case M4_SYMBOL_FUNC:  
       (*SYMBOL_FUNC (symbol)) (context, expansion, argc, argv);  
       break;  
   
     case M4_SYMBOL_TEXT:  
302        m4_process_macro (symbol, context, expansion, argc, argv);        m4_process_macro (symbol, context, expansion, argc, argv);
303        break;      }
304      else if (m4_is_symbol_func (symbol))
305      case M4_SYMBOL_VOID:      {
306          (*m4_get_symbol_func (symbol)) (context, expansion, argc, argv);
307        }
308      else
309        {
310        M4ERROR ((warning_status, 0,        M4ERROR ((warning_status, 0,
311                  "INTERNAL ERROR: Bad symbol type in call_macro ()"));                  "INTERNAL ERROR: Bad symbol type in call_macro ()"));
312        abort ();        abort ();
# Line 328  m4_process_macro (m4_symbol *symbol, m4 Line 325  m4_process_macro (m4_symbol *symbol, m4
325    const unsigned char *text;    const unsigned char *text;
326    int i;    int i;
327    
328    for (text = SYMBOL_TEXT (symbol); *text != '\0';)    for (text = m4_get_symbol_text (symbol); *text != '\0';)
329      {      {
330        if (*text != '$')        if (*text != '$')
331          {          {

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26