diff options
author | Nick Peskett <rockbox@peskett.co.uk> | 2011-12-20 08:15:36 +0000 |
---|---|---|
committer | Nick Peskett <rockbox@peskett.co.uk> | 2011-12-20 08:15:36 +0000 |
commit | 1b781df59c1b61009f36b64876372a00411b8be0 (patch) | |
tree | df4b5cceeadf560f084d43d683ebaab689fa805e /apps/misc.c | |
parent | c24a36dd9d54f4f77fb40b63fba1c76bac764aa6 (diff) | |
download | rockbox-1b781df59c1b61009f36b64876372a00411b8be0.tar.gz rockbox-1b781df59c1b61009f36b64876372a00411b8be0.zip |
Convert hard-coded unicode byte order mark values to constants.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31374 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/apps/misc.c b/apps/misc.c index 407a26c90f..b1def596ab 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1011,13 +1011,11 @@ void format_time(char* buf, int buf_size, long t) | |||
1011 | * If the file is opened for writing and O_TRUNC is set, write a BOM to | 1011 | * If the file is opened for writing and O_TRUNC is set, write a BOM to |
1012 | * the opened file and leave the file pointer set after the BOM. | 1012 | * the opened file and leave the file pointer set after the BOM. |
1013 | */ | 1013 | */ |
1014 | #define BOM "\xef\xbb\xbf" | ||
1015 | #define BOM_SIZE 3 | ||
1016 | 1014 | ||
1017 | int open_utf8(const char* pathname, int flags) | 1015 | int open_utf8(const char* pathname, int flags) |
1018 | { | 1016 | { |
1019 | int fd; | 1017 | int fd; |
1020 | unsigned char bom[BOM_SIZE]; | 1018 | unsigned char bom[BOM_UTF_8_SIZE]; |
1021 | 1019 | ||
1022 | fd = open(pathname, flags, 0666); | 1020 | fd = open(pathname, flags, 0666); |
1023 | if(fd < 0) | 1021 | if(fd < 0) |
@@ -1025,13 +1023,13 @@ int open_utf8(const char* pathname, int flags) | |||
1025 | 1023 | ||
1026 | if(flags & (O_TRUNC | O_WRONLY)) | 1024 | if(flags & (O_TRUNC | O_WRONLY)) |
1027 | { | 1025 | { |
1028 | write(fd, BOM, BOM_SIZE); | 1026 | write(fd, BOM_UTF_8, BOM_UTF_8_SIZE); |
1029 | } | 1027 | } |
1030 | else | 1028 | else |
1031 | { | 1029 | { |
1032 | read(fd, bom, BOM_SIZE); | 1030 | read(fd, bom, BOM_UTF_8_SIZE); |
1033 | /* check for BOM */ | 1031 | /* check for BOM */ |
1034 | if(memcmp(bom, BOM, BOM_SIZE)) | 1032 | if(memcmp(bom, BOM_UTF_8, BOM_UTF_8_SIZE)) |
1035 | lseek(fd, 0, SEEK_SET); | 1033 | lseek(fd, 0, SEEK_SET); |
1036 | } | 1034 | } |
1037 | return fd; | 1035 | return fd; |