From bd7e4225d18207250cc312be601ae1615f62f0ad Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 6 Sep 2026 00:52:48 +0200 Subject: Add prc front-end --- src/prc1/CMakeLists.txt | 3 ++- src/prc1/kw.c | 2 +- src/prc1/prc1.c | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/prc1') diff --git a/src/prc1/CMakeLists.txt b/src/prc1/CMakeLists.txt index 3579ca6..e2b9ad4 100644 --- a/src/prc1/CMakeLists.txt +++ b/src/prc1/CMakeLists.txt @@ -36,4 +36,5 @@ set_target_properties(prc1 PROPERTIES C_STANDARD 99 C_EXTENSIONS OFF) if(CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_options(prc1 PRIVATE -Og) endif() -# install(TARGETS prc1) +include(GNUInstallDirs) +install(TARGETS prc1 DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}) diff --git a/src/prc1/kw.c b/src/prc1/kw.c index d5e22ca..c72ac97 100644 --- a/src/prc1/kw.c +++ b/src/prc1/kw.c @@ -18,7 +18,7 @@ static const char *kws[] = /* built-in functions */ "display", "warn", /* flow control */ - "while", "if", "else", "end", "return", "go", "label", "default", + "while", "if", "else", "end", "return", "go", "label", /*"default",*/ /* prepositions */ "by", "from", "to", "than", "of", "etc", /* comparators */ diff --git a/src/prc1/prc1.c b/src/prc1/prc1.c index 69165ba..6378907 100644 --- a/src/prc1/prc1.c +++ b/src/prc1/prc1.c @@ -14,16 +14,19 @@ int main(int argc, char *argv[]) FILE *f = stdin; int opened = 0, ret = EXIT_FAILURE; - if (argc != 2) + for (int i = 1; i < argc; i++) + fprintf(stderr, "[%d]=%s\n", i, argv[i]); + + if (argc < 2) { - fprintf(stderr, "%s: error: missing input file\n", *argv); + fprintf(stderr, "%s [options ...] file\n", *argv); goto end; } else if (strcmp(argv[1], "-")) { if (!(f = fopen(argv[1], "rb"))) { - fprintf(stderr, "failed to open %s: %s\n", argv[1], + fprintf(stderr, "%s: failed to open %s: %s\n", *argv, argv[1], strerror(errno)); goto end; } -- cgit v1.2.3