utils: eliminate local variable "pos"
Just advance the "path" pointer.
This commit is contained in:
		| @@ -48,7 +48,6 @@ char *parsePath(char *path) | |||||||
| 		g_warning("\"%s\" is not an absolute path", path); | 		g_warning("\"%s\" is not an absolute path", path); | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} else if (path[0] == '~') { | 	} else if (path[0] == '~') { | ||||||
| 		size_t pos = 1; |  | ||||||
| 		const char *home; | 		const char *home; | ||||||
|  |  | ||||||
| 		if (path[1] == '/' || path[1] == '\0') { | 		if (path[1] == '/' || path[1] == '\0') { | ||||||
| @@ -69,6 +68,8 @@ char *parsePath(char *path) | |||||||
| 					return NULL; | 					return NULL; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | 			++path; | ||||||
| 		} else { | 		} else { | ||||||
| 			bool foundSlash = false; | 			bool foundSlash = false; | ||||||
| 			struct passwd *passwd; | 			struct passwd *passwd; | ||||||
| @@ -79,7 +80,6 @@ char *parsePath(char *path) | |||||||
| 				foundSlash = true; | 				foundSlash = true; | ||||||
| 				*c = '\0'; | 				*c = '\0'; | ||||||
| 			} | 			} | ||||||
| 			pos = c - path; |  | ||||||
|  |  | ||||||
| 			passwd = getpwnam(path + 1); | 			passwd = getpwnam(path + 1); | ||||||
| 			if (!passwd) { | 			if (!passwd) { | ||||||
| @@ -91,9 +91,10 @@ char *parsePath(char *path) | |||||||
| 				*c = '/'; | 				*c = '/'; | ||||||
|  |  | ||||||
| 			home = passwd->pw_dir; | 			home = passwd->pw_dir; | ||||||
|  | 			path = c; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return g_strconcat(home, path + pos, NULL); | 		return g_strconcat(home, path, NULL); | ||||||
| 	} else { | 	} else { | ||||||
| #endif | #endif | ||||||
| 		return g_strdup(path); | 		return g_strdup(path); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann