mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 04:22:35 +01:00
modules/qrpn: replace stderr with stdout; remove extraneous whitespace throughout
PBot modules do not send the stderr stream to the channel. Instead, the output is logged in <module-filename>-stderr, for private debugging purposes. PBot expects output intended for channels to be on stdout.
This commit is contained in:
parent
9172bcd29f
commit
da7d31229b
@ -316,7 +316,7 @@ static double datestr_to_unix_seconds(const char * const datestr) {
|
||||
char * after = NULL;
|
||||
microseconds_after_decimal = llrint(strtod(datestr, &after) * 1000000);
|
||||
if (after && *after != '\0')
|
||||
fprintf(stderr, "warning: %s: ignoring \"%s\"\n", __func__, after);
|
||||
fprintf(stdout, "warning: %s: ignoring \"%s\"\n", __func__, after);
|
||||
}
|
||||
|
||||
return (seconds * 1000000 + microseconds_after_decimal) * 1e-6;
|
||||
@ -959,8 +959,8 @@ int qrpn_evaluate_token(struct quantity * const stack, int S, const char * const
|
||||
}
|
||||
else if (!strcmp(token, "print")) {
|
||||
if (S < 1) return QRPN_ERROR_NOT_ENOUGH_STACK;
|
||||
fprintf_quantity(stderr, stack[S - 1]);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf_quantity(stdout, stack[S - 1]);
|
||||
fprintf(stdout, "\n");
|
||||
return S;
|
||||
}
|
||||
else
|
||||
@ -1222,7 +1222,7 @@ int qrpn_try_string(const struct quantity stack[static QRPN_STACK_SIZE_MAX], con
|
||||
__attribute((weak)) int main(const int argc, const char ** const argv) {
|
||||
if (isatty(STDIN_FILENO) && argc < 2) {
|
||||
/* never reached */
|
||||
fprintf(stderr, "%s: Evaluates an RPN expression with units\n", argv[0]);
|
||||
fprintf(stdout, "%s: Evaluates an RPN expression with units\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -1231,7 +1231,7 @@ __attribute((weak)) int main(const int argc, const char ** const argv) {
|
||||
int S = qrpn_evaluate_tokens(stack, 0, argv + 1, 0);
|
||||
|
||||
if (S < 0) {
|
||||
fprintf(stderr, "error: %s\n", qrpn_strerror(S));
|
||||
fprintf(stdout, "error: %s\n", qrpn_strerror(S));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user