85
85
* \param coordinates The coordinates structure to print.
86
86
* \param level Number of spaces before printing, for each line.
88
void osl_coordinates_idump(FILE * file, osl_coordinates_p coordinates,
88
void osl_coordinates_idump(FILE* file, osl_coordinates_p coordinates,
114
114
fprintf(file, "|\t");
116
116
// Display the lines.
117
fprintf(file, "Lines______: [%d, %d]\n",
118
coordinates->start, coordinates->end);
117
fprintf(file, "Coordinates: [%d,%d -> %d,%d]\n",
118
coordinates->line_start, coordinates->column_start,
119
coordinates->line_end, coordinates->column_end);
120
121
// Go to the right level.
121
122
for(j = 0; j <= level; j++)
139
140
* \param file The file where the information has to be printed.
140
141
* \param coordinates The coordinates structure to print.
142
void osl_coordinates_dump(FILE * file, osl_coordinates_p coordinates) {
143
void osl_coordinates_dump(FILE* file, osl_coordinates_p coordinates) {
143
144
osl_coordinates_idump(file, coordinates, 0);
151
152
* \param coordinates The coordinates structure to be print.
152
153
* \return A string containing the OpenScop dump of the coordinates structure.
154
char * osl_coordinates_sprint(osl_coordinates_p coordinates) {
155
char* osl_coordinates_sprint(osl_coordinates_p coordinates) {
155
156
int high_water_mark = OSL_MAX_STRING;
156
char * string = NULL;
157
158
char buffer[OSL_MAX_STRING];
159
160
if (coordinates != NULL) {
160
OSL_malloc(string, char *, high_water_mark * sizeof(char));
161
OSL_malloc(string, char*, high_water_mark * sizeof(char));
161
162
string[0] = '\0';
163
164
// Print the coordinates content.
164
165
sprintf(buffer, "# File name\n%s\n", coordinates->name);
165
166
osl_util_safe_strcat(&string, buffer, &high_water_mark);
167
sprintf(buffer, "# Starting line\n%d\n", coordinates->start);
168
sprintf(buffer, "# Starting line and column\n%d %d\n",
169
coordinates->line_start, coordinates->column_start);
168
170
osl_util_safe_strcat(&string, buffer, &high_water_mark);
170
sprintf(buffer, "# Ending line\n%d\n", coordinates->end);
172
sprintf(buffer, "# Ending line and column\n%d %d\n",
173
coordinates->line_end, coordinates->column_end);
171
174
osl_util_safe_strcat(&string, buffer, &high_water_mark);
173
176
sprintf(buffer, "# Indentation\n%d\n", coordinates->indent);
174
177
osl_util_safe_strcat(&string, buffer, &high_water_mark);
176
179
// Keep only the memory space we need.
177
OSL_realloc(string, char *, (strlen(string) + 1) * sizeof(char));
180
OSL_realloc(string, char*, (strlen(string) + 1) * sizeof(char));
196
199
* Updated to the position after what has been read.
197
200
* \return A pointer to the coordinates structure that has been read.
199
osl_coordinates_p osl_coordinates_sread(char ** input) {
202
osl_coordinates_p osl_coordinates_sread(char** input) {
200
203
osl_coordinates_p coordinates;
202
205
if (*input == NULL) {
210
213
// Read the file name (and path).
211
214
coordinates->name = osl_util_read_line(NULL, input);
213
// Read the number of the starting line.
214
coordinates->start = osl_util_read_int(NULL, input);
216
// Read the number of the ending line.
217
coordinates->end = osl_util_read_int(NULL, input);
216
// Read the coordinates.
217
coordinates->line_start = osl_util_read_int(NULL, input);
218
coordinates->column_start = osl_util_read_int(NULL, input);
219
coordinates->line_end = osl_util_read_int(NULL, input);
220
coordinates->column_end = osl_util_read_int(NULL, input);
219
222
// Read the indentation level.
220
223
coordinates->indent = osl_util_read_int(NULL, input);
240
243
osl_coordinates_p coordinates;
242
245
OSL_malloc(coordinates, osl_coordinates_p, sizeof(osl_coordinates_t));
243
coordinates->name = NULL;
244
coordinates->start = OSL_UNDEFINED;
245
coordinates->end = OSL_UNDEFINED;
246
coordinates->indent = OSL_UNDEFINED;
246
coordinates->name = NULL;
247
coordinates->line_start = OSL_UNDEFINED;
248
coordinates->column_start = OSL_UNDEFINED;
249
coordinates->line_end = OSL_UNDEFINED;
250
coordinates->column_end = OSL_UNDEFINED;
251
coordinates->indent = OSL_UNDEFINED;
248
253
return coordinates;
284
289
clone = osl_coordinates_malloc();
285
290
OSL_strdup(clone->name, coordinates->name);
286
clone->start = coordinates->start;
287
clone->end = coordinates->end;
288
clone->indent = coordinates->indent;
291
clone->line_start = coordinates->line_start;
292
clone->column_start = coordinates->column_start;
293
clone->line_end = coordinates->line_end;
294
clone->column_end = coordinates->column_end;
295
clone->indent = coordinates->indent;
314
if (c1->start != c2->start) {
321
if (c1->line_start != c2->line_start) {
315
322
OSL_info("starting lines are not the same");
326
if (c1->column_start != c2->column_start) {
327
OSL_info("starting columns are not the same");
331
if (c1->line_end != c2->line_end) {
332
OSL_info("Ending lines are not the same");
336
if (c1->column_end != c2->column_end) {
337
OSL_info("Ending columns are not the same");
319
341
if (c1->indent != c2->indent) {
320
342
OSL_info("indentations are not the same");