Apply new code format from CLion

This commit is contained in:
Thomas Jensen 2021-01-27 17:13:17 +01:00
parent dcd2328c77
commit f536d45f7a
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
6 changed files with 1022 additions and 897 deletions

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,9 @@
#define GENERATE_H #define GENERATE_H
int generate_box (sentry_t *thebox); int generate_box(sentry_t *thebox);
int output_box (const sentry_t *thebox);
int output_box(const sentry_t *thebox);
#endif /*GENERATE_H*/ #endif /*GENERATE_H*/

File diff suppressed because it is too large Load Diff

View File

@ -38,17 +38,21 @@ char *shape_name[] = {
"SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW" "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW"
}; };
shape_t north_side[SHAPES_PER_SIDE] = { NW, NNW, N, NNE, NE }; /* clockwise */ shape_t north_side[SHAPES_PER_SIDE] = {NW, NNW, N, NNE, NE}; /* clockwise */
shape_t east_side[SHAPES_PER_SIDE] = { NE, ENE, E, ESE, SE };
shape_t south_side[SHAPES_PER_SIDE] = { SE, SSE, S, SSW, SW }; shape_t east_side[SHAPES_PER_SIDE] = {NE, ENE, E, ESE, SE};
shape_t west_side[SHAPES_PER_SIDE] = { SW, WSW, W, WNW, NW };
shape_t corners[ANZ_CORNERS] = { NW, NE, SE, SW }; shape_t south_side[SHAPES_PER_SIDE] = {SE, SSE, S, SSW, SW};
shape_t *sides[] = { north_side, east_side, south_side, west_side };
shape_t west_side[SHAPES_PER_SIDE] = {SW, WSW, W, WNW, NW};
shape_t corners[ANZ_CORNERS] = {NW, NE, SE, SW};
shape_t *sides[] = {north_side, east_side, south_side, west_side};
shape_t findshape(const sentry_t *sarr, const int num)
shape_t findshape (const sentry_t *sarr, const int num)
/* /*
* Find a non-empty shape and return its name * Find a non-empty shape and return its name
* *
@ -63,19 +67,20 @@ shape_t findshape (const sentry_t *sarr, const int num)
{ {
int i; int i;
for (i=0; i<num; ++i) { for (i = 0; i < num; ++i) {
if (isempty(sarr+i)) if (isempty(sarr + i)) {
continue; continue;
else } else {
break; break;
} }
}
return (shape_t) i; return (shape_t) i;
} }
int on_side (const shape_t s, const int idx) int on_side(const shape_t s, const int idx)
/* /*
* Compute the side that shape s is on. * Compute the side that shape s is on.
* *
@ -92,23 +97,24 @@ int on_side (const shape_t s, const int idx)
int i; int i;
int found = 0; int found = 0;
for (side=0; side<ANZ_SIDES; ++side) { for (side = 0; side < ANZ_SIDES; ++side) {
for (i=0; i<SHAPES_PER_SIDE; ++i) { for (i = 0; i < SHAPES_PER_SIDE; ++i) {
if (sides[side][i] == s) { if (sides[side][i] == s) {
if (found == idx) if (found == idx) {
return side; return side;
else } else {
++found; ++found;
} }
} }
} }
}
return ANZ_SIDES; return ANZ_SIDES;
} }
int genshape (const size_t width, const size_t height, char ***chars) int genshape(const size_t width, const size_t height, char ***chars)
/* /*
* Generate a shape consisting of spaces only. * Generate a shape consisting of spaces only.
* *
@ -127,26 +133,25 @@ int genshape (const size_t width, const size_t height, char ***chars)
size_t j; size_t j;
if (width <= 0 || height <= 0 || width > LINE_MAX_BYTES) { if (width <= 0 || height <= 0 || width > LINE_MAX_BYTES) {
fprintf (stderr, "%s: internal error\n", PROJECT); fprintf(stderr, "%s: internal error\n", PROJECT);
return 1; return 1;
} }
*chars = (char **) calloc (height, sizeof(char *)); *chars = (char **) calloc(height, sizeof(char *));
if (*chars == NULL) { if (*chars == NULL) {
perror (PROJECT); perror(PROJECT);
return 2; return 2;
} }
for (j=0; j<height; ++j) { for (j = 0; j < height; ++j) {
(*chars)[j] = (char *) calloc (width+1, sizeof(char)); (*chars)[j] = (char *) calloc(width + 1, sizeof(char));
if ((*chars)[j] == NULL) { if ((*chars)[j] == NULL) {
perror (PROJECT); perror(PROJECT);
for (/*empty*/; j>0; --j) for (/*empty*/; j > 0; --j) BFREE ((*chars)[j - 1]);
BFREE ((*chars)[j-1]);
BFREE (*chars); BFREE (*chars);
return 3; return 3;
} }
memset ((*chars)[j], ' ', width); memset((*chars)[j], ' ', width);
} }
return 0; return 0;
@ -154,7 +159,7 @@ int genshape (const size_t width, const size_t height, char ***chars)
void freeshape (sentry_t *shape) void freeshape(sentry_t *shape)
/* /*
* Free all memory allocated by the shape and set the struct to * Free all memory allocated by the shape and set the struct to
* SENTRY_INITIALIZER. Do not free memory of the struct. * SENTRY_INITIALIZER. Do not free memory of the struct.
@ -164,8 +169,9 @@ void freeshape (sentry_t *shape)
{ {
size_t j; size_t j;
for (j=0; j<shape->height; ++j) for (j = 0; j < shape->height; ++j) {
BFREE (shape->chars[j]); BFREE (shape->chars[j]);
}
BFREE (shape->chars); BFREE (shape->chars);
*shape = SENTRY_INITIALIZER; *shape = SENTRY_INITIALIZER;
@ -173,26 +179,27 @@ void freeshape (sentry_t *shape)
int isempty (const sentry_t *shape) int isempty(const sentry_t *shape)
/* /*
* Return true if shape is empty. * Return true if shape is empty.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
{ {
if (shape == NULL) if (shape == NULL) {
return 1; return 1;
else if (shape->chars == NULL) } else if (shape->chars == NULL) {
return 1; return 1;
else if (shape->width == 0 || shape->height == 0) } else if (shape->width == 0 || shape->height == 0) {
return 1; return 1;
else } else {
return 0; return 0;
}
} }
int isdeepempty (const sentry_t *shape) int isdeepempty(const sentry_t *shape)
/* /*
* Return true if shape is empty, also checking if lines consist of spaces * Return true if shape is empty, also checking if lines consist of spaces
* only. * only.
@ -202,22 +209,24 @@ int isdeepempty (const sentry_t *shape)
{ {
size_t j; size_t j;
if (isempty (shape)) if (isempty(shape)) {
return 1; return 1;
}
for (j=0; j<shape->height; ++j) { for (j = 0; j < shape->height; ++j) {
if (shape->chars[j]) { if (shape->chars[j]) {
if (strspn (shape->chars[j], " ") != shape->width) if (strspn(shape->chars[j], " ") != shape->width) {
return 0; return 0;
} }
} }
}
return 1; return 1;
} }
size_t highest (const sentry_t *sarr, const int n, ...) size_t highest(const sentry_t *sarr, const int n, ...)
/* /*
* Return height (vert.) of highest shape in given list. * Return height (vert.) of highest shape in given list.
* *
@ -240,13 +249,14 @@ size_t highest (const sentry_t *sarr, const int n, ...)
va_start (ap, n); va_start (ap, n);
for (i=0; i<n; ++i) { for (i = 0; i < n; ++i) {
shape_t r = va_arg (ap, shape_t); shape_t r = va_arg (ap, shape_t);
if (!isempty (sarr + r)) { if (!isempty(sarr + r)) {
if (sarr[r].height > max) if (sarr[r].height > max) {
max = sarr[r].height; max = sarr[r].height;
} }
} }
}
va_end (ap); va_end (ap);
@ -255,7 +265,7 @@ size_t highest (const sentry_t *sarr, const int n, ...)
size_t widest (const sentry_t *sarr, const int n, ...) size_t widest(const sentry_t *sarr, const int n, ...)
/* /*
* Return width (horiz.) of widest shape in given list. * Return width (horiz.) of widest shape in given list.
* *
@ -278,13 +288,14 @@ size_t widest (const sentry_t *sarr, const int n, ...)
va_start (ap, n); va_start (ap, n);
for (i=0; i<n; ++i) { for (i = 0; i < n; ++i) {
shape_t r = va_arg (ap, shape_t); shape_t r = va_arg (ap, shape_t);
if (!isempty (sarr + r)) { if (!isempty(sarr + r)) {
if (sarr[r].width > max) if (sarr[r].width > max) {
max = sarr[r].width; max = sarr[r].width;
} }
} }
}
va_end (ap); va_end (ap);
@ -293,7 +304,7 @@ size_t widest (const sentry_t *sarr, const int n, ...)
shape_t leftmost (const int aside, const int cnt) shape_t leftmost(const int aside, const int cnt)
/* /*
* Return leftmost existing shape in specification for side aside * Return leftmost existing shape in specification for side aside
* (BTOP or BBOT), skipping cnt shapes. Corners are not considered. * (BTOP or BBOT), skipping cnt shapes. Corners are not considered.
@ -307,18 +318,21 @@ shape_t leftmost (const int aside, const int cnt)
int c = 0; int c = 0;
int s; int s;
if (cnt < 0) if (cnt < 0) {
return ANZ_SHAPES; return ANZ_SHAPES;
}
if (aside == BTOP) { if (aside == BTOP) {
s = 0; s = 0;
do { do {
++s; ++s;
while (s < SHAPES_PER_SIDE-1 && while (s < SHAPES_PER_SIDE - 1 &&
isempty(opt.design->shape + north_side[s])) isempty(opt.design->shape + north_side[s])) {
++s; ++s;
if (s == SHAPES_PER_SIDE-1) }
if (s == SHAPES_PER_SIDE - 1) {
return ANZ_SHAPES; return ANZ_SHAPES;
}
} while (c++ < cnt); } while (c++ < cnt);
return north_side[s]; return north_side[s];
} }
@ -327,10 +341,12 @@ shape_t leftmost (const int aside, const int cnt)
s = SHAPES_PER_SIDE - 1; s = SHAPES_PER_SIDE - 1;
do { do {
--s; --s;
while (s && isempty(opt.design->shape + south_side[s])) while (s && isempty(opt.design->shape + south_side[s])) {
--s; --s;
if (!s) }
if (!s) {
return ANZ_SHAPES; return ANZ_SHAPES;
}
} while (c++ < cnt); } while (c++ < cnt);
return south_side[s]; return south_side[s];
} }
@ -340,7 +356,7 @@ shape_t leftmost (const int aside, const int cnt)
int empty_side (sentry_t *sarr, const int aside) int empty_side(sentry_t *sarr, const int aside)
/* /*
* Return true if the shapes on the given side consist entirely out of * Return true if the shapes on the given side consist entirely out of
* spaces - and spaces only, tabs are considered non-empty. * spaces - and spaces only, tabs are considered non-empty.
@ -356,11 +372,12 @@ int empty_side (sentry_t *sarr, const int aside)
{ {
int i; int i;
for (i=0; i<SHAPES_PER_SIDE; ++i) { for (i = 0; i < SHAPES_PER_SIDE; ++i) {
if (isdeepempty (sarr + sides[aside][i])) if (isdeepempty(sarr + sides[aside][i])) {
continue; continue;
else } else {
return 0; /* side is not empty */ return 0;
} /* side is not empty */
} }
return 1; /* side is empty */ return 1; /* side is empty */

View File

@ -35,7 +35,7 @@
int yyerror (const char *fmt, ...) int yyerror(const char *fmt, ...)
/* /*
* Print configuration file parser errors. * Print configuration file parser errors.
* *
@ -46,10 +46,10 @@ int yyerror (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
fprintf (stderr, "%s: %s: line %d: ", PROJECT, fprintf(stderr, "%s: %s: line %d: ", PROJECT,
yyfilename? yyfilename: "(null)", tjlineno); yyfilename ? yyfilename : "(null)", tjlineno);
vfprintf (stderr, fmt, ap); vfprintf(stderr, fmt, ap);
fputc ('\n', stderr); fputc('\n', stderr);
va_end (ap); va_end (ap);
@ -58,23 +58,23 @@ int yyerror (const char *fmt, ...)
void regerror (char *msg) void regerror(char *msg)
/* /*
* Print regular expression andling error messages * Print regular expression andling error messages
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
{ {
fprintf (stderr, "%s: %s: line %d: %s\n", fprintf(stderr, "%s: %s: line %d: %s\n",
PROJECT, yyfilename? yyfilename: "(null)", PROJECT, yyfilename ? yyfilename : "(null)",
opt.design->current_rule? opt.design->current_rule->line: 0, opt.design->current_rule ? opt.design->current_rule->line : 0,
msg); msg);
errno = EINVAL; errno = EINVAL;
} }
int strisyes (const char *s) int strisyes(const char *s)
/* /*
* Determine if the string s has a contents indicating "yes". * Determine if the string s has a contents indicating "yes".
* *
@ -86,26 +86,28 @@ int strisyes (const char *s)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
{ {
if (s == NULL) if (s == NULL) {
return 0; return 0;
}
if (!strncasecmp ("on", s, 3)) if (!strncasecmp("on", s, 3)) {
return 1; return 1;
else if (!strncasecmp ("yes", s, 4)) } else if (!strncasecmp("yes", s, 4)) {
return 1; return 1;
else if (!strncasecmp ("true", s, 5)) } else if (!strncasecmp("true", s, 5)) {
return 1; return 1;
else if (!strncmp ("1", s, 2)) } else if (!strncmp("1", s, 2)) {
return 1; return 1;
else if (!strncasecmp ("t", s, 2)) } else if (!strncasecmp("t", s, 2)) {
return 1; return 1;
else } else {
return 0; return 0;
}
} }
int strisno (const char *s) int strisno(const char *s)
/* /*
* Determine if the string s has a contents indicating "no". * Determine if the string s has a contents indicating "no".
* *
@ -117,26 +119,28 @@ int strisno (const char *s)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
{ {
if (s == NULL) if (s == NULL) {
return 0; return 0;
}
if (!strncasecmp ("off", s, 4)) if (!strncasecmp("off", s, 4)) {
return 1; return 1;
else if (!strncasecmp ("no", s, 3)) } else if (!strncasecmp("no", s, 3)) {
return 1; return 1;
else if (!strncasecmp ("false", s, 6)) } else if (!strncasecmp("false", s, 6)) {
return 1; return 1;
else if (!strncmp ("0", s, 2)) } else if (!strncmp("0", s, 2)) {
return 1; return 1;
else if (!strncasecmp ("f", s, 2)) } else if (!strncasecmp("f", s, 2)) {
return 1; return 1;
else } else {
return 0; return 0;
}
} }
void concat_strings (char *dst, int max_len, int count, ...) void concat_strings(char *dst, int max_len, int count, ...)
/* /*
* Concatenate a variable number of strings into a fixed-length buffer. * Concatenate a variable number of strings into a fixed-length buffer.
* *
@ -159,8 +163,9 @@ void concat_strings (char *dst, int max_len, int count, ...)
/* /*
* Sanity check. * Sanity check.
*/ */
if (max_len < 1) if (max_len < 1) {
return; return;
}
if (max_len == 1 || count < 1) { if (max_len == 1 || count < 1) {
*dst = '\0'; *dst = '\0';
@ -170,7 +175,7 @@ void concat_strings (char *dst, int max_len, int count, ...)
/* /*
* Loop over all input strings. * Loop over all input strings.
*/ */
while (count-->0 && max_len > 1) { while (count-- > 0 && max_len > 1) {
/* /*
* Grab an input string pointer. If it's NULL, skip it (eg. treat * Grab an input string pointer. If it's NULL, skip it (eg. treat
@ -178,8 +183,9 @@ void concat_strings (char *dst, int max_len, int count, ...)
*/ */
src = va_arg (va, const char *); src = va_arg (va, const char *);
if (src == NULL) if (src == NULL) {
continue; continue;
}
/* /*
* Concatenate 'src' onto 'dst', as long as we have room. * Concatenate 'src' onto 'dst', as long as we have room.
@ -200,7 +206,7 @@ void concat_strings (char *dst, int max_len, int count, ...)
int empty_line (const line_t *line) int empty_line(const line_t *line)
/* /*
* Return true if line is empty. * Return true if line is empty.
* *
@ -212,21 +218,24 @@ int empty_line (const line_t *line)
char *p; char *p;
size_t j; size_t j;
if (!line) if (!line) {
return 1; return 1;
if (line->text == NULL || line->len <= 0) }
if (line->text == NULL || line->len <= 0) {
return 1; return 1;
}
for (p=line->text, j=0; *p && j<line->len; ++j, ++p) { for (p = line->text, j = 0; *p && j < line->len; ++j, ++p) {
if (*p != ' ' && *p != '\t' && *p != '\r') if (*p != ' ' && *p != '\t' && *p != '\r') {
return 0; return 0;
} }
}
return 1; return 1;
} }
size_t expand_tabs_into (const char *input_buffer, const size_t in_len, size_t expand_tabs_into(const char *input_buffer, const size_t in_len,
const int tabstop, char **text, size_t **tabpos, size_t *tabpos_len) const int tabstop, char **text, size_t **tabpos, size_t *tabpos_len)
/* /*
* Expand tab chars in input_buffer and store result in text. * Expand tab chars in input_buffer and store result in text.
@ -248,7 +257,7 @@ size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
{ {
static char temp [LINE_MAX_BYTES*MAX_TABSTOP+1]; /* work string */ static char temp[LINE_MAX_BYTES * MAX_TABSTOP + 1]; /* work string */
size_t ii; /* position in input string */ size_t ii; /* position in input string */
size_t io; /* position in work string */ size_t io; /* position in work string */
size_t jp; /* tab expansion jump point */ size_t jp; /* tab expansion jump point */
@ -256,27 +265,30 @@ size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
*text = NULL; *text = NULL;
for (ii=0, *tabpos_len=0; ii<in_len; ++ii) { for (ii = 0, *tabpos_len = 0; ii < in_len; ++ii) {
if (input_buffer[ii] == '\t') if (input_buffer[ii] == '\t') {
(*tabpos_len)++; (*tabpos_len)++;
} }
if (opt.tabexp != 'k') }
if (opt.tabexp != 'k') {
*tabpos_len = 0; *tabpos_len = 0;
}
if (*tabpos_len > 0) { if (*tabpos_len > 0) {
*tabpos = (size_t *) calloc ((*tabpos_len) + 1, sizeof(size_t)); *tabpos = (size_t *) calloc((*tabpos_len) + 1, sizeof(size_t));
if (*tabpos == NULL) { if (*tabpos == NULL) {
return 0; /* out of memory */ return 0; /* out of memory */
} }
} }
for (ii=0, io=0, tabnum=0; ii < in_len && ((int) io) < (LINE_MAX_BYTES*tabstop-1); ++ii) { for (ii = 0, io = 0, tabnum = 0; ii < in_len && ((int) io) < (LINE_MAX_BYTES * tabstop - 1); ++ii) {
if (input_buffer[ii] == '\t') { if (input_buffer[ii] == '\t') {
if (*tabpos_len > 0) { if (*tabpos_len > 0) {
(*tabpos)[tabnum++] = io; (*tabpos)[tabnum++] = io;
} }
for (jp=io+tabstop-(io%tabstop); io<jp; ++io) for (jp = io + tabstop - (io % tabstop); io < jp; ++io) {
temp[io] = ' '; temp[io] = ' ';
} }
}
else { else {
temp[io] = input_buffer[ii]; temp[io] = input_buffer[ii];
++io; ++io;
@ -284,15 +296,17 @@ size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
} }
temp[io] = '\0'; temp[io] = '\0';
*text = (char *) strdup (temp); *text = (char *) strdup(temp);
if (*text == NULL) return 0; if (*text == NULL) {
return 0;
}
return io; return io;
} }
void btrim (char *text, size_t *len) void btrim(char *text, size_t *len)
/* /*
* Remove trailing whitespace from line. * Remove trailing whitespace from line.
* *
@ -302,7 +316,7 @@ void btrim (char *text, size_t *len)
long idx = (long) (*len) - 1; long idx = (long) (*len) - 1;
while (idx >= 0 && (text[idx] == '\n' || text[idx] == '\r' while (idx >= 0 && (text[idx] == '\n' || text[idx] == '\r'
|| text[idx] == '\t' || text[idx] == ' ')) || text[idx] == '\t' || text[idx] == ' ')) /**/
{ {
text[idx--] = '\0'; text[idx--] = '\0';
} }
@ -312,7 +326,7 @@ void btrim (char *text, size_t *len)
char *my_strnrstr (const char *s1, const char *s2, const size_t s2_len, int skip) char *my_strnrstr(const char *s1, const char *s2, const size_t s2_len, int skip)
/* /*
* Return pointer to last occurrence of string s2 in string s1. * Return pointer to last occurrence of string s2 in string s1.
* *
@ -330,25 +344,30 @@ char *my_strnrstr (const char *s1, const char *s2, const size_t s2_len, int skip
char *p; char *p;
int comp; int comp;
if (!s2 || *s2 == '\0') if (!s2 || *s2 == '\0') {
return (char *) s1; return (char *) s1;
if (!s1 || *s1 == '\0') }
if (!s1 || *s1 == '\0') {
return NULL; return NULL;
if (skip < 0) }
if (skip < 0) {
skip = 0; skip = 0;
}
p = strrchr (s1, s2[0]); p = strrchr(s1, s2[0]);
if (!p) if (!p) {
return NULL; return NULL;
}
while (p >= s1) { while (p >= s1) {
comp = strncmp (p, s2, s2_len); comp = strncmp(p, s2, s2_len);
if (comp == 0) { if (comp == 0) {
if (skip--) if (skip--) {
--p; --p;
else } else {
return p; return p;
} }
}
else { else {
--p; --p;
} }
@ -359,7 +378,7 @@ char *my_strnrstr (const char *s1, const char *s2, const size_t s2_len, int skip
char *tabbify_indent (const size_t lineno, char *indentspc, const size_t indentspc_len) char *tabbify_indent(const size_t lineno, char *indentspc, const size_t indentspc_len)
/* /*
* Checks if tab expansion mode is "keep", and if so, calculates a new * Checks if tab expansion mode is "keep", and if so, calculates a new
* indentation string based on the one given. The new string contains * indentation string based on the one given. The new string contains
@ -388,20 +407,20 @@ char *tabbify_indent (const size_t lineno, char *indentspc, const size_t indents
return NULL; return NULL;
} }
if (indentspc_len == 0) { if (indentspc_len == 0) {
return (char *) strdup (""); return (char *) strdup("");
} }
result = (char *) malloc (indentspc_len + 1); result = (char *) malloc(indentspc_len + 1);
if (result == NULL) { if (result == NULL) {
perror (PROJECT); perror(PROJECT);
return NULL; return NULL;
} }
memset (result, (int)' ', indentspc_len); memset(result, (int) ' ', indentspc_len);
result[indentspc_len] = '\0'; result[indentspc_len] = '\0';
result_len = indentspc_len; result_len = indentspc_len;
for (i=0; i < input.lines[lineno].tabpos_len for (i = 0; i < input.lines[lineno].tabpos_len
&& input.lines[lineno].tabpos[i] < indentspc_len; ++i) && input.lines[lineno].tabpos[i] < indentspc_len; ++i) /**/
{ {
size_t tpos = input.lines[lineno].tabpos[i]; size_t tpos = input.lines[lineno].tabpos[i];
size_t nspc = opt.tabstop - (tpos % opt.tabstop); /* no of spcs covered by tab */ size_t nspc = opt.tabstop - (tpos % opt.tabstop); /* no of spcs covered by tab */

View File

@ -27,7 +27,7 @@
#define TOOLS_H #define TOOLS_H
#define BMAX(a,b) ((a)>(b)? (a):(b)) /* return the larger value */ #define BMAX(a, b) ((a)>(b)? (a):(b)) /* return the larger value */
#define BFREE(p) { /* free memory and clear pointer */ \ #define BFREE(p) { /* free memory and clear pointer */ \
if (p) { \ if (p) { \
@ -37,20 +37,28 @@
} }
int yyerror (const char *fmt, ...); int yyerror(const char *fmt, ...);
void regerror (char *msg);
int empty_line (const line_t *line); void regerror(char *msg);
size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
int empty_line(const line_t *line);
size_t expand_tabs_into(const char *input_buffer, const size_t in_len,
const int tabstop, char **text, size_t **tabpos, size_t *tabpos_len); const int tabstop, char **text, size_t **tabpos, size_t *tabpos_len);
void btrim (char *text, size_t *len);
char* my_strnrstr (const char *s1, const char *s2, const size_t s2_len, void btrim(char *text, size_t *len);
char *my_strnrstr(const char *s1, const char *s2, const size_t s2_len,
int skip); int skip);
int strisyes (const char *s);
int strisno (const char *s);
void concat_strings (char *dst, int max_len, int count, ...); int strisyes(const char *s);
int strisno(const char *s);
void concat_strings(char *dst, int max_len, int count, ...);
char *tabbify_indent(const size_t lineno, char *indentspc, const size_t indentspc_len);
char *tabbify_indent (const size_t lineno, char *indentspc, const size_t indentspc_len);
#endif #endif