Rename LINE_MAX macro to LINE_MAX_BYTES

This commit is contained in:
Thomas Jensen 2021-01-22 18:47:16 +01:00
parent a253fe105a
commit 07b634a16c
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
5 changed files with 32 additions and 32 deletions

View File

@ -964,10 +964,10 @@ static int list_styles()
design_t *d = opt.design;
int sstart = 0;
size_t w = 0;
char space[LINE_MAX+1];
char space[LINE_MAX_BYTES+1];
memset (&space, ' ', LINE_MAX);
space[LINE_MAX] = '\0';
memset (&space, ' ', LINE_MAX_BYTES);
space[LINE_MAX_BYTES] = '\0';
fprintf (opt.outfile, "Complete Design Information for \"%s\":\n",
d->name);
@ -1175,7 +1175,7 @@ static int get_indent (const line_t *lines, const size_t lanz)
*/
{
size_t j;
int res = LINE_MAX; /* result */
int res = LINE_MAX_BYTES; /* result */
int nonblank = 0; /* true if one non-blank line found */
if (lines == NULL) {
@ -1221,7 +1221,7 @@ static int apply_substitutions (const int mode)
size_t anz_rules;
reprule_t *rules;
size_t j, k;
char buf[LINE_MAX*2];
char buf[LINE_MAX_BYTES*2];
size_t buf_len; /* length of string in buf */
if (opt.design == NULL)
@ -1260,12 +1260,12 @@ static int apply_substitutions (const int mode)
#ifdef REGEXP_DEBUG
fprintf (stderr, "myregsub (0x%p, \"%s\", %d, \"%s\", buf, %d, \'%c\') == ",
rules[j].prog, input.lines[k].text,
input.lines[k].len, rules[j].repstr, LINE_MAX*2,
input.lines[k].len, rules[j].repstr, LINE_MAX_BYTES*2,
rules[j].mode);
#endif
errno = 0;
buf_len = myregsub (rules[j].prog, input.lines[k].text,
input.lines[k].len, rules[j].repstr, buf, LINE_MAX*2,
input.lines[k].len, rules[j].repstr, buf, LINE_MAX_BYTES*2,
rules[j].mode);
#ifdef REGEXP_DEBUG
fprintf (stderr, "%d\n", buf_len);
@ -1353,7 +1353,7 @@ static int read_all_input (const int use_stdin)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
{
char buf[LINE_MAX+2]; /* input buffer */
char buf[LINE_MAX_BYTES+2]; /* input buffer */
char c;
size_t invis; /* counts invisible characters */
int ansipos; /* progression of ansi sequence */
@ -1364,7 +1364,7 @@ static int read_all_input (const int use_stdin)
size_t i;
int rc;
input.indent = LINE_MAX;
input.indent = LINE_MAX_BYTES;
input.maxline = 0;
if (use_stdin) {
@ -1373,7 +1373,7 @@ static int read_all_input (const int use_stdin)
/*
* Start reading
*/
while (fgets (buf, LINE_MAX+1, opt.infile))
while (fgets (buf, LINE_MAX_BYTES+1, opt.infile))
{
if (input_size % 100 == 0) {
input_size += 100;

View File

@ -5,12 +5,12 @@
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2, as published
* by the Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -51,17 +51,17 @@
#define MAX_TABSTOP 16
/*
* max. supported line length
* max. supported line length in bytes
* This is how many characters of a line will be read. Anything beyond
* will be discarded. The line feed character at the end does not count.
* (This should have been done via sysconf(), but I didn't do it in order
* to ease porting to non-unix platforms.)
*/
#if defined(LINE_MAX) && (LINE_MAX < 1024)
#undef LINE_MAX
#if defined(LINE_MAX_BYTES) && (LINE_MAX_BYTES < 1024)
#undef LINE_MAX_BYTES
#endif
#ifndef LINE_MAX
#define LINE_MAX 2048
#ifndef LINE_MAX_BYTES
#define LINE_MAX_BYTES 2048
#endif
@ -163,7 +163,7 @@ typedef struct {
int final_newline; /* true if the last line of input ends with newline */
} input_t;
#define INPUT_INITIALIZER {NULL, 0, 0, LINE_MAX, 0}
#define INPUT_INITIALIZER {NULL, 0, 0, LINE_MAX_BYTES, 0}
extern input_t input;
#endif /*!FILE_LEXER_L*/

View File

@ -826,7 +826,7 @@ int output_box (const sentry_t *thebox)
{
size_t j;
size_t nol = thebox[BRIG].height; /* number of output lines */
char trailspc[LINE_MAX+1];
char trailspc[LINE_MAX_BYTES+1];
char *indentspc;
int indentspclen;
size_t vfill, vfill1, vfill1_save, vfill2; /* empty lines/columns in box */
@ -835,7 +835,7 @@ int output_box (const sentry_t *thebox)
size_t hpl, hpr;
size_t r;
int rc;
char obuf[LINE_MAX+1]; /* final output buffer */
char obuf[LINE_MAX_BYTES+1]; /* final output buffer */
size_t obuf_len; /* length of content of obuf */
size_t skip_start; /* lines to skip for box top */
size_t skip_end; /* lines to skip for box bottom */
@ -891,8 +891,8 @@ int output_box (const sentry_t *thebox)
* Provide string of spaces for filling of space between text and
* right side of box
*/
memset (trailspc, (int)' ', LINE_MAX);
trailspc[LINE_MAX] = '\0';
memset (trailspc, (int)' ', LINE_MAX_BYTES);
trailspc[LINE_MAX_BYTES] = '\0';
/*
* Compute number of empty lines in box (vfill).
@ -995,7 +995,7 @@ int output_box (const sentry_t *thebox)
if (j < thebox[BTOP].height) { /* box top */
restored_indent = tabbify_indent (0, indentspc, indentspclen);
concat_strings (obuf, LINE_MAX+1, 4, restored_indent,
concat_strings (obuf, LINE_MAX_BYTES+1, 4, restored_indent,
skip_left?"":thebox[BLEF].chars[j], thebox[BTOP].chars[j],
thebox[BRIG].chars[j]);
}
@ -1004,7 +1004,7 @@ int output_box (const sentry_t *thebox)
r = thebox[BTOP].width;
trailspc[r] = '\0';
restored_indent = tabbify_indent (0, indentspc, indentspclen);
concat_strings (obuf, LINE_MAX+1, 4, restored_indent,
concat_strings (obuf, LINE_MAX_BYTES+1, 4, restored_indent,
skip_left?"":thebox[BLEF].chars[j], trailspc,
thebox[BRIG].chars[j]);
trailspc[r] = ' ';
@ -1032,7 +1032,7 @@ int output_box (const sentry_t *thebox)
+ strlen(hfill1)
+ input.lines[ti].num_leading_blanks;
}
concat_strings (obuf, LINE_MAX+1, 7, restored_indent,
concat_strings (obuf, LINE_MAX_BYTES+1, 7, restored_indent,
skip_left?"":thebox[BLEF].chars[j], hfill1,
ti >= 0? input.lines[ti].text : "", hfill2,
trailspc, thebox[BRIG].chars[j]);
@ -1041,7 +1041,7 @@ int output_box (const sentry_t *thebox)
r = thebox[BTOP].width;
trailspc[r] = '\0';
restored_indent = tabbify_indent (input.anz_lines - 1, indentspc, indentspclen);
concat_strings (obuf, LINE_MAX+1, 4, restored_indent,
concat_strings (obuf, LINE_MAX_BYTES+1, 4, restored_indent,
skip_left?"":thebox[BLEF].chars[j], trailspc,
thebox[BRIG].chars[j]);
}
@ -1050,7 +1050,7 @@ int output_box (const sentry_t *thebox)
else { /* box bottom */
restored_indent = tabbify_indent (input.anz_lines - 1, indentspc, indentspclen);
concat_strings (obuf, LINE_MAX+1, 4, restored_indent,
concat_strings (obuf, LINE_MAX_BYTES+1, 4, restored_indent,
skip_left?"":thebox[BLEF].chars[j],
thebox[BBOT].chars[j-(nol-thebox[BBOT].height)],
thebox[BRIG].chars[j]);
@ -1058,8 +1058,8 @@ int output_box (const sentry_t *thebox)
obuf_len = strlen (obuf);
if (obuf_len > LINE_MAX) {
size_t newlen = LINE_MAX;
if (obuf_len > LINE_MAX_BYTES) {
size_t newlen = LINE_MAX_BYTES;
btrim (obuf, &newlen);
}
else {

View File

@ -126,7 +126,7 @@ int genshape (const size_t width, const size_t height, char ***chars)
{
size_t j;
if (width <= 0 || height <= 0 || width > LINE_MAX) {
if (width <= 0 || height <= 0 || width > LINE_MAX_BYTES) {
fprintf (stderr, "%s: internal error\n", PROJECT);
return 1;
}

View File

@ -248,7 +248,7 @@ size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
{
static char temp [LINE_MAX*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 io; /* position in work string */
size_t jp; /* tab expansion jump point */
@ -269,7 +269,7 @@ size_t expand_tabs_into (const char *input_buffer, const size_t in_len,
}
}
for (ii=0, io=0, tabnum=0; ii < in_len && ((int) io) < (LINE_MAX*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 (*tabpos_len > 0) {
(*tabpos)[tabnum++] = io;