redcarpet 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of redcarpet might be problematic. Click here for more details.

data/ext/buffer.c CHANGED
@@ -23,7 +23,6 @@
23
23
  */
24
24
 
25
25
  #define BUFFER_STDARG
26
- #define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) //16mb
27
26
 
28
27
  #include "buffer.h"
29
28
 
@@ -148,25 +147,6 @@ bufdup(const struct buf *src, size_t dupunit) {
148
147
  #endif
149
148
  return ret; }
150
149
 
151
- /* bufgrow • increasing the allocated size to the given value */
152
- int
153
- bufgrow(struct buf *buf, size_t neosz) {
154
- size_t neoasz;
155
- void *neodata;
156
- if (!buf || !buf->unit || neosz > BUFFER_MAX_ALLOC_SIZE) return 0;
157
- if (buf->asize >= neosz) return 1;
158
- neoasz = buf->asize + buf->unit;
159
- while (neoasz < neosz) neoasz += buf->unit;
160
- neodata = realloc(buf->data, neoasz);
161
- if (!neodata) return 0;
162
- #ifdef BUFFER_STATS
163
- buffer_stat_alloc_bytes += (neoasz - buf->asize);
164
- #endif
165
- buf->data = neodata;
166
- buf->asize = neoasz;
167
- return 1; }
168
-
169
-
170
150
  /* bufnew • allocation of a new buffer */
171
151
  struct buf *
172
152
  bufnew(size_t unit) {
@@ -216,18 +196,10 @@ bufputs(struct buf *buf, const char *str) {
216
196
  bufput(buf, str, strlen (str)); }
217
197
 
218
198
 
219
- /* bufputc • appends a single char to a buffer */
220
- void
221
- bufputc(struct buf *buf, char c) {
222
- if (!buf || !bufgrow(buf, buf->size + 1)) return;
223
- buf->data[buf->size] = c;
224
- buf->size += 1; }
225
-
226
-
227
199
  /* bufrelease • decrease the reference count and free the buffer if needed */
228
200
  void
229
201
  bufrelease(struct buf *buf) {
230
- if (!buf || !buf->unit || !buf->asize) return;
202
+ if (!buf) return;
231
203
  buf->ref -= 1;
232
204
  if (buf->ref == 0) {
233
205
  #ifdef BUFFER_STATS
@@ -241,7 +213,7 @@ bufrelease(struct buf *buf) {
241
213
  /* bufreset • frees internal data of the buffer */
242
214
  void
243
215
  bufreset(struct buf *buf) {
244
- if (!buf || !buf->unit || !buf->asize) return;
216
+ if (!buf) return;
245
217
  #ifdef BUFFER_STATS
246
218
  buffer_stat_alloc_bytes -= buf->asize;
247
219
  #endif
data/ext/buffer.h CHANGED
@@ -21,6 +21,7 @@
21
21
 
22
22
  #include <stddef.h>
23
23
 
24
+ #define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) /* 16mb */
24
25
 
25
26
  /********************
26
27
  * TYPE DEFINITIONS *
@@ -81,10 +82,6 @@ struct buf *
81
82
  bufdup(const struct buf *, size_t)
82
83
  __attribute__ ((malloc));
83
84
 
84
- /* bufgrow • increasing the allocated size to the given value */
85
- int
86
- bufgrow(struct buf *, size_t);
87
-
88
85
  /* bufnew • allocation of a new buffer */
89
86
  struct buf *
90
87
  bufnew(size_t)
@@ -107,10 +104,6 @@ bufput(struct buf *, const void*, size_t);
107
104
  void
108
105
  bufputs(struct buf *, const char*);
109
106
 
110
- /* bufputc • appends a single char to a buffer */
111
- void
112
- bufputc(struct buf *, char);
113
-
114
107
  /* bufrelease • decrease the reference count and free the buffer if needed */
115
108
  void
116
109
  bufrelease(struct buf *);
@@ -142,6 +135,33 @@ vbufprintf(struct buf *, const char*, va_list);
142
135
 
143
136
  #endif /* def BUFFER_STDARG */
144
137
 
138
+ #include <stdlib.h>
139
+
140
+ /* bufgrow • increasing the allocated size to the given value */
141
+ static inline int
142
+ bufgrow(struct buf *buf, size_t neosz) {
143
+ size_t neoasz;
144
+ void *neodata;
145
+ if (!buf || !buf->unit || neosz > BUFFER_MAX_ALLOC_SIZE) return 0;
146
+ if (buf->asize >= neosz) return 1;
147
+ neoasz = buf->asize + buf->unit;
148
+ while (neoasz < neosz) neoasz += buf->unit;
149
+ neodata = realloc(buf->data, neoasz);
150
+ if (!neodata) return 0;
151
+ #ifdef BUFFER_STATS
152
+ buffer_stat_alloc_bytes += (neoasz - buf->asize);
153
+ #endif
154
+ buf->data = neodata;
155
+ buf->asize = neoasz;
156
+ return 1; }
157
+
158
+ /* bufputc • appends a single char to a buffer */
159
+ static inline void
160
+ bufputc(struct buf *buf, char c) {
161
+ if (!buf || !bufgrow(buf, buf->size + 1)) return;
162
+ buf->data[buf->size] = c;
163
+ buf->size += 1; }
164
+
145
165
  #endif /* ndef LITHIUM_BUFFER_H */
146
166
 
147
167
  /* vim: set filetype=c: */
data/ext/markdown.c CHANGED
@@ -1947,7 +1947,7 @@ static void expand_tabs(struct buf *ob, const char *line, size_t size)
1947
1947
  void
1948
1948
  ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer, unsigned int extensions) {
1949
1949
  struct link_ref *lr;
1950
- struct buf *text = bufnew(TEXT_UNIT);
1950
+ struct buf *text;
1951
1951
  size_t i, beg, end;
1952
1952
  struct render rndr;
1953
1953
 
@@ -1955,6 +1955,10 @@ ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer,
1955
1955
  if (!rndrer)
1956
1956
  return;
1957
1957
 
1958
+ text = bufnew(TEXT_UNIT);
1959
+ if (!text)
1960
+ return;
1961
+
1958
1962
  rndr.make = *rndrer;
1959
1963
  arr_init(&rndr.refs, sizeof (struct link_ref));
1960
1964
  parr_init(&rndr.work);
@@ -2027,7 +2031,7 @@ ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer,
2027
2031
 
2028
2032
  /* adding a final newline if not already present */
2029
2033
  if (!text->size)
2030
- return;
2034
+ goto cleanup;
2031
2035
 
2032
2036
  if (text->data[text->size - 1] != '\n' && text->data[text->size - 1] != '\r')
2033
2037
  bufputc(text, '\n');
@@ -2042,6 +2046,7 @@ ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer,
2042
2046
  rndr.make.doc_footer(ob, rndr.make.opaque);
2043
2047
 
2044
2048
  /* clean-up */
2049
+ cleanup:
2045
2050
  bufrelease(text);
2046
2051
  lr = rndr.refs.base;
2047
2052
  for (i = 0; i < (size_t)rndr.refs.size; i += 1) {
data/lib/redcarpet.rb CHANGED
@@ -26,7 +26,7 @@
26
26
  # end
27
27
  #
28
28
  class Redcarpet
29
- VERSION = '1.11.1'
29
+ VERSION = '1.11.2'
30
30
 
31
31
  # Original Markdown formatted text.
32
32
  attr_reader :text
data/redcarpet.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'redcarpet'
3
- s.version = '1.11.1'
3
+ s.version = '1.11.2'
4
4
  s.summary = "Ruby bindings for libupskirt"
5
5
  s.description = 'A fast and safe Markdown to (X)HTML parser'
6
- s.date = '2011-04-25'
6
+ s.date = '2011-04-26'
7
7
  s.email = 'vicent@github.com'
8
8
  s.homepage = 'http://github.com/tanoku/redcarpet'
9
9
  s.has_rdoc = true
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcarpet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 11
9
- - 1
10
- version: 1.11.1
9
+ - 2
10
+ version: 1.11.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Natacha Port\xC3\xA9"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-25 00:00:00 +03:00
19
+ date: 2011-04-26 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies: []
22
22