Ignore:
Timestamp:
Apr 21, 2008, 12:46:03 AM (17 years ago)
Author:
bird
Message:

Use the value_length if possible (saves strlen). Assert its correctness instead of fallbacks.

File:
1 edited

Legend:

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

    r1458 r1536  
    186186    return o;
    187187
     188#ifdef CONFIG_WITH_VALUE_LENGTH
     189  if (!v->recursive)
     190    {
     191      assert (v->value_length == strlen (v->value));
     192      o = variable_buffer_output (o, v->value, v->value_length);
     193    }
     194  else
     195   {
     196     value = recursively_expand (v);
     197     o = variable_buffer_output (o, value, strlen (value));
     198     free (value);
     199   }
     200#else  /* !CONFIG_WITH_VALUE_LENGTH */
    188201  value = (v->recursive ? recursively_expand (v) : v->value);
    189202
     
    192205  if (v->recursive)
    193206    free (value);
     207#endif /* !CONFIG_WITH_VALUE_LENGTH */
    194208
    195209  return o;
     
    572586  if (buf > variable_buffer)
    573587    buf = variable_buffer_output (buf, " ", 1);
     588#ifdef CONFIG_WITH_VALUE_LENGTH
     589  assert (v->value_length == strlen (v->value));
     590#endif
    574591
    575592  /* Either expand it or copy it, depending.  */
    576593  if (! v->recursive)
    577594#ifdef CONFIG_WITH_VALUE_LENGTH
    578     return variable_buffer_output (buf, v->value,
    579                                    v->value_length >= 0 ? v->value_length : strlen (v->value));
     595    return variable_buffer_output (buf, v->value, v->value_length);
    580596#else
    581597    return variable_buffer_output (buf, v->value, strlen (v->value));
     
    583599
    584600#ifdef CONFIG_WITH_VALUE_LENGTH
    585   buf = variable_expand_string (buf, v->value, v->value_length >= 0 ? v->value_length : strlen (v->value));
     601  buf = variable_expand_string (buf, v->value, v->value_length);
    586602#else
    587603  buf = variable_expand_string (buf, v->value, strlen (v->value));
Note: See TracChangeset for help on using the changeset viewer.