Changeset View
Changeset View
Standalone View
Standalone View
indent_globs.h
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | #define CHECK_SIZE_CODE \ | ||||
} | } | ||||
#define CHECK_SIZE_COM \ | #define CHECK_SIZE_COM \ | ||||
if (e_com >= l_com) { \ | if (e_com >= l_com) { \ | ||||
int nsize = l_com-s_com+400; \ | int nsize = l_com-s_com+400; \ | ||||
combuf = (char *) realloc(combuf, nsize); \ | combuf = (char *) realloc(combuf, nsize); \ | ||||
if (combuf == NULL) \ | if (combuf == NULL) \ | ||||
err(1, NULL); \ | err(1, NULL); \ | ||||
e_com = combuf + (e_com-s_com) + 1; \ | e_com = combuf + (e_com-s_com) + 1; \ | ||||
last_bl = combuf + (last_bl-s_com) + 1; \ | |||||
l_com = combuf + nsize - 5; \ | l_com = combuf + nsize - 5; \ | ||||
s_com = combuf + 1; \ | s_com = combuf + 1; \ | ||||
jilles: If you're changing this code anyway, please also fix the undefined behaviour of using pointers… | |||||
Not Done Inline ActionsFixed. pstef: Fixed. | |||||
Not Done Inline ActionsLooks good to me. The fifth realloc() call, in io.c, was already correct. jilles: Looks good to me. The fifth realloc() call, in io.c, was already correct. | |||||
} | } | ||||
#define CHECK_SIZE_LAB \ | #define CHECK_SIZE_LAB \ | ||||
if (e_lab >= l_lab) { \ | if (e_lab >= l_lab) { \ | ||||
int nsize = l_lab-s_lab+400; \ | int nsize = l_lab-s_lab+400; \ | ||||
labbuf = (char *) realloc(labbuf, nsize); \ | labbuf = (char *) realloc(labbuf, nsize); \ | ||||
if (labbuf == NULL) \ | if (labbuf == NULL) \ | ||||
err(1, NULL); \ | err(1, NULL); \ | ||||
e_lab = labbuf + (e_lab-s_lab) + 1; \ | e_lab = labbuf + (e_lab-s_lab) + 1; \ | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | int extra_expression_indent; /* true if continuation lines from the | ||||
* they don't conflict with the code | * they don't conflict with the code | ||||
* that follows */ | * that follows */ | ||||
int function_brace_split; /* split function declaration and | int function_brace_split; /* split function declaration and | ||||
* brace onto separate lines */ | * brace onto separate lines */ | ||||
int use_tabs; /* set true to use tabs for spacing, | int use_tabs; /* set true to use tabs for spacing, | ||||
* false uses all spaces */ | * false uses all spaces */ | ||||
int auto_typedefs; /* set true to recognize identifiers | int auto_typedefs; /* set true to recognize identifiers | ||||
* ending in "_t" like typedefs */ | * ending in "_t" like typedefs */ | ||||
int space_after_cast; /* "b = (int) a" vs "b = (int)a" */ | |||||
/* -troff font state information */ | /* -troff font state information */ | ||||
struct fstate { | struct fstate { | ||||
char font[4]; | char font[4]; | ||||
char size; | char size; | ||||
int allcaps:1; | int allcaps:1; | ||||
} __aligned(sizeof(int)); | } __aligned(sizeof(int)); | ||||
Show All 16 Lines | struct parser_state { | ||||
int p_stack[STACKSIZE]; /* this is the parsers stack */ | int p_stack[STACKSIZE]; /* this is the parsers stack */ | ||||
int il[STACKSIZE]; /* this stack stores indentation levels */ | int il[STACKSIZE]; /* this stack stores indentation levels */ | ||||
float cstk[STACKSIZE];/* used to store case stmt indentation levels */ | float cstk[STACKSIZE];/* used to store case stmt indentation levels */ | ||||
int box_com; /* set to true when we are in a "boxed" | int box_com; /* set to true when we are in a "boxed" | ||||
* comment. In that case, the first non-blank | * comment. In that case, the first non-blank | ||||
* char should be lined up with the / in / followed by * */ | * char should be lined up with the / in / followed by * */ | ||||
int comment_delta, | int comment_delta, | ||||
n_comment_delta; | n_comment_delta; | ||||
int cast_mask; /* indicates which close parens close off | int cast_mask; /* indicates which close parens potentially | ||||
* casts */ | * close off casts */ | ||||
int sizeof_mask; /* indicates which close parens close off | int not_cast_mask; /* indicates which close parens definitely | ||||
* sizeof''s */ | * close off something else than casts */ | ||||
int block_init; /* true iff inside a block initialization */ | int block_init; /* true iff inside a block initialization */ | ||||
int block_init_level; /* The level of brace nesting in an | int block_init_level; /* The level of brace nesting in an | ||||
* initialization */ | * initialization */ | ||||
int last_nl; /* this is true if the last thing scanned was | int last_nl; /* this is true if the last thing scanned was | ||||
* a newline */ | * a newline */ | ||||
int in_or_st; /* Will be true iff there has been a | int in_or_st; /* Will be true iff there has been a | ||||
* declarator (e.g. int or char) and no left | * declarator (e.g. int or char) and no left | ||||
* paren since the last semicolon. When true, | * paren since the last semicolon. When true, | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | int use_ff; /* set to one if the current line should be | ||||
* terminated with a form feed */ | * terminated with a form feed */ | ||||
int want_blank; /* set to true when the following token should | int want_blank; /* set to true when the following token should | ||||
* be prefixed by a blank. (Said prefixing is | * be prefixed by a blank. (Said prefixing is | ||||
* ignored in some cases.) */ | * ignored in some cases.) */ | ||||
int else_if; /* True iff else if pairs should be handled | int else_if; /* True iff else if pairs should be handled | ||||
* specially */ | * specially */ | ||||
int decl_indent; /* column to indent declared identifiers to */ | int decl_indent; /* column to indent declared identifiers to */ | ||||
int local_decl_indent; /* like decl_indent but for locals */ | int local_decl_indent; /* like decl_indent but for locals */ | ||||
int its_a_keyword; | int keyword; /* the type of a keyword or 0 */ | ||||
int sizeof_keyword; | |||||
int dumped_decl_indent; | int dumped_decl_indent; | ||||
float case_indent; /* The distance to indent case labels from the | float case_indent; /* The distance to indent case labels from the | ||||
* switch statement */ | * switch statement */ | ||||
int in_parameter_declaration; | int in_parameter_declaration; | ||||
int indent_parameters; | int indent_parameters; | ||||
int tos; /* pointer to top of stack */ | int tos; /* pointer to top of stack */ | ||||
char procname[100]; /* The name of the current procedure */ | char procname[100]; /* The name of the current procedure */ | ||||
int just_saw_decl; | int just_saw_decl; | ||||
} ps; | } ps; | ||||
int ifdef_level; | int ifdef_level; | ||||
int rparen_count; | int rparen_count; | ||||
struct parser_state state_stack[5]; | struct parser_state state_stack[5]; | ||||
struct parser_state match_state[5]; | struct parser_state match_state[5]; |
If you're changing this code anyway, please also fix the undefined behaviour of using pointers derived from the original pointer after a successful call to realloc(). This can be done by calculating e_com-s_com and last_bl-s_com before calling realloc().