NAME
C::Utility - utilities for generating C programs
convert_to_c_string
my $c_string = convert_to_c_string ($perl_string);
Convert a piece of text into a C string. Converts
my $string =<<EOF;
The quick "brown" fox
jumped over the lazy dog-a-roon.
EOF
into
"The quick \"brown\" fox\n"
"jumped over the lazy dog-a-roon.\n"
convert_to_c_pc
my $c_string = convert_to_c_pc ($string);
As "convert_to_c" but also with % (the percent character) converted to double-percent, for use in C format strings.
escape_string
my $escaped_string = escape_string ($normal_string);
Escape double quotes (") in a string with a backslash.
c_to_h_name
my $h_file = c_to_h_name ("frog.c");
# $h_file = "frog.h".
Make a .h filename from a .c filename.
ch_files
Make a .h filename from a .c filename. Back up both C and .h files.
valid_c_variable
valid_c_variable ($variable_name);
Returns 1 if $variable_name is a valid C variable, the undefined value otherwise.
print_top_h_wrapper
print_top_h_wrapper ($file_handle, $file_name);
# Prints #ifndef wrapper at top of file.
Print an include wrapper for a .h file.
print_bottom_h_wrapper
print_bottom_h_wrapper ($file_handle, $file_name);
Print an include wrapper for a .h file.
print_include
print_include ($file_handle, $file_name);
Print an #include statement for a .h file
hash_to_c_file
Output a hash as a set of const char * strings. This is to be used in things like a deployment of a C program which contains its own version as a string.
line_directive
line_directive ($fh, 42, "file.x")
!!!!! #line 42 "file.x"
Print a C preprocessor #line directive to $fh.
brute_force_line
brute_force_line ($input_file, $output_file);
Put #line directives on every line of a file. This is a fix used to force line numbers into a file before it is processed by Template.
add_lines
my $text = add_lines ($file);
Replace the string #line in the file with a C -style line directive before it is processed by Template.
AUTHOR
Ben Bullock, <bkb@cpan.org>
COPYRIGHT AND LICENSE
This module and its associated files are copyright (C) 2012 Ben Bullock. They may be copied, used, modified and distributed under the same terms as the Perl programming language.