diff options
author | Gavin Howard <gavin@yzena.com> | 2021-07-16 23:54:41 -0600 |
---|---|---|
committer | Gavin Howard <gavin@yzena.com> | 2021-07-16 23:54:59 -0600 |
commit | 982249a3a127461a0ead011a19c19ac858119b08 (patch) | |
tree | 80ba7bbbdcb775e7317b67b3a64d9916f24bfb88 /src/main.c | |
parent | a596d22f0e97c09dce1972b706bd131d602840ac (diff) | |
download | platform_external_bc-982249a3a127461a0ead011a19c19ac858119b08.tar.gz platform_external_bc-982249a3a127461a0ead011a19c19ac858119b08.tar.bz2 platform_external_bc-982249a3a127461a0ead011a19c19ac858119b08.zip |
Do a lot of doc work and refactor along the way
Yay! I finished commenting the code!
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -56,17 +56,24 @@ int main(int argc, char *argv[]) { char *name; size_t len = strlen(BC_EXECPREFIX); + // Must set the locale properly in order to have the right error messages. vm.locale = setlocale(LC_ALL, ""); + // Set the start pledge(). bc_pledge(bc_pledge_start, NULL); + // Figure out the name of the calculator we are using. We can't use basename + // because it's not portable, but yes, this is stripping off the directory. name = strrchr(argv[0], BC_FILE_SEP); vm.name = (name == NULL) ? argv[0] : name + 1; + // If the name is longer than the length of the prefix, skip the prefix. if (strlen(vm.name) > len) vm.name += len; BC_SIG_LOCK; + // We *must* do this here. Otherwise, other code could not jump out all of + // the way. bc_vec_init(&vm.jmp_bufs, sizeof(sigjmp_buf), BC_DTOR_NONE); BC_SETJMP_LOCKED(exit); @@ -76,6 +83,7 @@ int main(int argc, char *argv[]) { #elif !BC_ENABLED dc_main(argc, argv); #else + // BC_IS_BC uses vm.name, which was set above. So we're good. if (BC_IS_BC) bc_main(argc, argv); else dc_main(argc, argv); #endif @@ -83,5 +91,6 @@ int main(int argc, char *argv[]) { exit: BC_SIG_MAYLOCK; + // Ensure we exit appropriately. return bc_vm_atexit((int) vm.status); } |