From 77c44782f4cbf6d60a7dbfe996b0649336ec7205 Mon Sep 17 00:00:00 2001 From: Cedric Bastoul Date: Thu, 28 Feb 2013 18:13:03 +0100 Subject: [PATCH] Support for OpenScop column coordinates --- osl | 2 +- source/program.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/osl b/osl index a1b65c3..8363600 160000 --- a/osl +++ b/osl @@ -1 +1 @@ -Subproject commit a1b65c33bf8cfd3fcfc1b258cea056a58298566d +Subproject commit 8363600c5453641b155ece344a574d32af5b25b6 diff --git a/source/program.c b/source/program.c index 2b3ec1a..2e31147 100644 --- a/source/program.c +++ b/source/program.c @@ -376,6 +376,7 @@ int cloog_program_osl_pprint(FILE * file, CloogProgram * program, CloogOptions * options) { #ifdef OSL_SUPPORT int lines = 0; + int columns = 0; int read = 1; char c; osl_scop_p scop = options->scop; @@ -398,15 +399,23 @@ int cloog_program_osl_pprint(FILE * file, CloogProgram * program, print_macros(file); /* Print what was before the SCoP in the original file. */ - while ((lines < coordinates->start) && (read != EOF)) { + while (((lines < coordinates->line_start - 1) || + (columns < coordinates->column_start - 1)) && (read != EOF)) { read = fscanf(original, "%c", &c); + columns++; if (read != EOF) { - if (c == '\n') - lines ++; + if (c == '\n') { + lines++; + columns = 0; + } fprintf(file, "%c", c); } } + /* Carriage return to preserve indentation if necessary. */ + if (coordinates->column_start > 0) + fprintf(file, "\n"); + /* Generate the clast from the pseudo-AST then pretty-print it. */ root = cloog_clast_create(program, options); clast_pprint(file, root, coordinates->indent, options); @@ -415,11 +424,16 @@ int cloog_program_osl_pprint(FILE * file, CloogProgram * program, /* Print what was after the SCoP in the original file. */ while (read != EOF) { read = fscanf(original, "%c", &c); + columns++; if (read != EOF) { - if (lines >= coordinates->end - 1) + if (((lines == coordinates->line_end - 1) && + (columns > coordinates->column_end)) || + (lines > coordinates->line_end - 1)) fprintf(file, "%c", c); - if (c == '\n') - lines ++; + if (c == '\n') { + lines++; + columns = 0; + } } } -- 2.11.4.GIT