Deleted Added
full compact
xo.c (277353) xo.c (287111)
1/*
2 * Copyright (c) 2014, Juniper Networks, Inc.
3 * All rights reserved.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
7 * LICENSE.
8 * Phil Shafer, July 2014
9 */
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <stdarg.h>
14#include <string.h>
15
1/*
2 * Copyright (c) 2014, Juniper Networks, Inc.
3 * All rights reserved.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
7 * LICENSE.
8 * Phil Shafer, July 2014
9 */
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <stdarg.h>
14#include <string.h>
15
16#include "xoconfig.h"
16#include "xo_config.h"
17#include "xo.h"
17#include "xo.h"
18#include "xoversion.h"
19
20#include <getopt.h> /* Include after xo.h for testing */
21
22#ifndef UNUSED
23#define UNUSED __attribute__ ((__unused__))
24#endif /* UNUSED */
25
26static int opt_warn; /* Enable warnings */

--- 63 unchanged lines hidden (view full) ---

90 * Our custom formatter is responsible for combining format string pieces
91 * with our command line arguments to build strings. This involves faking
92 * some printf-style logic.
93 */
94static int
95formatter (xo_handle_t *xop, char *buf, int bufsiz,
96 const char *fmt, va_list vap UNUSED)
97{
18
19#include <getopt.h> /* Include after xo.h for testing */
20
21#ifndef UNUSED
22#define UNUSED __attribute__ ((__unused__))
23#endif /* UNUSED */
24
25static int opt_warn; /* Enable warnings */

--- 63 unchanged lines hidden (view full) ---

89 * Our custom formatter is responsible for combining format string pieces
90 * with our command line arguments to build strings. This involves faking
91 * some printf-style logic.
92 */
93static int
94formatter (xo_handle_t *xop, char *buf, int bufsiz,
95 const char *fmt, va_list vap UNUSED)
96{
98 int lflag = 0, hflag = 0, jflag = 0, tflag = 0,
97 int lflag UNUSED = 0; /* Parse long flag, though currently ignored */
98 int hflag = 0, jflag = 0, tflag = 0,
99 zflag = 0, qflag = 0, star1 = 0, star2 = 0;
100 int rc = 0;
101 int w1 = 0, w2 = 0;
102 const char *cp;
103
104 for (cp = fmt + 1; *cp; cp++) {
105 if (*cp == 'l')
106 lflag += 1;

--- 89 unchanged lines hidden (view full) ---

196" --close <path> Close tags for the given path\n"
197" --depth <num> Set the depth for pretty printing\n"
198" --help Display this help text\n"
199" --html OR -H Generate HTML output\n"
200" --json OR -J Generate JSON output\n"
201" --leading-xpath <path> OR -l <path> "
202 "Add a prefix to generated XPaths (HTML)\n"
203" --open <path> Open tags for the given path\n"
99 zflag = 0, qflag = 0, star1 = 0, star2 = 0;
100 int rc = 0;
101 int w1 = 0, w2 = 0;
102 const char *cp;
103
104 for (cp = fmt + 1; *cp; cp++) {
105 if (*cp == 'l')
106 lflag += 1;

--- 89 unchanged lines hidden (view full) ---

196" --close <path> Close tags for the given path\n"
197" --depth <num> Set the depth for pretty printing\n"
198" --help Display this help text\n"
199" --html OR -H Generate HTML output\n"
200" --json OR -J Generate JSON output\n"
201" --leading-xpath <path> OR -l <path> "
202 "Add a prefix to generated XPaths (HTML)\n"
203" --open <path> Open tags for the given path\n"
204" --option <opts> -or -O <opts> Give formatting options\n"
204" --pretty OR -p Make 'pretty' output (add indent, newlines)\n"
205" --style <style> OR -s <style> "
206 "Generate given style (xml, json, text, html)\n"
207" --text OR -T Generate text output (the default style)\n"
208" --version Display version information\n"
209" --warn OR -W Display warnings in text on stderr\n"
210" --warn-xml Display warnings in xml on stdout\n"
211" --wrap <path> Wrap output in a set of containers\n"

--- 42 unchanged lines hidden (view full) ---

254 int opt_depth = 0;
255 int opt_not_first = 0;
256 int rc;
257
258 argc = xo_parse_args(argc, argv);
259 if (argc < 0)
260 return 1;
261
205" --pretty OR -p Make 'pretty' output (add indent, newlines)\n"
206" --style <style> OR -s <style> "
207 "Generate given style (xml, json, text, html)\n"
208" --text OR -T Generate text output (the default style)\n"
209" --version Display version information\n"
210" --warn OR -W Display warnings in text on stderr\n"
211" --warn-xml Display warnings in xml on stdout\n"
212" --wrap <path> Wrap output in a set of containers\n"

--- 42 unchanged lines hidden (view full) ---

255 int opt_depth = 0;
256 int opt_not_first = 0;
257 int rc;
258
259 argc = xo_parse_args(argc, argv);
260 if (argc < 0)
261 return 1;
262
262 while ((rc = getopt_long(argc, argv, "c:HJl:ps:TXW",
263 while ((rc = getopt_long(argc, argv, "c:HJl:O:o:ps:TXW",
263 long_opts, NULL)) != -1) {
264 switch (rc) {
265 case 'c':
266 opt_closer = optarg;
267 xo_set_flags(NULL, XOF_IGNORE_CLOSE);
268 break;
269
270 case 'H':

--- 169 unchanged lines hidden ---
264 long_opts, NULL)) != -1) {
265 switch (rc) {
266 case 'c':
267 opt_closer = optarg;
268 xo_set_flags(NULL, XOF_IGNORE_CLOSE);
269 break;
270
271 case 'H':

--- 169 unchanged lines hidden ---