View | Details | Raw Unified | Return to bug 246514
Collapse All | Expand All

(-)b/contrib/libxo/libxo/libxo.c (+15 lines)
Lines 42-47 Link Here
42
#include <ctype.h>
42
#include <ctype.h>
43
#include <wctype.h>
43
#include <wctype.h>
44
#include <getopt.h>
44
#include <getopt.h>
45
#include <stdbool.h>
45
46
46
#include "xo_config.h"
47
#include "xo_config.h"
47
#include "xo.h"
48
#include "xo.h"
Lines 268-273 struct xo_handle_s { Link Here
268
    char *xo_gt_domain;		/* Gettext domain, suitable for dgettext(3) */
269
    char *xo_gt_domain;		/* Gettext domain, suitable for dgettext(3) */
269
    xo_encoder_func_t xo_encoder; /* Encoding function */
270
    xo_encoder_func_t xo_encoder; /* Encoding function */
270
    void *xo_private;		/* Private data for external encoders */
271
    void *xo_private;		/* Private data for external encoders */
272
    bool xo_libxo_set;		/* Initial flags passed via --libxo */
271
};
273
};
272
274
273
/* Flag operations */
275
/* Flag operations */
Lines 8170-8175 xo_parse_args (int argc, char **argv) Link Here
8170
    }
8172
    }
8171
8173
8172
    xo_handle_t *xop = xo_default(NULL);
8174
    xo_handle_t *xop = xo_default(NULL);
8175
    xop->xo_libxo_set = false;
8173
8176
8174
    for (save = i = 1; i < argc; i++) {
8177
    for (save = i = 1; i < argc; i++) {
8175
	if (argv[i] == NULL
8178
	if (argv[i] == NULL
Lines 8180-8185 xo_parse_args (int argc, char **argv) Link Here
8180
	    continue;
8183
	    continue;
8181
	}
8184
	}
8182
8185
8186
	xop->xo_libxo_set = true;
8183
	cp = argv[i] + sizeof(libxo_opt) - 1;
8187
	cp = argv[i] + sizeof(libxo_opt) - 1;
8184
	if (*cp == '\0') {
8188
	if (*cp == '\0') {
8185
	    cp = argv[++i];
8189
	    cp = argv[++i];
Lines 8224-8229 xo_parse_args (int argc, char **argv) Link Here
8224
    return save;
8228
    return save;
8225
}
8229
}
8226
8230
8231
/*
8232
 * Let consumers know if --libxo was passed in argv.
8233
 */
8234
bool
8235
xo_libxo_set(void)
8236
{
8237
    xo_handle_t *xop = xo_default(NULL);
8238
8239
    return (xop->xo_libxo_set);
8240
}
8241
8227
/*
8242
/*
8228
 * Debugging function that dumps the current stack of open libxo constructs,
8243
 * Debugging function that dumps the current stack of open libxo constructs,
8229
 * suitable for calling from the debugger.
8244
 * suitable for calling from the debugger.
(-)b/contrib/libxo/libxo/xo.h (+4 lines)
Lines 26-31 Link Here
26
#include <limits.h>
26
#include <limits.h>
27
#include <stdlib.h>
27
#include <stdlib.h>
28
#include <errno.h>
28
#include <errno.h>
29
#include <stdbool.h>
29
30
30
#ifdef __dead2
31
#ifdef __dead2
31
#define NORETURN __dead2
32
#define NORETURN __dead2
Lines 583-588 xo_no_setlocale (void); Link Here
583
int
584
int
584
xo_parse_args (int argc, char **argv);
585
xo_parse_args (int argc, char **argv);
585
586
587
bool
588
xo_libxo_set(void);
589
586
/**
590
/**
587
 * This is the "magic" number returned by libxo-supporting commands
591
 * This is the "magic" number returned by libxo-supporting commands
588
 * when passed the equally magic "--libxo-check" option.  If you
592
 * when passed the equally magic "--libxo-check" option.  If you
(-)b/usr.bin/w/w.c (-8 / +15 lines)
Lines 95-101 static struct utmpx *utmp; Link Here
95
static struct winsize ws;
95
static struct winsize ws;
96
static kvm_t   *kd;
96
static kvm_t   *kd;
97
static time_t	now;		/* the current time of day */
97
static time_t	now;		/* the current time of day */
98
static int	ttywidth;	/* width of tty */
99
static int	fromwidth = 0;	/* max width of "from" field */
98
static int	fromwidth = 0;	/* max width of "from" field */
100
static int	argwidth;	/* width of arguments */
99
static int	argwidth;	/* width of arguments */
101
static int	header = 1;	/* true if -h flag: don't print heading */
100
static int	header = 1;	/* true if -h flag: don't print heading */
Lines 381-393 main(int argc, char *argv[]) Link Here
381
			}
380
			}
382
		}
381
		}
383
	}
382
	}
384
	if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 &&
383
	/* Don't truncate the argument list if --libxo was specified */
385
	     ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 &&
384
	if (xo_libxo_set()) {
386
	     ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) || ws.ws_col == 0)
385
		argwidth = ARG_MAX;
387
	       ttywidth = 79;
386
	} else {
388
        else
387
		int	ttywidth;	/* width of tty */
389
	       ttywidth = ws.ws_col - 1;
388
390
	argwidth = ttywidth - WUSED;
389
		if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 &&
390
		    ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 &&
391
		    ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) ||
392
		    ws.ws_col == 0)
393
			ttywidth = 79;
394
		else
395
			ttywidth = ws.ws_col - 1;
396
		argwidth = ttywidth - WUSED;
397
	}
391
	if (argwidth < 4)
398
	if (argwidth < 4)
392
		argwidth = 8;
399
		argwidth = 8;
393
	for (ep = ehead; ep != NULL; ep = ep->next) {
400
	for (ep = ehead; ep != NULL; ep = ep->next) {

Return to bug 246514