crasher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING ADDED
@@ -0,0 +1,52 @@
1
+ The core Discount C sources are
2
+ Copyright (C) 2007 David Loren Parsons.
3
+
4
+ The Discount Ruby extension sources are
5
+ Copyright (C) 2008 Ryan Tomayko.
6
+
7
+ All rights reserved.
8
+
9
+ Permission is hereby granted, free of charge, to any person
10
+ obtaining a copy of this software and associated documentation files
11
+ (the "Software"), to deal in the Software without restriction,
12
+ including without limitation the rights to use, copy, modify, merge,
13
+ publish, distribute, sublicence, and/or sell copies of the Software,
14
+ and to permit persons to whom the Software is furnished to do so,
15
+ subject to the following conditions:
16
+
17
+ 1. Redistributions of source code must retain the above copyright
18
+ notice, this list of conditions, and the following disclaimer.
19
+
20
+ 2. Redistributions in binary form must reproduce the above
21
+ copyright notice, this list of conditions and the following
22
+ disclaimer in the documentation and/or other materials provided
23
+ with the distribution, and in the same place and form as other
24
+ copyright, license and disclaimer information.
25
+
26
+ 3. The end-user documentation included with the redistribution, if
27
+ any, must include the following acknowledgment:
28
+
29
+ This product includes software developed by
30
+ David Loren Parsons <http://www.pell.portland.or.us/~orc>
31
+
32
+ in the same place and form as other third-party acknowledgments.
33
+ Alternately, this acknowledgment may appear in the software
34
+ itself, in the same form and location as other such third-party
35
+ acknowledgments.
36
+
37
+ 4. Except as contained in this notice, the name of David Loren
38
+ Parsons shall not be used in advertising or otherwise to promote
39
+ the sale, use or other dealings in this Software without prior
40
+ written authorization from David Loren Parsons.
41
+
42
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
43
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45
+ IN NO EVENT SHALL DAVID LOREN PARSONS BE LIABLE FOR ANY DIRECT,
46
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
47
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52
+ OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,58 @@
1
+ Discount Markdown Processor for Ruby
2
+ ====================================
3
+
4
+ Discount is an implementation of John Gruber's Markdown markup language in C. It
5
+ implements all of the language described in [the markdown syntax document][1] and
6
+ passes the [Markdown 1.0 test suite][2].
7
+
8
+ Discount was developed by [David Loren Parsons][3]. The Ruby extension was
9
+ developed by [Ryan Tomayko][4].
10
+
11
+ [1]: http://daringfireball.net/projects/markdown/syntax
12
+ [2]: http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip
13
+ [3]: http://www.pell.portland.or.us/~orc
14
+ [4]: http://tomayko.com/
15
+
16
+ Installation, Hacking
17
+ ---------------------
18
+
19
+ RDiscount Gem releases are published to RubyForge and can be installed as
20
+ follows:
21
+
22
+ $ [sudo] gem install rdiscount
23
+
24
+ The RDiscount sources are available via Git:
25
+
26
+ $ git clone git://github.com/rtomayko/rdiscount.git
27
+ $ cd rdiscount
28
+ $ rake --tasks
29
+
30
+ For more information, see [the project page](http://github.com/rtomayko/rdiscount).
31
+
32
+ Usage
33
+ -----
34
+
35
+ RDiscount implements the basic protocol popularized by RedCloth and adopted
36
+ by BlueCloth:
37
+
38
+ require 'rdiscount'
39
+ markdown = RDiscount.new("Hello World!")
40
+ puts markdown.to_html
41
+
42
+ Inject RDiscount into your BlueCloth-using code by replacing your bluecloth
43
+ require statements with the following:
44
+
45
+ begin
46
+ require 'rdiscount'
47
+ BlueCloth = RDiscount
48
+ rescue LoadError
49
+ require 'bluecloth'
50
+ end
51
+
52
+ COPYING
53
+ -------
54
+
55
+ Discount is free software; it is released under a BSD-style license
56
+ that allows you to do as you wish with it as long as you don't attempt
57
+ to claim it as your own work. RDiscount adopts Discount's license
58
+ verbatim. See the file `COPYING` for more information.
@@ -0,0 +1,199 @@
1
+ require 'rake/clean'
2
+
3
+ task :default => :test
4
+
5
+ # PACKAGING =================================================================
6
+
7
+ # Load the gemspec using the same limitations as github
8
+ $spec =
9
+ begin
10
+ require 'rubygems/specification'
11
+ data = File.read('crasher.gemspec')
12
+ spec = nil
13
+ Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
14
+ spec
15
+ end
16
+
17
+ def package(ext='')
18
+ "pkg/crasher-#{$spec.version}" + ext
19
+ end
20
+
21
+ desc 'Build packages'
22
+ task :package => %w[.gem .tar.gz].map {|e| package(e)}
23
+
24
+ desc 'Build and install as local gem'
25
+ task :install => package('.gem') do
26
+ sh "gem install #{package('.gem')}"
27
+ end
28
+
29
+ directory 'pkg/'
30
+
31
+ file package('.gem') => %w[pkg/ crasher.gemspec] + $spec.files do |f|
32
+ sh "gem build crasher.gemspec"
33
+ end
34
+
35
+ file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
36
+ sh "git archive --format=tar HEAD | gzip > #{f.name}"
37
+ end
38
+
39
+ # GEMSPEC HELPERS ==========================================================
40
+
41
+ def source_version
42
+ '0.0.1'
43
+ end
44
+
45
+ file 'crasher.gemspec' => FileList['Rakefile','lib/crasher.rb'] do |f|
46
+ # read spec file and split out manifest section
47
+ spec = File.read(f.name)
48
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
49
+ head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
50
+ head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
51
+ # determine file list from git ls-files
52
+ files = `git ls-files`.
53
+ split("\n").
54
+ sort.
55
+ reject{ |file| file =~ /^\./ || file =~ /^test\/MarkdownTest/ }.
56
+ map{ |file| " #{file}" }.
57
+ join("\n")
58
+ # piece file back together and write...
59
+ manifest = " s.files = %w[\n#{files}\n ]\n"
60
+ spec = [head,manifest,tail].join(" # = MANIFEST =\n")
61
+ File.open(f.name, 'w') { |io| io.write(spec) }
62
+ puts "updated #{f.name}"
63
+ end
64
+
65
+ # ==========================================================
66
+ # Ruby Extension
67
+ # ==========================================================
68
+
69
+ DLEXT = Config::CONFIG['DLEXT']
70
+
71
+ file 'ext/Makefile' => FileList['ext/{*.c,*.h,*.rb}'] do
72
+ chdir('ext') { ruby 'extconf.rb' }
73
+ end
74
+ CLEAN.include 'ext/Makefile', 'ext/mkmf.log'
75
+
76
+ file "ext/rdiscount.#{DLEXT}" => FileList['ext/Makefile', 'ext/*.{c,h,rb}'] do |f|
77
+ sh 'cd ext && make'
78
+ end
79
+ CLEAN.include 'ext/*.{o,bundle,so,dll}'
80
+
81
+ file "lib/rdiscount.#{DLEXT}" => "ext/rdiscount.#{DLEXT}" do |f|
82
+ cp f.prerequisites, "lib/", :preserve => true
83
+ end
84
+
85
+ desc 'Build the rdiscount extension'
86
+ task :build => "lib/rdiscount.#{DLEXT}"
87
+
88
+ # ==========================================================
89
+ # Testing
90
+ # ==========================================================
91
+
92
+ desc 'Run unit tests'
93
+ task 'test:unit' => [:build] do |t|
94
+ sh 'testrb test/markdown_test.rb test/rdiscount_test.rb'
95
+ end
96
+
97
+ desc 'Run conformance tests (MARKDOWN_TEST_VER=1.0)'
98
+ task 'test:conformance' => [:build] do |t|
99
+ script = "#{pwd}/bin/rdiscount"
100
+ test_version = ENV['MARKDOWN_TEST_VER'] || '1.0.3'
101
+ chdir("test/MarkdownTest_#{test_version}") do
102
+ sh "./MarkdownTest.pl --script='#{script}' --tidy"
103
+ end
104
+ end
105
+
106
+ desc 'Run version 1.0 conformance suite'
107
+ task 'test:conformance:1.0' => [:build] do |t|
108
+ ENV['MARKDOWN_TEST_VER'] = '1.0'
109
+ Rake::Task['test:conformance'].invoke
110
+ end
111
+
112
+ desc 'Run 1.0.3 conformance suite'
113
+ task 'test:conformance:1.0.3' => [:build] do |t|
114
+ ENV['MARKDOWN_TEST_VER'] = '1.0.3'
115
+ Rake::Task['test:conformance'].invoke
116
+ end
117
+
118
+ desc 'Run unit and conformance tests'
119
+ task :test => %w[test:unit test:conformance]
120
+
121
+ desc 'Run benchmarks'
122
+ task :benchmark => :build do |t|
123
+ $:.unshift 'lib'
124
+ load 'test/benchmark.rb'
125
+ end
126
+
127
+ # ==========================================================
128
+ # Documentation
129
+ # ==========================================================
130
+
131
+ desc 'Generate API documentation'
132
+ task :doc => 'doc/index.html'
133
+
134
+ file 'doc/index.html' => FileList['lib/*.rb'] do |f|
135
+ sh((<<-end).gsub(/\s+/, ' '))
136
+ hanna --charset utf8 \
137
+ --fmt html \
138
+ --inline-source \
139
+ --line-numbers \
140
+ --main RDiscount \
141
+ --op doc \
142
+ --title 'RDiscount API Documentation' \
143
+ #{f.prerequisites.join(' ')}
144
+ end
145
+ end
146
+
147
+ CLEAN.include 'doc'
148
+
149
+
150
+ # ==========================================================
151
+ # Rubyforge
152
+ # ==========================================================
153
+
154
+ desc 'Publish new release to rubyforge'
155
+ task :release => [package('.gem'), package('.tar.gz')] do |t|
156
+ sh <<-end
157
+ rubyforge add_release wink rdiscount #{$spec.version} #{package('.gem')} &&
158
+ rubyforge add_file wink rdiscount #{$spec.version} #{package('.tar.gz')}
159
+ end
160
+ end
161
+
162
+ desc 'Publish API docs to rubyforge'
163
+ task :publish => :doc do |t|
164
+ sh 'scp -rp doc/. rubyforge.org:/var/www/gforge-projects/wink/rdiscount'
165
+ end
166
+
167
+ # ==========================================================
168
+ # Update package's Discount sources
169
+ # ==========================================================
170
+
171
+ desc 'Gather required discount sources into extension directory'
172
+ task :gather => 'discount' do |t|
173
+ files =
174
+ FileList[
175
+ 'discount/{markdown,mkdio,amalloc,cstring}.h',
176
+ 'discount/{markdown,docheader,dumptree,generate,mkdio,resource,toc,Csio}.c'
177
+ ]
178
+ cp files, 'ext/',
179
+ :preserve => true,
180
+ :verbose => true
181
+ end
182
+
183
+ # best. task. ever.
184
+ file 'discount' do |f|
185
+ STDERR.puts((<<-TEXT).gsub(/^ +/, ''))
186
+ Sorry, this operation requires a human. Tell your human to:
187
+
188
+ Grab a discount tarball from:
189
+ http://www.pell.portland.or.us/~orc/Code/discount/
190
+
191
+ Extract here with something like:
192
+ tar xvzf discount-1.2.9.tar.gz
193
+
194
+ Create a discount symlink pointing at the version directory:
195
+ ln -hsf discount-1.2.9 discount
196
+
197
+ TEXT
198
+ fail "discount sources required."
199
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
4
+ require 'rdiscount'
5
+ STDOUT.write(RDiscount.new(ARGF.read).to_html)
@@ -0,0 +1,41 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'crasher'
3
+ s.version = '0.0.1'
4
+ s.summary = "x"
5
+ # = MANIFEST =
6
+ s.files = %w[
7
+ COPYING
8
+ README.markdown
9
+ Rakefile
10
+ bin/rdiscount
11
+ crasher.gemspec
12
+ ext/Csio.c
13
+ ext/amalloc.h
14
+ ext/config.h
15
+ ext/cstring.h
16
+ ext/docheader.c
17
+ ext/dumptree.c
18
+ ext/extconf.rb
19
+ ext/generate.c
20
+ ext/markdown.c
21
+ ext/markdown.h
22
+ ext/mkdio.c
23
+ ext/mkdio.h
24
+ ext/rdiscount.c
25
+ ext/resource.c
26
+ ext/toc.c
27
+ lib/crasher.rb
28
+ lib/markdown.rb
29
+ test/benchmark.rb
30
+ test/benchmark.txt
31
+ test/markdown_test.rb
32
+ test/rdiscount_test.rb
33
+ ]
34
+ # = MANIFEST =
35
+ s.test_files = ["test/markdown_test.rb", "test/rdiscount_test.rb"]
36
+ s.extra_rdoc_files = ["COPYING"]
37
+ s.extensions = ["ext/extconf.rb"]
38
+ s.executables = ["rdiscount"]
39
+ s.require_paths = ["lib"]
40
+ s.rubyforge_project = 'wink'
41
+ end
@@ -0,0 +1,49 @@
1
+ #include <stdio.h>
2
+ #include <string.h>
3
+ #include <stdarg.h>
4
+ #include "cstring.h"
5
+ #include "markdown.h"
6
+ #include "amalloc.h"
7
+
8
+
9
+ /* putc() into a cstring
10
+ */
11
+ void
12
+ Csputc(int c, Cstring *iot)
13
+ {
14
+ EXPAND(*iot) = c;
15
+ }
16
+
17
+
18
+ /* printf() into a cstring
19
+ */
20
+ int
21
+ Csprintf(Cstring *iot, char *fmt, ...)
22
+ {
23
+ va_list ptr;
24
+ int siz=100;
25
+
26
+ do {
27
+ RESERVE(*iot, siz);
28
+ va_start(ptr, fmt);
29
+ siz = vsnprintf(T(*iot)+S(*iot), ALL(*iot)-S(*iot), fmt, ptr);
30
+ va_end(ptr);
31
+ } while ( siz > (ALL(*iot)-S(*iot)) );
32
+
33
+ S(*iot) += siz;
34
+ return siz;
35
+ }
36
+
37
+
38
+ /* reparse() into a cstring
39
+ */
40
+ void
41
+ Csreparse(Cstring *iot, char *buf, int size, int flags)
42
+ {
43
+ MMIOT f;
44
+ ___mkd_initmmiot(&f, 0);
45
+ ___mkd_reparse(buf, size, 0, &f);
46
+ ___mkd_emblock(&f);
47
+ SUFFIX(*iot, T(f.out), S(f.out));
48
+ ___mkd_freemmiot(&f, 0);
49
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * debugging malloc()/realloc()/calloc()/free() that attempts
3
+ * to keep track of just what's been allocated today.
4
+ */
5
+ #ifndef AMALLOC_D
6
+ #define AMALLOC_D
7
+
8
+ #include "config.h"
9
+
10
+ #ifdef USE_AMALLOC
11
+
12
+ extern void *amalloc(int);
13
+ extern void *acalloc(int,int);
14
+ extern void *arealloc(void*,int);
15
+ extern void afree(void*);
16
+ extern void adump();
17
+
18
+ #define malloc amalloc
19
+ #define calloc acalloc
20
+ #define realloc arealloc
21
+ #define free afree
22
+
23
+ #else
24
+
25
+ #define adump() (void)1
26
+
27
+ #endif
28
+
29
+ #endif/*AMALLOC_D*/
@@ -0,0 +1,9 @@
1
+
2
+ /* rdiscount extension configuration */
3
+
4
+ #undef USE_AMALLOC
5
+
6
+ #define TABSTOP 4
7
+ #define COINTOSS() (random()&1)
8
+ #define INITRNG(x) srandom((unsigned int)x)
9
+ #define RELAXED_EMPHASIS 1