rmultimarkdown 4.7.1.1 → 6.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/README.md +7 -9
- data/Rakefile +33 -18
- data/ext/Makefile +261 -0
- data/ext/extconf.rb +23 -3
- data/ext/mmd/aho-corasick.c +596 -0
- data/ext/mmd/aho-corasick.h +120 -0
- data/ext/mmd/beamer.c +344 -0
- data/ext/mmd/beamer.h +72 -0
- data/ext/mmd/char.c +156 -0
- data/ext/mmd/char.h +111 -0
- data/ext/mmd/char_lookup.c +212 -0
- data/ext/mmd/critic_markup.c +330 -0
- data/ext/mmd/critic_markup.h +94 -0
- data/ext/mmd/d_string.c +402 -0
- data/ext/mmd/epub.c +563 -0
- data/ext/mmd/epub.h +69 -0
- data/ext/mmd/fodt.c +2288 -0
- data/ext/mmd/fodt.h +81 -0
- data/ext/mmd/html.c +2460 -0
- data/ext/mmd/html.h +81 -0
- data/ext/mmd/i18n.h +170 -0
- data/ext/mmd/include/d_string.h +182 -0
- data/ext/mmd/include/libMultiMarkdown.h +548 -0
- data/ext/mmd/include/token.h +233 -0
- data/ext/mmd/latex.c +2435 -0
- data/ext/mmd/latex.h +83 -0
- data/ext/mmd/lexer.c +3001 -0
- data/ext/mmd/lexer.h +75 -0
- data/ext/mmd/memoir.c +138 -0
- data/ext/mmd/memoir.h +67 -0
- data/ext/mmd/miniz.c +7557 -0
- data/ext/mmd/miniz.h +1328 -0
- data/ext/mmd/mmd.c +2798 -0
- data/ext/mmd/mmd.h +120 -0
- data/ext/mmd/object_pool.c +141 -0
- data/ext/mmd/object_pool.h +101 -0
- data/ext/mmd/opendocument-content.c +2071 -0
- data/ext/mmd/opendocument-content.h +135 -0
- data/ext/mmd/opendocument.c +981 -0
- data/ext/mmd/opendocument.h +118 -0
- data/ext/mmd/parser.c +1760 -0
- data/ext/mmd/parser.h +39 -0
- data/{MultiMarkdown-4 → ext/mmd}/rng.c +90 -49
- data/ext/mmd/scanners.c +77512 -0
- data/ext/mmd/scanners.h +101 -0
- data/ext/mmd/stack.c +142 -0
- data/ext/mmd/stack.h +113 -0
- data/ext/mmd/textbundle.c +455 -0
- data/ext/mmd/textbundle.h +115 -0
- data/ext/mmd/token.c +773 -0
- data/ext/mmd/token_pairs.c +263 -0
- data/ext/mmd/token_pairs.h +123 -0
- data/ext/mmd/transclude.c +549 -0
- data/ext/mmd/transclude.h +87 -0
- data/ext/mmd/uthash.h +1074 -0
- data/ext/mmd/uuid.c +154 -0
- data/ext/mmd/uuid.h +77 -0
- data/ext/mmd/version.h +111 -0
- data/ext/mmd/writer.c +2652 -0
- data/ext/mmd/writer.h +260 -0
- data/ext/mmd/zip.c +210 -0
- data/ext/mmd/zip.h +120 -0
- data/ext/{multi_markdown.c → ruby_multi_markdown.c} +87 -18
- data/lib/multi_markdown.bundle +0 -0
- data/lib/multi_markdown.rb +5 -8
- data/lib/multi_markdown/version.rb +1 -1
- data/rmultimarkdown.gemspec +2 -2
- data/test/{extensions_test.rb.rb → extensions_test.rb} +10 -54
- data/test/multi_markdown_test.rb +13 -0
- metadata +67 -47
- data/MultiMarkdown-4/GLibFacade.c +0 -310
- data/MultiMarkdown-4/GLibFacade.h +0 -100
- data/MultiMarkdown-4/beamer.c +0 -182
- data/MultiMarkdown-4/beamer.h +0 -11
- data/MultiMarkdown-4/critic.c +0 -111
- data/MultiMarkdown-4/critic.h +0 -15
- data/MultiMarkdown-4/glib.h +0 -11
- data/MultiMarkdown-4/html.c +0 -1117
- data/MultiMarkdown-4/html.h +0 -14
- data/MultiMarkdown-4/latex.c +0 -1217
- data/MultiMarkdown-4/latex.h +0 -16
- data/MultiMarkdown-4/libMultiMarkdown.h +0 -177
- data/MultiMarkdown-4/lyx.c +0 -2265
- data/MultiMarkdown-4/lyx.h +0 -37
- data/MultiMarkdown-4/lyxbeamer.c +0 -265
- data/MultiMarkdown-4/lyxbeamer.h +0 -11
- data/MultiMarkdown-4/memoir.c +0 -80
- data/MultiMarkdown-4/memoir.h +0 -10
- data/MultiMarkdown-4/multimarkdown.c +0 -518
- data/MultiMarkdown-4/odf.c +0 -1222
- data/MultiMarkdown-4/odf.h +0 -18
- data/MultiMarkdown-4/opml.c +0 -189
- data/MultiMarkdown-4/opml.h +0 -15
- data/MultiMarkdown-4/parse_utilities.c +0 -884
- data/MultiMarkdown-4/parser.c +0 -16656
- data/MultiMarkdown-4/parser.h +0 -188
- data/MultiMarkdown-4/rtf.c +0 -665
- data/MultiMarkdown-4/rtf.h +0 -17
- data/MultiMarkdown-4/strtok.c +0 -56
- data/MultiMarkdown-4/strtok.h +0 -9
- data/MultiMarkdown-4/text.c +0 -53
- data/MultiMarkdown-4/text.h +0 -11
- data/MultiMarkdown-4/toc.c +0 -142
- data/MultiMarkdown-4/toc.h +0 -15
- data/MultiMarkdown-4/transclude.c +0 -307
- data/MultiMarkdown-4/transclude.h +0 -28
- data/MultiMarkdown-4/writer.c +0 -731
- data/MultiMarkdown-4/writer.h +0 -38
data/test/multi_markdown_test.rb
CHANGED
@@ -30,6 +30,19 @@ class MultiMarkdownTest < Test::Unit::TestCase
|
|
30
30
|
assert_equal "<p>Hello <span><em>World</em></span>!</p>", multimarkdown.to_html.strip
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_multimarkdown_smart_quote_languages
|
34
|
+
multimarkdown = MultiMarkdown.new('Hello "world"')
|
35
|
+
assert_respond_to multimarkdown, :to_html
|
36
|
+
assert_equal '<p>Hello “world”</p>', multimarkdown.to_html.strip
|
37
|
+
|
38
|
+
multimarkdown.language = :de
|
39
|
+
assert_equal '<p>Hello „world”</p>', multimarkdown.to_html.strip
|
40
|
+
|
41
|
+
multimarkdown.language = :ch
|
42
|
+
assert_equal '<p>Hello «world»</p>', multimarkdown.to_html.strip
|
43
|
+
end
|
44
|
+
|
45
|
+
|
33
46
|
def test_version_fits
|
34
47
|
assert MultiMarkdown::VERSION =~ /^#{MultiMarkdown::MMD_VERSION}/,
|
35
48
|
"Expected MultiMarkdown's version (#{MultiMarkdown::VERSION}) to start with the C library's version (#{MultiMarkdown::MMD_VERSION})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmultimarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Till Schulte-Coerne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: A MultiMarkdown
|
27
|
+
description: A MultiMarkdown 6 binding for Ruby
|
28
28
|
email:
|
29
29
|
- till.schulte-coerne@innoq.com
|
30
30
|
executables:
|
@@ -36,57 +36,77 @@ extra_rdoc_files:
|
|
36
36
|
- LICENSE
|
37
37
|
files:
|
38
38
|
- LICENSE
|
39
|
-
- MultiMarkdown-4/GLibFacade.c
|
40
|
-
- MultiMarkdown-4/GLibFacade.h
|
41
|
-
- MultiMarkdown-4/beamer.c
|
42
|
-
- MultiMarkdown-4/beamer.h
|
43
|
-
- MultiMarkdown-4/critic.c
|
44
|
-
- MultiMarkdown-4/critic.h
|
45
|
-
- MultiMarkdown-4/glib.h
|
46
|
-
- MultiMarkdown-4/html.c
|
47
|
-
- MultiMarkdown-4/html.h
|
48
|
-
- MultiMarkdown-4/latex.c
|
49
|
-
- MultiMarkdown-4/latex.h
|
50
|
-
- MultiMarkdown-4/libMultiMarkdown.h
|
51
|
-
- MultiMarkdown-4/lyx.c
|
52
|
-
- MultiMarkdown-4/lyx.h
|
53
|
-
- MultiMarkdown-4/lyxbeamer.c
|
54
|
-
- MultiMarkdown-4/lyxbeamer.h
|
55
|
-
- MultiMarkdown-4/memoir.c
|
56
|
-
- MultiMarkdown-4/memoir.h
|
57
|
-
- MultiMarkdown-4/multimarkdown.c
|
58
|
-
- MultiMarkdown-4/odf.c
|
59
|
-
- MultiMarkdown-4/odf.h
|
60
|
-
- MultiMarkdown-4/opml.c
|
61
|
-
- MultiMarkdown-4/opml.h
|
62
|
-
- MultiMarkdown-4/parse_utilities.c
|
63
|
-
- MultiMarkdown-4/parser.c
|
64
|
-
- MultiMarkdown-4/parser.h
|
65
|
-
- MultiMarkdown-4/rng.c
|
66
|
-
- MultiMarkdown-4/rtf.c
|
67
|
-
- MultiMarkdown-4/rtf.h
|
68
|
-
- MultiMarkdown-4/strtok.c
|
69
|
-
- MultiMarkdown-4/strtok.h
|
70
|
-
- MultiMarkdown-4/text.c
|
71
|
-
- MultiMarkdown-4/text.h
|
72
|
-
- MultiMarkdown-4/toc.c
|
73
|
-
- MultiMarkdown-4/toc.h
|
74
|
-
- MultiMarkdown-4/transclude.c
|
75
|
-
- MultiMarkdown-4/transclude.h
|
76
|
-
- MultiMarkdown-4/writer.c
|
77
|
-
- MultiMarkdown-4/writer.h
|
78
39
|
- README.md
|
79
40
|
- Rakefile
|
80
41
|
- bin/rmultimarkdown
|
42
|
+
- ext/Makefile
|
81
43
|
- ext/extconf.h
|
82
44
|
- ext/extconf.rb
|
83
|
-
- ext/
|
45
|
+
- ext/mmd/aho-corasick.c
|
46
|
+
- ext/mmd/aho-corasick.h
|
47
|
+
- ext/mmd/beamer.c
|
48
|
+
- ext/mmd/beamer.h
|
49
|
+
- ext/mmd/char.c
|
50
|
+
- ext/mmd/char.h
|
51
|
+
- ext/mmd/char_lookup.c
|
52
|
+
- ext/mmd/critic_markup.c
|
53
|
+
- ext/mmd/critic_markup.h
|
54
|
+
- ext/mmd/d_string.c
|
55
|
+
- ext/mmd/epub.c
|
56
|
+
- ext/mmd/epub.h
|
57
|
+
- ext/mmd/fodt.c
|
58
|
+
- ext/mmd/fodt.h
|
59
|
+
- ext/mmd/html.c
|
60
|
+
- ext/mmd/html.h
|
61
|
+
- ext/mmd/i18n.h
|
62
|
+
- ext/mmd/include/d_string.h
|
63
|
+
- ext/mmd/include/libMultiMarkdown.h
|
64
|
+
- ext/mmd/include/token.h
|
65
|
+
- ext/mmd/latex.c
|
66
|
+
- ext/mmd/latex.h
|
67
|
+
- ext/mmd/lexer.c
|
68
|
+
- ext/mmd/lexer.h
|
69
|
+
- ext/mmd/memoir.c
|
70
|
+
- ext/mmd/memoir.h
|
71
|
+
- ext/mmd/miniz.c
|
72
|
+
- ext/mmd/miniz.h
|
73
|
+
- ext/mmd/mmd.c
|
74
|
+
- ext/mmd/mmd.h
|
75
|
+
- ext/mmd/object_pool.c
|
76
|
+
- ext/mmd/object_pool.h
|
77
|
+
- ext/mmd/opendocument-content.c
|
78
|
+
- ext/mmd/opendocument-content.h
|
79
|
+
- ext/mmd/opendocument.c
|
80
|
+
- ext/mmd/opendocument.h
|
81
|
+
- ext/mmd/parser.c
|
82
|
+
- ext/mmd/parser.h
|
83
|
+
- ext/mmd/rng.c
|
84
|
+
- ext/mmd/scanners.c
|
85
|
+
- ext/mmd/scanners.h
|
86
|
+
- ext/mmd/stack.c
|
87
|
+
- ext/mmd/stack.h
|
88
|
+
- ext/mmd/textbundle.c
|
89
|
+
- ext/mmd/textbundle.h
|
90
|
+
- ext/mmd/token.c
|
91
|
+
- ext/mmd/token_pairs.c
|
92
|
+
- ext/mmd/token_pairs.h
|
93
|
+
- ext/mmd/transclude.c
|
94
|
+
- ext/mmd/transclude.h
|
95
|
+
- ext/mmd/uthash.h
|
96
|
+
- ext/mmd/uuid.c
|
97
|
+
- ext/mmd/uuid.h
|
98
|
+
- ext/mmd/version.h
|
99
|
+
- ext/mmd/writer.c
|
100
|
+
- ext/mmd/writer.h
|
101
|
+
- ext/mmd/zip.c
|
102
|
+
- ext/mmd/zip.h
|
103
|
+
- ext/ruby_multi_markdown.c
|
84
104
|
- lib/multi_markdown.bundle
|
85
105
|
- lib/multi_markdown.rb
|
86
106
|
- lib/multi_markdown/version.rb
|
87
107
|
- lib/rmultimarkdown.rb
|
88
108
|
- rmultimarkdown.gemspec
|
89
|
-
- test/extensions_test.rb
|
109
|
+
- test/extensions_test.rb
|
90
110
|
- test/multi_markdown_test.rb
|
91
111
|
homepage: http://github.com/tillsc/multi_markdown
|
92
112
|
licenses: []
|
@@ -107,10 +127,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
127
|
version: '0'
|
108
128
|
requirements: []
|
109
129
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
111
131
|
signing_key:
|
112
132
|
specification_version: 4
|
113
|
-
summary: A MultiMarkdown
|
133
|
+
summary: A MultiMarkdown 6 binding for Ruby
|
114
134
|
test_files:
|
115
|
-
- test/extensions_test.rb
|
135
|
+
- test/extensions_test.rb
|
116
136
|
- test/multi_markdown_test.rb
|
@@ -1,310 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* GLibFacade.c
|
3
|
-
* MultiMarkdown
|
4
|
-
*
|
5
|
-
* Created by Daniel Jalkut on 7/26/11.
|
6
|
-
* Modified by Fletcher T. Penney on 9/15/11 and 12/3/13.
|
7
|
-
* Modified by Dan Lowe on 1/3/12.
|
8
|
-
*
|
9
|
-
* License for original code by Daniel Jalkut:
|
10
|
-
*
|
11
|
-
* Copyright 2011 Daniel Jalkut. All rights reserved.
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
14
|
-
* this software and associated documentation files (the “Software”), to deal in
|
15
|
-
* the Software without restriction, including without limitation the rights to
|
16
|
-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
17
|
-
* of the Software, and to permit persons to whom the Software is furnished to do
|
18
|
-
* so, subject to the following conditions:
|
19
|
-
*
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
21
|
-
* copies or substantial portions of the Software.
|
22
|
-
*
|
23
|
-
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
|
-
* SOFTWARE.
|
30
|
-
*/
|
31
|
-
|
32
|
-
#include "GLibFacade.h"
|
33
|
-
|
34
|
-
#include <stdio.h>
|
35
|
-
#include <stdlib.h>
|
36
|
-
#include <string.h>
|
37
|
-
#include <stdarg.h>
|
38
|
-
|
39
|
-
/*
|
40
|
-
* The following section came from:
|
41
|
-
*
|
42
|
-
* http://lists-archives.org/mingw-users/12649-asprintf-missing-vsnprintf-
|
43
|
-
* behaving-differently-and-_vsncprintf-undefined.html
|
44
|
-
*
|
45
|
-
* and
|
46
|
-
*
|
47
|
-
* http://groups.google.com/group/jansson-users/browse_thread/thread/
|
48
|
-
* 76a88d63d9519978/041a7d0570de2d48?lnk=raot
|
49
|
-
*/
|
50
|
-
|
51
|
-
/* Solaris and Windows do not provide vasprintf() or asprintf(). */
|
52
|
-
#if defined(__WIN32) || (defined(__SVR4) && defined(__sun))
|
53
|
-
int vasprintf( char **sptr, char *fmt, va_list argv )
|
54
|
-
{
|
55
|
-
int wanted = vsnprintf( *sptr = NULL, 0, fmt, argv );
|
56
|
-
if( (wanted > 0) && ((*sptr = malloc( 1 + wanted )) != NULL) )
|
57
|
-
return vsprintf( *sptr, fmt, argv );
|
58
|
-
|
59
|
-
return wanted;
|
60
|
-
}
|
61
|
-
|
62
|
-
int asprintf( char **sptr, char *fmt, ... )
|
63
|
-
{
|
64
|
-
int retval;
|
65
|
-
va_list argv;
|
66
|
-
va_start( argv, fmt );
|
67
|
-
retval = vasprintf( sptr, fmt, argv );
|
68
|
-
va_end( argv );
|
69
|
-
return retval;
|
70
|
-
}
|
71
|
-
#endif
|
72
|
-
|
73
|
-
|
74
|
-
/* GString */
|
75
|
-
|
76
|
-
#define kStringBufferStartingSize 1024
|
77
|
-
#define kStringBufferGrowthMultiplier 2
|
78
|
-
|
79
|
-
GString* g_string_new(char *startingString)
|
80
|
-
{
|
81
|
-
GString* newString = malloc(sizeof(GString));
|
82
|
-
|
83
|
-
if (startingString == NULL) startingString = "";
|
84
|
-
|
85
|
-
size_t startingBufferSize = kStringBufferStartingSize;
|
86
|
-
size_t startingStringSize = strlen(startingString);
|
87
|
-
while (startingBufferSize < (startingStringSize + 1))
|
88
|
-
{
|
89
|
-
startingBufferSize *= kStringBufferGrowthMultiplier;
|
90
|
-
}
|
91
|
-
|
92
|
-
newString->str = malloc(startingBufferSize);
|
93
|
-
newString->currentStringBufferSize = startingBufferSize;
|
94
|
-
strncpy(newString->str, startingString, startingStringSize);
|
95
|
-
newString->str[startingStringSize] = '\0';
|
96
|
-
newString->currentStringLength = startingStringSize;
|
97
|
-
|
98
|
-
return newString;
|
99
|
-
}
|
100
|
-
|
101
|
-
char* g_string_free(GString* ripString, bool freeCharacterData)
|
102
|
-
{
|
103
|
-
if (ripString == NULL)
|
104
|
-
return NULL;
|
105
|
-
|
106
|
-
char* returnedString = ripString->str;
|
107
|
-
if (freeCharacterData)
|
108
|
-
{
|
109
|
-
if (ripString->str != NULL)
|
110
|
-
{
|
111
|
-
free(ripString->str);
|
112
|
-
}
|
113
|
-
returnedString = NULL;
|
114
|
-
}
|
115
|
-
|
116
|
-
free(ripString);
|
117
|
-
|
118
|
-
return returnedString;
|
119
|
-
}
|
120
|
-
|
121
|
-
static void ensureStringBufferCanHold(GString* baseString, size_t newStringSize)
|
122
|
-
{
|
123
|
-
size_t newBufferSizeNeeded = newStringSize + 1;
|
124
|
-
if (newBufferSizeNeeded > baseString->currentStringBufferSize)
|
125
|
-
{
|
126
|
-
size_t newBufferSize = baseString->currentStringBufferSize;
|
127
|
-
|
128
|
-
while (newBufferSizeNeeded > newBufferSize)
|
129
|
-
{
|
130
|
-
newBufferSize *= kStringBufferGrowthMultiplier;
|
131
|
-
}
|
132
|
-
|
133
|
-
char *temp;
|
134
|
-
temp = realloc(baseString->str, newBufferSize);
|
135
|
-
|
136
|
-
if (temp == NULL) {
|
137
|
-
/* realloc failed */
|
138
|
-
fprintf(stderr, "error reallocating memory\n");
|
139
|
-
|
140
|
-
exit(1);
|
141
|
-
}
|
142
|
-
baseString->str = temp;
|
143
|
-
baseString->currentStringBufferSize = newBufferSize;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
void g_string_append(GString* baseString, char* appendedString)
|
148
|
-
{
|
149
|
-
if ((appendedString != NULL) && (strlen(appendedString) > 0))
|
150
|
-
{
|
151
|
-
size_t appendedStringLength = strlen(appendedString);
|
152
|
-
size_t newStringLength = baseString->currentStringLength + appendedStringLength;
|
153
|
-
ensureStringBufferCanHold(baseString, newStringLength);
|
154
|
-
|
155
|
-
/* We already know where the current string ends, so pass that as the starting address for strncat */
|
156
|
-
strncat(baseString->str + baseString->currentStringLength, appendedString, appendedStringLength);
|
157
|
-
baseString->currentStringLength = newStringLength;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
void g_string_append_c(GString* baseString, char appendedCharacter)
|
162
|
-
{
|
163
|
-
size_t newSizeNeeded = baseString->currentStringLength + 1;
|
164
|
-
ensureStringBufferCanHold(baseString, newSizeNeeded);
|
165
|
-
|
166
|
-
baseString->str[baseString->currentStringLength] = appendedCharacter;
|
167
|
-
baseString->currentStringLength++;
|
168
|
-
baseString->str[baseString->currentStringLength] = '\0';
|
169
|
-
}
|
170
|
-
|
171
|
-
void g_string_append_printf(GString* baseString, char* format, ...)
|
172
|
-
{
|
173
|
-
va_list args;
|
174
|
-
va_start(args, format);
|
175
|
-
|
176
|
-
char* formattedString = NULL;
|
177
|
-
vasprintf(&formattedString, format, args);
|
178
|
-
if (formattedString != NULL)
|
179
|
-
{
|
180
|
-
g_string_append(baseString, formattedString);
|
181
|
-
free(formattedString);
|
182
|
-
}
|
183
|
-
va_end(args);
|
184
|
-
}
|
185
|
-
|
186
|
-
void g_string_prepend(GString* baseString, char* prependedString)
|
187
|
-
{
|
188
|
-
if ((prependedString != NULL) && (strlen(prependedString) > 0))
|
189
|
-
{
|
190
|
-
size_t prependedStringLength = strlen(prependedString);
|
191
|
-
size_t newStringLength = baseString->currentStringLength + prependedStringLength;
|
192
|
-
ensureStringBufferCanHold(baseString, newStringLength);
|
193
|
-
|
194
|
-
memmove(baseString->str + prependedStringLength, baseString->str, baseString->currentStringLength);
|
195
|
-
strncpy(baseString->str, prependedString, prependedStringLength);
|
196
|
-
baseString->currentStringLength = newStringLength;
|
197
|
-
baseString->str[baseString->currentStringLength] = '\0';
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
void g_string_insert(GString* baseString, size_t pos, char * insertedString)
|
202
|
-
{
|
203
|
-
if ((insertedString != NULL) && (strlen(insertedString) > 0))
|
204
|
-
{
|
205
|
-
if (pos > baseString->currentStringLength)
|
206
|
-
pos = baseString->currentStringLength;
|
207
|
-
|
208
|
-
size_t insertedStringLength = strlen(insertedString);
|
209
|
-
size_t newStringLength = baseString->currentStringLength + insertedStringLength;
|
210
|
-
ensureStringBufferCanHold(baseString, newStringLength);
|
211
|
-
|
212
|
-
/* Shift following string to 'right' */
|
213
|
-
memmove(baseString->str + pos + insertedStringLength, baseString->str + pos, baseString->currentStringLength - pos);
|
214
|
-
strncpy(baseString->str + pos, insertedString, insertedStringLength);
|
215
|
-
baseString->currentStringLength = newStringLength;
|
216
|
-
baseString->str[baseString->currentStringLength] = '\0';
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
void g_string_insert_c(GString* baseString, size_t pos, char insertedCharacter)
|
221
|
-
{
|
222
|
-
if (pos > baseString->currentStringLength)
|
223
|
-
pos = baseString->currentStringLength;
|
224
|
-
|
225
|
-
size_t newSizeNeeded = baseString->currentStringLength + 1;
|
226
|
-
ensureStringBufferCanHold(baseString, newSizeNeeded);
|
227
|
-
|
228
|
-
/* Shift following string to 'right' */
|
229
|
-
memmove(baseString->str + pos + 1, baseString->str + pos, baseString->currentStringLength - pos);
|
230
|
-
|
231
|
-
baseString->str[pos] = insertedCharacter;
|
232
|
-
baseString->currentStringLength++;
|
233
|
-
baseString->str[baseString->currentStringLength] = '\0';
|
234
|
-
}
|
235
|
-
|
236
|
-
|
237
|
-
void g_string_insert_printf(GString* baseString, size_t pos, char* format, ...)
|
238
|
-
{
|
239
|
-
va_list args;
|
240
|
-
va_start(args, format);
|
241
|
-
|
242
|
-
char* formattedString = NULL;
|
243
|
-
vasprintf(&formattedString, format, args);
|
244
|
-
if (formattedString != NULL)
|
245
|
-
{
|
246
|
-
g_string_insert(baseString, pos, formattedString);
|
247
|
-
free(formattedString);
|
248
|
-
}
|
249
|
-
va_end(args);
|
250
|
-
}
|
251
|
-
|
252
|
-
void g_string_erase(GString* baseString, size_t pos, size_t len)
|
253
|
-
{
|
254
|
-
if ((pos > baseString->currentStringLength) || (len <= 0))
|
255
|
-
return;
|
256
|
-
|
257
|
-
if ((pos + len) >= baseString->currentStringLength)
|
258
|
-
len = -1;
|
259
|
-
|
260
|
-
if (len == -1) {
|
261
|
-
baseString->currentStringLength = pos;
|
262
|
-
} else {
|
263
|
-
memmove(baseString->str + pos, baseString->str + pos + len, baseString->currentStringLength - pos - len);
|
264
|
-
baseString->currentStringLength -= len;
|
265
|
-
}
|
266
|
-
baseString->str[baseString->currentStringLength] = '\0';
|
267
|
-
}
|
268
|
-
|
269
|
-
/* GSList */
|
270
|
-
|
271
|
-
void g_slist_free(GSList* ripList)
|
272
|
-
{
|
273
|
-
GSList* thisListItem = ripList;
|
274
|
-
while (thisListItem != NULL)
|
275
|
-
{
|
276
|
-
GSList* nextItem = thisListItem->next;
|
277
|
-
|
278
|
-
/* I guess we don't release the data? Non-retained memory management is hard... let's figure it out later. */
|
279
|
-
free(thisListItem);
|
280
|
-
|
281
|
-
thisListItem = nextItem;
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
|
-
/* Currently only used for markdown_output.c endnotes printing */
|
286
|
-
GSList* g_slist_reverse(GSList* theList)
|
287
|
-
{
|
288
|
-
GSList* lastNodeSeen = NULL;
|
289
|
-
|
290
|
-
/* Iterate the list items, tacking them on to our new reversed List as we find them */
|
291
|
-
GSList* listWalker = theList;
|
292
|
-
while (listWalker != NULL)
|
293
|
-
{
|
294
|
-
GSList* nextNode = listWalker->next;
|
295
|
-
listWalker->next = lastNodeSeen;
|
296
|
-
lastNodeSeen = listWalker;
|
297
|
-
listWalker = nextNode;
|
298
|
-
}
|
299
|
-
|
300
|
-
return lastNodeSeen;
|
301
|
-
}
|
302
|
-
|
303
|
-
GSList* g_slist_prepend(GSList* targetElement, void* newElementData)
|
304
|
-
{
|
305
|
-
GSList* newElement = malloc(sizeof(GSList));
|
306
|
-
newElement->data = newElementData;
|
307
|
-
newElement->next = targetElement;
|
308
|
-
return newElement;
|
309
|
-
}
|
310
|
-
|