mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Shrink code by letting a separate function handle the resetting of optind
This commit is contained in:
parent
99b5352cff
commit
a2a9ed054d
23
src/conky.cc
23
src/conky.cc
@ -3953,6 +3953,15 @@ static void print_help(const char *prog_name) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void reset_optind() {
|
||||||
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
||||||
|
|| defined(__NetBSD__)
|
||||||
|
optind = optreset = 1;
|
||||||
|
#else
|
||||||
|
optind = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* : means that character before that takes an argument */
|
/* : means that character before that takes an argument */
|
||||||
static const char *getopt_string = "vVqdDs:t:u:i:hc:p:"
|
static const char *getopt_string = "vVqdDs:t:u:i:hc:p:"
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
@ -4002,13 +4011,8 @@ void initialisation(int argc, char **argv) {
|
|||||||
bool for_scripts = false;
|
bool for_scripts = false;
|
||||||
|
|
||||||
set_default_configurations();
|
set_default_configurations();
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
|
||||||
|| defined(__NetBSD__)
|
|
||||||
optind = optreset = 1;
|
|
||||||
#else
|
|
||||||
optind = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
reset_optind();
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
|
int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
|
||||||
|
|
||||||
@ -4050,12 +4054,7 @@ void initialisation(int argc, char **argv) {
|
|||||||
|
|
||||||
/* handle other command line arguments */
|
/* handle other command line arguments */
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
reset_optind();
|
||||||
|| defined(__NetBSD__)
|
|
||||||
optind = optreset = 1;
|
|
||||||
#else
|
|
||||||
optind = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
|
if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
|
||||||
|
Loading…
Reference in New Issue
Block a user