mathematical 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -7
  3. data/Rakefile +4 -1
  4. data/ext/mathematical/cairo_callbacks.h +5 -0
  5. data/ext/mathematical/extconf.rb +34 -8
  6. data/ext/mathematical/lasem_overrides.c +32 -3
  7. data/ext/mathematical/lasem_overrides.h +11 -2
  8. data/ext/mathematical/mathematical.c +27 -26
  9. data/ext/mathematical/mathematical.h +5 -1
  10. data/ext/mathematical/mtex2MML/deps/strdup/strdup.c +24 -0
  11. data/ext/mathematical/mtex2MML/deps/strdup/strdup.h +24 -0
  12. data/ext/mathematical/mtex2MML/deps/uthash/utarray.h +1 -0
  13. data/ext/mathematical/mtex2MML/src/{color_definitions.c → colors.c} +2 -3
  14. data/ext/mathematical/mtex2MML/src/colors.h +23 -0
  15. data/ext/mathematical/mtex2MML/src/em.c +99 -0
  16. data/ext/mathematical/mtex2MML/src/em.h +31 -0
  17. data/ext/mathematical/mtex2MML/src/{parse_extras.c → environment.c} +73 -157
  18. data/ext/mathematical/mtex2MML/src/environment.h +85 -0
  19. data/ext/mathematical/mtex2MML/src/{mtex2MML.l → lexer.l} +26 -15
  20. data/ext/mathematical/mtex2MML/src/main.c +31 -10
  21. data/ext/mathematical/mtex2MML/src/mtex2MML.h +19 -7
  22. data/ext/mathematical/mtex2MML/src/{mtex2MML.y → parser.y} +451 -446
  23. data/ext/mathematical/mtex2MML/src/string_extras.c +4 -3
  24. data/ext/mathematical/mtex2MML/src/string_extras.h +7 -7
  25. data/ext/mathematical/mtex2MML/tests/array.c +11 -11
  26. data/ext/mathematical/mtex2MML/tests/basic.c +14 -13
  27. data/ext/mathematical/mtex2MML/tests/clar.c +2 -0
  28. data/ext/mathematical/mtex2MML/tests/clar/fs.h +3 -1
  29. data/ext/mathematical/mtex2MML/tests/clar/sandbox.h +3 -1
  30. data/ext/mathematical/mtex2MML/tests/cornercases.c +3 -2
  31. data/ext/mathematical/mtex2MML/tests/delimiters.c +126 -0
  32. data/ext/mathematical/mtex2MML/tests/deps/file2str/file2str.c +2 -4
  33. data/ext/mathematical/mtex2MML/tests/deps/mkdtemp/mkdtemp.c +151 -0
  34. data/ext/mathematical/mtex2MML/tests/deps/mkdtemp/mkdtemp.h +10 -0
  35. data/ext/mathematical/mtex2MML/tests/deps/trim/trim.c +4 -1
  36. data/ext/mathematical/mtex2MML/tests/env.c +35 -34
  37. data/ext/mathematical/mtex2MML/tests/functions.c +3 -2
  38. data/ext/mathematical/mtex2MML/tests/helpers.c +6 -4
  39. data/ext/mathematical/mtex2MML/tests/helpers.h +2 -2
  40. data/ext/mathematical/mtex2MML/tests/main.c +1 -1
  41. data/ext/mathematical/mtex2MML/tests/maliciousness.c +35 -9
  42. data/ext/mathematical/mtex2MML/tests/mathjax.c +202 -202
  43. data/ext/mathematical/mtex2MML/tests/numbered_equations.c +6 -6
  44. data/ext/mathematical/mtex2MML/tests/performance.c +39 -0
  45. data/lib/mathematical.rb +38 -5
  46. data/lib/mathematical/configuration.rb +19 -0
  47. data/lib/mathematical/validator.rb +17 -31
  48. data/lib/mathematical/version.rb +1 -1
  49. data/mathematical.gemspec +3 -1
  50. data/test/mathematical/basic_test.rb +60 -7
  51. data/test/mathematical/corrections_test.rb +1 -1
  52. data/test/mathematical/delimiters_test.rb +58 -0
  53. data/test/mathematical/fixtures_test.rb +3 -2
  54. data/test/mathematical/maliciousness_test.rb +19 -27
  55. data/test/mathematical/mathjax_test.rb +6 -5
  56. data/test/mathematical/mathml_test.rb +1 -1
  57. data/test/mathematical/multiples_test.rb +1 -1
  58. data/test/mathematical/performance_test.rb +3 -1
  59. data/test/mathematical/png_test.rb +3 -3
  60. data/test/test_helper.rb +4 -1
  61. metadata +35 -21
  62. data/ext/mathematical/lasem/src/lsmdomenumtypes.c +0 -99
  63. data/ext/mathematical/lasem/src/lsmdomenumtypes.h +0 -26
  64. data/ext/mathematical/lasem/src/lsmmathmlenumtypes.c +0 -737
  65. data/ext/mathematical/lasem/src/lsmmathmlenumtypes.h +0 -93
  66. data/ext/mathematical/lasem/src/lsmsvgenumtypes.c +0 -1083
  67. data/ext/mathematical/lasem/src/lsmsvgenumtypes.h +0 -111
  68. data/ext/mathematical/mtex2MML/Makefile +0 -100
  69. data/ext/mathematical/mtex2MML/build/libmtex2MML.a +0 -0
  70. data/ext/mathematical/mtex2MML/build/mtex2MML.h +0 -73
  71. data/ext/mathematical/mtex2MML/src/lex.yy.c +0 -8845
  72. data/ext/mathematical/mtex2MML/src/parse_extras.h +0 -111
  73. data/ext/mathematical/mtex2MML/src/y.tab.c +0 -10178
  74. data/ext/mathematical/mtex2MML/src/y.tab.h +0 -617
@@ -0,0 +1,10 @@
1
+ #ifndef _MKDTEMP_H_
2
+ #define _MKDTEMP_H_
3
+
4
+ static int
5
+ do_mkdtemp (char *path);
6
+
7
+ char *
8
+ mkdtemp (char *path);
9
+
10
+ #endif
@@ -1,3 +1,6 @@
1
+ #include <string.h>
2
+ #include <ctype.h>
3
+
1
4
  char *
2
5
  trim(char *str)
3
6
  {
@@ -21,4 +24,4 @@ trim(char *str)
21
24
  *(end+1) = 0;
22
25
 
23
26
  return str;
24
- }
27
+ }
@@ -1,6 +1,7 @@
1
1
  #include "clar.h"
2
2
  #include "clar_test.h"
3
3
  #include <stdio.h>
4
+ #include <string.h>
4
5
 
5
6
  static char *fixture_tex;
6
7
  static char *fixture_mml;
@@ -30,7 +31,7 @@ void test_env__matrix_ex_spacing(void)
30
31
  {
31
32
  fixture_tex = read_fixture_tex("env/matrix_ex_spacing.txt");
32
33
  fixture_mml = read_fixture_mml("env/matrix_ex_spacing.html");
33
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
34
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
34
35
 
35
36
  cl_assert_equal_s(fixture_mml, result);
36
37
  }
@@ -39,7 +40,7 @@ void test_env__matrix_no_ex_spacing(void)
39
40
  {
40
41
  fixture_tex = read_fixture_tex("env/matrix_no_ex_spacing.txt");
41
42
  fixture_mml = read_fixture_mml("env/matrix_no_ex_spacing.html");
42
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
43
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
43
44
 
44
45
  cl_assert_equal_s(fixture_mml, result);
45
46
  }
@@ -48,7 +49,7 @@ void test_env__matrix_no_lines(void)
48
49
  {
49
50
  fixture_tex = read_fixture_tex("env/matrix_no_lines.txt");
50
51
  fixture_mml = read_fixture_mml("env/matrix_no_lines.html");
51
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
52
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
52
53
 
53
54
  cl_assert_equal_s(fixture_mml, result);
54
55
  }
@@ -57,7 +58,7 @@ void test_env__pmatrix_ex_spacing(void)
57
58
  {
58
59
  fixture_tex = read_fixture_tex("env/pmatrix_ex_spacing.txt");
59
60
  fixture_mml = read_fixture_mml("env/pmatrix_ex_spacing.html");
60
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
61
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
61
62
 
62
63
  cl_assert_equal_s(fixture_mml, result);
63
64
  }
@@ -66,7 +67,7 @@ void test_env__pmatrix_no_ex_spacing(void)
66
67
  {
67
68
  fixture_tex = read_fixture_tex("env/pmatrix_no_ex_spacing.txt");
68
69
  fixture_mml = read_fixture_mml("env/pmatrix_no_ex_spacing.html");
69
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
70
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
70
71
 
71
72
  cl_assert_equal_s(fixture_mml, result);
72
73
  }
@@ -75,7 +76,7 @@ void test_env__pmatrix_no_lines(void)
75
76
  {
76
77
  fixture_tex = read_fixture_tex("env/pmatrix_no_lines.txt");
77
78
  fixture_mml = read_fixture_mml("env/pmatrix_no_lines.html");
78
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
79
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
79
80
 
80
81
  cl_assert_equal_s(fixture_mml, result);
81
82
  }
@@ -84,7 +85,7 @@ void test_env__bmatrix_ex_spacing(void)
84
85
  {
85
86
  fixture_tex = read_fixture_tex("env/bmatrix_ex_spacing.txt");
86
87
  fixture_mml = read_fixture_mml("env/bmatrix_ex_spacing.html");
87
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
88
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
88
89
 
89
90
  cl_assert_equal_s(fixture_mml, result);
90
91
  }
@@ -93,7 +94,7 @@ void test_env__bmatrix_no_ex_spacing(void)
93
94
  {
94
95
  fixture_tex = read_fixture_tex("env/bmatrix_no_ex_spacing.txt");
95
96
  fixture_mml = read_fixture_mml("env/bmatrix_no_ex_spacing.html");
96
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
97
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
97
98
 
98
99
  cl_assert_equal_s(fixture_mml, result);
99
100
  }
@@ -102,7 +103,7 @@ void test_env__bmatrix_no_lines(void)
102
103
  {
103
104
  fixture_tex = read_fixture_tex("env/bmatrix_no_lines.txt");
104
105
  fixture_mml = read_fixture_mml("env/bmatrix_no_lines.html");
105
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
106
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
106
107
 
107
108
  cl_assert_equal_s(fixture_mml, result);
108
109
  }
@@ -111,7 +112,7 @@ void test_env__bbmatrix_ex_spacing(void)
111
112
  {
112
113
  fixture_tex = read_fixture_tex("env/bbmatrix_ex_spacing.txt");
113
114
  fixture_mml = read_fixture_mml("env/bbmatrix_ex_spacing.html");
114
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
115
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
115
116
 
116
117
  cl_assert_equal_s(fixture_mml, result);
117
118
  }
@@ -120,7 +121,7 @@ void test_env__bbmatrix_no_ex_spacing(void)
120
121
  {
121
122
  fixture_tex = read_fixture_tex("env/bbmatrix_no_ex_spacing.txt");
122
123
  fixture_mml = read_fixture_mml("env/bbmatrix_no_ex_spacing.html");
123
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
124
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
124
125
 
125
126
  cl_assert_equal_s(fixture_mml, result);
126
127
  }
@@ -129,7 +130,7 @@ void test_env__bbmatrix_no_lines(void)
129
130
  {
130
131
  fixture_tex = read_fixture_tex("env/bbmatrix_no_lines.txt");
131
132
  fixture_mml = read_fixture_mml("env/bbmatrix_no_lines.html");
132
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
133
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
133
134
 
134
135
  cl_assert_equal_s(fixture_mml, result);
135
136
  }
@@ -138,7 +139,7 @@ void test_env__vmatrix_ex_spacing(void)
138
139
  {
139
140
  fixture_tex = read_fixture_tex("env/vmatrix_ex_spacing.txt");
140
141
  fixture_mml = read_fixture_mml("env/vmatrix_ex_spacing.html");
141
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
142
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
142
143
 
143
144
  cl_assert_equal_s(fixture_mml, result);
144
145
  }
@@ -147,7 +148,7 @@ void test_env__vmatrix_no_ex_spacing(void)
147
148
  {
148
149
  fixture_tex = read_fixture_tex("env/vmatrix_no_ex_spacing.txt");
149
150
  fixture_mml = read_fixture_mml("env/vmatrix_no_ex_spacing.html");
150
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
151
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
151
152
 
152
153
  cl_assert_equal_s(fixture_mml, result);
153
154
  }
@@ -156,7 +157,7 @@ void test_env__vmatrix_no_lines(void)
156
157
  {
157
158
  fixture_tex = read_fixture_tex("env/vmatrix_no_lines.txt");
158
159
  fixture_mml = read_fixture_mml("env/vmatrix_no_lines.html");
159
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
160
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
160
161
 
161
162
  cl_assert_equal_s(fixture_mml, result);
162
163
  }
@@ -165,7 +166,7 @@ void test_env__vvmatrix_ex_spacing(void)
165
166
  {
166
167
  fixture_tex = read_fixture_tex("env/vvmatrix_ex_spacing.txt");
167
168
  fixture_mml = read_fixture_mml("env/vvmatrix_ex_spacing.html");
168
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
169
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
169
170
 
170
171
  cl_assert_equal_s(fixture_mml, result);
171
172
  }
@@ -174,7 +175,7 @@ void test_env__vvmatrix_no_ex_spacing(void)
174
175
  {
175
176
  fixture_tex = read_fixture_tex("env/vvmatrix_no_ex_spacing.txt");
176
177
  fixture_mml = read_fixture_mml("env/vvmatrix_no_ex_spacing.html");
177
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
178
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
178
179
 
179
180
  cl_assert_equal_s(fixture_mml, result);
180
181
  }
@@ -183,7 +184,7 @@ void test_env__vvmatrix_no_lines(void)
183
184
  {
184
185
  fixture_tex = read_fixture_tex("env/vvmatrix_no_lines.txt");
185
186
  fixture_mml = read_fixture_mml("env/vvmatrix_no_lines.html");
186
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
187
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
187
188
 
188
189
  cl_assert_equal_s(fixture_mml, result);
189
190
  }
@@ -192,7 +193,7 @@ void test_env__smallmatrix_ex_spacing(void)
192
193
  {
193
194
  fixture_tex = read_fixture_tex("env/smallmatrix_ex_spacing.txt");
194
195
  fixture_mml = read_fixture_mml("env/smallmatrix_ex_spacing.html");
195
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
196
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
196
197
 
197
198
  cl_assert_equal_s(fixture_mml, result);
198
199
  }
@@ -201,7 +202,7 @@ void test_env__smallmatrix_no_ex_spacing(void)
201
202
  {
202
203
  fixture_tex = read_fixture_tex("env/smallmatrix_no_ex_spacing.txt");
203
204
  fixture_mml = read_fixture_mml("env/smallmatrix_no_ex_spacing.html");
204
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
205
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
205
206
 
206
207
  cl_assert_equal_s(fixture_mml, result);
207
208
  }
@@ -210,7 +211,7 @@ void test_env__smallmatrix_no_lines(void)
210
211
  {
211
212
  fixture_tex = read_fixture_tex("env/smallmatrix_no_lines.txt");
212
213
  fixture_mml = read_fixture_mml("env/smallmatrix_no_lines.html");
213
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
214
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
214
215
 
215
216
  cl_assert_equal_s(fixture_mml, result);
216
217
  }
@@ -219,7 +220,7 @@ void test_env__aligned_ex_spacing(void)
219
220
  {
220
221
  fixture_tex = read_fixture_tex("env/aligned_ex_spacing.txt");
221
222
  fixture_mml = read_fixture_mml("env/aligned_ex_spacing.html");
222
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
223
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
223
224
 
224
225
  cl_assert_equal_s(fixture_mml, result);
225
226
  }
@@ -228,7 +229,7 @@ void test_env__aligned_no_ex_spacing(void)
228
229
  {
229
230
  fixture_tex = read_fixture_tex("env/aligned_no_ex_spacing.txt");
230
231
  fixture_mml = read_fixture_mml("env/aligned_no_ex_spacing.html");
231
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
232
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
232
233
 
233
234
  cl_assert_equal_s(fixture_mml, result);
234
235
  }
@@ -237,7 +238,7 @@ void test_env__aligned_no_lines(void)
237
238
  {
238
239
  fixture_tex = read_fixture_tex("env/aligned_no_lines.txt");
239
240
  fixture_mml = read_fixture_mml("env/aligned_no_lines.html");
240
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
241
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
241
242
 
242
243
  cl_assert_equal_s(fixture_mml, result);
243
244
  }
@@ -246,7 +247,7 @@ void test_env__gathered_ex_spacing(void)
246
247
  {
247
248
  fixture_tex = read_fixture_tex("env/gathered_ex_spacing.txt");
248
249
  fixture_mml = read_fixture_mml("env/gathered_ex_spacing.html");
249
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
250
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
250
251
 
251
252
  cl_assert_equal_s(fixture_mml, result);
252
253
  }
@@ -255,7 +256,7 @@ void test_env__gathered_no_ex_spacing(void)
255
256
  {
256
257
  fixture_tex = read_fixture_tex("env/gathered_no_ex_spacing.txt");
257
258
  fixture_mml = read_fixture_mml("env/gathered_no_ex_spacing.html");
258
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
259
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
259
260
 
260
261
  cl_assert_equal_s(fixture_mml, result);
261
262
  }
@@ -264,7 +265,7 @@ void test_env__gathered_no_lines(void)
264
265
  {
265
266
  fixture_tex = read_fixture_tex("env/gathered_no_lines.txt");
266
267
  fixture_mml = read_fixture_mml("env/gathered_no_lines.html");
267
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
268
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
268
269
 
269
270
  cl_assert_equal_s(fixture_mml, result);
270
271
  }
@@ -273,7 +274,7 @@ void test_env__split_ex_spacing(void)
273
274
  {
274
275
  fixture_tex = read_fixture_tex("env/split_ex_spacing.txt");
275
276
  fixture_mml = read_fixture_mml("env/split_ex_spacing.html");
276
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
277
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
277
278
 
278
279
  cl_assert_equal_s(fixture_mml, result);
279
280
  }
@@ -282,7 +283,7 @@ void test_env__split_no_ex_spacing(void)
282
283
  {
283
284
  fixture_tex = read_fixture_tex("env/split_no_ex_spacing.txt");
284
285
  fixture_mml = read_fixture_mml("env/split_no_ex_spacing.html");
285
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
286
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
286
287
 
287
288
  cl_assert_equal_s(fixture_mml, result);
288
289
  }
@@ -291,7 +292,7 @@ void test_env__split_no_lines(void)
291
292
  {
292
293
  fixture_tex = read_fixture_tex("env/split_no_lines.txt");
293
294
  fixture_mml = read_fixture_mml("env/split_no_lines.html");
294
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
295
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
295
296
 
296
297
  cl_assert_equal_s(fixture_mml, result);
297
298
  }
@@ -300,7 +301,7 @@ void test_env__spaces_after_rowsep(void)
300
301
  {
301
302
  fixture_tex = read_fixture_tex("env/spaces_after_rowsep.txt");
302
303
  fixture_mml = read_fixture_mml("env/spaces_after_rowsep.html");
303
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
304
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
304
305
 
305
306
  cl_assert_equal_s(fixture_mml, result);
306
307
  }
@@ -309,7 +310,7 @@ void test_env__cases_ex_spacing(void)
309
310
  {
310
311
  fixture_tex = read_fixture_tex("env/cases_ex_spacing.txt");
311
312
  fixture_mml = read_fixture_mml("env/cases_ex_spacing.html");
312
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
313
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
313
314
 
314
315
  cl_assert_equal_s(fixture_mml, result);
315
316
  }
@@ -318,7 +319,7 @@ void test_env__cases_no_ex_spacing(void)
318
319
  {
319
320
  fixture_tex = read_fixture_tex("env/cases_no_ex_spacing.txt");
320
321
  fixture_mml = read_fixture_mml("env/cases_no_ex_spacing.html");
321
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
322
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
322
323
 
323
324
  cl_assert_equal_s(fixture_mml, result);
324
325
  }
@@ -327,7 +328,7 @@ void test_env__cases_no_lines(void)
327
328
  {
328
329
  fixture_tex = read_fixture_tex("env/cases_no_lines.txt");
329
330
  fixture_mml = read_fixture_mml("env/cases_no_lines.html");
330
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
331
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
331
332
 
332
333
  cl_assert_equal_s(fixture_mml, result);
333
334
  }
@@ -1,6 +1,7 @@
1
1
  #include "clar.h"
2
2
  #include "clar_test.h"
3
3
  #include <stdio.h>
4
+ #include <string.h>
4
5
 
5
6
  static char *fixture_tex;
6
7
  static char *fixture_mml;
@@ -30,7 +31,7 @@ void test_functions__max_limits(void)
30
31
  {
31
32
  fixture_tex = read_fixture_tex("functions/max_limits.txt");
32
33
  fixture_mml = read_fixture_mml("functions/max_limits.html");
33
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
34
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
34
35
 
35
36
  cl_assert_equal_s(fixture_mml, result);
36
37
  }
@@ -39,7 +40,7 @@ void test_functions__min_limits(void)
39
40
  {
40
41
  fixture_tex = read_fixture_tex("functions/min_limits.txt");
41
42
  fixture_mml = read_fixture_mml("functions/min_limits.html");
42
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
43
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
43
44
 
44
45
  cl_assert_equal_s(fixture_mml, result);
45
46
  }
@@ -5,14 +5,16 @@
5
5
  #include <stdio.h>
6
6
  #include <string.h>
7
7
 
8
- char * read_fixture_tex(char *filename)
8
+ char * read_fixture_tex(const char *filename)
9
9
  {
10
- return file2str(cl_fixture(filename));
10
+ const char *tex = cl_fixture(filename);
11
+ return file2str(tex);
11
12
  }
12
13
 
13
- char * read_fixture_mml(char *filename)
14
+ char * read_fixture_mml(const char *filename)
14
15
  {
15
- char * data = file2str(cl_fixture(filename));
16
+ const char *mml = cl_fixture(filename);
17
+ char * data = file2str(mml);
16
18
 
17
19
  return trim(data);
18
20
  }
@@ -1,8 +1,8 @@
1
1
  #ifndef __HELPERS__
2
2
  #define __HELPERS__
3
3
 
4
- char * read_fixture_tex(char *filename);
5
- char * read_fixture_mml(char *filename);
4
+ char * read_fixture_tex(const char *filename);
5
+ char * read_fixture_mml(const char *filename);
6
6
  void write_test_file(char *data);
7
7
 
8
8
  #endif
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
29
29
  /* Run the test suite */
30
30
  int ret = clar_test(argc, argv);
31
31
 
32
- // cl_assert_equal_i(3, global_test_counter);
32
+ /* cl_assert_equal_i(3, global_test_counter); */
33
33
 
34
34
  return ret;
35
35
  }
@@ -1,6 +1,7 @@
1
1
  #include "clar.h"
2
2
  #include "clar_test.h"
3
3
  #include <stdio.h>
4
+ #include <string.h>
4
5
 
5
6
  static char *fixture_tex;
6
7
  static char *fixture_mml;
@@ -30,7 +31,7 @@ void test_maliciousness__parsing(void)
30
31
  {
31
32
  fixture_tex = read_fixture_tex("maliciousness/just_enough_parsing.txt");
32
33
  fixture_mml = read_fixture_mml("maliciousness/just_enough_parsing.html");
33
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
34
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
34
35
 
35
36
  cl_assert_equal_s(fixture_mml, result);
36
37
  }
@@ -39,43 +40,68 @@ void test_maliciousness__excess_parsing(void)
39
40
  {
40
41
  fixture_tex = read_fixture_tex("maliciousness/excess_parsing.txt");
41
42
  fixture_mml = read_fixture_mml("maliciousness/just_enough_parsing.html");
42
- result = mtex2MML_parse(fixture_tex, strlen(fixture_tex));
43
+ result = mtex2MML_parse(fixture_tex, strlen(fixture_tex), MTEX2MML_DELIMITER_DEFAULT);
43
44
 
44
45
  cl_assert(result == NULL);
45
- result = malloc(1);
46
46
  }
47
47
 
48
48
  void test_maliciousness__unknown_command_with_parse(void)
49
49
  {
50
- // lazy way to continue with the free in cleanup
50
+ /* lazy way to continue with the free in cleanup */
51
51
  fixture_tex = malloc(1);
52
52
  fixture_mml = malloc(1);
53
53
 
54
54
  char *s1 = "$\\not__thisisnotreal$";
55
- result = mtex2MML_parse(s1, strlen(s1));
55
+ result = mtex2MML_parse(s1, strlen(s1), 0);
56
56
  cl_assert(result == NULL);
57
+ free(result);
57
58
 
58
59
  char *s2 = "$x$";
59
- result = mtex2MML_parse(s2, strlen(s2));
60
+ result = mtex2MML_parse(s2, strlen(s2), 0);
60
61
  cl_assert(result != NULL);
61
62
  }
62
63
 
63
64
  void test_maliciousness__unknown_command_with_filter(void)
64
65
  {
65
- // lazy way to continue with the free in cleanup
66
+ /* lazy way to continue with the free in cleanup */
66
67
  fixture_tex = malloc(1);
67
68
  fixture_mml = malloc(1);
68
69
 
69
70
  char *s1 = "$\\not__thisisnotreal$";
70
- int status1 = mtex2MML_filter(s1, strlen(s1));
71
+ int status1 = mtex2MML_filter(s1, strlen(s1), 0);
71
72
  result = mtex2MML_output();
72
73
  cl_assert(status1 == 1);
73
74
  cl_assert(strlen(result) == 0);
74
75
  free(result);
75
76
 
76
77
  char *s2 = "$x$";
77
- int status2 = mtex2MML_filter(s2, strlen(s2));
78
+ int status2 = mtex2MML_filter(s2, strlen(s2), 0);
78
79
  result = mtex2MML_output();
79
80
  cl_assert(status2 == 0);
80
81
  cl_assert(strlen(result) > 0);
81
82
  }
83
+
84
+ void test_maliciousness__bad_options(void)
85
+ {
86
+ /* lazy way to continue with the free in cleanup */
87
+ fixture_tex = malloc(1);
88
+ fixture_mml = malloc(1);
89
+
90
+ char *s1 = "$\\pi";
91
+ int status = mtex2MML_filter(s1, strlen(s1), 9000);
92
+ result = mtex2MML_output();
93
+ cl_assert(status == 0);
94
+ cl_assert(strlen(result) == 0);
95
+ }
96
+
97
+ void test_maliciousness__imbalanced_dollars(void)
98
+ {
99
+ /* lazy way to continue with the free in cleanup */
100
+ fixture_tex = malloc(1);
101
+ fixture_mml = malloc(1);
102
+
103
+ char *s1 = "x$$";
104
+ result = mtex2MML_parse(s1, strlen(s1), 0);
105
+
106
+ cl_assert(result == NULL);
107
+ }