libvterm-Remove-VLAs-for-MSVC.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From eb386b1d82f7d07363c9133b7aa06902ccd555fe Mon Sep 17 00:00:00 2001
  2. Date: Tue, 27 Feb 2018 17:54:20 -0600
  3. Subject: [PATCH] Remove VLAs for MSVC
  4. VLAs are replaced with calls to _alloca() because MSVC does not support them.
  5. ---
  6. src/state.c | 7 ++++---
  7. 1 file changed, 4 insertions(+), 3 deletions(-)
  8. diff --git a/src/state.c b/src/state.c
  9. index 84299df..f9aabb3 100644
  10. --- a/src/state.c
  11. +++ b/src/state.c
  12. @@ -1,5 +1,6 @@
  13. #include "vterm_internal.h"
  14. +#include <malloc.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. @@ -236,7 +237,7 @@ static int on_text(const char bytes[], size_t len, void *user)
  18. VTermPos oldpos = state->pos;
  19. // We'll have at most len codepoints
  20. - uint32_t codepoints[len];
  21. + uint32_t* codepoints = _alloca(len * sizeof(uint32_t));
  22. int npoints = 0;
  23. size_t eaten = 0;
  24. @@ -313,7 +314,7 @@ static int on_text(const char bytes[], size_t len, void *user)
  25. int width = 0;
  26. - uint32_t chars[glyph_ends - glyph_starts + 1];
  27. + uint32_t* chars = _alloca((glyph_ends - glyph_starts + 1) * sizeof(uint32_t));
  28. for( ; i < glyph_ends; i++) {
  29. chars[i - glyph_starts] = codepoints[i];
  30. @@ -512,7 +513,7 @@ static int settermprop_int(VTermState *state, VTermProp prop, int v)
  31. static int settermprop_string(VTermState *state, VTermProp prop, const char *str, size_t len)
  32. {
  33. - char strvalue[len+1];
  34. + char* strvalue = _alloca(len+1);
  35. strncpy(strvalue, str, len);
  36. strvalue[len] = 0;
  37. --
  38. 2.16.1.windows.4