Advertisement
Guest User

Untitled

a guest
Jul 26th, 2020
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.65 KB | None | 0 0
  1. diff -r src/parser.c /home/danilak/test/src/gumbo-parser/src/parser.c
  2. 578d577
  3. <
  4. diff -r src/tokenizer.c /home/danilak/test/src/gumbo-parser/src/tokenizer.c
  5. 2847,2849c2847,2849
  6. <     int c = utf8iterator_current(&tokenizer->_input);
  7. <     gumbo_debug(
  8. <         "Lexing character '%c' (%d) in state %d.\n", c, c, tokenizer->_state);
  9. ---
  10. >     int c = tokenizer->_input._current;
  11. >     // gumbo_debug(
  12. >         // "Lexing character '%c' (%d) in state %d.\n", c, c, tokenizer->_state);
  13. diff -r src/utf8.c /home/danilak/test/src/gumbo-parser/src/utf8.c
  14. 127c127
  15. < static void read_char(Utf8Iterator* iter) {
  16. ---
  17. > void read_char(Utf8Iterator* iter) {
  18. 183,195d182
  19. < static void update_position(Utf8Iterator* iter) {
  20. <   iter->_pos.offset += iter->_width;
  21. <   if (iter->_current == '\n') {
  22. <     ++iter->_pos.line;
  23. <     iter->_pos.column = 1;
  24. <   } else if (iter->_current == '\t') {
  25. <     int tab_stop = iter->_parser->_options->tab_stop;
  26. <     iter->_pos.column = ((iter->_pos.column / tab_stop) + 1) * tab_stop;
  27. <   } else if (iter->_current != -1) {
  28. <     ++iter->_pos.column;
  29. <   }
  30. < }
  31. <
  32. 215,223d201
  33. < void utf8iterator_next(Utf8Iterator* iter) {
  34. <   // We update positions based on the *last* character read, so that the first
  35. <   // character following a newline is at column 1 in the next line.
  36. <   update_position(iter);
  37. <   iter->_start += iter->_width;
  38. <   read_char(iter);
  39. < }
  40. <
  41. < int utf8iterator_current(const Utf8Iterator* iter) { return iter->_current; }
  42. diff -r src/utf8.h /home/danilak/test/src/gumbo-parser/src/utf8.h
  43. 37a38
  44. > #include "parser.h"
  45. 45d45
  46. < struct GumboInternalParser;
  47. 86a87,101
  48. > static inline void update_position(Utf8Iterator* iter) {
  49. >   iter->_pos.offset += iter->_width;
  50. >   if (iter->_current == '\n') {
  51. >     ++iter->_pos.line;
  52. >     iter->_pos.column = 1;
  53. >   } else if (iter->_current == '\t') {
  54. >     int tab_stop = iter->_parser->_options->tab_stop;
  55. >     iter->_pos.column = ((iter->_pos.column / tab_stop) + 1) * tab_stop;
  56. >   } else if (iter->_current != -1) {
  57. >     ++iter->_pos.column;
  58. >   }
  59. > }
  60. >
  61. > void read_char(Utf8Iterator* iter);
  62. >
  63. 88c103,109
  64. < void utf8iterator_next(Utf8Iterator* iter);
  65. ---
  66. > static __attribute__((always_inline)) inline void utf8iterator_next(Utf8Iterator* iter) {
  67. >   // We update positions based on the *last* character read, so that the first
  68. >   // character following a newline is at column 1 in the next line.
  69. >   update_position(iter);
  70. >   iter->_start += iter->_width;
  71. >   read_char(iter);
  72. > }
  73. 91c112
  74. < int utf8iterator_current(const Utf8Iterator* iter);
  75. ---
  76. > static inline int utf8iterator_current(const Utf8Iterator* iter) { return iter->_current; }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement