Ignore:
Timestamp:
Dec 29, 2008, 5:08:15 PM (17 years ago)
Author:
bird
Message:

kmk: extended call, evalcall and evalcall2 with a local .ARGC automatic variable holding the argument count.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r2157 r2159  
    51755175  unsigned int len;
    51765176#endif
     5177#if defined (CONFIG_WITH_EVALPLUS) || defined (CONFIG_WITH_VALUE_LENGTH)
     5178  char num[11];
     5179#endif
    51775180
    51785181  /* There is no way to define a variable with a space in the name, so strip
     
    52305233
    52315234  for (i=0; *argv; ++i, ++argv)
     5235#ifdef CONFIG_WITH_VALUE_LENGTH
     5236    define_variable (num, sprintf (num, "%d", i), *argv, o_automatic, 0);
     5237#else
    52325238    {
    52335239      char num[11];
     
    52365242      define_variable (num, strlen (num), *argv, o_automatic, 0);
    52375243    }
     5244#endif
     5245
     5246#ifdef CONFIG_WITH_EVALPLUS
     5247  /* $(.ARGC) is the argument count. */
     5248
     5249  len = sprintf (num, "%d", i - 1);
     5250  define_variable_vl (".ARGC", sizeof (".ARGC") - 1, num, len,
     5251                      1 /* dup val */, o_automatic, 0);
     5252  define_variable (".ARGC", sizeof (".ARGC") - 1, num, o_automatic, 0);
     5253#endif
    52385254
    52395255  /* If the number of arguments we have is < max_args, it means we're inside
     
    52435259
    52445260  for (; i < max_args; ++i)
     5261#ifdef CONFIG_WITH_VALUE_LENGTH
     5262    define_variable (num, sprintf (num, "%d", i), "", o_automatic, 0);
     5263#else
    52455264    {
    52465265      char num[11];
    52475266
    5248 #ifndef CONFIG_WITH_VALUE_LENGTH
    52495267      sprintf (num, "%d", i);
    52505268      define_variable (num, strlen (num), "", o_automatic, 0);
    5251 #else
    5252       define_variable (num, sprintf (num, "%d", i), "", o_automatic, 0);
    5253 #endif
    5254     }
     5269    }
     5270#endif
    52555271
    52565272  saved_args = max_args;
Note: See TracChangeset for help on using the changeset viewer.