Changeset 0950551c3ff5af5e8476f5dfec8f5da9c2695c93
- Timestamp:
- 01/30/06 23:02:47
(3 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1138658567 +0000
- git-parent:
[9a1afdac05291bf7adb8986c0c66fa45533e2654]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1138658567 +0000
- Message:
Fix error handling in (From|To)Locale
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd3cb142 |
r0950551 |
|
| 2 | 2 | * libvlc.c: main libvlc source |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 1998-2004 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 1998-2006 the VideoLAN team |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 9 | 9 | * Gildas Bazin <gbazin@videolan.org> |
|---|
| 10 | 10 | * Derk-Jan Hartman <hartman at videolan dot org> |
|---|
| | 11 | * Rémi Denis-Courmont <rem # videolan : org> |
|---|
| 11 | 12 | * |
|---|
| 12 | 13 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 42 | 43 | #include <string.h> /* strerror() */ |
|---|
| 43 | 44 | #include <stdlib.h> /* free() */ |
|---|
| | 45 | #include <assert.h> |
|---|
| 44 | 46 | |
|---|
| 45 | 47 | #ifndef WIN32 |
|---|
| … | … | |
| 2709 | 2711 | */ |
|---|
| 2710 | 2712 | inb = strlen( locale ); |
|---|
| 2711 | | outb = inb * 6 + 1; |
|---|
| 2712 | | |
|---|
| 2713 | 2713 | /* FIXME: I'm not sure about the value for the multiplication |
|---|
| 2714 | 2714 | * (for western people, multiplication by 3 (Latin9) is sufficient) */ |
|---|
| | 2715 | outb = inb * 6 + 1; |
|---|
| | 2716 | |
|---|
| 2715 | 2717 | optr = output = calloc( outb , 1); |
|---|
| 2716 | 2718 | |
|---|
| … | … | |
| 2721 | 2723 | == (size_t)-1 ) |
|---|
| 2722 | 2724 | { |
|---|
| 2723 | | *optr = '?'; |
|---|
| 2724 | | optr++; |
|---|
| | 2725 | *optr++ = '?'; |
|---|
| | 2726 | outb--; |
|---|
| 2725 | 2727 | iptr++; |
|---|
| | 2728 | inb--; |
|---|
| 2726 | 2729 | vlc_iconv( libvlc.from_locale, NULL, NULL, NULL, NULL ); |
|---|
| 2727 | 2730 | } |
|---|
| 2728 | 2731 | vlc_mutex_unlock( &libvlc.from_locale_lock ); |
|---|
| 2729 | 2732 | |
|---|
| 2730 | | return realloc( output, strlen( output ) + 1 ); |
|---|
| | 2733 | assert (inb == 0); |
|---|
| | 2734 | assert (*iptr == '\0'); |
|---|
| | 2735 | assert (*optr == '\0'); |
|---|
| | 2736 | assert (strlen( output ) == (size_t)(optr - output)); |
|---|
| | 2737 | return realloc( output, optr - output + 1 ); |
|---|
| 2731 | 2738 | } |
|---|
| 2732 | 2739 | return (char *)locale; |
|---|
| … | … | |
| 2762 | 2769 | == (size_t)-1 ) |
|---|
| 2763 | 2770 | { |
|---|
| 2764 | | *optr = '?'; /* should not happen, and yes, it sucks */ |
|---|
| 2765 | | optr++; |
|---|
| | 2771 | *optr++ = '?'; /* should not happen, and yes, it sucks */ |
|---|
| | 2772 | outb--; |
|---|
| 2766 | 2773 | iptr++; |
|---|
| | 2774 | inb--; |
|---|
| 2767 | 2775 | vlc_iconv( libvlc.to_locale, NULL, NULL, NULL, NULL ); |
|---|
| 2768 | 2776 | } |
|---|
| 2769 | 2777 | vlc_mutex_unlock( &libvlc.to_locale_lock ); |
|---|
| 2770 | 2778 | |
|---|
| 2771 | | return realloc( output, strlen( output ) + 1 ); |
|---|
| | 2779 | assert (inb == 0); |
|---|
| | 2780 | assert (*iptr == '\0'); |
|---|
| | 2781 | assert (*optr == '\0'); |
|---|
| | 2782 | assert (strlen( output ) == (size_t)(optr - output)); |
|---|
| | 2783 | return realloc( output, optr - output + 1 ); |
|---|
| 2772 | 2784 | } |
|---|
| 2773 | 2785 | return (char *)utf8; |
|---|