File: pparagraph.c

package info (click to toggle)
yodl 4.04.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,720 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 164
file content (58 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download | duplicates (9)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "parser.ih"

static int s_nested = 0;

void p_paragraph(register Parser *pp, String const *sp)
{
    register HashItem *item;

    if
    (
        s_nested++
        ||
        (item = hashmap_find(pp->d_symtab_ptr, "PARAGRAPH", MACRO))
                                                            == PFAILED
    )
        (*pp->d_insert)(pp, string_str(sp));        /* no paragraph macro   */

    else if (!ostream_empty(pp->d_outs_ptr))
    {                                               /* get paragraph funct  */
        char const *def = macro_definition(hashitem_value(item));

        if (def == PFAILED)
        {
            if (message_show(MSG_ERR))
                message("MACRO PARAGRAPH': no expansion");
        }
        else
        {
            register void (*saved)(struct Parser *, char const *);
            register char *evaluated;

            HashItem *paragraph =
                    hashmap_find(pp->d_symtab_ptr, "XXparagraph", SYMBOL);

                                               /* See if we have a new par. */
            HashItem *parcount =
                    hashmap_find(pp->d_symtab_ptr, "XXwrotetext", COUNTER);

            if (paragraph != PFAILED)
                symbol_set(paragraph, string_str(sp));

            if (parcount != PFAILED)
                counter_set(parcount, 
                            (int)ostream_inserted_text(pp->d_outs_ptr));

            evaluated = parser_eval(pp, new_str(def));

            saved = parser_suppress_chartab(&parser);
            (*pp->d_insert)(pp, evaluated);
            pp->d_insert = saved;

            ostream_inserted_blanks(pp->d_outs_ptr);
            free(evaluated);
        }

    }
    s_nested--;
}