summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_amain.c18
-rw-r--r--src/slibtool.c2
2 files changed, 12 insertions, 8 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c
index a331b3b..e0d6bb9 100644
--- a/src/driver/slbt_amain.c
+++ b/src/driver/slbt_amain.c
@@ -83,10 +83,10 @@ static int slbt_exit(struct slbt_driver_ctx * dctx, int ret)
return ret;
}
-int slbt_main(int argc, char ** argv, char ** envp,
- const struct slbt_fd_ctx * fdctx)
+int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx)
{
int ret;
+ const char * harg;
int fdout;
uint64_t flags;
struct slbt_driver_ctx * dctx;
@@ -97,11 +97,15 @@ int slbt_main(int argc, char ** argv, char ** envp,
flags = SLBT_DRIVER_FLAGS;
fdout = fdctx ? fdctx->fdout : STDOUT_FILENO;
+ /* harg */
+ harg = (!argv || !argv[0] || !argv[1] || argv[2])
+ ? 0 : argv[1];
+
/* --version only? */
- if ((argc == 2) && (!strcmp(argv[1],"--version")
- || !strcmp(argv[1],"--help-all")
- || !strcmp(argv[1],"--help")
- || !strcmp(argv[1],"-h"))) {
+ if (harg && (!strcmp(harg,"--version")
+ || !strcmp(harg,"--help-all")
+ || !strcmp(harg,"--help")
+ || !strcmp(harg,"-h"))) {
sargv[0] = argv[0];
sargv[1] = argv[1];
sargv[2] = "--mode=compile";
@@ -153,7 +157,7 @@ int slbt_main(int argc, char ** argv, char ** envp,
/* driver context */
if ((ret = slbt_get_driver_ctx(argv,envp,flags,fdctx,&dctx)))
return (ret == SLBT_USAGE)
- ? !--argc
+ ? !argv || !argv[0] || !argv[1]
: SLBT_ERROR;
if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION)
diff --git a/src/slibtool.c b/src/slibtool.c
index a21c9f1..130474e 100644
--- a/src/slibtool.c
+++ b/src/slibtool.c
@@ -8,5 +8,5 @@
int main(int argc, char ** argv, char ** envp)
{
- return slbt_main(argc,argv,envp,0);
+ return slbt_main(argv,envp,0);
}