VirtualBox

Changeset 2159 in kBuild for trunk


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

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

Location:
trunk/src/kmk
Files:
2 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;
  • trunk/src/kmk/tests/scripts/functions/evalcall

    r2158 r2159  
    7777endif
    7878
    79 # negative tests:
     79
     80# Negative tests:
    8081
    8182.RETURN = $2 $1
     
    9192endif
    9293
     94
     95# Test .ARGC:
     96
     97FUNC = local .RETURN = $(.ARGC)
     98ifneq ($(evalcall FUNC,a,b),2)
     99$(error sub-test 20 failed)
     100endif
     101ifneq ($(evalcall FUNC),0)
     102$(error sub-test 21 failed)
     103endif
     104ifneq ($(evalcall FUNC,aasdfasdf),1)
     105$(error sub-test 22 failed)
     106endif
     107
     108
    93109.PHONY: all
    94110all: ; @:
     
    99115
    100116
    101 
    102117# Indicate that we're done.
    1031181;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette