|
@@ -10,6 +10,7 @@
|
10
|
10
|
#include <cstdlib>
|
11
|
11
|
#include <stdio.h>
|
12
|
12
|
#include <string.h>
|
|
13
|
+#include <assert.h>
|
13
|
14
|
|
14
|
15
|
#if defined(unix) || defined(__APPLE__)
|
15
|
16
|
#include <wordexp.h>
|
|
@@ -18,8 +19,8 @@
|
18
|
19
|
#include "utils/strings.h"
|
19
|
20
|
|
20
|
21
|
bool stringEndsWith(const char *str, const char *suffix) {
|
21
|
|
- if (!str || !suffix)
|
22
|
|
- return false;
|
|
22
|
+ assert(str != NULL);
|
|
23
|
+ assert(suffix != NULL);
|
23
|
24
|
|
24
|
25
|
size_t lenstr = strlen(str);
|
25
|
26
|
size_t lensuffix = strlen(suffix);
|
|
@@ -36,8 +37,8 @@ char *bufferString(const char *string, ...) {
|
36
|
37
|
char *text;
|
37
|
38
|
va_list args;
|
38
|
39
|
|
39
|
|
- if (!string || !string[0])
|
40
|
|
- return NULL;
|
|
40
|
+ assert(string != NULL);
|
|
41
|
+ assert(string[0] != '\0');
|
41
|
42
|
|
42
|
43
|
text = new char[sz];
|
43
|
44
|
|
|
@@ -65,8 +66,8 @@ char *fullPath(const char *path, char end) {
|
65
|
66
|
wordexp_t word;
|
66
|
67
|
char *dir;
|
67
|
68
|
|
68
|
|
- if (!path || !path[0])
|
69
|
|
- return NULL;
|
|
69
|
+ assert(path != NULL);
|
|
70
|
+ assert(path[0] != '\0');
|
70
|
71
|
|
71
|
72
|
if (path[0] == '~') {
|
72
|
73
|
#if defined(unix) || defined(__APPLE__)
|
|
@@ -127,8 +128,10 @@ char *fullPath(const char *path, char end) {
|
127
|
128
|
}
|
128
|
129
|
|
129
|
130
|
bool rc_command(const char *symbol, char *command) {
|
130
|
|
- if (!symbol || !symbol[0] || !command || !command[0])
|
131
|
|
- return false;
|
|
131
|
+ assert(symbol != NULL);
|
|
132
|
+ assert(symbol[0] != '\0');
|
|
133
|
+ assert(command != NULL);
|
|
134
|
+ assert(command[0] != '\0');
|
132
|
135
|
|
133
|
136
|
int lens = strlen(symbol);
|
134
|
137
|
|
|
@@ -149,8 +152,9 @@ bool rc_command(const char *symbol, char *command) {
|
149
|
152
|
}
|
150
|
153
|
|
151
|
154
|
int rc_get_bool(const char *buffer, bool *val) {
|
152
|
|
- if (!buffer || !buffer[0])
|
153
|
|
- return -1;
|
|
155
|
+ assert(buffer != NULL);
|
|
156
|
+ assert(buffer[0] != '\0');
|
|
157
|
+ assert(val != NULL);
|
154
|
158
|
|
155
|
159
|
if ((buffer[0] == '1') || (strncmp(buffer, "true", 4) == 0))
|
156
|
160
|
*val = true;
|