~ubuntu-branches/ubuntu/trusty/cloog/trusty

« back to all changes in this revision

Viewing changes to osl/source/extensions/coordinates.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-10-17 15:54:24 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20131017155424-3q1gw7yhddylfkpj
Tags: 0.18.1-1
* New upstream version.
* Add a comment to build-depend on libpod-latex-perl | perl (<< 5.17.0),
  when the documentation is built. Closes: #711681.
* Use dh_autotools-dev to update config.{sub,guess}. Closes: #719957.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
 * \param coordinates The coordinates structure to print.
86
86
 * \param level       Number of spaces before printing, for each line.
87
87
 */
88
 
void osl_coordinates_idump(FILE * file, osl_coordinates_p coordinates,
 
88
void osl_coordinates_idump(FILE* file, osl_coordinates_p coordinates,
89
89
                           int level) {
90
90
  int j;
91
91
 
114
114
      fprintf(file, "|\t");
115
115
 
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);
119
120
 
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.
141
142
 */
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);
144
145
}
145
146
 
151
152
 * \param  coordinates The coordinates structure to be print.
152
153
 * \return A string containing the OpenScop dump of the coordinates structure.
153
154
 */
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
  char* string = NULL;
157
158
  char buffer[OSL_MAX_STRING];
158
159
 
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';
162
163
   
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);
166
167
 
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);
169
171
 
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);
172
175
 
173
176
    sprintf(buffer, "# Indentation\n%d\n", coordinates->indent);
174
177
    osl_util_safe_strcat(&string, buffer, &high_water_mark);
175
178
  
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));
178
181
  }
179
182
 
180
183
  return string;
196
199
 *                      Updated to the position after what has been read.
197
200
 * \return A pointer to the coordinates structure that has been read.
198
201
 */
199
 
osl_coordinates_p osl_coordinates_sread(char ** input) {
 
202
osl_coordinates_p osl_coordinates_sread(char** input) {
200
203
  osl_coordinates_p coordinates;
201
204
 
202
205
  if (*input == NULL) {
210
213
  // Read the file name (and path).
211
214
  coordinates->name = osl_util_read_line(NULL, input);
212
215
 
213
 
  // Read the number of the starting line.
214
 
  coordinates->start = osl_util_read_int(NULL, input);
215
 
 
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);
218
221
 
219
222
  // Read the indentation level.
220
223
  coordinates->indent = osl_util_read_int(NULL, input);
240
243
  osl_coordinates_p coordinates;
241
244
  
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;
247
252
 
248
253
  return coordinates;
249
254
}
283
288
 
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;
289
296
 
290
297
  return clone;
291
298
}
311
318
    return 0;
312
319
  }
313
320
 
314
 
  if (c1->start != c2->start) {
 
321
  if (c1->line_start != c2->line_start) {
315
322
    OSL_info("starting lines are not the same");
316
323
    return 0;
317
324
  }
318
325
 
 
326
  if (c1->column_start != c2->column_start) {
 
327
    OSL_info("starting columns are not the same");
 
328
    return 0;
 
329
  }
 
330
 
 
331
  if (c1->line_end != c2->line_end) {
 
332
    OSL_info("Ending lines are not the same");
 
333
    return 0;
 
334
  }
 
335
 
 
336
  if (c1->column_end != c2->column_end) {
 
337
    OSL_info("Ending columns are not the same");
 
338
    return 0;
 
339
  }
 
340
 
319
341
  if (c1->indent != c2->indent) {
320
342
    OSL_info("indentations are not the same");
321
343
    return 0;
345
367
 
346
368
  return interface;
347
369
}
348