The following commit has been merged in the master branch:
commit 537a50764317c9a2ed37afe7a4acc3f1114f8c55
Author: Guillem Jover <[email protected]>
Date: Sun Oct 31 06:01:02 2010 +0100
libdpkg: Change switch into if/else in path_quote_filename
This reduces the code depth, and will allow further code simplification.
diff --git a/lib/dpkg/path.c b/lib/dpkg/path.c
index 01bac7a..2f54916 100644
--- a/lib/dpkg/path.c
+++ b/lib/dpkg/path.c
@@ -114,11 +114,10 @@ path_quote_filename(char *dst, const char *src, size_t n)
return r;
while (size > 0) {
- switch (*src) {
- case '\0':
+ if (*src == '\0') {
*dst = '\0';
return r;
- case '\\':
+ } else if (*src == '\\') {
if (size <= 2) {
/* Buffer full. */
*dst = '\0';
@@ -128,23 +127,20 @@ path_quote_filename(char *dst, const char *src, size_t n)
*dst++ = '\\';
src++;
size -= 2;
- break;
- default:
- if (((*src) & 0x80) == '\0') {
- *dst++ = *src++;
- --size;
+ } else if (((*src) & 0x80) == '\0') {
+ *dst++ = *src++;
+ --size;
+ } else {
+ if (size > 4) {
+ sprintf(dst, "\\%03o",
+ *(const unsigned char *)src);
+ size -= 4;
+ dst += 4;
+ src++;
} else {
- if (size > 4) {
- sprintf(dst, "\\%03o",
- *(const unsigned char *)src);
- size -= 4;
- dst += 4;
- src++;
- } else {
- /* Buffer full. */
- *dst = '\0';
- return r;
- }
+ /* Buffer full. */
+ *dst = '\0';
+ return r;
}
}
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]