PIPS
|
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
#include <regex.h>
#include "genC.h"
#include "misc.h"
Go to the source code of this file.
Macros | |
#define | to_escape(c) !isalnum(c) && c != '_' && c != '/' && c != '.' |
#define | COLON ':' |
#define | PATH_MAX 255 |
#define | MAX_INPUT_LINE_SIZE (200) |
#define | MAX_INPUT_LINE_SIZE (200) |
#define | SLASH_SUBSTITUTION_CHARACTER '_' |
#define | DEFAULT_CONFIG_DIR "etc" |
utility to open configuration file, (read only!) its name can be found using various ways property and env can be NULL (and ignored) if the file if not found a pips_error is generated canonical_name should be a file name, not a path More... | |
#define | CONFIG_DEFAULT_RIGHT "r" |
Functions | |
bool | get_bool_property (const string) |
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties.h". More... | |
char * | get_string_property (const char *) |
FILE * | check_fopen (const char *file, const char *mode) |
file.c More... | |
FILE * | safe_fopen (const char *filename, const char *what) |
int | safe_fclose (FILE *stream, const char *filename) |
int | safe_fflush (FILE *stream, char *filename) |
FILE * | safe_freopen (char *filename, char *what, FILE *stream) |
int | safe_fseek (FILE *stream, long int offset, int wherefrom, char *filename) |
long int | safe_ftell (FILE *stream, char *filename) |
void | safe_rewind (FILE *stream, char *filename) |
int | safe_fgetc (FILE *stream, char *filename) |
int | safe_getc (FILE *stream, char *filename) |
char * | safe_fgets (char *s, int n, FILE *stream, char *filename) |
int | safe_fputc (char c, FILE *stream, char *filename) |
int | safe_putc (char c, FILE *stream, char *filename) |
int | safe_fputs (char *s, FILE *stream, char *filename) |
int | safe_fread (char *ptr, int element_size, int count, FILE *stream, char *filename) |
int | safe_fwrite (char *ptr, int element_size, int count, FILE *stream, char *filename) |
int | safe_list_files_in_directory (gen_array_t files, string dir, string re, bool(*file_name_predicate)(const char *)) |
returns a sorted arg list of files matching regular expression re in directory 'dir' and with file_name_predicate() returning true on the file name (for example use directory_exists_p to select directories, of file_exists_p to select regular files). More... | |
void | list_files_in_directory (gen_array_t files, string dir, string re, bool(*file_name_predicate)(const char *)) |
The same as the previous safe_list_files_in_directory() but with no return code and a call to user error if it cannot open the directory. More... | |
bool | directory_exists_p (const char *name) |
bool | file_exists_p (const char *name) |
char * | strescape (const char *source) |
protect a string, for example for use in a system call list of non escaped characters in the macro above. More... | |
string | nth_path (const char *path_list, int n) |
Returns the allocated nth path from colon-separated path string. More... | |
static char * | relative_name_if_necessary (const char *name) |
char * | find_file_in_directories (const char *file_name, const char *dir_path) |
returns an allocated string pointing to the file, possibly with an additional path taken from colon-separated dir_path. More... | |
bool | file_readable_p (char *name) |
bool | create_directory (char *name) |
bool | purge_directory (char *name) |
char * | get_cwd (void) |
returns the current working directory name. More... | |
char * | safe_readline (FILE *file) |
returns the allocated line read, whatever its length. More... | |
string | safe_read_nth_line (string fn, int n) |
Assumes "fn" is the name of a text file, opens it, and returns its nth line (starting with 1) in a newly allocated buffer, whatever the line length. More... | |
string | safe_get_line_interval (const string fn, int f, int l) |
return lines f-l from file fn as a string More... | |
void | safe_copy_line_interval (string fn, int f, int l, FILE *out) |
Assumes "fn" is the name of a text file, opens it, and copies the lines whose number belongs to [f..l] into file descriptor "out", except if they have been generated by a C preprocessor. More... | |
char * | safe_readfile (FILE *file) |
returns the file as an allocated string. More... | |
void | safe_cat (FILE *out, FILE *in) |
void | safe_append (FILE *out, char *file, int margin, bool but_comments) |
void | safe_copy (char *source, char *target) |
int | safe_display (char *fname) |
Display a file through $PIPS_MORE (or $PAGER) if stdout is a TTY, on stdout otherwise. More... | |
char * | pips_filename (char *fullpath, char *suffix, bool short_p) |
Some OS do not define basename and dirname. More... | |
char * | pips_basename (char *fullpath, char *suffix) |
char * | pips_initial_filename (char *fullpath, char *suffix) |
The source file name access path is shortened or not depending on the property. More... | |
some path to file suffix some path to *char * | pips_dirname (char *fullpath) |
void | safe_unlink (const char *file_name) |
Delete the given file. More... | |
void | safe_symlink (const char *topath, const char *frompath) |
void | safe_link (const char *topath, const char *frompath) |
Create a hard link to topath. More... | |
char * | safe_system_output (char *what) |
attempt shell substitutions to what. More... | |
char * | safe_system_substitute (char *what) |
returns what after variable, command and file substitutions. More... | |
char * | safe_new_tmp_file (char *prefix) |
SunOS forgets to declare this one. More... | |
FILE * | fopen_config (const char *canonical_name, const char *cproperty, const char *cenv) |
#define DEFAULT_CONFIG_DIR "etc" |
#define MAX_INPUT_LINE_SIZE (200) |
#define MAX_INPUT_LINE_SIZE (200) |
#define SLASH_SUBSTITUTION_CHARACTER '_' |
#define to_escape | ( | c | ) | !isalnum(c) && c != '_' && c != '/' && c != '.' |
FILE* check_fopen | ( | const char * | file, |
const char * | mode | ||
) |
file | ile |
mode | ode |
Definition at line 56 of file file.c.
References pips_user_warning.
Referenced by load_meta_data().
bool create_directory | ( | char * | name | ) |
name | ame |
Definition at line 435 of file file.c.
References directory_exists_p(), pips_internal_error, and pips_user_warning.
Referenced by db_create_workspace(), and db_get_directory_name_for_module().
bool directory_exists_p | ( | const char * | name | ) |
name | ame |
Definition at line 314 of file file.c.
References buf.
Referenced by create_directory(), db_get_directory_name_for_module(), db_open_workspace(), generate_a_directory_menu(), pips_change_directory(), pips_get_workspace_list(), purge_directory(), and workspace_exists_p().
bool file_exists_p | ( | const char * | name | ) |
name | ame |
Definition at line 321 of file file.c.
References buf.
Referenced by add_new_compilation_unit(), add_new_module_from_text(), find_file_in_directories(), get_first_main_module(), hpfc_get_file_list(), load_meta_data(), parse_arguments(), pips_get_fortran_list(), safe_display(), and text_area_included().
bool file_readable_p | ( | char * | name | ) |
name | ame |
Definition at line 428 of file file.c.
References buf.
Referenced by freia_compile(), freia_opencl_compile_calls(), and workspace_ok_p().
char* find_file_in_directories | ( | const char * | file_name, |
const char * | dir_path | ||
) |
returns an allocated string pointing to the file, possibly with an additional path taken from colon-separated dir_path.
returns NULL if no file was found.
looks for the file with an additional path ahead.
file_name | ile_name |
dir_path | ir_path |
Definition at line 399 of file file.c.
References concatenate(), file_exists_p(), file_name, free(), nth_path(), pips_assert, relative_name_if_necessary(), and strdup().
Referenced by find_file(), parse_arguments(), and process_user_file().
FILE* fopen_config | ( | const char * | canonical_name, |
const char * | cproperty, | ||
const char * | cenv | ||
) |
canonical_name | anonical_name |
cproperty | property |
cenv | env |
Definition at line 952 of file file.c.
References concatenate(), CONFIG_DEFAULT_RIGHT, DEFAULT_CONFIG_DIR, get_string_property(), and safe_fopen().
Referenced by build_aliases(), get_help_topic(), get_help_topics(), get_model(), init_cost_table(), parse_makefile(), and simd_treematcher().
bool get_bool_property | ( | const | string | ) |
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties.h".
Definition at line 173 of file gfc2pips-stubs.c.
References fprintf(), and STUB_WARNING.
Referenced by abstract_locations_max(), activate_phase(), add_formal_parameters_to_hash_table(), add_implicit_interprocedural_write_effects(), add_loop_parallel_threshold(), add_pragma(), add_rule(), add_values_for_simple_effects_of_statement(), AK_ignore_this_level(), AK_ignore_this_successor(), alias_propagation(), alias_propagation_callers(), AnalyzeData(), any_complexities(), any_user_call_site_to_transformer(), application_to_points_to_sinks(), apply_a_rule(), arguments_to_complexity(), array_formal_parameter_to_stub_points_to(), atomize_call_statement(), atomize_this_expression(), atomizer(), average_probability_matrix(), begin_attachment_prettyprint(), block_to_complexity(), bottom_up_abc_reference(), bourdoncle_partition(), build_outline_name(), build_trail(), c_basic_string(), c_dim_string(), c_head(), c_include(), c_parser_user_warning_alist(), c_return_to_transformer(), c_text_related_entities(), c_unstructured(), c_user_call_to_transformer(), call_to_complexity(), call_to_polynome(), call_to_postcondition(), call_to_transformer(), cast_constant(), cast_to_polynome(), cell_to_nowhere_sink(), check_in_declarations(), clean_up_points_to_stubs(), cluster_stage_spire(), cluster_stage_spire_generation(), CodeGenerate(), comEngine_generate_HRECode(), commutative_call_p(), complexity_check_and_warn(), complexity_var_subst(), ComputeAddresses(), ConnectedStatements(), constraints_to_loop_bound(), controlize_forloop(), controlize_sequence(), controlizer(), convert_constant_from_double_to_dcomplex(), convert_constant_from_real_to_complex(), create_advanced_stub_points_to(), create_HRE_module(), create_k_limited_stub_points_to(), create_pointer_to_array_stub_points_to(), create_stub_points_to(), create_workspace(), cse_atom_call_flt(), cse_call_flt(), csplit_copy(), csplit_parser_warning_alist(), current_entity_is_updated_before_p(), current_entity_is_used_later_p(), cusq_ctxt_init(), cycle_to_flow_sensitive_preconditions(), dag_or_cycle_to_flow_sensitive_postconditions_or_transformers(), dag_to_flow_sensitive_preconditions(), dagvtx_dot(), dbll_stat_file(), debug_print_effects_list(), declaration_to_transformer(), declaration_to_transformer_list(), DeclarePointer(), decorate_trail(), dereferencing_to_points_to(), dereferencing_to_sinks(), derived_formal_parameter_to_stub_points_to(), display_clean_up_sequences_statistics(), display_unspaghettify_statistics(), distance_between_expression(), distributer(), do_check_isolate_statement_preconditions_on_call(), do_convert_this_array_to_pointer_p(), do_group_constant_entity(), do_group_statement_constant(), do_grouping_filter_out_self(), do_inlining(), do_loop_unroll(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_unfolding(), DSC(), dsc_code_parallelization(), dump_common_layout(), effect_words_reference(), effects_to_dma(), EndOfProcedure(), ensure_comment_consistency(), EvalCall(), EvalSyntax(), evaluate_var_to_complexity(), expr_compute_local_index(), expression_to_complexity_polynome(), expression_to_postcondition(), extended_source_to_sinks(), extract_lattice(), fetch_callees_complexities(), fetch_complexity_parameters(), filter_formal_context_according_to_actual_context(), fix_storage(), FixCReturnStatements(), flag_loop(), flatten_code(), float_call_expression_to_transformer(), flow_sensitive_malloc_to_points_to_sinks(), formal_source_to_sinks(), freia_allocate_new_images_if_needed(), freia_compile(), freia_dag_optimize(), freia_extract_params(), freia_opencl_compile_calls(), fs_filter(), fsm_generation(), full_loop_unroll(), full_simd_unroll_loop_filter(), fuse_sequences_in_unstructured(), gen_may_set(), generate_code_call(), generate_remapping_code(), generate_remapping_guard(), generic_apply_effects_to_transformer(), generic_c_words_simplified_entity(), generic_entity_typed_anywhere_locations(), generic_initializer(), generic_module_name_to_transformers(), generic_reference_to_points_to_matching_list(), generic_reference_to_transformer(), generic_stub_source_to_sinks(), generic_substitute_formal_array_elements_in_transformer(), get_final_offset(), get_text_preconditions(), get_text_total_preconditions(), get_variables_to_remove(), global_source_to_sinks(), gpips_user_error_message(), gpips_user_log(), gpu_ify_statement(), gpu_loop_nest_annotate_on_statement(), gpu_qualify_pointers(), group_constant_range_filter(), handle_hpf_directives(), handle_set_directive(), handle_synchro_directive(), handle_time_directive(), hbdsc_parallelization(), hierarchical_schedule(), hierarchical_schedule_step(), hpf_remapping(), hpfc_algorithm_row_echelon(), hpfc_broadcast_buffers(), hpfc_compute_lid(), html_prettyprint(), if_different_pe_and_not_twin(), init_convex_rw_regions(), init_live_paths_context(), init_parser_reader_properties(), init_points_to_analysis(), init_text_statement(), inline_expression_call(), inline_statement_crawler(), insert_test_before_statement(), integer_binary_operation_to_transformer(), integer_call_expression_to_transformer(), integer_expression_to_transformer(), interface_basic_string(), io_comp_regions(), io_efficient_compile(), keep_directive_in_code_p(), linearize_array_generic(), list_assignment_to_points_to(), live_paths_from_block_to_statements(), load_control_fix_point(), load_cost_file(), load_cycle_temporary_precondition(), logs_off(), logs_on(), loop_expansion(), loop_private_variables(), loop_to_complexity(), loop_to_postcondition(), loop_to_total_precondition(), loop_to_transformer(), main_summary_precondition(), make_anywhere_points_to_cell(), make_anywhere_reference(), make_bottom_up_abc_tests(), make_constraint_expression(), make_filtered_dg_or_dvdg(), make_interprocedural_abc_tests(), make_loadsave_statement(), MakeAssignInst(), MakeAtom(), MakeDoInst(), MakeForloopWithIndexDeclaration(), MakeFortranType(), MakeNestOfParallelLoops(), MakeNewLabelledStatement(), MakeStatement(), malloc_type_to_abstract_location(), mark_block(), module_name_to_preconditions(), module_name_to_total_preconditions(), module_name_to_transformers_in_context(), move_declaration_control_node_declarations_to_statement(), new_controlizer(), new_filter_formal_context_according_to_actual_context(), node_successors_to_matrix(), NormalizeCall(), nowhere_source_to_sinks(), null_equal_condition_to_points_to(), null_source_to_sinks(), offset_cell(), offset_points_to_cell(), old_array_bound_check_instrumentation(), opencl_compile_mergeable_dag(), opencl_merge_and_compile(), ordinary_summary_precondition(), outline(), outliner(), outliner_compilation_unit(), outliner_file(), outliner_independent(), outliner_independent_recursively(), outliner_init(), outliner_parameters(), outliner_scan(), parallel_tiling(), parser_substitute_all_macros(), partial_eval_syntax(), pips_check_syntax(), pips_initial_filename(), pixel_name(), pointer_call_expression_to_transformer(), pointer_formal_parameter_to_stub_points_to(), points_to_cell_null_initialization(), points_to_cell_types_compatibility(), points_to_unary_operation_to_transformer(), points_to_with_stripped_sink(), potential_out_effects_p(), ppt_call(), ppt_min_max(), ppt_unknown(), pragma_scop(), prettyprint_dependence_graph(), prettyprint_dependence_graph_view(), prettyprint_dot_dependence_graph(), print_code_or_source(), print_code_or_source_comp(), print_code_preconditions(), print_code_semantics(), print_code_total_preconditions(), print_code_with_comp_regions(), print_continuation_conditions(), print_dependence_or_chains_graph(), print_module_icfg(), print_parallelization_statistics(), print_parallelizedOMP_code(), print_sentence(), print_source_preconditions(), print_source_total_preconditions(), process_ready_node(), process_user_file(), ProcessEntries(), ProcessEntry(), put_summary(), pvecteur_to_polynome(), range_to_complexity(), rdg_loop(), reference_add_field_dimension(), reference_filter(), reference_to_complexity(), reference_to_polynome(), references_may_conflict_p(), regenerate_expression(), region_translation(), remapping_compile(), remapping_stats(), remove_common_variables_from_hash_table(), remove_formal_parameters_from_hash_table(), remove_impossible_arcs_to_null(), remove_points_to_cell(), rename_operator(), rename_statement_declarations(), replace_formal_parameters_by_real_ones(), reset_resources_for_module(), ResetCurrentCompilationUnitEntity(), ResetCurrentModule(), ReuseLabelledStatement(), rice(), rice_dependence_graph(), rice_loop(), safe_assigned_expression_to_transformer(), safe_assigned_expression_to_transformer_list(), sc_delimiter(), sc_inst(), scalar_by_pointer(), select_fix_point_operator(), semantics_user_warning_alist(), sentence_area(), sentence_data_statement(), set_analyzed_types(), set_conflict_testing_properties(), set_resources_for_module(), set_translation_mode(), simd_atomize_this_expression(), simd_loop_unroll(), simd_unroll_as_needed(), simple_simd_unroll_rate(), simplify_sc_to_complexity(), source_to_sinks(), spaghettify_statement(), split_initializations_in_statement(), sreference_offset(), st_compute_current_computer(), st_compute_current_owners(), statement_dependence_graph(), statement_remove_useless_label(), statement_to_complexity(), statement_to_postcondition(), statement_to_transformer(), statement_to_transformer_list(), statements_localize_declarations(), static_controlize_statement(), step_compile_analysed_module(), step_print_directives_regions(), string_predicate_to_commentary(), stub_text(), subscript_to_points_to_sinks(), SubstituteAlternateReturns(), summary_complexity(), summary_precondition(), summary_total_postcondition(), switch_specific_cmplx(), switch_specific_dcmplx(), symbolic_tiling_valid_p(), taskify(), test_to_complexity(), TestCoupleOfReferences(), text_array_comp_regions(), text_block(), text_block_else(), text_block_if(), text_comp_region(), text_complexity(), text_continuation_conditions(), text_directive(), text_entity_declaration(), text_equivalence_class(), text_instruction(), text_loop(), text_loop_default(), text_pointer_values(), text_points_to_relations(), text_region_no_action(), text_test(), text_trail(), text_transformer(), text_unstructured(), text_whileloop(), this_entity_cdeclaration(), tiling_transformation(), top_down_abc_array(), tp_substitutions(), tpips_behaves_like_a_shell(), tpips_init(), tpips_internal_error(), tpips_user_error(), trace_off(), trace_on(), transfer_cost(), transformer_list_closure_to_precondition_depth_two(), transformer_list_closure_to_precondition_max_depth(), transformer_list_multiple_closure_to_precondition(), transformers_intra_fast(), two_addresses_code_generator_split_p(), typedef_formal_parameter_to_stub_points_to(), unique_malloc_to_points_to_sinks(), unspaghettify_or_restructure_statement(), unspaghettify_statement(), unstructured_to_flow_insensitive_transformer(), unstructured_to_flow_sensitive_postconditions(), unstructured_to_transformer(), update_functional_type_with_actual_arguments(), user_call_to_points_to_sinks(), user_call_to_transformer(), values_for_current_module_intraprocedural_simple_effects(), variable_to_abstract_location(), verify_array_element(), verify_array_variable(), verify_scalar_variable(), whileloop_to_complexity(), whileloop_to_postcondition(), words_brace_expression(), words_comma_op(), words_declaration(), words_dimensions(), words_implied_do(), words_io_inst(), words_parameters(), words_regular_call(), words_stat_io_inst(), words_va_arg(), wpips_user_error_message(), wpips_user_log(), and xml_Chain_Graph().
char* get_cwd | ( | void | ) |
returns the current working directory name.
argh
Definition at line 486 of file file.c.
References PATH_MAX.
Referenced by direct_change_directory(), generate_directory_menu(), make_open_workspace(), pips_change_directory(), send_view_to_emacs(), show_directory(), and wpips_display_graph_file_display().
const char * get_string_property | ( | const char * | ) |
Referenced by activate_phases(), add_pragma(), c_basic_string(), c_head(), c_include(), call_load_store_p(), clean_statement_label(), common_subexpression_elimination(), delete_some_resources(), do_group_constants_terapix(), do_inlining(), do_loop_expansion_init(), do_solve_hardware_constraints(), do_statement_insertion(), do_unfolding(), dsc_code_parallelization(), entity_sesam_buffer_p(), fetch_complexity_parameters(), find_code_status(), fopen_config(), formal_label_replacement_p(), freia_is_transpose_call(), freia_terapix_call(), generate_compact(), generate_pseudo_formal_variable_for_formal_label(), generic_initializer(), generic_words_qualifiers(), get_clean_mod_name(), get_dma_name(), get_eole_command(), get_grouping_layout(), get_if_clause_policy(), get_model(), get_next_task_name(), get_variables_to_filter(), GetReturnCodeVariable(), gpu_ify_statement(), group_constants(), hbdsc_parallelization(), icm(), init_computation_intensity_param(), init_cost_table(), interface_basic_string(), isolate_statement(), kernel_load_store_generator(), load_atomic_profile(), local_tile_constraints(), loop_expansion(), loop_expansion_init(), loop_fully_unrollable_p(), make_eliminate_original_variables(), make_exec_statement_from_name(), make_get_rc_statement(), make_loadsave_statement(), make_phi_assign_instruction(), make_reduction_vector_entity(), make_required(), make_statement_copy_i(), MakeCurrentFunction(), malloc_to_points_to_sinks(), malloc_type_to_abstract_location(), normalize_microcode(), omp_merge_pragma(), opencl_compile_mergeable_dag(), optimize_expressions(), outline(), outliner(), outliner_independent_recursively(), parallel_tiling(), pp_style_p(), pragma_outliner(), prepend_call(), prepend_comment(), prettyprint_dot_dependence_graph(), print_code_or_source(), print_loopnest_dependence_cone(), print_parallel_statement(), print_parallelized_code_common(), print_parallelizedCMF_code(), print_parallelizedCRAFT_code(), print_sesam_tasks_buffers_header(), region_entity_variable_to_new_declare_entity(), rename_operator(), replace_sender_entity_by_receiver_entity_in_reference(), replicate_declaration(), reset_step_transform(), retrieve_a_missing_file_using_external_resolver(), sac_expression_reduction_p(), scalopragma(), select_fix_point_operator(), sesam_buffer_to_server_entity(), sesam_task_label_p(), set_current_optimization_strategy(), set_pattern(), set_prettyprint_language_from_property(), set_rc_function(), simd_load_call_p(), simd_store_call_p(), simd_work_call_p(), solve_hardware_constraints(), statement_phi_function_p(), step_install(), symbolic_tiling(), system_sorted_text_format(), text_entity_declaration(), tile_hyperplane_constraints(), tiling_transformation(), transformer_list_closure_to_precondition(), uses_alternate_return(), words_basic(), words_regular_call(), wp65(), and wrap_kernel_argument().
void list_files_in_directory | ( | gen_array_t | files, |
string | dir, | ||
string | re, | ||
bool(*)(const char *) | file_name_predicate | ||
) |
The same as the previous safe_list_files_in_directory() but with no return code and a call to user error if it cannot open the directory.
files | iles |
dir | ir |
re | e |
Definition at line 299 of file file.c.
References pips_user_error, and safe_list_files_in_directory().
Referenced by pips_get_fortran_list(), and pips_get_workspace_list().
Returns the allocated nth path from colon-separated path string.
path_list | the string that contains a colon-separated path |
n | the n-th instance to extract |
If the path is empty or if n is out-of-bound, NULL is returned. The resulting string is *not*escaped, and can contain spaces
Find the n-th part:
Out-of-bound...
Compute the length up to the COLON or the end of string:
path_list | ath_list |
Definition at line 362 of file file.c.
References COLON, and strndup().
Referenced by find_file_in_directories(), and include_path_to_include_flags().
char* pips_basename | ( | char * | fullpath, |
char * | suffix | ||
) |
fullpath | ullpath |
suffix | uffix |
Definition at line 822 of file file.c.
References pips_filename().
Referenced by compilation_unit_of_module(), csplit_open_compilation_unit(), get_new_user_file(), hpfc_fclose(), hpfc_fopen(), insert_check_alias_before_statement(), insert_flag_before_call_site(), insert_test_before_caller(), insert_test_before_statement(), module_name_to_input_file_name(), process_thru_fortran_pp(), step_install(), and used_before_set().
fullpath | ullpath |
Definition at line 837 of file file.c.
References strdup().
Referenced by filter_file(), and parse_arguments().
char* pips_filename | ( | char * | fullpath, |
char * | suffix, | ||
bool | short_p | ||
) |
Some OS do not define basename and dirname.
Others like DEC OSF1 do. So define them and use another name for them:
/some/path/to/file.suffix -> file
This may create conflicting file names, when the same source filename is used in different subdirectory as in:
create foo mod.c src/mod.c src/init/mod.c src/close/mod.c
To avoid the problem a larger part of the access path should be preserved. This can be done by substituting / by another character.
Drop the suffix
ok
Keep the basename only
fullpath[i+1:len]
Or substitute slashes by a neutral character
fullpath | ullpath |
suffix | uffix |
short_p | hort_p |
Definition at line 775 of file file.c.
References malloc(), SLASH_SUBSTITUTION_CHARACTER, and strndup().
Referenced by pips_basename(), and pips_initial_filename().
char* pips_initial_filename | ( | char * | fullpath, |
char * | suffix | ||
) |
The source file name access path is shortened or not depending on the property.
It is shorten if the name conflicts are not managed.
fullpath | ullpath |
suffix | uffix |
Definition at line 829 of file file.c.
References get_bool_property(), and pips_filename().
Referenced by process_thru_C_pp().
bool purge_directory | ( | char * | name | ) |
name | ame |
Definition at line 453 of file file.c.
References concatenate(), directory_exists_p(), and pips_user_warning.
Referenced by db_create_workspace().
|
static |
Definition at line 388 of file file.c.
References concatenate(), and strdup().
Referenced by find_file_in_directories().
out | where to output the file content |
file | the content of which is appended |
margin | number of spaces for shifting |
but_comments | do not shift F77 comment lines |
Definition at line 679 of file file.c.
References out, pips_internal_error, safe_fclose(), and safe_fopen().
Referenced by callgraph_module_name().
void safe_cat | ( | FILE * | out, |
FILE * | in | ||
) |
out | ut |
in | n |
Definition at line 669 of file file.c.
References out, pips_internal_error, and safe_fflush().
Referenced by handle_include_file(), safe_copy(), safe_display(), step_install(), and unsplit_internal().
void safe_copy | ( | char * | source, |
char * | target | ||
) |
source | ource |
target | arget |
Definition at line 706 of file file.c.
References out, safe_cat(), safe_fclose(), and safe_fopen().
Referenced by compile_a_pure_function(), compile_a_special_io_function(), and step_compile_generated_module().
Assumes "fn" is the name of a text file, opens it, and copies the lines whose number belongs to [f..l] into file descriptor "out", except if they have been generated by a C preprocessor.
Line starting with '#' are counted but not copied.
This function is used by the PIPS preprocessor and its parsers to print out the lines where an error has been detected.
Do not reproduce this line as it was generated by an external preprocessor whose behavior is not controlled
fn | n |
out | ut |
Definition at line 601 of file file.c.
References current_line, f(), MAX_INPUT_LINE_SIZE, out, pips_assert, safe_fclose(), safe_fgets(), and safe_fopen().
int safe_display | ( | char * | fname | ) |
Display a file through $PIPS_MORE (or $PAGER) if stdout is a TTY, on stdout otherwise.
Return false if the file couldn't be displayed.
fname | name |
Definition at line 722 of file file.c.
References exit, file_exists_p(), pips_internal_error, pips_user_error, safe_cat(), safe_fclose(), and safe_fopen().
Referenced by display(), and display_a_resource().
int safe_fclose | ( | FILE * | stream, |
const char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 77 of file file.c.
References pips_internal_error, and pips_user_irrecoverable_error.
Referenced by actual_c_parser(), actual_symbol_table_dump(), add_new_compilation_unit(), add_new_module_from_text(), alias_check(), build_aliases(), check_first_statement(), clean_file(), close_resource_file(), close_warning_file(), close_xml_logfile(), csplit_close_compilation_unit(), csplit_close_files(), csplit_copy(), dag_dot_dump(), davinci_dump_expressions(), davinci_print_control_nodes(), davinci_print_non_deterministic_unstructured(), direct_change_directory(), directive_in_file_p(), dump_current_statement(), f95split(), find_eol_coding(), flinter(), freia_compile(), freia_opencl_compile_calls(), full_graph_of_calls(), generic_print_xml_application(), get_first_main_module(), get_new_user_file(), gfc2pips_namespace(), gpu_xml_dump(), graph_of_calls(), handle_file_name(), handle_include_file(), hbdsc_parallelization(), hpfc_fclose(), html_prettyprint(), html_prettyprint_symbol_table(), load_entities(), load_meta_data(), make_resource_from_starting_node(), make_text_resource(), module_to_callgraph(), open_logfile(), open_makefile(), outliner_independent(), parse_arguments(), parse_makefile(), ParserError(), pips_process_file(), pips_split_file(), print_array_dfg(), print_bdt(), print_code_smalltalk(), print_crough(), print_dependence_or_chains_graph(), print_dinf_statistics(), print_dot_dependence_or_chains_graph(), print_dsup_statistics(), print_filtered_dg_or_dvdg(), print_interface(), print_loopnest_dependence_cone(), print_loops(), print_module_name_to_toposorts(), print_plc(), print_proj_op_statistics(), print_sesam_tasks_buffers_header(), print_umay_statistics(), print_umust_statistics(), print_xml_code(), print_xml_code_with_explicit_motif(), process_user_file(), put_result(), region_translation_statistics_close(), rice_dependence_graph(), safe_append(), safe_copy(), safe_copy_line_interval(), safe_display(), safe_get_line_interval(), safe_read_nth_line(), save_entities(), save_makefile(), save_meta_data(), sequence_dependence_graph(), step_compile_analysed_module(), step_compile_generated_module(), step_install(), text_area_included(), the_actual_parser(), tpips_close(), unimodular(), unsplit_internal(), used_before_set(), write_an_attachment_file(), write_to_eole(), and writeresult().
int safe_fflush | ( | FILE * | stream, |
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 90 of file file.c.
References pips_internal_error.
Referenced by safe_cat().
int safe_fgetc | ( | FILE * | stream, |
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 147 of file file.c.
References pips_internal_error.
char* safe_fgets | ( | char * | s, |
int | n, | ||
FILE * | stream, | ||
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 170 of file file.c.
References pips_internal_error.
Referenced by get_main_entity_name(), safe_copy_line_interval(), and safe_read_nth_line().
FILE* safe_fopen | ( | const char * | filename, |
const char * | what | ||
) |
filename | ilename |
what | hat |
Definition at line 67 of file file.c.
References f(), and pips_internal_error.
Referenced by actual_c_parser(), actual_symbol_table_dump(), add_new_compilation_unit(), add_new_module_from_text(), alias_check(), check_first_statement(), clean_file(), csplit(), csplit_open_compilation_unit(), dag_dot_dump(), davinci_dump_expressions(), davinci_print_control_nodes(), davinci_print_non_deterministic_unstructured(), direct_change_directory(), directive_in_file_p(), do_recompile_module(), dump_current_statement(), f95split(), find_eol_coding(), flinter(), fopen_config(), freia_compile(), freia_opencl_compile_calls(), full_graph_of_calls(), generic_print_xml_application(), get_first_main_module(), get_new_user_file(), gfc2pips_namespace(), gpu_xml_dump(), graph_of_calls(), handle_file_name(), handle_include_file(), hbdsc_parallelization(), Hierarchical_tiling(), hpfc_fopen(), html_prettyprint(), html_prettyprint_symbol_table(), load_entities(), make_resource_from_starting_node(), make_text_resource(), module_to_callgraph(), open_logfile(), open_resource_file(), open_warning_file(), open_xml_logfile(), outliner_independent(), pips_process_file(), pips_split_file(), print_array_dfg(), print_bdt(), print_code_smalltalk(), print_crough(), print_dependence_or_chains_graph(), print_dinf_statistics(), print_dot_dependence_or_chains_graph(), print_dsup_statistics(), print_filtered_dg_or_dvdg(), print_interface(), print_loopnest_dependence_cone(), print_loops(), print_module_name_to_toposorts(), print_plc(), print_proj_op_statistics(), print_sesam_tasks_buffers_header(), print_umay_statistics(), print_umust_statistics(), print_xml_code(), print_xml_code_with_explicit_motif(), process_user_file(), put_result(), read_from_eole(), region_translation_statistics_close(), rice_dependence_graph(), safe_append(), safe_copy(), safe_copy_line_interval(), safe_display(), safe_get_line_interval(), safe_read_nth_line(), save_entities(), save_makefile(), save_meta_data(), sc_delimiter(), sequence_dependence_graph(), step_compile_analysed_module(), step_compile_generated_module(), step_install(), text_area_included(), the_actual_parser(), Tiling2_buffer(), Tiling_buffer_allocation(), unimodular(), unsplit_internal(), used_before_set(), write_an_attachment_file(), write_to_eole(), and writeresult().
int safe_fputc | ( | char | c, |
FILE * | stream, | ||
char * | filename | ||
) |
int safe_fputs | ( | char * | s, |
FILE * | stream, | ||
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 203 of file file.c.
References pips_internal_error.
ptr | tr |
element_size | lement_size |
count | ount |
stream | tream |
filename | ilename |
Definition at line 214 of file file.c.
References count, and pips_internal_error.
FILE* safe_freopen | ( | char * | filename, |
char * | what, | ||
FILE * | stream | ||
) |
filename | ilename |
what | hat |
stream | tream |
Definition at line 99 of file file.c.
References f(), and pips_internal_error.
stream | tream |
offset | ffset |
wherefrom | herefrom |
filename | ilename |
Definition at line 112 of file file.c.
References offset, and pips_internal_error.
long int safe_ftell | ( | FILE * | stream, |
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 123 of file file.c.
References pips_internal_error.
ptr | tr |
element_size | lement_size |
count | ount |
stream | tream |
filename | ilename |
Definition at line 227 of file file.c.
References count, and pips_internal_error.
return lines f-l from file fn as a string
fn | n |
Definition at line 539 of file file.c.
References asprintf, f(), free(), line, pips_assert, safe_fclose(), safe_fopen(), safe_readline(), string_buffer_append(), string_buffer_free(), string_buffer_make(), and string_buffer_to_string().
Referenced by c_parser_user_warning_alist().
int safe_getc | ( | FILE * | stream, |
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 158 of file file.c.
References pips_internal_error.
void safe_link | ( | const char * | topath, |
const char * | frompath | ||
) |
Create a hard link to topath.
That means that the file is accessible with the new name frompath too.
Throw a pips_internal_error() if it fails.
topath | opath |
frompath | rompath |
Definition at line 878 of file file.c.
References pips_internal_error.
Referenced by add_new_module_from_text().
int safe_list_files_in_directory | ( | gen_array_t | files, |
string | dir, | ||
string | re, | ||
bool(*)(const char *) | file_name_predicate | ||
) |
returns a sorted arg list of files matching regular expression re in directory 'dir' and with file_name_predicate() returning true on the file name (for example use directory_exists_p to select directories, of file_exists_p to select regular files).
re has the ed syntax.
Return 0 on success, -1 on directory openning error.
files | iles |
dir | an allocated array |
re | the directory we're interested in |
file_name_predicate | regular expression condition to list a file |
Definition at line 250 of file file.c.
References concatenate(), free(), gen_array_dupaddto(), gen_array_sort(), pips_assert, pips_user_error, and strdup().
Referenced by generate_a_directory_menu(), hpfc_get_file_list(), and list_files_in_directory().
char* safe_new_tmp_file | ( | char * | prefix | ) |
SunOS forgets to declare this one.
extern char * mktemp(char *);
FI: mkstemp() is being deprecated and it returns an integer, usable as file descriptor, not a character string.
prefix | refix |
Definition at line 935 of file file.c.
References concatenate(), pips_assert, prefix, and strdup().
Referenced by apply_eole_on_statement(), and parse_arguments().
int safe_putc | ( | char | c, |
FILE * | stream, | ||
char * | filename | ||
) |
Assumes "fn" is the name of a text file, opens it, and returns its nth line (starting with 1) in a newly allocated buffer, whatever the line length.
Returns NULL if it does not exist.
This function is used by the PIPS preprocessor and its parsers to print out the line where an error has been detected.
fn | n |
Definition at line 523 of file file.c.
References current_line, MAX_INPUT_LINE_SIZE, safe_fclose(), safe_fgets(), safe_fopen(), and safe_readline().
Referenced by csplit_parser_warning_alist().
char* safe_readfile | ( | FILE * | file | ) |
returns the file as an allocated string.
is dropped at the time.
file | ile |
Definition at line 650 of file file.c.
References buf, free(), line, and safe_readline().
Referenced by safe_system_output().
char* safe_readline | ( | FILE * | file | ) |
returns the allocated line read, whatever its length.
returns NULL on EOF. also some asserts. FC 09/97.
larger for trailing '\0'
file | ile |
Definition at line 497 of file file.c.
References buf, free(), malloc(), pips_assert, and strdup().
Referenced by clean_file(), declarations_read(), default_user_request(), get_first_main_module(), get_help_topic(), get_help_topics(), get_next_line(), handle_file(), load_meta_data(), process_user_file(), safe_get_line_interval(), safe_read_nth_line(), and safe_readfile().
void safe_rewind | ( | FILE * | stream, |
char * | filename | ||
) |
stream | tream |
filename | ilename |
Definition at line 136 of file file.c.
References pips_internal_error.
void safe_symlink | ( | const char * | topath, |
const char * | frompath | ||
) |
topath | opath |
frompath | rompath |
Definition at line 862 of file file.c.
References pips_internal_error.
char* safe_system_output | ( | char * | what | ) |
attempt shell substitutions to what.
returns NULL on errors.
on failures, do not stop it anyway...
what | hat |
Definition at line 890 of file file.c.
References free(), pips_internal_error, pips_user_warning, and safe_readfile().
Referenced by safe_system_substitute().
char* safe_system_substitute | ( | char * | what | ) |
returns what after variable, command and file substitutions.
the returned string is newly allocated. it's NULL on errors.
what | hat |
Definition at line 919 of file file.c.
References concatenate(), and safe_system_output().
Referenced by tp_substitutions().
void safe_unlink | ( | const char * | file_name | ) |
Delete the given file.
Throw a pips_internal_error() if it fails.
file_name | ile_name |
Definition at line 852 of file file.c.
References file_name, and pips_internal_error.
Referenced by add_new_module_from_text(), apply_eole_on_statement(), filter_file(), and handle_include_file().
char* strescape | ( | const char * | source | ) |
protect a string, for example for use in a system call list of non escaped characters in the macro above.
source | ource |
Definition at line 334 of file file.c.
References malloc(), and to_escape.
Referenced by check_delete_workspace(), check_input_file_syntax(), and process_thru_C_pp().