Browse Source

printucddata: check all command-line arguments

master
Reece H. Dunn 8 years ago
parent
commit
3aecbfecb3
2 changed files with 35 additions and 25 deletions
  1. 17
    12
      tests/printucddata.c
  2. 18
    13
      tests/printucddata_cpp.cpp

+ 17
- 12
tests/printucddata.c View File

/* /*
* Copyright (C) 2012-2016 Reece H. Dunn
* Copyright (C) 2012-2017 Reece H. Dunn
* *
* This file is part of ucd-tools. * This file is part of ucd-tools.
* *


int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (argc == 2)
FILE *in = NULL;
for (int argn = 1; argn != argc; ++argn)
{ {
if (!strcmp(argv[1], "--stdin") || !strcmp(argv[1], "-"))
print_file(stdin);
else
const char *arg = argv[argn];
if (!strcmp(arg, "--stdin") || !strcmp(arg, "-"))
in = stdin;
else if (in == NULL)
{ {
FILE *in = fopen(argv[1], "r");
if (in)
{
print_file(in);
fclose(in);
}
else
in = fopen(arg, "r");
if (!in)
fprintf(stdout, "cannot open `%s`\n", argv[1]); fprintf(stdout, "cannot open `%s`\n", argv[1]);
} }
} }

if (in == stdin)
print_file(stdin);
else if (in != NULL)
{
print_file(in);
fclose(in);
}
else else
{ {
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) for (codepoint_t c = 0; c <= 0x10FFFF; ++c)

+ 18
- 13
tests/printucddata_cpp.cpp View File

/* /*
* Copyright (C) 2012-2016 Reece H. Dunn
* Copyright (C) 2012-2017 Reece H. Dunn
* *
* This file is part of ucd-tools. * This file is part of ucd-tools.
* *


int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (argc == 2)
FILE *in = NULL;
for (int argn = 1; argn != argc; ++argn)
{ {
if (!strcmp(argv[1], "--stdin") || !strcmp(argv[1], "-"))
print_file(stdin);
else
const char *arg = argv[argn];
if (!strcmp(arg, "--stdin") || !strcmp(arg, "-"))
in = stdin;
else if (in == NULL)
{ {
FILE *in = fopen(argv[1], "r");
if (in)
{
print_file(in);
fclose(in);
}
else
in = fopen(arg, "r");
if (!in)
fprintf(stdout, "cannot open `%s`\n", argv[1]); fprintf(stdout, "cannot open `%s`\n", argv[1]);
} }
} }

if (in == stdin)
print_file(stdin);
else if (in != NULL)
{
print_file(in);
fclose(in);
}
else else
{ {
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, "%pH %s %C %c %UH %LH %TH %W\n"); uprintf(stdout, c, "%pH %s %C %c %UH %LH %TH %W\n");
} }
return 0; return 0;

Loading…
Cancel
Save