summaryrefslogtreecommitdiff
blob: 204c39e762eddf527a04ae4c1dd8814d33bcbcee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
diff -Naurp codeblocks-8.02-orig/src/src/prefix.cpp codeblocks-8.02/src/src/prefix.cpp
--- codeblocks-8.02-orig/src/src/prefix.cpp	2008-02-27 07:15:26.000000000 -0600
+++ codeblocks-8.02/src/src/prefix.cpp	2009-07-29 17:05:52.797543317 -0600
@@ -12,7 +12,7 @@
  * Written by: Mike Hearn <mike@theoretic.com>
  *             Hongli Lai <h.lai@chello.nl>
  * http://autopackage.org/
- * 
+ *
  * This source code is public domain. You can relicense this code
  * under whatever license you want.
  *
@@ -202,21 +202,20 @@ br_locate_prefix (void *symbol)
 char *
 br_prepend_prefix (void *symbol, char *path)
 {
-	char *tmp, *newpath;
-
-	br_return_val_if_fail (symbol != NULL, (char*)NULL);
-	br_return_val_if_fail (path != NULL, (char*)NULL);
+	br_return_val_if_fail (symbol != 0, (char*)0);
+	br_return_val_if_fail (path != 0, (char*)0);
 
-	tmp = br_locate_prefix (symbol);
-	if (!tmp) return (char*)NULL;
+	char* tmp = br_locate_prefix (symbol);
+	if (!tmp) return (char*)0;
 
+	char *newpath;
 	if (strcmp (tmp, "/") == 0)
 		newpath = strdup (path);
 	else
 		newpath = br_strcat (tmp, path);
 
 	/* Get rid of compiler warning ("br_prepend_prefix never used") */
-	if (0) br_prepend_prefix (NULL,  (char*)NULL);
+	if (0) br_prepend_prefix (0,  (char*)0);
 
 	free (tmp);
 	return newpath;
@@ -240,9 +239,7 @@ static pthread_once_t br_thread_key_once
 static void
 br_thread_local_store_fini ()
 {
-	char *specific;
-
-	specific = (char *) pthread_getspecific (br_thread_key);
+	char* specific = (char *) pthread_getspecific (br_thread_key);
 	if (specific)
 	{
 		free (specific);
@@ -301,11 +298,9 @@ const char *
 br_thread_local_store (char *str)
 {
 	#if BR_PTHREADS
-		char *specific;
-
 		pthread_once (&br_thread_key_once, br_thread_local_store_init);
 
-		specific = (char *) pthread_getspecific (br_thread_key);
+		char* specific = (char *) pthread_getspecific (br_thread_key);
 		br_str_free (specific);
 		pthread_setspecific (br_thread_key, str);
 
@@ -338,16 +333,13 @@ br_thread_local_store (char *str)
 char *
 br_strcat (const char *str1, const char *str2)
 {
-	char *result;
-	size_t len1, len2;
-
 	if (!str1) str1 = "";
 	if (!str2) str2 = "";
 
-	len1 = strlen (str1);
-	len2 = strlen (str2);
+	size_t len1 = strlen (str1);
+	size_t len2 = strlen (str2);
 
-	result = (char *) malloc (len1 + len2 + 1);
+	char* result = (char *) malloc (len1 + len2 + 1);
 	memcpy (result, str1, len1);
 	memcpy (result + len1, str2, len2);
 	result[len1 + len2] = '\0';
@@ -360,16 +352,13 @@ br_strcat (const char *str1, const char 
 static char *
 br_strndup (char *str, size_t size)
 {
-	char *result = (char *) NULL;
-	size_t len;
+	br_return_val_if_fail (str != (char *) 0, (char *) 0);
 
-	br_return_val_if_fail (str != (char *) NULL, (char *) NULL);
-
-	len = strlen (str);
+	size_t len = strlen (str);
 	if (!len) return strdup ("");
 	if (size > len) size = len;
 
-	result = (char *) calloc (sizeof (char), len + 1);
+	char* result = (char *) calloc (sizeof (char), len + 1);
 	memcpy (result, str, size);
 	return result;
 }
@@ -389,16 +378,16 @@ br_strndup (char *str, size_t size)
 char *
 br_extract_dir (const char *path)
 {
-	char *end, *result;
-
-	br_return_val_if_fail (path != (char *) NULL, (char *) NULL);
+	br_return_val_if_fail (path != (char *) 0, (char *) 0);
 
-	end = strrchr (path, '/');
+	const char* end = strrchr (path, '/');
 	if (!end) return strdup (".");
 
 	while (end > path && *end == '/')
+	{
 		end--;
-	result = br_strndup ((char *) path, end - path + 1);
+	}
+	char* result = br_strndup ((char *) path, end - path + 1);
 	if (!*result)
 	{
 		free (result);
@@ -424,15 +413,13 @@ br_extract_dir (const char *path)
 char *
 br_extract_prefix (const char *path)
 {
-	char *end, *tmp, *result;
-
-	br_return_val_if_fail (path != (char *) NULL, (char *) NULL);
+	br_return_val_if_fail (path != (char *) 0, (char *) 0);
 
 	if (!*path) return strdup ("/");
-	end = strrchr (path, '/');
+	const char* end = strrchr (path, '/');
 	if (!end) return strdup (path);
 
-	tmp = br_strndup ((char *) path, end - path);
+	char* tmp = br_strndup ((char *) path, end - path);
 	if (!*tmp)
 	{
 		free (tmp);
@@ -441,7 +428,7 @@ br_extract_prefix (const char *path)
 	end = strrchr (tmp, '/');
 	if (!end) return tmp;
 
-	result = br_strndup (tmp, end - tmp);
+	char* result = br_strndup (tmp, end - tmp);
 	free (tmp);
 
 	if (!*result)