home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
utilities
/
utilsf
/
indent
/
Source
/
h
/
indntglobs
< prev
Wrap
Text File
|
1995-10-30
|
13KB
|
297 lines
/*
* Copyright 1989 Object Design, Inc.
* Copyright (c) 1985 Sun Microsystems, Inc.
* Copyright (c) 1980 The Regents of the University of California.
* Copyright (c) 1976 Board of Trustees of the University of Illinois.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley, the University of Illinois,
* Urbana, and Sun Microsystems, Inc. The name of either University
* or Sun Microsystems may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#)indent_globs.h 5.7 (Berkeley) 9/15/88
*/
/* Archimedes port by Steven Flintham
Wednesday 25th October 1995
Friday 27th October 1995
Saturday 28th October 1995
Monday 30th October 1995 */
/* SF: None of the external variables declared in this file had the extern
keyword prefixing them. See the accompanying documentation for more
details. */
#include <stdio.h>
#ifndef __riscos /* SF */
#include <memory.h> /* gst: 3/24/89 */
#endif /* __riscos */
#define BACKSLASH '\\'
#define bufsize 200 /* size of internal buffers */
#define inp_bufs 600 /* size of input buffer */
#define sc_size 5000 /* size of save_com buffer */
#define label_offset 2 /* number of levels a label is placed to left
* of code */
#define cplus_ppp_indent 2 /* spaces to indent public, private, protected in c++ */
#define tabsize 8 /* the size of a tab */
#define tabmask 0177770 /* mask used when figuring length of lines
* with tabs */
#define false 0
#define true 1
extern FILE *input; /* the fid for the input file */
extern FILE *output; /* the output file */
/* SF: changed to use ## */
#define check_size(name) \
if (e_##name >= l_##name) { \
register nsize = l_##name-s_##name+400; \
name##buf = (char *) realloc(name##buf, nsize); \
e_##name = name##buf + (e_##name-s_##name) + 1; \
l_##name = name##buf + nsize - 5; \
s_##name = name##buf + 1; \
}
extern char *labbuf; /* buffer for label */
extern char *s_lab; /* start ... */
extern char *e_lab; /* .. and end of stored label */
extern char *l_lab; /* limit of label buffer */
extern char *codebuf; /* buffer for code section */
extern char *s_code; /* start ... */
extern char *e_code; /* .. and end of stored code */
extern char *l_code; /* limit of code section */
extern char *combuf; /* buffer for comments */
extern char *s_com; /* start ... */
extern char *e_com; /* ... and end of stored comments */
extern char *l_com; /* limit of comment buffer */
extern char in_buffer[inp_bufs];/* input buffer */
extern char *buf_ptr; /* ptr to next character to be taken from
* in_buffer */
extern char *buf_end; /* ptr to first after last char in in_buffer */
extern char save_com[sc_size]; /* input text is saved here when looking for
* the brace after an if, while, etc */
extern char *sc_end; /* pointer into save_com buffer */
extern char *bp_save; /* saved value of buf_ptr when taking input
* from save_com */
extern char *be_save; /* similarly saved value of buf_end */
extern char token[bufsize]; /* the last token scanned */
extern int cplus; /* c++ */
extern int pointer_as_binop;
extern int blanklines_after_declarations;
extern int blanklines_before_blockcomments;
extern int blanklines_after_procs;
extern int blanklines_around_conditional_compilation;
extern int swallow_optional_blanklines;
extern int n_real_blanklines;
extern int prefix_blankline_requested;
extern int postfix_blankline_requested;
extern int break_comma; /* when true and not in parens, break after a
* comma */
extern int btype_2; /* when true, brace should be on same line as
* if, while, etc */
extern int btype_3; /* when true, braces are not only on the next
* line but indented with the enclosed code */
extern float case_ind; /* indentation level to be used for a "case
* n:" */
extern int code_lines; /* count of lines with code */
extern int had_eof; /* set to true when input is exhausted */
extern int line_no; /* the current line number. */
extern int max_col; /* the maximum allowable line length */
extern int verbose; /* when true, non-essential error messages are
* printed */
extern int cuddle_else; /* true if else should cuddle up to '}' */
extern int star_comment_cont; /* true iff comment continuation lines should
* have stars at the beginning of each line. */
extern int comment_delimiter_on_blankline;
extern int troff; /* true iff were generating troff input */
extern int procnames_start_line; /* if true, the names of procedures
* being defined get placed in column
* 1 (ie. a newline is placed between
* the type of the procedure and its
* name) */
extern int proc_calls_space; /* If true, procedure calls look like:
* foo(bar) rather than foo (bar) */
extern int parens_space; /* If true, parens gets spaces inside them */
extern int format_col1_comments; /* If comments which start in column 1
* are to be magically reformatted
* (just like comments that begin in
* later columns) */
extern int inhibit_formatting; /* true if INDENT OFF is in effect */
extern int suppress_blanklines;/* set iff following blanklines should be
* suppressed */
extern int continuation_indent;/* set to the indentation between the edge of
* code and continuation lines */
extern int lineup_to_parens; /* if true, continued code within parens will
* be lined up to the open paren */
extern int Bill_Shannon; /* true iff a blank should always be inserted
* after sizeof */
extern int blanklines_after_declarations_at_proctop; /* This is vaguely
* similar to
* blanklines_after_decla
* rations except that
* it only applies to
* the first set of
* declarations in a
* procedure (just after
* the first '{') and it
* causes a blank line
* to be generated even
* if there are no
* declarations */
extern int block_comment_max_col;
extern int extra_expression_indent; /* True if continuation lines from the
* expression part of "if(e)",
* "while(e)", "for(e;e;e)" should be
* indented an extra tab stop so that
* they don't conflict with the code
* that follows */
/* -troff font state information */
struct fstate {
char font[4];
char size;
int allcaps:1;
};
extern char *chfont();
extern struct fstate
keywordf, /* keyword font */
stringf, /* string font */
boxcomf, /* Box comment font */
blkcomf, /* Block comment font */
scomf, /* Same line comment font */
bodyf; /* major body font */
#define STACKSIZE 150
extern struct parser_state {
int last_token;
struct fstate cfont; /* Current font */
int p_stack[STACKSIZE]; /* this is the parsers stack */
int il[STACKSIZE]; /* this stack stores indentation levels */
float cstk[STACKSIZE];/* used to store case stmt indentation levels */
int box_com; /* set to true when we are in a "boxed"
* comment. In that case, the first non-blank
* char should be lined up with the / in /* */