From 073c12600b554650c8d838609d1dd71dde8a9cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Fri, 1 Jul 2016 19:29:43 +0200 Subject: [PATCH] Adds usability features. --- libvm/as/as.c | 7 ++++++- libvm/explink.c | 22 +++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/libvm/as/as.c b/libvm/as/as.c index e8726f0..e404b66 100644 --- a/libvm/as/as.c +++ b/libvm/as/as.c @@ -286,12 +286,17 @@ int main(int argc, char **argv) } } + if(optind >= argc) { + fprintf(stderr, "No input files.\n"); + exit(1); + } + if(output == NULL) { fprintf(stderr, "An output file must be given by -o fileName\n"); exit(1); } - + for (int index = optind; index < argc; index++) { FILE *f = fopen(argv[index], "r"); diff --git a/libvm/explink.c b/libvm/explink.c index 186c7a9..36dc97d 100644 --- a/libvm/explink.c +++ b/libvm/explink.c @@ -72,19 +72,27 @@ int main(int argc, char **argv) for (int index = optind; index < argc; index++) printf("Non-option argument %s\n", argv[index]); + /////////////////////////////////////////////////////////////////////////////// + + // fprintf(stderr, "Out: %s\n", outfileName); + // fprintf(stderr, "Code: %s\n", codefileName); + // fprintf(stderr, "Data: %s\n", datafileName); + + if(!codefileName && !datafileName) + { + fprintf(stderr, "No input files.\n"); + exit(1); + } + + /////////////////////////////////////////////////////////////////////////////// + FILE *f = fopen(outfileName, "wb"); if (f == NULL) { fprintf(stderr, "Could not open file %s\n", outfileName); return 1; } - - /////////////////////////////////////////////////////////////////////////////// - - fprintf(stderr, "Out: %s\n", outfileName); - fprintf(stderr, "Code: %s\n", codefileName); - fprintf(stderr, "Data: %s\n", datafileName); - + /////////////////////////////////////////////////////////////////////////////// int numSections = 0;