mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_HAL: allow getopt_cpp on QURT
avoid using stderr
This commit is contained in:
parent
ea1e3f4928
commit
dafc9b4c6b
@ -36,12 +36,19 @@
|
||||
*/
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
#if HAL_OS_POSIX_IO && CONFIG_HAL_BOARD != HAL_BOARD_QURT
|
||||
#if HAL_OS_POSIX_IO
|
||||
|
||||
#include "getopt_cpp.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_QURT
|
||||
#define GETOPT_ERROR(...) HAP_printf(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define GETOPT_ERROR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
constructor
|
||||
*/
|
||||
@ -117,10 +124,10 @@ int GetOptLong::getoption(void)
|
||||
{
|
||||
if (optstring[0] == ':')
|
||||
return BADARG;
|
||||
if (opterr)
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %s\n",
|
||||
argv[0], place);
|
||||
if (opterr) {
|
||||
GETOPT_ERROR("%s: option requires an argument -- %s\n",
|
||||
argv[0], place);
|
||||
}
|
||||
place = "";
|
||||
optind++;
|
||||
return BADCH;
|
||||
@ -151,9 +158,9 @@ int GetOptLong::getoption(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (opterr && optstring[0] != ':')
|
||||
fprintf(stderr,
|
||||
"%s: illegal option -- %s\n", argv[0], place);
|
||||
if (opterr && optstring[0] != ':') {
|
||||
GETOPT_ERROR("%s: illegal option -- %s\n", argv[0], place);
|
||||
}
|
||||
place = "";
|
||||
optind++;
|
||||
return BADCH;
|
||||
@ -168,9 +175,9 @@ int GetOptLong::getoption(void)
|
||||
{
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *optstring != ':')
|
||||
fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", argv[0], optopt);
|
||||
if (opterr && *optstring != ':') {
|
||||
GETOPT_ERROR("%s: illegal option -- %c\n", argv[0], optopt);
|
||||
}
|
||||
return BADCH;
|
||||
}
|
||||
|
||||
@ -189,10 +196,10 @@ int GetOptLong::getoption(void)
|
||||
place = "";
|
||||
if (*optstring == ':')
|
||||
return BADARG;
|
||||
if (opterr)
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
argv[0], optopt);
|
||||
if (opterr) {
|
||||
GETOPT_ERROR("%s: option requires an argument -- %c\n",
|
||||
argv[0], optopt);
|
||||
}
|
||||
return BADCH;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user