]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/live-uselocale.patch
contribs: compilation fixes
[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 -ru live-orig/config.mingw live/config.mingw
4 --- live-orig/config.mingw      2009-02-13 09:09:42.000000000 +0100
5 +++ live/config.mingw   2009-02-20 14:17:20.000000000 +0100
6 @@ -1,4 +1,4 @@
7 -COMPILE_OPTS =         $(INCLUDES) -I. -O -DSOCKLEN_T=int
8 +COMPILE_OPTS =         $(INCLUDES) -I. -O -DSOCKLEN_T=int -DLOCALE_NOT_USED
9  C =                    c
10  C_COMPILER =           $(CC)
11  C_FLAGS =              $(COMPILE_OPTS) -DUSE_OUR_BZERO=1 -D__MINGW32__
12 diff -ru live-orig/liveMedia/Locale.cpp live/liveMedia/Locale.cpp
13 --- live-orig/liveMedia/Locale.cpp      2009-02-13 09:09:42.000000000 +0100
14 +++ live/liveMedia/Locale.cpp   2009-02-20 14:17:20.000000000 +0100
15 @@ -22,19 +22,18 @@
16  #include "Locale.hh"
17  #include <strDup.hh>
18  
19 -Locale::Locale(char const* newLocale, int category)
20 -  : fCategory(category) {
21 +Locale::Locale(char const* newLocale, int category) {
22  #ifndef LOCALE_NOT_USED
23 -  fPrevLocale = strDup(setlocale(category, NULL));
24 -  setlocale(category, newLocale);
25 +  fLocale = newlocale(category, newLocale, NULL);
26 +  fPrevLocale = uselocale(fLocale);
27  #endif
28  }
29  
30  Locale::~Locale() {
31  #ifndef LOCALE_NOT_USED
32 -  if (fPrevLocale != NULL) {
33 -    setlocale(fCategory, fPrevLocale);
34 -    delete[] fPrevLocale;
35 +  if (fLocale != (locale_t)0) {
36 +    uselocale(fPrevLocale);
37 +    freelocale(fLocale);
38    }
39  #endif
40  }
41 diff -ru live-orig/liveMedia/RTSPClient.cpp live/liveMedia/RTSPClient.cpp
42 --- live-orig/liveMedia/RTSPClient.cpp  2009-02-13 09:09:42.000000000 +0100
43 +++ live/liveMedia/RTSPClient.cpp       2009-02-20 14:27:06.000000000 +0100
44 @@ -1019,7 +1019,7 @@
45      // This is the default value; we don't need a "Scale:" header:
46      buf[0] = '\0';
47    } else {
48 -    Locale l("C", LC_NUMERIC);
49 +    Locale l("C", LC_NUMERIC_MASK);
50      sprintf(buf, "Scale: %f\r\n", scale);
51    }
52  
53 @@ -1033,11 +1033,11 @@
54      buf[0] = '\0';
55    } else if (end < 0) {
56      // There's no end time:
57 -    Locale l("C", LC_NUMERIC);
58 +    Locale l("C", LC_NUMERIC_MASK);
59      sprintf(buf, "Range: npt=%.3f-\r\n", start);
60    } else {
61      // There's both a start and an end time; include them both in the "Range:" hdr
62 -    Locale l("C", LC_NUMERIC);
63 +    Locale l("C", LC_NUMERIC_MASK);
64      sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
65    }
66  
67 @@ -2342,7 +2342,7 @@
68    if (_strncasecmp(line, "Scale: ", 7) != 0) return False;
69    line += 7;
70  
71 -  Locale l("C", LC_NUMERIC);
72 +  Locale l("C", LC_NUMERIC_MASK);
73    return sscanf(line, "%f", &scale) == 1;
74  }
75  
76 diff -ru live-orig/liveMedia/RTSPCommon.cpp live/liveMedia/RTSPCommon.cpp
77 --- live-orig/liveMedia/RTSPCommon.cpp  2009-02-13 09:09:42.000000000 +0100
78 +++ live/liveMedia/RTSPCommon.cpp       2009-02-20 14:26:01.000000000 +0100
79 @@ -146,7 +146,7 @@
80    char const* fields = buf + 7;
81    while (*fields == ' ') ++fields;
82    double start, end;
83 -  Locale l("C", LC_NUMERIC);
84 +  Locale l("C", LC_NUMERIC_MASK);
85    if (sscanf(fields, "npt = %lf - %lf", &start, &end) == 2) {
86      rangeStart = start;
87      rangeEnd = end;
88 diff -ru live-orig/liveMedia/include/Locale.hh live/liveMedia/include/Locale.hh
89 --- live-orig/liveMedia/include/Locale.hh       2009-02-13 09:09:42.000000000 +0100
90 +++ live/liveMedia/include/Locale.hh    2009-02-20 14:17:20.000000000 +0100
91 @@ -27,23 +27,26 @@
92  
93  #ifndef LOCALE_NOT_USED
94  #include <locale.h>
95 +#ifdef __APPLE__
96 +#include <xlocale.h>
97 +#endif
98  #else
99 -#ifndef LC_ALL
100 -#define LC_ALL 0
101 +#ifndef LC_ALL_MASK
102 +#define LC_ALL_MASK 0
103  #endif
104 -#ifndef LC_NUMERIC
105 -#define LC_NUMERIC 4
106 +#ifndef LC_NUMERIC_MASK
107 +#define LC_NUMERIC_MASK 0
108  #endif
109 +typedef int locale_t;
110  #endif
111  
112  class Locale {
113  public:
114 -  Locale(char const* newLocale, int category = LC_ALL);
115 +  Locale(char const* newLocale, int category = LC_ALL_MASK);
116    virtual ~Locale();
117  
118  private:
119 -  int fCategory;
120 -  char* fPrevLocale;
121 +  locale_t fLocale, fPrevLocale;
122  };
123  
124  #endif