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

View File

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

View File

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

View File

@ -126,7 +126,7 @@ 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) { 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;
} }

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 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 */
@ -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 (input_buffer[ii] == '\t') {
if (*tabpos_len > 0) { if (*tabpos_len > 0) {
(*tabpos)[tabnum++] = io; (*tabpos)[tabnum++] = io;