69 lines
2.8 KiB
Plaintext
69 lines
2.8 KiB
Plaintext
dnl $Id: m4.ret,v 10.133 2004/08/13 03:38:58 bostic Exp $
|
|
dnl
|
|
dnl ###################################################################
|
|
dnl RETURN VALUES:
|
|
dnl m4_return:
|
|
dnl #1: API name
|
|
dnl #2: Variadic list of return conditions
|
|
dnl ###################################################################
|
|
define(m4_return, [dnl
|
|
define([__m4_retapi], [$1])
|
|
m4_p([__m4_retloop(shift($@))])])
|
|
dnl ###################################################################
|
|
dnl __m4_common_ret_txt
|
|
dnl Standard return text.
|
|
dnl ###################################################################
|
|
define(__m4_common_ret_txt, [dnl
|
|
m4_refT(__m4_retapi)
|
|
ifelse(M4EXCEPT, except_return, [either returns a non-zero error value
|
|
or throws an exception that encapsulates a non-zero error value on
|
|
failure, and returns 0 on success.],
|
|
M4EXCEPT, except_only, [throws an exception that encapsulates a non-zero
|
|
error value on failure.],[returns a non-zero error value on failure
|
|
and 0 on success.])])
|
|
dnl ###################################################################
|
|
dnl __m4_retloop
|
|
dnl Helper macro: loop through return list.
|
|
dnl ###################################################################
|
|
define(__m4_retloop, [ifelse([$1],,,
|
|
dnl ###################################################################
|
|
dnl "std"
|
|
dnl Returning 0 or errno.
|
|
dnl ###################################################################
|
|
[$1], std, [The __m4_common_ret_txt
|
|
__m4_retloop(shift($@))],
|
|
dnl ###################################################################
|
|
dnl "prev"
|
|
dnl Otherwise, returning 0 or errno.
|
|
dnl ###################################################################
|
|
[$1], prev, [Unless otherwise specified, the __m4_common_ret_txt
|
|
__m4_retloop(shift($@))],
|
|
dnl ###################################################################
|
|
dnl "except"
|
|
dnl Specific return that may be an exception.
|
|
dnl #2: the condition
|
|
dnl #3: the return value.
|
|
dnl ###################################################################
|
|
[$1], except, [dnl
|
|
The m4_refT(__m4_retapi)
|
|
ifelse(M4EXCEPT, except_return, [will either return m4_ref($2) or
|
|
throw an exception that encapsulates m4_ref($2)],
|
|
M4EXCEPT, except_only,
|
|
[will throw an exception that encapsulates m4_ref($2)],
|
|
[will return m4_ref($2)]) $3.
|
|
__m4_retloop(shift(shift(shift($@))))],
|
|
dnl ###################################################################
|
|
dnl "specific"
|
|
dnl Specific return that is never an exception
|
|
dnl #2: the condition
|
|
dnl #3: the return value.
|
|
dnl ###################################################################
|
|
[$1], specific, [dnl
|
|
The m4_refT(__m4_retapi) will return m4_ref($2) $3.
|
|
__m4_retloop(shift(shift(shift($@))))],
|
|
dnl ###################################################################
|
|
dnl Everything else.
|
|
dnl ###################################################################
|
|
[$1
|
|
__m4_retloop(shift($@))])])
|