~ubuntu-branches/ubuntu/natty/augeas/natty

« back to all changes in this revision

Viewing changes to src/info.c

  • Committer: Bazaar Package Importer
  • Author(s): Raphaël Pinson
  • Date: 2011-02-24 09:32:22 UTC
  • mfrom: (1.2.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224093222-bfd4fkm6envek6ys
Tags: 0.8.0-0ubuntu1
* New upstream release.
* Remove obsolete ruby Build-Depend.
* Build PDF docs and add them to augeas-doc.
* Build-Depend on texlive-latex-base to build PDF docs.
* Install txt doc files in augeas-doc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <config.h>
24
24
#include "info.h"
25
25
#include "internal.h"
 
26
#include "memory.h"
26
27
#include "ref.h"
27
28
 
28
29
/*
113
114
    free(info);
114
115
}
115
116
 
 
117
struct span *make_span(struct info *info) {
 
118
    struct span *span = NULL;
 
119
    if (ALLOC(span) < 0) {
 
120
        return NULL;
 
121
    }
 
122
    /* UINT_MAX means span is not initialized yet */
 
123
    span->span_start = UINT_MAX;
 
124
    span->filename = ref(info->filename);
 
125
    return span;
 
126
}
 
127
 
 
128
void free_span(struct span *span) {
 
129
    if (span == NULL)
 
130
        return;
 
131
    unref(span->filename, string);
 
132
    free(span);
 
133
}
 
134
 
 
135
void print_span(struct span *span) {
 
136
    if (span == NULL)
 
137
        return;
 
138
    printf("%s label=(%i:%i) value=(%i:%i) span=(%i,%i)\n",
 
139
            span->filename->str,
 
140
            span->label_start, span->label_end,
 
141
            span->value_start, span->value_end,
 
142
            span->span_start, span->span_end);
 
143
}
 
144
 
 
145
void update_span(struct span *node_info, int x, int y) {
 
146
    if (node_info == NULL)
 
147
        return;
 
148
    if (node_info->span_start == UINT_MAX) {
 
149
        node_info->span_start = x;
 
150
        node_info->span_end = y;
 
151
    } else {
 
152
        if (node_info->span_start > x)
 
153
            node_info->span_start = x;
 
154
        if (node_info->span_end < y)
 
155
            node_info->span_end = y;
 
156
    }
 
157
}
 
158
 
116
159
/*
117
160
 * Local variables:
118
161
 *  indent-tabs-mode: nil