Kaynağa Gözat

libdpkg: Change order and rename path_quote_filename arguments

Place the size at the end, and rename buf to dst, and s to src.
Guillem Jover 17 yıl önce
ebeveyn
işleme
3adb9397a0
3 değiştirilmiş dosya ile 17 ekleme ve 17 silme
  1. 14 14
      lib/dpkg/path.c
  2. 1 1
      lib/dpkg/path.h
  3. 2 2
      src/archives.c

+ 14 - 14
lib/dpkg/path.c

@@ -77,40 +77,40 @@ path_skip_slash_dotslash(const char *path)
  * - ukai@debian.or.jp
  */
 char *
-path_quote_filename(char *buf, size_t size, const char *s)
+path_quote_filename(char *dst, const char *src, size_t size)
 {
-	char *r = buf;
+	char *r = dst;
 
 	while (size > 0) {
-		switch (*s) {
+		switch (*src) {
 		case '\0':
-			*buf = '\0';
+			*dst = '\0';
 			return r;
 		case '\\':
-			*buf++ = '\\';
-			*buf++ = '\\';
+			*dst++ = '\\';
+			*dst++ = '\\';
 			size -= 2;
 			break;
 		default:
-			if (((*s) & 0x80) == '\0') {
-				*buf++ = *s++;
+			if (((*src) & 0x80) == '\0') {
+				*dst++ = *src++;
 				--size;
 			} else {
 				if (size > 4) {
-					sprintf(buf, "\\%03o",
-					        *(unsigned char *)s);
+					sprintf(dst, "\\%03o",
+					        *(unsigned char *)src);
 					size -= 4;
-					buf += 4;
-					s++;
+					dst += 4;
+					src++;
 				} else {
 					/* Buffer full. */
-					*buf = '\0'; /* XXX */
+					*dst = '\0'; /* XXX */
 					return r;
 				}
 			}
 		}
 	}
-	*buf = '\0'; /* XXX */
+	*dst = '\0'; /* XXX */
 
 	return r;
 }

+ 1 - 1
lib/dpkg/path.h

@@ -32,7 +32,7 @@ DPKG_BEGIN_DECLS
 
 size_t path_rtrim_slash_slashdot(char *path);
 const char *path_skip_slash_dotslash(const char *path);
-char *path_quote_filename(char *buf, size_t size, const char *s);
+char *path_quote_filename(char *dst, const char *src, size_t size);
 
 DPKG_END_DECLS
 

+ 2 - 2
src/archives.c

@@ -201,7 +201,7 @@ tarfile_skip_one_forward(struct TarInfo *ti,
 
     fd_null_copy(tc->backendpipe, ti->Size,
                  _("skipped unpacking file '%.255s' (replaced or excluded?)"),
-                 path_quote_filename(fnamebuf, 256, ti->Name));
+                 path_quote_filename(fnamebuf, ti->Name, 256));
     r = ti->Size % TARBLKSZ;
     if (r > 0)
       r = safe_read(tc->backendpipe, databuf, TARBLKSZ - r);
@@ -639,7 +639,7 @@ int tarobject(struct TarInfo *ti) {
     { char fnamebuf[256];
     fd_fd_copy(tc->backendpipe, fd, ti->Size,
                _("backend dpkg-deb during `%.255s'"),
-               path_quote_filename(fnamebuf, 256, ti->Name));
+               path_quote_filename(fnamebuf, ti->Name, 256));
     }
     r= ti->Size % TARBLKSZ;
     if (r > 0) r= safe_read(tc->backendpipe,databuf,TARBLKSZ - r);