]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/live.patch
*Contribs: Yet another x264 patch
[vlc] / extras / contrib / src / Patches / live.patch
1 diff -ru live/groupsock/Groupsock.cpp live-patched/groupsock/Groupsock.cpp
2 --- live/groupsock/Groupsock.cpp        Thu Nov  6 03:53:15 2003
3 +++ live-patched/groupsock/Groupsock.cpp        Sun Dec  7 21:30:15 2003
4 @@ -26,7 +26,7 @@
5  #if defined(__WIN32__) || defined(_WIN32)
6  #include <strstrea.h>
7  #else
8 -#include <strstream.h>
9 +#include <strstream>
10  #endif
11  #include <stdio.h>
12  
13 diff -ru live/groupsock/NetInterface.cpp live-patched/groupsock/NetInterface.cpp
14 --- live/groupsock/NetInterface.cpp     Thu Nov  6 03:53:15 2003
15 +++ live-patched/groupsock/NetInterface.cpp     Sun Dec  7 21:30:30 2003
16 @@ -24,7 +24,7 @@
17  #if defined(__WIN32__) || defined(_WIN32)
18  #include <strstrea.h>
19  #else
20 -#include <strstream.h>
21 +#include <strstream>
22  #endif
23  
24  ////////// NetInterface //////////
25 --- live/liveMedia/RTSPClient.cpp       2005-10-28 18:54:17.000000000 +0200
26 +++ live-patched/liveMedia/RTSPClient.cpp       2005-10-28 22:04:54.000000000 +0200
27 @@ -32,40 +32,47 @@
28  #define _strncasecmp strncasecmp
29  #endif
30  
31 -// Experimental support for temporarily setting the locale (e.g., to POSIX,
32 -// for parsing or printing floating-point numbers in protocol headers).
33 -#ifdef USE_LOCALE
34  #include <locale.h>
35 -#else
36 -#ifndef LC_NUMERIC
37 -#define LC_NUMERIC 0
38 -#endif
39 -#endif
40 +#include <stdarg.h>
41  
42 -class Locale {
43 -public:
44 -  Locale(char const* newLocale, int category = LC_NUMERIC)
45 -    : fCategory(category) {
46 -#ifdef USE_LOCALE
47 -    fPrevLocale = strDup(setlocale(category, NULL));
48 -    setlocale(category, newLocale);
49 -#endif
50 -  }
51 +/* Radix safe (always uses .) printf and friends */
52 +int radix_safe_sprintf( char *str, const char *format, ...)
53 +{
54 +    va_list args;
55 +    int result = 0;
56 +    char *locale = NULL;
57  
58 -  virtual ~Locale() {
59 -#ifdef USE_LOCALE
60 -    if (fPrevLocale != NULL) {
61 -      setlocale(fCategory, fPrevLocale);
62 -      delete[] fPrevLocale;
63 -    }
64 -#endif
65 -  }
66 +    locale = strDup( setlocale( LC_NUMERIC, NULL ) );
67 +    setlocale( LC_NUMERIC, "C" );
68 +
69 +    va_start( args, format );
70 +    result = vsprintf(str, format, args );
71 +    va_end( args );
72  
73 -private:
74 -  int fCategory;
75 -  char* fPrevLocale;
76 -};
77 +    setlocale( LC_NUMERIC, locale );
78 +    delete[] locale;
79  
80 +    return result;
81 +}
82 +
83 +int radix_safe_sscanf( const char *str, const char *format, ...)
84 +{
85 +    va_list args;
86 +    int result = 0;
87 +    char *locale = NULL;
88 +
89 +    locale = strDup( setlocale( LC_NUMERIC, NULL ) );
90 +    setlocale( LC_NUMERIC, "C" );
91 +
92 +    va_start( args, format );
93 +    result = vsscanf(str, format, args );
94 +    va_end( args );
95 +
96 +    setlocale( LC_NUMERIC, locale );
97 +    delete[] locale;
98 +
99 +    return result;
100 +}
101  
102  
103  ////////// RTSPClient //////////
104 @@ -948,8 +955,7 @@
105      // This is the default value; we don't need a "Scale:" header:
106      buf[0] = '\0';
107    } else {
108 -    Locale("POSIX");
109 -    sprintf(buf, "Scale: %f\r\n", scale);
110 +    radix_safe_sprintf(buf, "Scale: %f\r\n", scale);
111    }
112  
113    return strDup(buf);
114 @@ -962,12 +968,10 @@
115      buf[0] = '\0';
116    } else if (end < 0) {
117      // There's no end time:
118 -    Locale("POSIX");
119 -    sprintf(buf, "Range: npt=%.3f-\r\n", start);
120 +    radix_safe_sprintf(buf, "Range: npt=%.3f-\r\n", start);
121    } else {
122      // There's both a start and an end time; include them both in the "Range:" hdr
123 -    Locale("POSIX");
124 -    sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
125 +    radix_safe_sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
126    }
127  
128    return strDup(buf);
129 @@ -2153,8 +2157,7 @@
130    if (_strncasecmp(line, "Scale: ", 7) != 0) return False;
131    line += 7;
132  
133 -  Locale("POSIX");
134 -  return sscanf(line, "%f", &scale) == 1;
135 +  return radix_safe_sscanf(line, "%f", &scale) == 1;
136  }
137  
138  Boolean RTSPClient::parseGetParameterHeader(char const* line,