File: sunsubstvalue.c

package info (click to toggle)
yodl 4.05.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,724 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 163
file content (33 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "subst.ih"

char *s_unsubstValue(StrVector const *sv, char *value)
{
    String str;
    string_construct(&str, 0);

    char *end = value;
    char *begin;
    while (true)
    {
        begin = strstr(end, "+XXSUBST(");               /* ) */

        if (begin == 0)
        {
            string_addstr(&str, end);            /* append the tail */
            break;
        }

        string_additerators(&str, begin, end);
        begin += strlen("+XXSUBST(");                  /* )    */
        int idx;
        end = begin + 1 + sscanf(begin, "%d", &idx);     /* get the index */

        string_addstr(&str, strVector_index(sv, idx)->d_value);
    }

    free(value);
    return string_release(&str);
}