VirtualBox

Changeset 2021 in kBuild


Ignore:
Timestamp:
Nov 2, 2008 1:18:47 AM (16 years ago)
Author:
bird
Message:

kmk: Added a $(intersects set-a, set-b) function to complement the if1of/ifn1of conditionals. Fixes #56.

Location:
trunk/src/kmk
Files:
1 added
2 edited

Legend:

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

    r2011 r2021  
    37053705func_if_expr (char *o, char **argv, const char *funcname UNUSED)
    37063706{
    3707     int rc;
    3708     char *to_expand;
    3709 
    3710     /* Evaluate the condition in argv[0] and expand the 2nd or
    3711        3rd argument according to the result. */
    3712     rc = expr_eval_if_conditionals (argv[0], NULL);
    3713     to_expand = rc == 0 ? argv[1] : argv[2];
    3714     if (*to_expand)
    3715       {
    3716         char *expansion = expand_argument (to_expand, NULL);
    3717 
    3718         o = variable_buffer_output (o, expansion, strlen (expansion));
    3719 
    3720         free (expansion);
    3721       }
    3722 
    3723     return o;
     3707  int rc;
     3708  char *to_expand;
     3709
     3710  /* Evaluate the condition in argv[0] and expand the 2nd or
     3711     3rd argument according to the result. */
     3712  rc = expr_eval_if_conditionals (argv[0], NULL);
     3713  to_expand = rc == 0 ? argv[1] : argv[2];
     3714  if (*to_expand)
     3715    {
     3716      char *expansion = expand_argument (to_expand, NULL);
     3717
     3718      o = variable_buffer_output (o, expansion, strlen (expansion));
     3719
     3720      free (expansion);
     3721    }
     3722
     3723  return o;
    37243724}
    37253725
    37263726#endif /* CONFIG_WITH_IF_CONDITIONALS */
     3727
     3728#ifdef CONFIG_WITH_SET_CONDITIONALS
     3729static char *
     3730func_set_intersects (char *o, char **argv, const char *funcname UNUSED)
     3731{
     3732  const char *s1_cur;
     3733  unsigned int s1_len;
     3734  const char *s1_iterator = argv[0];
     3735
     3736  while ((s1_cur = find_next_token (&s1_iterator, &s1_len)) != 0)
     3737    {
     3738      const char *s2_cur;
     3739      unsigned int s2_len;
     3740      const char *s2_iterator = argv[1];
     3741      while ((s2_cur = find_next_token (&s2_iterator, &s2_len)) != 0)
     3742        if (s2_len == s1_len
     3743         && strneq (s2_cur, s1_cur, s1_len) )
     3744          return variable_buffer_output (o, "1", 1); /* found intersection */
     3745    }
     3746
     3747  return o; /* no intersection */
     3748}
     3749#endif /* CONFIG_WITH_SET_CONDITIONALS */
    37273750
    37283751#ifdef CONFIG_WITH_STACK
     
    46114634  { STRING_SIZE_TUPLE("if-expr"),       2,  3,  0,  func_if_expr},
    46124635#endif
     4636#ifdef CONFIG_WITH_SET_CONDITIONALS
     4637  { STRING_SIZE_TUPLE("intersects"),    2,  2,  1,  func_set_intersects},
     4638#endif
    46134639#ifdef CONFIG_WITH_STACK
    46144640  { STRING_SIZE_TUPLE("stack-push"),    2,  2,  1,  func_stack_push},
  • trunk/src/kmk/variable.c

    r2011 r2021  
    12171217                          " explicit-multitarget"
    12181218                          " prepend-assignment"
    1219                           " set-conditionals"
     1219                          " set-conditionals intersects"
    12201220                          " date"
    12211221                          " file-size"
     
    12611261#  endif
    12621262#  if defined (CONFIG_WITH_SET_CONDITIONALS)
    1263   strcat (buf, " set-conditionals");
     1263  strcat (buf, " set-conditionals intersects");
    12641264#  endif
    12651265#  if defined (CONFIG_WITH_DATE)
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