set to the sum for the indents from all references on the path from
the root.
+Finally we need to know if the `code_node` was recognised by being
+indented or not. If it was, the client of this data will want to
+strip of the leading tab or 4 spaces. Hence a `needs_strip` flag is
+needed.
+
##### exported types
struct text {
struct text code;
int indent;
int line_no;
+ int needs_strip;
struct code_node *next;
struct section *child;
};
##### internal functions
static void code_add_text(struct psection *where, struct text txt,
- int line_no)
+ int line_no, int needs_strip)
{
struct code_node *n;
if (txt.len == 0)
n->code = txt;
n->indent = 0;
n->line_no = line_no;
+ n->needs_strip = needs_strip;
n->next = NULL;
n->child = NULL;
if (where->last)
struct text txt;
txt.txt = start;
txt.len = pos - start;
- code_add_text(sect, txt, start_line);
+ code_add_text(sect, txt, start_line,
+ marker == NULL);
}
ref = take_header(t, end);
if (ref.len) {
struct text txt;
txt.txt = start;
txt.len = pos - start;
- code_add_text(sect, txt, start_line);
+ code_add_text(sect, txt, start_line,
+ marker == NULL);
}
if (marker) {
pos = skip_line(pos, end);
for (; node; node = node->next) {
char *c = node->code.txt;
int len = node->code.len;
- int undent = 0;
if (!len)
continue;
fprintf(out, "#line %d \"%s\"\n",
node->line_no, fname);
- if (*c == ' ' || *c == '\t')
- undent = 1;
while (len && *c) {
fprintf(out, "%*s", node->indent, "");
- if (undent) {
+ if (node->needs_strip) {
if (*c == '\t' && len > 1) {
c++;
len--;