Mercurial > projects > pwm
diff util.c @ 16:a07665727c19
Add status command
Add status command to redisplay an error message of the previous command and
unsaved changes.
Add pwm_err function to display and save error messages.
author | Guido Berhoerster <guido+pwm@berhoerster.name> |
---|---|
date | Tue, 08 Aug 2017 10:47:04 +0200 |
parents | a7e41e1a79c8 |
children |
line wrap: on
line diff
--- a/util.c Mon Aug 07 19:11:56 2017 +0200 +++ b/util.c Tue Aug 08 10:47:04 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Guido Berhoerster <guido+pwm@berhoerster.name> + * Copyright (C) 2017 Guido Berhoerster <guido+pwm@berhoerster.name> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -69,14 +69,22 @@ } char * +xvasprintf(char **strp, const char *fmt, va_list args) +{ + if (vasprintf(strp, fmt, args) < 0) { + err(1, "vasprintf"); + } + + return (*strp); +} + +char * xasprintf(char **strp, const char *fmt, ...) { va_list args; va_start(args, fmt); - if (vasprintf(strp, fmt, args) < 0) { - err(1, "vasprintf"); - } + xvasprintf(strp, fmt, args); va_end(args); return (*strp);