annotate common/strhelp.c @ 164:6d64d7e9fa32

Implemented port_dirname for windows.
author Sascha Wilde <wilde@intevation.de>
date Tue, 25 Mar 2014 12:01:26 +0100
parents b026e6d2a161
children bf4bfd8843bd
rev   line source
134
5f830969e4a1 Added missing include.
Sascha Wilde <wilde@intevation.de>
parents: 133
diff changeset
1 #include <ctype.h>
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
2 #include <stdbool.h>
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include <stdio.h>
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 #include <stdlib.h>
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 #include <string.h>
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 #include <assert.h>
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7
143
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
8 /* Remarks regarding the "Flawfinder: ignore" comments in this file:
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
9 *
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
10 * - strlen:
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
11 *
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
12 * It's true that strlen might crash if input is not null
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
13 * terminated. But by design there is not safe way to get the
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
14 * length of an string in C, and defining an additional length
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
15 * parameter for string parameter will only transfere the problem to
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
16 * the caller.
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
17 */
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
18
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 static void
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 out_of_core(void)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 fputs("\nfatal: out of memory\n", stderr);
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 exit(2);
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 void *
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 xmalloc( size_t n )
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 void *p = malloc( n );
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 if( !p )
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 out_of_core();
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 return p;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 void *
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 xrealloc( void *a, size_t n )
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 void *p = realloc( a, n );
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 if( !p )
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 out_of_core();
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 return p;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 char *
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
44 xstrndup( const char *string, const size_t len )
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 {
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
46 char *p = xmalloc( len + 1 );
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
47 memcpy( p, string, len );
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
48 p[len] = '\0';
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 return p;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 unsigned int
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 strv_length (char **str_array)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 unsigned int i = 0;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 if (!str_array)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 return 0;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 while (str_array[i])
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 ++i;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 return i;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65
116
c602d8cfa619 Refactoring: unified naming of string vector functions.
Sascha Wilde <wilde@intevation.de>
parents: 91
diff changeset
66 void strv_append (char ***pArray, const char *string, const size_t len)
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 {
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
68 unsigned int old_len = 0;
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
69
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
70 if (!*pArray) {
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
71 *pArray = xmalloc(2 * sizeof(char*));
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
72 (*pArray)[0] = xstrndup(string, len);
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
73 (*pArray)[1] = NULL;
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
74 return;
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
75 }
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
76 old_len = strv_length(*pArray);
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 *pArray = xrealloc(*pArray, sizeof(char**) * (old_len + 2));
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
79 (*pArray)[old_len] = xstrndup(string, len);
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
80 (*pArray)[old_len + 1] = NULL;
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
81 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
83 void
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
84 str_append_str(char **pDst, size_t *dst_len, const char *appendage, const size_t len)
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 if (!appendage)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 return;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
88
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
89 if (!(*pDst)) {
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
90 *pDst = xstrndup(appendage, len);
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
91 *dst_len = len;
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
92 } else {
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
93 size_t new_size = (*dst_len) + len + 1;
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
94 char *p_old = *pDst;
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
95 *pDst = xmalloc(new_size);
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
96 strncpy(*pDst, p_old, *dst_len);
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
97 strncpy(*pDst + *dst_len, appendage, len);
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
98 *dst_len = new_size - 1;
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
99 (*pDst)[*dst_len] = '\0';
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 63
diff changeset
100 free (p_old);
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
101 }
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
102 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
103
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
104 void
116
c602d8cfa619 Refactoring: unified naming of string vector functions.
Sascha Wilde <wilde@intevation.de>
parents: 91
diff changeset
105 strv_free (char **str_array)
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
107 if (str_array)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
108 {
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
109 int i;
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
110
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
111 for (i = 0; str_array[i] != NULL; i++)
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
112 free (str_array[i]);
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
113
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
114 free (str_array);
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
115 }
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
116 }
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
117
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
118 bool
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
119 str_equal (char *s1, char *s2)
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
120 {
143
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
121 size_t l1 = strlen(s1); /* Flawfinder: ignore */
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
122 size_t l2 = strlen(s2); /* Flawfinder: ignore */
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
123 if ((l1 == l2) &&
136
5fa4791d6d0e Replaced unnecessary strncmp with strcmp.
Sascha Wilde <wilde@intevation.de>
parents: 135
diff changeset
124 (strcmp(s1, s2) == 0))
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
125 return true;
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
126 else
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
127 return false;
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
128 }
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
129
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
130 bool
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
131 str_starts_with (char *s1, char *s2)
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
132 {
143
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
133 size_t l2 = strlen(s2); /* Flawfinder: ignore */
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
134 if (strncmp(s1, s2, l2) == 0)
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
135 return true;
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
136 else
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
137 return false;
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
138 }
133
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
139
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
140 void
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
141 str_trim (char **s)
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
142 {
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
143 size_t i;
135
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
144 if (*s != NULL)
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
145 {
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
146 while (isspace(**s))
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
147 (*s)++;
143
b026e6d2a161 Make flawfinder (a bit more) happy.
Sascha Wilde <wilde@intevation.de>
parents: 136
diff changeset
148 i = strlen(*s); /* Flawfinder: ignore */
135
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
149 while (isspace((*s)[--i]))
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
150 (*s)[i] = '\0';
3fb6ddd6b70d str_trim: do nothing if *s is NULL.
Sascha Wilde <wilde@intevation.de>
parents: 134
diff changeset
151 }
133
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
152 }

http://wald.intevation.org/projects/trustbridge/