1
1
#include <stdlib.h>
2
2
#include <string.h>
3
3
#include <stdio.h>
4
+ #include <pthread.h>
4
5
5
6
#include "cmark_ctype.h"
6
7
#include "cmark-gfm_config.h"
@@ -64,7 +65,7 @@ typedef struct subject{
64
65
} subject ;
65
66
66
67
// Extensions may populate this.
67
- static int8_t SKIP_CHARS [256 ];
68
+ static _Atomic int8_t SKIP_CHARS [256 ];
68
69
69
70
static CMARK_INLINE bool S_is_line_end_char (char c ) {
70
71
return (c == '\n' || c == '\r' );
@@ -1321,7 +1322,7 @@ static cmark_node *handle_newline(subject *subj) {
1321
1322
}
1322
1323
1323
1324
// "\r\n\\`&_*[]<!"
1324
- static int8_t SPECIAL_CHARS [256 ] = {
1325
+ static _Atomic int8_t SPECIAL_CHARS [256 ] = {
1325
1326
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1326
1327
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ,
1327
1328
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@@ -1349,6 +1350,8 @@ static char SMART_PUNCT_CHARS[] = {
1349
1350
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1350
1351
};
1351
1352
1353
+ pthread_mutex_t chars_lock ;
1354
+
1352
1355
static bufsize_t subject_find_special_char (subject * subj , int options ) {
1353
1356
bufsize_t n = subj -> pos + 1 ;
1354
1357
@@ -1364,15 +1367,19 @@ static bufsize_t subject_find_special_char(subject *subj, int options) {
1364
1367
}
1365
1368
1366
1369
void cmark_inlines_add_special_character (unsigned char c , bool emphasis ) {
1370
+ pthread_mutex_lock (& chars_lock );
1367
1371
SPECIAL_CHARS [c ] = 1 ;
1368
1372
if (emphasis )
1369
1373
SKIP_CHARS [c ] = 1 ;
1374
+ pthread_mutex_unlock (& chars_lock );
1370
1375
}
1371
1376
1372
1377
void cmark_inlines_remove_special_character (unsigned char c , bool emphasis ) {
1378
+ pthread_mutex_lock (& chars_lock );
1373
1379
SPECIAL_CHARS [c ] = 0 ;
1374
1380
if (emphasis )
1375
1381
SKIP_CHARS [c ] = 0 ;
1382
+ pthread_mutex_unlock (& chars_lock );
1376
1383
}
1377
1384
1378
1385
static cmark_node * try_extensions (cmark_parser * parser ,
0 commit comments