File: replace-gcc-array-extension-with-stdvector.patch

package info (click to toggle)
marsshooter 0.7.6-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,812 kB
  • sloc: cpp: 20,216; xml: 29; makefile: 6
file content (42 lines) | stat: -rw-r--r-- 1,970 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Descriotion: Replace GCC array extension with std::vector
Origin: upstream, https://github.com/thelaui/M.A.R.S./commit/fe07fa2e9b26f4ee86100823403b8c5c988a72c2
Author: Lukas Dürrenberger <eXpl0it3r@my-gate.net>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/

--- a/src/Media/file.cpp
+++ b/src/Media/file.cpp
@@ -20,6 +20,7 @@ this program.  If not, see <http://www.g
 # include <iostream>
 # include <fstream>
 # include <sstream>
+# include <vector>
 
 # include <fribidi/fribidi.h>
 
@@ -41,18 +42,18 @@ namespace file {
                     line.erase(line.end()-1);
                 // Convert it to utf-32
                 int inSize = line.size();
-                FriBidiChar logical[inSize];
+                std::vector<FriBidiChar> logical(inSize);
                 const char* tmp(line.c_str());
-                int outSize = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, tmp, inSize, logical);
+                int outSize = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, tmp, inSize, logical.data());
 
-                FriBidiChar visual[outSize];
+                std::vector<FriBidiChar> visual(outSize);
                 FriBidiParType base = FRIBIDI_PAR_LTR;
-                fribidi_log2vis(logical, outSize, &base, visual, NULL, NULL, NULL);
+                fribidi_log2vis(logical.data(), outSize, &base, visual.data(), NULL, NULL, NULL);
 
-                char outstring[outSize];
-                fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8, visual, outSize, outstring);
+                std::vector<char> outstring(outSize);
+                fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8, visual.data(), outSize, outstring.data());
 
-                line = std::string(outstring);
+                line = std::string(outstring.begin(), outstring.end());
 
                 std::basic_string<sf::Uint32> utf32line;
                 sf::Utf8::toUtf32(line.begin(), line.end(), back_inserter(utf32line));