]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/live-uselocale.patch
67c03ea337bda7a3ab211b127e7015e0423c4bce
[vlc] / extras / contrib / src / Patches / live-uselocale.patch
1 Copyright (C) 2008 Rémi Denis-Courmont, adaptation by Felix Kühne (C) 2009.
2 Licensed under GNU General Public License version 2 or higher.
3 diff -urN live.orig/liveMedia/include/Locale.hh live/liveMedia/include/Locale.hh
4 --- live.orig/liveMedia/include/Locale.hh       2009-03-23 01:26:16 +0300
5 +++ live/liveMedia/include/Locale.hh    2009-03-26 19:17:43 +0300
6 @@ -27,23 +27,26 @@
7  
8  #ifndef LOCALE_NOT_USED
9  #include <locale.h>
10 +#ifdef __APPLE__
11 +#include <xlocale.h>
12 +#endif
13  #else
14 -#ifndef LC_ALL
15 -#define LC_ALL 0
16 +#ifndef LC_ALL_MASK
17 +#define LC_ALL_MASK 0
18  #endif
19 -#ifndef LC_NUMERIC
20 -#define LC_NUMERIC 4
21 +#ifndef LC_NUMERIC_MASK
22 +#define LC_NUMERIC_MASK 0
23  #endif
24 +typedef int locale_t;
25  #endif
26  
27  class Locale {
28  public:
29 -  Locale(char const* newLocale, int category = LC_ALL);
30 +  Locale(char const* newLocale, int category = LC_ALL_MASK);
31    virtual ~Locale();
32  
33  private:
34 -  int fCategory;
35 -  char* fPrevLocale;
36 +  locale_t fLocale, fPrevLocale;
37  };
38  
39  #endif
40 diff -urN live.orig/liveMedia/Locale.cpp live/liveMedia/Locale.cpp
41 --- live.orig/liveMedia/Locale.cpp      2009-03-23 01:26:16 +0300
42 +++ live/liveMedia/Locale.cpp   2009-03-26 19:17:43 +0300
43 @@ -22,19 +22,18 @@
44  #include "Locale.hh"
45  #include <strDup.hh>
46  
47 -Locale::Locale(char const* newLocale, int category)
48 -  : fCategory(category) {
49 +Locale::Locale(char const* newLocale, int category) {
50  #ifndef LOCALE_NOT_USED
51 -  fPrevLocale = strDup(setlocale(category, NULL));
52 -  setlocale(category, newLocale);
53 +  fLocale = newlocale(category, newLocale, NULL);
54 +  fPrevLocale = uselocale(fLocale);
55  #endif
56  }
57  
58  Locale::~Locale() {
59  #ifndef LOCALE_NOT_USED
60 -  if (fPrevLocale != NULL) {
61 -    setlocale(fCategory, fPrevLocale);
62 -    delete[] fPrevLocale;
63 +  if (fLocale != (locale_t)0) {
64 +    uselocale(fPrevLocale);
65 +    freelocale(fLocale);
66    }
67  #endif
68  }
69 --- live.orig/liveMedia/RTSPClient.cpp  2010-03-16 03:09:46.000000000 +0100
70 +++ live/liveMedia/RTSPClient.cpp       2010-08-24 15:04:31.000000000 +0200
71 @@ -1019,7 +1019,7 @@
72      // This is the default value; we don't need a "Scale:" header:
73      buf[0] = '\0';
74    } else {
75 -    Locale l("C", LC_NUMERIC);
76 +    Locale l("C", LC_NUMERIC_MASK);
77      sprintf(buf, "Scale: %f\r\n", scale);
78    }
79  
80 @@ -1033,11 +1033,11 @@
81      buf[0] = '\0';
82    } else if (end < 0) {
83      // There's no end time:
84 -    Locale l("C", LC_NUMERIC);
85 +    Locale l("C", LC_NUMERIC_MASK);
86      sprintf(buf, "Range: npt=%.3f-\r\n", start);
87    } else {
88      // There's both a start and an end time; include them both in the "Range:" hdr
89 -    Locale l("C", LC_NUMERIC);
90 +    Locale l("C", LC_NUMERIC_MASK);
91      sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
92    }
93  
94 @@ -2328,7 +2328,7 @@
95    if (_strncasecmp(line, "Scale: ", 7) != 0) return False;
96    line += 7;
97  
98 -  Locale l("C", LC_NUMERIC);
99 +  Locale l("C", LC_NUMERIC_MASK);
100    return sscanf(line, "%f", &scale) == 1;
101  }
102  
103 --- live.orig/liveMedia/RTSPCommon.cpp  2010-03-16 03:09:46.000000000 +0100
104 +++ live/liveMedia/RTSPCommon.cpp       2010-08-24 15:04:44.000000000 +0200
105 @@ -146,7 +146,7 @@
106    char const* fields = buf + 7;
107    while (*fields == ' ') ++fields;
108    double start, end;
109 -  Locale l("C", LC_NUMERIC);
110 +  Locale l("C", LC_NUMERIC_MASK);
111    if (sscanf(fields, "npt = %lf - %lf", &start, &end) == 2) {
112      rangeStart = start;
113      rangeEnd = end;