Переглянути джерело

libdpkg: Make rtrim_slash_slashdot return the string size

Guillem Jover 18 роки тому
батько
коміт
8d2ea9a803
3 змінених файлів з 9 додано та 3 видалено
  1. 4 0
      ChangeLog
  2. 1 1
      lib/dpkg-priv.h
  3. 4 2
      lib/path.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+2008-06-01  Guillem Jover  <guillem@debian.org>
+
+	* lib/dpkg-priv.h (rtrim_slash_slashdot): Return the string size.
+
 2008-06-01  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/Dpkg/Control.pm (parse, parse_fh, new): Add a new function

+ 1 - 1
lib/dpkg-priv.h

@@ -34,7 +34,7 @@ extern "C" {
 
 /* Path handling. */
 
-void rtrim_slash_slashdot(char *path);
+size_t rtrim_slash_slashdot(char *path);
 
 /* Subprocess handling. */
 

+ 4 - 2
lib/path.c

@@ -23,13 +23,13 @@
 #include <string.h>
 #include <dpkg-priv.h>
 
-void
+size_t
 rtrim_slash_slashdot(char *path)
 {
 	char *end;
 
 	if (!path || !*path)
-		return;
+		return 0;
 
 	for (end = path + strlen(path) - 1; end - path >= 1; end--) {
 		if (*end == '/' || (*(end - 1) == '/' && *end == '.'))
@@ -37,5 +37,7 @@ rtrim_slash_slashdot(char *path)
 		else
 			break;
 	}
+
+	return end - path + 1;
 }