osprey/kg++fe/gnu/protoize.c File Reference

#include "config.h"
#include "system.h"
#include "intl.h"
#include "cppdefault.h"
#include <setjmp.h>
#include <signal.h>
#include "version.h"
#include "getopt.h"

Include dependency graph for protoize.c:

Go to the source code of this file.

Data Types

type  string_list
type  hash_table_entry_struct
type  file_info_struct
type  f_list_chain_item_struct
type  def_dec_info_struct

Defines

#define IS_SAME_PATH_CHAR(a, b)   ((a) == (b))
#define IS_SAME_PATH(a, b)   (strcmp (a, b) == 0)
#define AUX_INFO_SUFFIX   ".X"
#define SAVE_SUFFIX   ".save"
#define CPLUS_FILE_SUFFIX   "C"
#define NONCONST
#define STANDARD_EXEC_PREFIX   "/usr/local/lib/gcc-lib/"
#define HASH_TABLE_SIZE   (1 << 9)
#define ddip   _info._ddip
#define fip   _info._fip

Typedefs

typedef struct unexpansion_struct unexpansion
typedef struct
hash_table_entry_struct 
hash_table_entry
typedef struct def_dec_info_struct def_dec_info
typedef struct file_info_struct file_info
typedef struct
f_list_chain_item_struct 
f_list_chain_item
typedef hash_table_entry hash_table [HASH_TABLE_SIZE]

Functions/Subroutines

static void usage PARAMS ((void))
static struct string_list
*string_list_cons 
PARAMS ((const char *, struct string_list *))
static int is_syscalls_file PARAMS ((const file_info *))
static void rename_c_file PARAMS ((const hash_table_entry *))
static const def_dec_info
*find_extern_def 
PARAMS ((const def_dec_info *, const def_dec_info *))
static const def_dec_info
*find_static_definition 
PARAMS ((const def_dec_info *))
static void add_local_decl PARAMS ((const def_dec_info *, const char *))
static void add_global_decls PARAMS ((const file_info *, const char *))
static void visit_each_hash_node PARAMS ((const hash_table_entry *, void(*)(const hash_table_entry *)))
static hash_table_entry *add_symbol PARAMS ((hash_table_entry *, const char *))
static void free_def_dec PARAMS ((def_dec_info *))
static file_info *find_file PARAMS ((const char *, int))
static int edit_formals_lists PARAMS ((const char *, unsigned int, const def_dec_info *))
static void notice VPARAMS ((const char *msgid,...))
static char * savestring (char *input, unsigned int size) const
void fancy_abort ()
static char * dupnstr (char *s, size_t n) const
static const char * substr (char *s1, const char *const s2) const
static int safe_read (int desc, PTR ptr, int len)
static void safe_write (int desc, PTR ptr, int len, const char *out_fname)
static void save_pointers ()
static void restore_pointers ()
static int is_id_char (int ch)
static void usage ()
static int in_system_include_dir (char *path) const
static int is_syscalls_file (file_info *fi_p) const
static int needs_to_be_converted (file_info *file_p) const
static int directory_specified_p (char *name) const
static int file_excluded_p (char *name) const
static struct string_liststring_list_cons (char *string, struct string_list *rest) const
static void visit_each_hash_node (hash_table_entry *hash_tab_p, func) const
static hash_table_entryadd_symbol (hash_table_entry *p, const char *s)
static hash_table_entrylookup (hash_table_entry *hash_tab_p, const char *search_symbol)
static void free_def_dec (def_dec_info *p)
static char * unexpand_if_needed (char *aux_info_line) const
static int is_abspath (char *path) const
static char * abspath (char *cwd, const char *rel_filename) const
static const char * shortpath (char *cwd, const char *filename) const
static file_infofind_file (char *filename, int do_not_stat) const
static void aux_info_corrupted ()
static void check_aux_info (int cond)
static const char * find_corresponding_lparen (char *p) const
static int referenced_file_is_newer (char *l, time_t aux_info_mtime) const
static void save_def_or_dec (char *l, int is_syscalls) const
static void munge_compile_params (char *params_list) const
static int gen_aux_info_file (char *base_filename) const
static void process_aux_info_file (char *base_source_filename, int keep_it, int is_syscalls) const
static void rename_c_file (hash_table_entry *hp) const
static void reverse_def_dec_list (hash_table_entry *hp) const
static const def_dec_infofind_extern_def (def_dec_info *head, const def_dec_info *user) const
static const def_dec_infofind_static_definition (def_dec_info *user) const
static void connect_defs_and_decs (hash_table_entry *hp) const
static int identify_lineno (char *clean_p) const
static void declare_source_confusing (char *clean_p) const
static void check_source (int cond, const char *clean_p)
static const char * seek_to_line (int n)
static const char * forward_to_next_token_char (char *ptr) const
static void output_bytes (char *str, size_t len) const
static void output_string (char *str) const
static void output_up_to (char *p) const
static int other_variable_style_function (char *ansi_header) const
static void edit_fn_declaration (def_dec_info *def_dec_p, const char *volatile clean_text_p) const
static int edit_formals_lists (char *end_formals, unsigned int f_list_count, const def_dec_info *def_dec_p) const
static const char * find_rightmost_formals_list (char *clean_text_p) const
static void add_local_decl (def_dec_info *def_dec_p, const char *clean_text_p) const
static void add_global_decls (file_info *file_p, const char *clean_text_p) const
static void edit_fn_definition (def_dec_info *def_dec_p, const char *clean_text_p) const
static void do_cleaning (char *new_clean_text_base, const char *new_clean_text_limit)
static const char * careful_find_l_paren (char *p) const
static void scan_for_missed_items (file_info *file_p) const
static void edit_file (hash_table_entry *hp) const
static void do_processing ()
int main PARAMS ((int, char **const))
int main (int argc, char **const argv)

Variables

static const unexpansion unexpansions []
static const int hash_mask = (HASH_TABLE_SIZE - 1)
struct string_listdirectory_list
struct string_listexclude_list
static const char *const other_var_style = "varargs"
static const char * varargs_style_indicator = STRINGX (va_alist)
static const char * pname
static int errors = 0
static const char * compiler_file_name = "gcc"
static int version_flag = 0
static int quiet_flag = 0
static int nochange_flag = 0
static int nosave_flag = 0
static int keep_flag = 0
static const char ** compile_params = 0
static int local_flag = 0
static int global_flag = 0
static int cplusplus_flag = 0
static const char * nondefault_syscalls_dir = 0
static int input_file_name_index = 0
static int aux_info_file_name_index = 0
static int n_base_source_files = 0
static const char ** base_source_filenames
static int current_aux_info_lineno
static const char * convert_filename
static const char * invocation_filename
static const char * orig_text_base
static const char * orig_text_limit
static const char * clean_text_base
static const char * clean_text_limit
static const char * clean_read_ptr
static char * repl_text_base
static char * repl_text_limit
static char * repl_write_ptr
static const char * last_known_line_start
static int last_known_line_number
static hash_table filename_primary
static hash_table function_name_primary
static jmp_buf source_confusion_recovery
static char * cwd_buffer
static const char * saved_clean_read_ptr
static char * saved_repl_write_ptr
static struct option longopts []


Define Documentation

#define AUX_INFO_SUFFIX   ".X"

Definition at line 59 of file protoize.c.

#define CPLUS_FILE_SUFFIX   "C"

Definition at line 73 of file protoize.c.

#define ddip   _info._ddip

Definition at line 294 of file protoize.c.

#define fip   _info._fip

Definition at line 295 of file protoize.c.

Referenced by __attribute__().

#define HASH_TABLE_SIZE   (1 << 9)

Definition at line 188 of file protoize.c.

#define IS_SAME_PATH ( a,
b   )     (strcmp (a, b) == 0)

Definition at line 52 of file protoize.c.

Referenced by rename_c_file().

#define IS_SAME_PATH_CHAR ( a,
b   )     ((a) == (b))

Definition at line 45 of file protoize.c.

Referenced by shortpath().

#define NONCONST

#define SAVE_SUFFIX   ".save"

Definition at line 66 of file protoize.c.

#define STANDARD_EXEC_PREFIX   "/usr/local/lib/gcc-lib/"


Typedef Documentation

Definition at line 245 of file protoize.c.

Definition at line 247 of file protoize.c.

Definition at line 246 of file protoize.c.

typedef hash_table_entry hash_table[HASH_TABLE_SIZE]

Definition at line 299 of file protoize.c.

Definition at line 241 of file protoize.c.

typedef struct unexpansion_struct unexpansion

Definition at line 170 of file protoize.c.


Function Documentation

static char* abspath ( char *  cwd,
const char *  rel_filename 
) const [static]

static void add_global_decls ( file_info file_p,
const char *  clean_text_p 
) const [static]

static void add_local_decl ( def_dec_info def_dec_p,
const char *  clean_text_p 
) const [static]

static hash_table_entry* add_symbol ( hash_table_entry p,
const char *  s 
) [static]

Definition at line 968 of file protoize.c.

References NULL, and xstrdup().

Referenced by lookup().

static void aux_info_corrupted ( void   )  [static]

Definition at line 1393 of file protoize.c.

References exit(), FATAL_EXIT_CODE, and notice().

Referenced by check_aux_info().

static const char* careful_find_l_paren ( char *  p  )  const [static]

Definition at line 3887 of file protoize.c.

References check_source(), and q.

Referenced by scan_for_missed_items().

static void check_aux_info ( int  cond  )  [static]

Definition at line 1404 of file protoize.c.

References aux_info_corrupted().

Referenced by referenced_file_is_newer(), and save_def_or_dec().

static void check_source ( int  cond,
const char *  clean_p 
) [static]

static void connect_defs_and_decs ( hash_table_entry hp  )  const [static]

static void declare_source_confusing ( char *  clean_p  )  const [static]

Definition at line 2809 of file protoize.c.

References identify_lineno(), longjmp(), notice(), NULL, and shortpath().

Referenced by check_source().

static int directory_specified_p ( char *  name  )  const [static]

Definition at line 878 of file protoize.c.

References IS_DIR_SEPARATOR, string_list::name, string_list::next, p, q, strlen(), and strncmp().

Referenced by edit_file().

static void do_cleaning ( char *  new_clean_text_base,
const char *  new_clean_text_limit 
) [static]

Definition at line 3781 of file protoize.c.

References abort, and ISSPACE.

Referenced by edit_file().

static void do_processing ( void   )  [static]

static char* dupnstr ( char *  s,
size_t  n 
) const [static]

Definition at line 550 of file protoize.c.

References strncpy(), and xmalloc().

Referenced by edit_formals_lists(), munge_compile_params(), and save_def_or_dec().

static void edit_file ( hash_table_entry hp  )  const [static]

static void edit_fn_declaration ( def_dec_info def_dec_p,
const char *volatile  clean_text_p 
) const [static]

static void edit_fn_definition ( def_dec_info def_dec_p,
const char *  clean_text_p 
) const [static]

static int edit_formals_lists ( char *  end_formals,
unsigned int  f_list_count,
const def_dec_info def_dec_p 
) const [static]

void fancy_abort ( void   ) 

Definition at line 540 of file protoize.c.

References exit(), FATAL_EXIT_CODE, and notice().

static int file_excluded_p ( char *  name  )  const [static]

Definition at line 905 of file protoize.c.

References IS_DIR_SEPARATOR, len, string_list::name, string_list::next, p, strcmp(), and strlen().

Referenced by edit_file().

static const char* find_corresponding_lparen ( char *  p  )  const [static]

Definition at line 1416 of file protoize.c.

References q.

Referenced by save_def_or_dec().

static const def_dec_info* find_extern_def ( def_dec_info head,
const def_dec_info user 
) const [static]

static file_info* find_file ( char *  filename,
int  do_not_stat 
) const [static]

static const char* find_rightmost_formals_list ( char *  clean_text_p  )  const [static]

Definition at line 3321 of file protoize.c.

References check_source(), forward_to_next_token_char(), ISALPHA, and ISSPACE.

Referenced by add_global_decls(), and edit_fn_definition().

static const def_dec_info* find_static_definition ( def_dec_info user  )  const [static]

static const char* forward_to_next_token_char ( char *  ptr  )  const [static]

Definition at line 2874 of file protoize.c.

References check_source(), and ISSPACE.

Referenced by add_local_decl(), edit_fn_declaration(), and find_rightmost_formals_list().

static void free_def_dec ( def_dec_info p  )  [static]

Definition at line 1018 of file protoize.c.

References f_list_chain_item_struct::chain_next, free(), next, and NONCONST.

Referenced by save_def_or_dec().

static int gen_aux_info_file ( char *  base_filename  )  const [static]

static int identify_lineno ( char *  clean_p  )  const [static]

static int in_system_include_dir ( char *  path  )  const [static]

static int is_abspath ( char *  path  )  const [static]

Definition at line 1120 of file protoize.c.

References HAVE_DOS_BASED_FILE_SYSTEM, and IS_DIR_SEPARATOR.

Referenced by abspath(), in_system_include_dir(), and process_aux_info_file().

static int is_id_char ( int  ch  )  [static]

static int is_syscalls_file ( file_info fi_p  )  const [static]

Definition at line 819 of file protoize.c.

References f, strcmp(), and strlen().

Referenced by find_extern_def(), and needs_to_be_converted().

static hash_table_entry* lookup ( hash_table_entry hash_tab_p,
const char *  search_symbol 
) [static]

int main ( int argc  ,
char **const  argv 
)

static void munge_compile_params ( char *  params_list  )  const [static]

Definition at line 1890 of file protoize.c.

References access, alloca, dupnstr(), HOST_BIT_BUCKET, ISSPACE, memcpy, NULL, S_ISDIR, stat::st_mode, strlen(), W_OK, and xmalloc().

Referenced by gen_aux_info_file(), and main().

static int needs_to_be_converted ( file_info file_p  )  const [static]

static int other_variable_style_function ( char *  ansi_header  )  const [static]

Definition at line 2955 of file protoize.c.

References is_id_char(), len, p, strlen(), and substr().

Referenced by edit_fn_declaration(), and edit_fn_definition().

static void output_bytes ( char *  str,
size_t  len 
) const [static]

Definition at line 2888 of file protoize.c.

References memcpy, and xrealloc().

Referenced by add_local_decl(), edit_fn_definition(), output_string(), and output_up_to().

static void output_string ( char *  str  )  const [static]

static void output_up_to ( char *  p  )  const [static]

int main PARAMS ( (int, char **const)   ) 

static int edit_formals_lists PARAMS ( (const char *, unsigned int, const def_dec_info *)   )  [static]

static file_info* find_file PARAMS ( (const char *, int)   )  [static]

static void free_def_dec PARAMS ( (def_dec_info *)   )  [static]

static hash_table_entry* add_symbol PARAMS ( (hash_table_entry *, const char *)   )  [static]

static void visit_each_hash_node PARAMS ( (const hash_table_entry *, void(*)(const hash_table_entry *))   )  [static]

static void add_global_decls PARAMS ( (const file_info *, const char *)   )  [static]

static void add_local_decl PARAMS ( (const def_dec_info *, const char *)   )  [static]

static const def_dec_info* find_static_definition PARAMS ( (const def_dec_info *)   )  [static]

static const def_dec_info* find_extern_def PARAMS ( (const def_dec_info *, const def_dec_info *)   )  [static]

static void rename_c_file PARAMS ( (const hash_table_entry *)   )  [static]

static int is_syscalls_file PARAMS ( (const file_info *)   )  [static]

static struct string_list* string_list_cons PARAMS ( (const char *, struct string_list *)   )  [static, read]

static void usage PARAMS ( (void  )  [static]

Definition at line 76 of file protoize.c.

static void process_aux_info_file ( char *  base_source_filename,
int  keep_it,
int  is_syscalls 
) const [static]

static int referenced_file_is_newer ( char *  l,
time_t  aux_info_mtime 
) const [static]

static void rename_c_file ( hash_table_entry hp  )  const [static]

Definition at line 2371 of file protoize.c.

References alloca, errno, filename, IS_SAME_PATH, notice(), NULL, rename(), shortpath(), strcpy, strlen(), and xstrerror().

Referenced by do_processing().

static void restore_pointers ( void   )  [static]

static void reverse_def_dec_list ( hash_table_entry hp  )  const [static]

Definition at line 2414 of file protoize.c.

References if(), next, def_dec_info_struct::next_in_file, NULL, and prev.

Referenced by do_processing().

static int safe_read ( int  desc,
PTR  ptr,
int  len 
) [static]

Definition at line 589 of file protoize.c.

References errno, and read.

Referenced by edit_file(), and process_aux_info_file().

static void safe_write ( int  desc,
PTR  ptr,
int  len,
const char *  out_fname 
) [static]

Definition at line 618 of file protoize.c.

References errno, notice(), NULL, shortpath(), write, and xstrerror().

Referenced by edit_file().

static void save_def_or_dec ( char *  l,
int  is_syscalls 
) const [static]

static void save_pointers ( void   )  [static]

static char* savestring ( char *  input,
unsigned int  size 
) const [static]

Definition at line 527 of file protoize.c.

References strcpy, and xmalloc().

Referenced by abspath(), main(), and unexpand_if_needed().

static void scan_for_missed_items ( file_info file_p  )  const [static]

static const char* seek_to_line ( int  n  )  [static]

Definition at line 2854 of file protoize.c.

References abort, and check_source().

Referenced by edit_file().

static const char* shortpath ( char *  cwd,
const char *  filename 
) const [static]

static struct string_list* string_list_cons ( char *  string,
struct string_list rest 
) const [static, read]

Definition at line 923 of file protoize.c.

References string_list::name, string_list::next, and xmalloc().

Referenced by main().

static const char* substr ( char *  s1,
const char *const  s2 
) const [static]

Definition at line 565 of file protoize.c.

References c, p1, and p2.

Referenced by find_extern_def(), and other_variable_style_function().

static char* unexpand_if_needed ( char *  aux_info_line  )  const [static]

Definition at line 1045 of file protoize.c.

References is_id_char(), len, line_buf, offset, s, savestring(), size, strcpy, strlen(), strncmp(), xmalloc(), and xrealloc().

Referenced by process_aux_info_file().

static void usage ( void   )  [static]

Definition at line 675 of file protoize.c.

References exit(), FATAL_EXIT_CODE, and notice().

static void visit_each_hash_node ( hash_table_entry hash_tab_p,
func   
) const [static]

static void notice VPARAMS ( (const char *msgid,...)   )  [static]

Definition at line 514 of file protoize.c.

References _, VA_CLOSE, VA_FIXEDARG, VA_OPEN, and vfprintf().


Variable Documentation

int aux_info_file_name_index = 0 [static]

Definition at line 405 of file protoize.c.

const char** base_source_filenames [static]

Definition at line 414 of file protoize.c.

const char* clean_read_ptr [static]

Definition at line 455 of file protoize.c.

const char* clean_text_base [static]

Definition at line 445 of file protoize.c.

const char* clean_text_limit [static]

Definition at line 450 of file protoize.c.

const char** compile_params = 0 [static]

Definition at line 385 of file protoize.c.

const char* compiler_file_name = "gcc" [static]

Definition at line 377 of file protoize.c.

const char* convert_filename [static]

Definition at line 424 of file protoize.c.

Referenced by process_command().

int cplusplus_flag = 0 [static]

Definition at line 392 of file protoize.c.

Definition at line 420 of file protoize.c.

char* cwd_buffer [static]

Definition at line 500 of file protoize.c.

Referenced by cwh_dst_init_file(), and DST_build().

Definition at line 207 of file protoize.c.

int errors = 0 [static]

Definition at line 369 of file protoize.c.

Definition at line 213 of file protoize.c.

Definition at line 487 of file protoize.c.

Definition at line 491 of file protoize.c.

int global_flag = 0 [static]

Definition at line 391 of file protoize.c.

const int hash_mask = (HASH_TABLE_SIZE - 1) [static]

Definition at line 192 of file protoize.c.

int input_file_name_index = 0 [static]

Definition at line 401 of file protoize.c.

const char* invocation_filename [static]

Definition at line 430 of file protoize.c.

int keep_flag = 0 [static]

Definition at line 384 of file protoize.c.

int last_known_line_number [static]

Definition at line 483 of file protoize.c.

const char* last_known_line_start [static]

Definition at line 477 of file protoize.c.

int local_flag = 0 [static]

Definition at line 390 of file protoize.c.

struct option longopts[] [static]

Initial value:

{
  {"version", 0, 0, 'V'},
  {"file_name", 0, 0, 'p'},
  {"quiet", 0, 0, 'q'},
  {"silent", 0, 0, 'q'},
  {"force", 0, 0, 'f'},
  {"keep", 0, 0, 'k'},
  {"nosave", 0, 0, 'N'},
  {"nochange", 0, 0, 'n'},
  {"compiler-options", 1, 0, 'c'},
  {"exclude", 1, 0, 'x'},
  {"directory", 1, 0, 'd'},



  {"local", 0, 0, 'l'},
  {"global", 0, 0, 'g'},
  {"c++", 0, 0, 'C'},
  {"syscalls-dir", 1, 0, 'B'},

  {0, 0, 0, 0}
}

Definition at line 4483 of file protoize.c.

Referenced by parse_args().

int n_base_source_files = 0 [static]

Definition at line 409 of file protoize.c.

int nochange_flag = 0 [static]

Definition at line 381 of file protoize.c.

const char* nondefault_syscalls_dir = 0 [static]

Definition at line 393 of file protoize.c.

int nosave_flag = 0 [static]

Definition at line 383 of file protoize.c.

const char* orig_text_base [static]

Definition at line 435 of file protoize.c.

Referenced by Setup_Text_Section_For_PU().

const char* orig_text_limit [static]

Definition at line 440 of file protoize.c.

const char* const other_var_style = "varargs" [static]

Definition at line 227 of file protoize.c.

const char* pname [static]

int quiet_flag = 0 [static]

Definition at line 380 of file protoize.c.

char* repl_text_base [static]

Definition at line 460 of file protoize.c.

char* repl_text_limit [static]

Definition at line 465 of file protoize.c.

char* repl_write_ptr [static]

Definition at line 471 of file protoize.c.

const char* saved_clean_read_ptr [static]

Definition at line 505 of file protoize.c.

char* saved_repl_write_ptr [static]

Definition at line 510 of file protoize.c.

Definition at line 496 of file protoize.c.

const unexpansion unexpansions[] [static]

Initial value:

 {
  { "struct _iobuf", "FILE" },
  { 0, 0 }
}

Definition at line 179 of file protoize.c.

const char* varargs_style_indicator = STRINGX (va_alist) [static]

Definition at line 230 of file protoize.c.

int version_flag = 0 [static]

Definition at line 379 of file protoize.c.

Referenced by c_common_init(), and process_options().


Generated on Wed Apr 8 15:42:06 2009 for Open64 by  doxygen 1.5.6