Rename "null" state boolean to "null_terminated_lines" so it is more descriptive and less confusing.
This commit is contained in:
@@ -34,7 +34,7 @@ struct opts_s { /* structure describing run-time options */
|
||||
bool numeric; /* numeric output only */
|
||||
bool wait; /* wait for transfer before display */
|
||||
bool linemode; /* count lines instead of bytes */
|
||||
bool null; /* lines are null-terminated */
|
||||
bool null_terminated_lines; /* lines are null-terminated */
|
||||
bool no_display; /* do nothing other than pipe data */
|
||||
unsigned long long rate_limit; /* rate limit, in bytes per second */
|
||||
unsigned long long buffer_size;/* buffer size, in bytes (0=default) */
|
||||
|
||||
@@ -89,7 +89,7 @@ struct pvstate_s {
|
||||
bool wait; /* wait for data before display */
|
||||
bool linemode; /* count lines instead of bytes */
|
||||
bool bits; /* report bits instead of bytes */
|
||||
bool null; /* lines are null-terminated */
|
||||
bool null_terminated_lines; /* lines are null-terminated */
|
||||
bool no_display; /* do nothing other than pipe data */
|
||||
unsigned int skip_errors; /* skip read errors counter */
|
||||
bool stop_at_size; /* set if we stop at "size" bytes */
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ extern void pv_state_wait_set(pvstate_t, bool);
|
||||
extern void pv_state_delay_start_set(pvstate_t, double);
|
||||
extern void pv_state_linemode_set(pvstate_t, bool);
|
||||
extern void pv_state_bits_set(pvstate_t, bool);
|
||||
extern void pv_state_null_set(pvstate_t, bool);
|
||||
extern void pv_state_null_terminated_lines_set(pvstate_t, bool);
|
||||
extern void pv_state_no_display_set(pvstate_t, bool);
|
||||
extern void pv_state_skip_errors_set(pvstate_t, unsigned int);
|
||||
extern void pv_state_stop_at_size_set(pvstate_t, bool);
|
||||
|
||||
+2
-2
@@ -191,7 +191,7 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
if (0 == opts->size) {
|
||||
pv_state_linemode_set(state, opts->linemode);
|
||||
pv_state_null_set(state, opts->null);
|
||||
pv_state_null_terminated_lines_set(state, opts->null_terminated_lines);
|
||||
opts->size = pv_calc_total_size(state);
|
||||
debug("%s: %llu", "no size given - calculated", opts->size);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
|
||||
pv_state_delay_start_set(state, opts->delay_start);
|
||||
pv_state_linemode_set(state, opts->linemode);
|
||||
pv_state_bits_set(state, opts->bits);
|
||||
pv_state_null_set(state, opts->null);
|
||||
pv_state_null_terminated_lines_set(state, opts->null_terminated_lines);
|
||||
pv_state_skip_errors_set(state, opts->skip_errors);
|
||||
pv_state_stop_at_size_set(state, opts->stop_at_size);
|
||||
pv_state_sync_after_write_set(state, opts->sync_after_write);
|
||||
|
||||
+2
-2
@@ -422,7 +422,7 @@ opts_t opts_parse(unsigned int argc, char **argv)
|
||||
opts->linemode = true;
|
||||
break;
|
||||
case '0':
|
||||
opts->null = true;
|
||||
opts->null_terminated_lines = true;
|
||||
opts->linemode = true;
|
||||
break;
|
||||
case 'i':
|
||||
@@ -529,7 +529,7 @@ opts_t opts_parse(unsigned int argc, char **argv)
|
||||
return NULL;
|
||||
|
||||
if (0 != opts->watch_pid) {
|
||||
if (opts->linemode || opts->null || opts->stop_at_size
|
||||
if (opts->linemode || opts->null_terminated_lines || opts->stop_at_size
|
||||
|| (opts->skip_errors > 0) || (opts->buffer_size > 0)
|
||||
|| (opts->rate_limit > 0)) {
|
||||
/*@-mustfreefresh@ *//* see above */
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ static unsigned long long pv_calc_total_lines(pvstate_t state)
|
||||
break;
|
||||
}
|
||||
for (buf_idx = 0; buf_idx < numread; buf_idx++) {
|
||||
if (state->null) {
|
||||
if (state->null_terminated_lines) {
|
||||
if ('\0' == scanbuf[buf_idx])
|
||||
total++;
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -192,9 +192,9 @@ void pv_state_bits_set(pvstate_t state, bool bits)
|
||||
state->bits = bits;
|
||||
};
|
||||
|
||||
void pv_state_null_set(pvstate_t state, bool val)
|
||||
void pv_state_null_terminated_lines_set(pvstate_t state, bool val)
|
||||
{
|
||||
state->null = val;
|
||||
state->null_terminated_lines = val;
|
||||
};
|
||||
|
||||
void pv_state_no_display_set(pvstate_t state, bool val)
|
||||
|
||||
+2
-2
@@ -529,7 +529,7 @@ static int pv__transfer_write(pvstate_t state, int *eof_in, int *eof_out, long *
|
||||
state->transfer_buffer[state->write_position + nwritten] = 0;
|
||||
ptr = (char *) (state->transfer_buffer + state->write_position - 1);
|
||||
|
||||
if (state->null) {
|
||||
if (state->null_terminated_lines) {
|
||||
for (ptr++;
|
||||
ptr -
|
||||
(char *) state->transfer_buffer -
|
||||
@@ -861,7 +861,7 @@ long pv_transfer(pvstate_t state, int fd, int *eof_in, int *eof_out, unsigned lo
|
||||
* In line mode, only write up to and including the last newline,
|
||||
* so that we're writing output line-by-line.
|
||||
*/
|
||||
if ((state->to_write > 0) && (state->linemode) && !(state->null)) {
|
||||
if ((state->to_write > 0) && (state->linemode) && !(state->null_terminated_lines)) {
|
||||
/*
|
||||
* Guillaume Marcais: use strrchr to find last \n
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user