[libbluray-devel] commit: Fixed _string_to_uint() (hpi1 )
git at videolan.org
git at videolan.org
Mon Nov 15 16:02:58 CET 2010
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Nov 15 16:37:42 2010 +0200| [7492c8af1f8b605be07a64f482367cafdcf2f1a0] | committer: hpi1
Fixed _string_to_uint()
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=7492c8af1f8b605be07a64f482367cafdcf2f1a0
---
src/libbluray/bluray.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 32ac0e9..3a114b2 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1435,15 +1435,23 @@ int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value)
return 0;
}
-static uint32_t _string_to_uint(const char *s, int n)
+static uint32_t _string_to_uint32(const char *s, int n)
{
uint32_t val = 0;
if (n > 4)
n = 4;
- while (n--)
- val = (val << 8) | s[n];
+ if (!s || !*s) {
+ return (INT64_C(1) << (8*n)) - 1; /* default: all bits one */
+ }
+
+ while (n--) {
+ val = (val << 8) | *s;
+ if (*s) {
+ s++;
+ }
+ }
return val;
}
@@ -1454,10 +1462,10 @@ int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s)
case BLURAY_PLAYER_SETTING_AUDIO_LANG:
case BLURAY_PLAYER_SETTING_PG_LANG:
case BLURAY_PLAYER_SETTING_MENU_LANG:
- return bd_set_player_setting(bd, idx, s ? _string_to_uint(s, 3) : 0xffffff);
+ return bd_set_player_setting(bd, idx, _string_to_uint32(s, 3));
case BLURAY_PLAYER_SETTING_COUNTRY_CODE:
- return bd_set_player_setting(bd, idx, s ? _string_to_uint(s, 2) : 0xffff );
+ return bd_set_player_setting(bd, idx, _string_to_uint32(s, 2));
default:
return 0;
More information about the libbluray-devel
mailing list