PIPS
print.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "misc.h"
#include "arithmetique.h"
#include "text-util.h"
+ Include dependency graph for print.c:

Go to the source code of this file.

Functions

void print_sentence (FILE *fd, sentence s)
 FI: just to make sure that text.h is built; pips-makemake -l does not tale into account a library whose modules do not use the library header. More...
 
void dump_sentence (sentence s)
 
void print_text (FILE *fd, text t)
 
void dump_text (text t)
 FI: print_text() should be fprint_text() and dump_text(), print_text() More...
 
string words_to_string (cons *lw)
 
string sentence_to_string (sentence sen)
 SG: moved here from icfdg. More...
 
string text_to_string (text t)
 SG: moved here from ricedg. More...
 
void dump_words (list lw)
 
void dump_strings (list sl)
 print a list of strings More...
 
void print_words (FILE *fd, cons *lw)
 

Function Documentation

◆ dump_sentence()

void dump_sentence ( sentence  s)

Definition at line 190 of file print.c.

191 {
192  print_sentence(stderr, s);
193 }
void print_sentence(FILE *fd, sentence s)
FI: just to make sure that text.h is built; pips-makemake -l does not tale into account a library who...
Definition: print.c:53

References print_sentence().

+ Here is the call graph for this function:

◆ dump_strings()

void dump_strings ( list  sl)

print a list of strings

Definition at line 257 of file print.c.

258 {
259  dump_words(sl);
260 }
void dump_words(list lw)
Definition: print.c:251

References dump_words().

+ Here is the call graph for this function:

◆ dump_text()

void dump_text ( text  t)

FI: print_text() should be fprint_text() and dump_text(), print_text()

Definition at line 205 of file print.c.

207 {
208  print_text(stderr, t);
209 }
void print_text(FILE *fd, text t)
Definition: print.c:195

References print_text().

Referenced by get_semantic_text(), and text_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dump_words()

void dump_words ( list  lw)
Parameters
lww

Definition at line 251 of file print.c.

252 {
253  print_words(stderr, lw);
254 }
void print_words(FILE *fd, cons *lw)
Definition: print.c:263

References print_words().

Referenced by dump_strings(), print_qualifiers(), and print_type().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_sentence()

void print_sentence ( FILE *  fd,
sentence  s 
)

FI: just to make sure that text.h is built; pips-makemake -l does not tale into account a library whose modules do not use the library header.

cproto-generated files

print_sentence:

FI: I had to change this module to handle string longer than the space available on one line; I tried to preserve as much as I could of the previous behavior to avoid pseudo-hyphenation at the wrong place and to avoid extensicve problems with validate; the resulting code is lousy, of course; FI, 15 March 1993

RK: the print_sentence could print lower case letter according to a property... 17/12/1993.

FI/FC: Why on earth?!? (void) putc((islower((int) c) ? (char) toupper((int) c) : c), fd);

if the string fits on the current line: no problem

if the string fits on one line: use the 88 algorithm to break as few syntactic constructs as possible

complete current line

start a new line with its prefix

Special label for Cray directives

if the string has to be broken in at least two lines: new algorithmic part to avoid line overflow (FI, March 1993)

complete the current line

start a new line with its prefix but no indentation since string constants may be broken onto two lines

Special label for Cray directives

Parameters
fdd

Definition at line 53 of file print.c.

54 {
55  if (sentence_formatted_p(s)) {
56  string ps = sentence_formatted(s);
57  while (*ps) {
58  char c = *ps++;
59  /* FI/FC: Why on earth?!?
60  (void) putc((islower((int) c) ? (char) toupper((int) c) : c), fd);
61  */
62  (void) putc( c, fd);
63  }
64  }
65  else {
67  int col;
68  int i;
69  int line_num = 1;
70  string label = unformatted_label(u);
71  int em = unformatted_extra_margin(u);
72  int n = unformatted_number(u);
73  cons *lw = unformatted_words(u);
74 
75  if (label != (char *) NULL) {
76  fprintf(fd, "%-5s ", label);
77  }
79  fputs(" ", fd);
80  }
81 
82 
83  for (i = 0; i < em; i++)
84  putc(' ', fd);
85  col = 7+em;
86 
87  pips_assert("print_sentence", col <= MAX_LINE_LENGTH);
88 
89  while (lw) {
90  string w = STRING(CAR(lw));
91 
92  STRING(CAR(lw)) = NULL;
93  lw = CDR(lw);
94 
95  /* if the string fits on the current line: no problem */
96  if (col + strlen(w) <= 70) {
97  (void) fprintf(fd, "%s", w);
98  col += strlen(w);
99  }
100  /* if the string fits on one line:
101  * use the 88 algorithm to break as few
102  * syntactic constructs as possible */
103  else if(strlen(w) < 70-7-em) {
104  if (col + strlen(w) > 70) {
105  /* complete current line */
106  if (n > 0) {
107  for (i = col; i <= MAX_LINE_LENGTH; i++) putc(' ', fd);
108  fprintf(fd, "%04d", n);
109  }
110 
111  /* start a new line with its prefix */
112  putc('\n', fd);
113 
114  if(label != (char *) NULL
115  && (strcmp(label,"CDIR$")==0
116  || strcmp(label,"CDIR@")==0
117  || strcmp(label,"CMIC$")==0)) {
118  /* Special label for Cray directives */
119  fputs(label, fd);
120  fprintf(fd, "%d", (++line_num)%10);
121  }
122  else
123  fputs(" &", fd);
124 
125  for (i = 0; i < em; i++)
126  putc(' ', fd);
127 
128  col = 7+em;
129  }
130  (void) fprintf(fd, "%s", w);
131  col += strlen(w);
132  }
133  /* if the string has to be broken in at least two lines:
134  * new algorithmic part
135  * to avoid line overflow (FI, March 1993) */
136  else {
137  char * line = w;
138  int ncar;
139 
140  /* complete the current line */
141  ncar = MAX_LINE_LENGTH - col + 1;
142  fprintf(fd,"%.*s", ncar, line);
143  line += ncar;
144  col = 73;
145 
146  /*
147  if (n > 0) {
148  for (i = col; i <= 72; i++) putc(' ', fd);
149  fprintf(fd, "%04d", n);
150  }
151  */
152 
153  while(strlen(line)!=0) {
154  ncar = MIN(MAX_LINE_LENGTH - 7 +1, strlen(line));
155 
156  /* start a new line with its prefix but no indentation
157  * since string constants may be broken onto two lines */
158  putc('\n', fd);
159 
160  if(label != (char *) NULL
161  && (strcmp(label,"CDIR$")==0
162  || strcmp(label,"CDIR@")==0
163  || strcmp(label,"CMIC$")==0)) {
164  /* Special label for Cray directives */
165  fputs(label, fd);
166  (void) fprintf(fd, "%d", (++line_num)%10);
167  }
168  else
169  fputs(" &", fd);
170 
171  col = 7 ;
172  (void) fprintf(fd,"%.*s", ncar, line);
173  line += ncar;
174  col += ncar;
175  }
176  }
177  free(w);
178  }
179 
180  pips_assert("print_sentence", col <= MAX_LINE_LENGTH);
181 
182  if (n > 0) {
183  for (i = col; i <= MAX_LINE_LENGTH; i++) putc(' ', fd);
184  fprintf(fd, "%04d", n);
185  }
186  putc('\n', fd);
187  }
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
#define STRING(x)
Definition: genC.h:87
void free(void *)
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
bool prettyprint_language_is_fortran_p()
Definition: language.c:75
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
static int line
FLEX_SCANNER.
Definition: scanner.c:852
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define MAX_LINE_LENGTH
maximum length of a line when prettyprinting...
#define unformatted_number(x)
Definition: text.h:151
#define unformatted_extra_margin(x)
Definition: text.h:153
#define sentence_unformatted(x)
Definition: text.h:81
#define sentence_formatted(x)
Definition: text.h:78
#define unformatted_words(x)
Definition: text.h:155
#define unformatted_label(x)
Definition: text.h:149
#define sentence_formatted_p(x)
Definition: text.h:76

References CAR, CDR, fprintf(), free(), line, MAX_LINE_LENGTH, MIN, pips_assert, prettyprint_language_is_fortran_p(), sentence_formatted, sentence_formatted_p, sentence_unformatted, STRING, unformatted_extra_margin, unformatted_label, unformatted_number, and unformatted_words.

Referenced by dump_sentence(), make_emulated_shared_variable(), print_text(), and set_dimensions_of_local_variable_family().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_text()

◆ print_words()

void print_words ( FILE *  fd,
cons lw 
)

◆ sentence_to_string()

string sentence_to_string ( sentence  sen)

SG: moved here from icfdg.

Parameters
senen

Definition at line 230 of file print.c.

231 {
232  if (!sentence_formatted_p(sen))
234  else
235  return sentence_formatted(sen);
236 }

References sentence_formatted, sentence_formatted_p, sentence_unformatted, unformatted_words, and words_to_string().

Referenced by print_graph_of_text_to_daVinci(), print_marged_text_from_starting_node(), print_module_icfg(), and text_to_string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ text_to_string()

string text_to_string ( text  t)

SG: moved here from ricedg.

Definition at line 239 of file print.c.

240 {
241  string str = strdup("");
242  string str_new;
243  MAP(SENTENCE, sen, {
244  str_new = strdup(concatenate(str, sentence_to_string(sen), NULL));
245  free(str);
246  str = str_new;
247  }, text_sentences(t));
248  return(str);
249 }
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
char * strdup()
string sentence_to_string(sentence sen)
SG: moved here from icfdg.
Definition: print.c:230

References concatenate(), free(), MAP, SENTENCE, sentence_to_string(), strdup(), and text_sentences.

Referenced by concerned_entity_p(), control_graph(), debug_print_effects_list(), insert_impact_description_as_comment(), prettyprint_dot_label(), region_to_statement(), step_compute_CHAINS_DG_remove_summary_regions(), step_print_directives_regions(), step_translate_and_map(), and subtsitute_variable_in_reference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ words_to_string()

string words_to_string ( cons lw)

Definition at line 211 of file print.c.

213 {
214  static char buffer[1024];
215 
216  buffer[0] = '\0';
217  MAPL(pw, {
218  string w = STRING(CAR(pw));
219  if (strlen(buffer)+strlen(w) > 1023) {
220  fprintf(stderr, "[words_to_string] buffer too small\n");
221  exit(1);
222  }
223  (void) strcat(buffer, w);
224  }, lw);
225 
226  return(strdup(buffer));
227 }
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#define exit(code)
Definition: misc-local.h:54
static string buffer
Definition: string.c:113

References buffer, CAR, exit, fprintf(), MAPL, strdup(), and STRING.

Referenced by adg_fprint_dataflow(), adg_fprint_list_of_exp(), can_terapixify_expression_p(), comp_regions_of_syntax(), conflicts_sort_callback(), defs_elim_of_assign_call(), dereferencing_to_sinks(), do_simdizer_init(), effect_reference_first_pointer_dimension_rank(), effect_reference_to_string(), expression_to_string(), extended_source_to_sinks(), fprint_list_of_exp(), generic_reference_to_points_to_matching_list(), generic_transform_sink_cells_from_matching_list(), get_log_buffer(), get_sp_of_call_p(), imprime_special_quast(), insert_common_declaration(), io_filter(), make_bounds(), make_filtered_dg_or_dvdg(), maxima_simplify(), print_call_path(), print_structurals(), print_words(), proper_to_summary_simple_effect(), reference_to_string(), sentence_to_string(), store_sc_text_line(), string_of_type(), task_complexity(), task_time_polynome(), text_complexity(), text_loop_craft(), text_summary_complexity(), type_to_full_string_definition(), words_predicate_to_commentary(), and xml_Argument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: