]> mj.ucw.cz Git - xsv.git/blobdiff - xsv.c
Convert a couple of remaining putchar's to unlocked
[xsv.git] / xsv.c
diff --git a/xsv.c b/xsv.c
index b11946c7c1b92aa47d91de00ddfccc453609199a..0d2d972b055544ddab45ad06132ed09ea4e2b8c6 100644 (file)
--- a/xsv.c
+++ b/xsv.c
@@ -4,8 +4,6 @@
  *     (c) 2012 Martin Mares <mj@ucw.cz>
  */
 
-#define _GNU_SOURCE
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -452,7 +450,7 @@ static void table_write(struct format *fmt)
                                cw = fw;
                        }
                        while (len--)
-                               putchar(*p++);
+                               putchar_unlocked(*p++);
                }
                while (fw < cw) {
                        putchar_unlocked(' ');
@@ -477,7 +475,7 @@ static void table_write_grid(struct format *fmt, int pos UNUSED)
                putchar_unlocked('+');
                int w = fmt->table_sep + *intarray_nth(&column_widths, i);
                while (w--)
-                       putchar('-');
+                       putchar_unlocked('-');
        }
        putchar_unlocked('+');
        putchar_unlocked('\n');
@@ -871,6 +869,7 @@ static const char short_options[] = "cd:f:hqr:twW";
 
 enum long_options {
        OPT_HELP = 256,
+       OPT_VERSION,
        OPT_TRIM,
        OPT_ALWAYS_QUOTE,
        OPT_TABLE,
@@ -887,6 +886,7 @@ static const struct option long_options[] = {
        { "fs",                 1,      NULL,   'd' },
        { "grid",               0,      NULL,   OPT_GRID },
        { "header",             0,      NULL,   'h' },
+       { "help",               0,      NULL,   OPT_HELP },
        { "quiet",              0,      NULL,   'q' },
        { "regex",              1,      NULL,   'r' },
        { "sloppy",             0,      NULL,   's' },
@@ -894,8 +894,8 @@ static const struct option long_options[] = {
        { "table-sep",          1,      NULL,   OPT_TABLE_SEP },
        { "trim",               0,      NULL,   OPT_TRIM },
        { "tsv",                0,      NULL,   't' },
+       { "version",            0,      NULL,   OPT_VERSION },
        { "ws",                 0,      NULL,   'w' },
-       { "help",               0,      NULL,   OPT_HELP },
        { NULL,                 0,      NULL,   0 },
 };
 
@@ -1001,6 +1001,9 @@ int main(int argc, char **argv)
                                break;
                        case OPT_HELP:
                                usage();
+                       case OPT_VERSION:
+                               puts("This is xsv version " VERSION ".");
+                               exit(0);
                        case OPT_TRIM:
                                want_trim = 1;
                                break;