Remove the state from the pv_error arguments, by adding a new function pv_set_error_prefix to call on startup, eliminating the need for a state program_name string; and add a private boolean to track whether there has been any output which means errors need preceding by a newline, which is updated by pv_display directly (#165).
This commit is contained in:
@@ -142,7 +142,6 @@ struct pvstate_s {
|
||||
* Program status *
|
||||
******************/
|
||||
struct pvprogramstatus_s {
|
||||
/*@only@*/ char *program_name; /* program name for error reporting */
|
||||
char cwd[PV_SIZEOF_CWD]; /* current working directory for relative path */
|
||||
int current_input_file; /* index of current file being read */
|
||||
int exit_status; /* exit status to give (0=OK) */
|
||||
@@ -505,7 +504,7 @@ struct pvwatchfd_s {
|
||||
};
|
||||
typedef struct pvwatchfd_s *pvwatchfd_t;
|
||||
|
||||
void pv_error(pvstate_t, char *, ...);
|
||||
void pv_error(char *, ...);
|
||||
|
||||
int pv_main_loop(pvstate_t);
|
||||
void pv_calculate_transfer_rate(pvtransfercalc_t, readonly_pvtransferstate_t, readonly_pvcontrol_t, readonly_pvdisplay_t, bool);
|
||||
|
||||
+6
-1
@@ -175,10 +175,15 @@ void pv_nanosleep(long long);
|
||||
* Main PV functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set the prefix (program name) for any PV error messages.
|
||||
*/
|
||||
extern void pv_set_error_prefix(/*@unique@ */ const char *);
|
||||
|
||||
/*
|
||||
* Create a new state structure, and return it, or 0 (NULL) on error.
|
||||
*/
|
||||
extern /*@null@*/ /*@only@*/ pvstate_t pv_state_alloc(const char *);
|
||||
extern /*@null@*/ /*@only@*/ pvstate_t pv_state_alloc(void);
|
||||
|
||||
/*
|
||||
* Clear the calculated parts of a state structure.
|
||||
|
||||
Reference in New Issue
Block a user