static uintmax_t increment_size = 0;
/* The maximum distance between tab stops. */
-size_t max_column_width;
+idx_t max_column_width;
/* Array of the explicit column numbers of the tab stops;
after 'tab_list' is exhausted, each additional tab is replaced
static uintmax_t *tab_list = nullptr;
/* The number of allocated entries in 'tab_list'. */
-static size_t n_tabs_allocated = 0;
+static idx_t n_tabs_allocated = 0;
/* The index of the first invalid element of 'tab_list',
where the next element can be added. */
-static size_t first_free_tab = 0;
+static idx_t first_free_tab = 0;
/* Null-terminated array of input filenames. */
static char **file_list = nullptr;
uintmax_t column_width = prev_column <= tabval ? tabval - prev_column : 0;
if (first_free_tab == n_tabs_allocated)
- tab_list = X2NREALLOC (tab_list, &n_tabs_allocated);
+ tab_list = xpalloc (tab_list, &n_tabs_allocated, 1, -1, sizeof *tab_list);
tab_list[first_free_tab++] = tabval;
if (max_column_width < column_width)
{
- if (SIZE_MAX < column_width)
+ if (ckd_add (&max_column_width, column_width, 0))
error (EXIT_FAILURE, 0, _("tabs are too far apart"));
- max_column_width = column_width;
}
}
/* Detect overflow. */
if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0'))
{
- size_t len = strspn (num_start, "0123456789");
+ idx_t len = strspn (num_start, "0123456789");
char *bad_num = ximemdup0 (num_start, len);
error (0, 0, _("tab stop is too large %s"), quote (bad_num));
free (bad_num);
contains only nonzero, ascending values. */
static void
-validate_tab_stops (uintmax_t const *tabs, size_t entries)
+validate_tab_stops (uintmax_t const *tabs, idx_t entries)
{
uintmax_t prev_tab = 0;
- for (size_t i = 0; i < entries; i++)
+ for (idx_t i = 0; i < entries; i++)
{
if (tabs[i] == 0)
error (EXIT_FAILURE, 0, _("tab size cannot be 0"));
extern uintmax_t
-get_next_tab_column (const uintmax_t column, size_t *tab_index,
+get_next_tab_column (const uintmax_t column, idx_t *tab_index,
bool *last_tab)
{
*last_tab = false;
extern bool convert_entire_line;
/* The maximum distance between tab stops. */
-extern size_t max_column_width;
+extern idx_t max_column_width;
/* The desired exit status. */
extern int exit_status;
/* TODO: Document */
extern uintmax_t
-get_next_tab_column (const uintmax_t column, size_t *tab_index,
+get_next_tab_column (const uintmax_t column, idx_t *tab_index,
bool *last_tab)
_GL_ATTRIBUTE_NONNULL ((3));
/* The worst case is a non-blank character, then one blank, then a
tab stop, then MAX_COLUMN_WIDTH - 1 blanks, then a non-blank; so
allocate MAX_COLUMN_WIDTH bytes to store the blanks. */
- pending_blank = xmalloc (max_column_width);
+ pending_blank = ximalloc (max_column_width);
while (true)
{
uintmax_t next_tab_column = 0;
/* Index in TAB_LIST of next tab stop to examine. */
- size_t tab_index = 0;
+ idx_t tab_index = 0;
/* If true, the first pending blank came just before a tab stop. */
bool one_blank_before_tab_stop = false;
bool prev_blank = true;
/* Number of pending columns of blanks. */
- size_t pending = 0;
+ idx_t pending = 0;
/* Convert a line of text. */