From 6bc75ea5118dd2808cb4801d3c4e3b279df93992 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 20 Jun 2020 12:23:14 -0700 Subject: exit: argument becomes optional * sysif.c (exit_wrap): Check for missing status argument, and map to EXIT_SUCCESS. (sysif_init): Register exit as having optional argument. * txr.1: Update documentation regarding optional argument of exit. Also, EXIT_SUCCESS and EXIT_FAILURE are no longer mentioned, only that t maps to succes and nil to failure. --- sysif.c | 6 ++++-- txr.1 | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sysif.c b/sysif.c index 7c55ffed..e54d6c5f 100644 --- a/sysif.c +++ b/sysif.c @@ -173,7 +173,9 @@ static val exit_wrap(val status) { int stat; - if (status == nil) + if missingp(status) + stat = EXIT_SUCCESS; + else if (status == nil) stat = EXIT_FAILURE; else if (status == t) stat = EXIT_SUCCESS; @@ -2348,7 +2350,7 @@ void sysif_init(void) reg_fun(intern(lit("errno"), user_package), func_n1o(errno_wrap, 0)); reg_fun(intern(lit("strerror"), user_package), func_n1o(strerror_wrap, 0)); - reg_fun(intern(lit("exit"), user_package), func_n1(exit_wrap)); + reg_fun(intern(lit("exit"), user_package), func_n1o(exit_wrap, 0)); reg_fun(intern(lit("at-exit-call"), user_package), func_n1(at_exit_call)); reg_fun(intern(lit("at-exit-do-not-call"), user_package), func_n1(at_exit_do_not_call)); reg_fun(intern(lit("abort"), user_package), func_n0(abort_wrap)); diff --git a/txr.1 b/txr.1 index 0e8dba44..597c0723 100644 --- a/txr.1 +++ b/txr.1 @@ -58603,28 +58603,30 @@ If the host platform fails to provide a description, the function returns .coNP Function @ exit .synb -.mets (exit << status ) +.mets (exit <> [ status ]) .syne .desc The .code exit function terminates the entire process (running \*(TX image), specifying -the termination status to the operating system. Values of +the termination status to the operating system. Values of the optional .meta status -may be +parameter may be .codn nil , .codn t , or an integer value. The value .code nil -corresponds to the C constant -.codn EXIT_FAILURE , -and +indicates an unsuccessful termination status, whereas .code t -corresponds to -.codn EXIT_SUCCESS . -These are platform-independent -indicators of failed or successful termination. The numeric value 0 also -indicates success. +indicates a successful termination status. +An absence of the +.meta status +argument also specifies a successful termination status. +If +.meta status +is an integer value, it specifies a successful termination if it is +.code 0 +otherwise the interpretation of the value is platform specific. .coNP Variables @, e2big @, eacces @, eaddrinuse @, eaddrnotavail @, eafnosupport @, eagain @, ealready @, ebadf @, ebadmsg @, ebusy @, ecanceled @, echild @, econnaborted @, econnrefused @, econnreset @, edeadlk @, edestaddrreq @, edom @, edquot @, eexist @, efault @, efbig @, ehostunreach @, eidrm @, eilseq @, einprogress @, eintr @, einval @, eio @, eisconn @, eisdir @, eloop @, emfile @, emlink @, emsgsize @, emultihop @, enametoolong @, enetdown @, enetreset @, enetunreach @, enfile @, enobufs @, enodata @, enodev @, enoent @, enoexec @, enolck @, enolink @, enomem @, enomsg @, enoprotoopt @, enospc @, enosr @, enostr @, enosys @, enotconn @, enotdir @, enotempty @, enotrecoverable @, enotsock @, enotsup @, enotty @, enxio @, eopnotsupp @, eoverflow @, eownerdead @, eperm @, epipe @, eproto @, eprotonosupport @, eprototype @, erange @, erofs @, espipe @, esrch @, estale @, etime @, etimedout @, etxtbsy @ ewouldblock and @ exdev .desc -- cgit v1.2.3