#include "list.h"
enum {
- TT_FL_TRUNC = (1 << 1),
- TT_FL_TREE = (1 << 2),
- TT_FL_RAW = (1 << 3),
- TT_FL_ASCII = (1 << 4),
- TT_FL_NOHEADINGS = (1 << 5),
- TT_FL_RIGHT = (1 << 6),
- TT_FL_STRICTWIDTH = (1 << 7)
+ /*
+ * Global flags
+ */
+ TT_FL_RAW = (1 << 1),
+ TT_FL_ASCII = (1 << 2),
+ TT_FL_NOHEADINGS = (1 << 3),
+ TT_FL_EXPORT = (1 << 4),
+
+ /*
+ * Column flags
+ */
+ TT_FL_TRUNC = (1 << 5),
+ TT_FL_TREE = (1 << 6),
+ TT_FL_RIGHT = (1 << 7),
+ TT_FL_STRICTWIDTH = (1 << 8)
};
struct tt {
return;
}
+ /* NAME=value mode */
+ if (tb->flags & TT_FL_EXPORT) {
+ fprintf(stdout, "%s=\"%s\"", cl->name, data);
+ if (!is_last_column(tb, cl))
+ fputc(' ', stdout);
+ return;
+ }
+
/* note that 'len' and 'width' are number of cells, not bytes */
len = mbs_width(data);
if (!tb->first_run ||
(tb->flags & TT_FL_NOHEADINGS) ||
+ (tb->flags & TT_FL_EXPORT) ||
list_empty(&tb->tb_lines))
return;
if (!line)
return -1;
- if (tb->first_run && !(tb->flags & TT_FL_RAW))
+ if (tb->first_run &&
+ !((tb->flags & TT_FL_RAW) || (tb->flags & TT_FL_EXPORT)))
recount_widths(tb, line, line_sz);
if (tb->flags & TT_FL_TREE)
printf("%s [--ascii | --raw | --list]\n",
program_invocation_short_name);
return EXIT_SUCCESS;
- } else if (argc == 2 && !strcmp(argv[1], "--ascii"))
+ } else if (argc == 2 && !strcmp(argv[1], "--ascii")) {
flags |= TT_FL_ASCII;
- else if (argc == 2 && !strcmp(argv[1], "--raw")) {
+ } else if (argc == 2 && !strcmp(argv[1], "--raw")) {
flags |= TT_FL_RAW;
notree = 1;
+ } else if (argc == 2 && !strcmp(argv[1], "--export")) {
+ flags |= TT_FL_EXPORT;
+ notree = 1;
} else if (argc == 2 && !strcmp(argv[1], "--list"))
notree = 1;