Mercurial > projects > pwm
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:3380c8fd9776 | 16:a07665727c19 |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2016 Guido Berhoerster <guido+pwm@berhoerster.name> | 2 * Copyright (C) 2017 Guido Berhoerster <guido+pwm@berhoerster.name> |
3 * | 3 * |
4 * Permission is hereby granted, free of charge, to any person obtaining | 4 * Permission is hereby granted, free of charge, to any person obtaining |
5 * a copy of this software and associated documentation files (the | 5 * a copy of this software and associated documentation files (the |
6 * "Software"), to deal in the Software without restriction, including | 6 * "Software"), to deal in the Software without restriction, including |
7 * without limitation the rights to use, copy, modify, merge, publish, | 7 * without limitation the rights to use, copy, modify, merge, publish, |
67 | 67 |
68 return (new); | 68 return (new); |
69 } | 69 } |
70 | 70 |
71 char * | 71 char * |
72 xvasprintf(char **strp, const char *fmt, va_list args) | |
73 { | |
74 if (vasprintf(strp, fmt, args) < 0) { | |
75 err(1, "vasprintf"); | |
76 } | |
77 | |
78 return (*strp); | |
79 } | |
80 | |
81 char * | |
72 xasprintf(char **strp, const char *fmt, ...) | 82 xasprintf(char **strp, const char *fmt, ...) |
73 { | 83 { |
74 va_list args; | 84 va_list args; |
75 | 85 |
76 va_start(args, fmt); | 86 va_start(args, fmt); |
77 if (vasprintf(strp, fmt, args) < 0) { | 87 xvasprintf(strp, fmt, args); |
78 err(1, "vasprintf"); | |
79 } | |
80 va_end(args); | 88 va_end(args); |
81 | 89 |
82 return (*strp); | 90 return (*strp); |
83 } | 91 } |