This is needed to correctly adjust for this indent when processing the
code.
Signed-off-by: NeilBrown <neilb@suse.de>
set to the sum for the indents from all references on the path from
the root.
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 {
##### exported types
struct text {
struct text code;
int indent;
int line_no;
struct text code;
int indent;
int line_no;
struct code_node *next;
struct section *child;
};
struct code_node *next;
struct section *child;
};
##### internal functions
static void code_add_text(struct psection *where, struct text txt,
##### internal functions
static void code_add_text(struct psection *where, struct text txt,
+ int line_no, int needs_strip)
{
struct code_node *n;
if (txt.len == 0)
{
struct code_node *n;
if (txt.len == 0)
n->code = txt;
n->indent = 0;
n->line_no = line_no;
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)
n->next = NULL;
n->child = NULL;
if (where->last)
struct text txt;
txt.txt = start;
txt.len = pos - start;
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) {
}
ref = take_header(t, end);
if (ref.len) {
struct text txt;
txt.txt = start;
txt.len = pos - start;
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);
}
if (marker) {
pos = skip_line(pos, end);
for (; node; node = node->next) {
char *c = node->code.txt;
int len = node->code.len;
for (; node; node = node->next) {
char *c = node->code.txt;
int len = node->code.len;
if (!len)
continue;
fprintf(out, "#line %d \"%s\"\n",
node->line_no, fname);
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, "");
while (len && *c) {
fprintf(out, "%*s", node->indent, "");
+ if (node->needs_strip) {
if (*c == '\t' && len > 1) {
c++;
len--;
if (*c == '\t' && len > 1) {
c++;
len--;