*/
#ifndef lint
-static char sccsid[] = "@(#)io.c 5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)io.c 5.13 (Berkeley) %G%";
#endif /* not lint */
#include "indent_globs.h"
while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
e_lab--;
cur_col = pad_output(1, compute_label_target());
- fprintf(output, "%.*s", e_lab - s_lab, s_lab);
+ if (s_lab[0] == '#' && (strncmp(s_lab, "#else", 5) == 0
+ || strncmp(s_lab, "#endif", 6) == 0)) {
+ register char *s = s_lab;
+ if (e_lab[-1] == '\n') e_lab--;
+ do putc(*s++, output);
+ while (s < e_lab && 'a' <= *s && *s<='z');
+ while ((*s == ' ' || *s == '\t') && s < e_lab)
+ s++;
+ if (s < e_lab)
+ fprintf(output, s[0]=='/' && s[1]=='*' ? "\t%.*s" : "\t/* %.*s */",
+ e_lab - s, s);
+ }
+ else fprintf(output, "%.*s", e_lab - s_lab, s_lab);
cur_col = count_spaces(cur_col, s_lab);
}
else
ps.ind_level = ps.i_l_follow;
ps.paren_level = ps.p_l_follow;
paren_target = -ps.paren_indents[ps.paren_level - 1];
- paren_target = (ps.paren_level > 0 ? -ps.paren_indents[ps.paren_level - 1]
- : 0);
not_first_line = 1;
return;
-};
+}
compute_code_target()
{
* Willcox of CAC Added check for switch back to partly full input
* buffer from temporary buffer
*
- */\f
+ */
int
fill_buffer()
{ /* this routine reads stuff from the input */
return; /* only return if there is really something in
* this buffer */
}
- for (p = buf_ptr = in_buffer;;) {
+ for (p = in_buffer;;) {
+ if (p >= in_buffer_limit) {
+ register size = (in_buffer_limit - in_buffer) * 2 + 10;
+ register offset = p - in_buffer;
+ in_buffer = (char *) realloc(in_buffer, size);
+ if (in_buffer == 0)
+ err("input line too long");
+ p = in_buffer + offset;
+ in_buffer_limit = in_buffer + size - 2;
+ }
if ((i = getc(f)) == EOF) {
*p++ = ' ';
*p++ = '\n';
if (i == '\n')
break;
}
+ buf_ptr = in_buffer;
buf_end = p;
- if (p - in_buffer > 3 && p[-2] == '/' && p[-3] == '*') {
+ if (p[-2] == '/' && p[-3] == '*') {
if (in_buffer[3] == 'I' && strncmp(in_buffer, "/**INDENT**", 11) == 0)
fill_buffer(); /* flush indent error message */
else {
while (*p++ != '\n');
}
return;
-};
+}
/*
* Copyright (C) 1976 by the Board of Trustees of the University of Illinois
*
* HISTORY: initial coding November 1976 D A Willcox of CAC
*
- */\f
+ */
pad_output(current, target) /* writes tabs and blanks (if necessary) to
* get the current output position up to the
* target column */
putc(' ', output); /* pad with final blanks */
}
return (target);
-};
+}
/*
* Copyright (C) 1976 by the Board of Trustees of the University of Illinois
*
* HISTORY: initial coding November 1976 D A Willcox of CAC
*
- */\f
+ */
int
count_spaces(current, buffer)
/*
cur = ((cur - 1) & tabmask) + tabsize + 1;
break;
- case '\b': /* this is a backspace */
+ case 010: /* backspace */
--cur;
break;
} /* end of switch */
} /* end of for loop */
return (cur);
-};
+}
int found_err;
+/* VARARGS2 */
diag(level, msg, a, b)
{
if (level)