X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Futil.c;h=1a42376e21216fc0c3a07ea928dd172719f1515e;hb=c3729ee42dc25a8240cee6c0041b7db3e4070414;hp=b9dbdc48063164e1755c0c887901cd2f6d621306;hpb=c1c8308a3971526f5126201a6d1659c9247c1f0a;p=openvswitch diff --git a/lib/util.c b/lib/util.c index b9dbdc48..1a42376e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -204,9 +204,14 @@ ovs_fatal(int err_no, const char *format, ...) va_list args; va_start(args, format); - ovs_error_valist(err_no, format, args); - va_end(args); + ovs_fatal_valist(err_no, format, args); +} +/* Same as ovs_fatal() except that the arguments are supplied as a va_list. */ +void +ovs_fatal_valist(int err_no, const char *format, va_list args) +{ + ovs_error_valist(err_no, format, args); exit(EXIT_FAILURE); } @@ -591,3 +596,14 @@ abs_file_name(const char *dir, const char *file_name) * its return value. (Note that every scalar type can be implicitly * converted to bool.) */ void ignore(bool x OVS_UNUSED) { } + +/* Returns an appropriate delimiter for inserting just before the 0-based item + * 'index' in a list that has 'total' items in it. */ +const char * +english_list_delimiter(size_t index, size_t total) +{ + return (index == 0 ? "" + : index < total - 1 ? ", " + : total > 2 ? ", and " + : " and "); +}