Skip to content

Commit

Permalink
Merge "Merge Android Pie into master"
Browse files Browse the repository at this point in the history
  • Loading branch information
delphij authored and Gerrit Code Review committed Aug 7, 2018
2 parents 1697f66 + d71f793 commit 6c0086c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/blkid/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include "blkidP.h"

Expand Down
35 changes: 34 additions & 1 deletion lib/blkid/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,37 @@ static void unicode_16be_to_utf8(unsigned char *str, int out_len,
str[j] = '\0';
}

static void unicode_16le_to_utf8(unsigned char *str, int out_len,
const unsigned char *buf, int in_len)
{
int i, j;
unsigned int c;

for (i = j = 0; i + 2 <= in_len; i += 2) {
c = (buf[i+1] << 8) | buf[i];
if (c == 0) {
str[j] = '\0';
break;
} else if (c < 0x80) {
if (j+1 >= out_len)
break;
str[j++] = (unsigned char) c;
} else if (c < 0x800) {
if (j+2 >= out_len)
break;
str[j++] = (unsigned char) (0xc0 | (c >> 6));
str[j++] = (unsigned char) (0x80 | (c & 0x3f));
} else {
if (j+3 >= out_len)
break;
str[j++] = (unsigned char) (0xe0 | (c >> 12));
str[j++] = (unsigned char) (0x80 | ((c >> 6) & 0x3f));
str[j++] = (unsigned char) (0x80 | (c & 0x3f));
}
}
str[j] = '\0';
}

static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
Expand Down Expand Up @@ -1482,7 +1513,9 @@ static int probe_exfat(struct blkid_probe *probe, struct blkid_magic *id,

label = find_exfat_entry_label(probe, sb);
if (label) {
blkid_set_tag(probe->dev, "LABEL", label->name, label->length);
char utf8_label[128];
unicode_16le_to_utf8(utf8_label, sizeof(utf8_label), label->name, label->length * 2);
blkid_set_tag(probe->dev, "LABEL", utf8_label, 0);
} else {
blkid_set_tag(probe->dev, "LABEL", "disk", 4);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/ext2fs/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \
get_pathname.o \
getsize.o \
getsectsize.o \
hashmap.o \
i_block.o \
icount.o \
ind_block.o \
Expand Down Expand Up @@ -173,7 +172,6 @@ SRCS= ext2_err.c \
$(srcdir)/get_pathname.c \
$(srcdir)/getsize.c \
$(srcdir)/getsectsize.c \
$(srcdir)/hashmap.c \
$(srcdir)/i_block.c \
$(srcdir)/icount.c \
$(srcdir)/ind_block.c \
Expand Down
4 changes: 3 additions & 1 deletion misc/blkid.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ static void safe_print(const char *cp, int len)
fputc('^', stdout);
ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
}
fputc(ch, stdout);
if (ch != '"') {
fputc(ch, stdout);
}
}
}

Expand Down

0 comments on commit 6c0086c

Please sign in to comment.