Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 2c46fcb478295212be8716afad3c0be0b5f7ff97 @sekimura committed Feb 13, 2009
Showing with 7,174 additions and 0 deletions.
  1. +6 −0 Changes
  2. +8 −0 MANIFEST
  3. +17 −0 Makefile.PL
  4. +40 −0 README
  5. +39 −0 XS.xs
  6. +29 −0 amalloc.h
  7. +28 −0 config.h
  8. +68 −0 cstring.h
  9. +86 −0 lib/Text/Markdown/XS.pm
  10. +131 −0 markdown.h
  11. +65 −0 mkdio.h
  12. +6,376 −0 ppport.h
  13. +15 −0 t/Text-Markdown-XS.t
  14. +233 −0 xt/index.text
  15. +33 −0 xt/test.pl
@@ -0,0 +1,6 @@
+Revision history for Perl extension Text::Markdown::XS.
+
+0.01 Thu Feb 12 22:49:17 2009
+ - original version; created by h2xs 1.23 with options
+ -A -n Text::Markdown::XS
+
@@ -0,0 +1,8 @@
+Changes
+Makefile.PL
+MANIFEST
+ppport.h
+README
+XS.xs
+t/Text-Markdown-XS.t
+lib/Text/Markdown/XS.pm
@@ -0,0 +1,17 @@
+use 5.010000;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ NAME => 'Text::Markdown::XS',
+ VERSION_FROM => 'lib/Text/Markdown/XS.pm', # finds $VERSION
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => 'lib/Text/Markdown/XS.pm', # retrieve abstract from module
+ AUTHOR => 'Masayoshi Sekimura <sekimura@>') : ()),
+ LIBS => ['-lmarkdown'], # e.g., '-lm'
+ DEFINE => '', # e.g., '-DHAVE_SOMETHING'
+ INC => '-I.', # e.g., '-I. -I/usr/include/other'
+ # Un-comment this if you add C files to link with later:
+ # OBJECT => '$(O_FILES)', # link all the C files too
+);
@@ -0,0 +1,40 @@
+Text-Markdown-XS version 0.01
+=============================
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the
+README file from a module distribution so that people browsing the
+archive can use it get an idea of the modules uses. It is usually a
+good idea to provide version information here so that people can
+decide whether fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+ blah blah blah
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2009 by Masayoshi Sekimura
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.0 or,
+at your option, any later version of Perl 5 you may have available.
+
+
@@ -0,0 +1,39 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include "ppport.h"
+
+#include "cstring.h"
+#include "markdown.h"
+
+typedef struct {
+ char sym;
+ char * xml_sym;
+} e_char;
+
+
+
+MODULE = Text::Markdown::XS PACKAGE = Text::Markdown::XS
+
+SV *
+_markdown(text)
+ char *text;
+ PREINIT:
+ SV* r = &PL_sv_undef;
+ CODE:
+ int rc;
+ int flags = 0x0004;
+ char *ret;
+ int szret;
+ Document *doc;
+ if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
+ exit(1);
+ }
+ mkd_compile(doc, flags);
+ szret = mkd_document(doc, &ret);
+
+ r = newSVpv(ret, 0);
+ RETVAL = r;
+ OUTPUT:
+ RETVAL
@@ -0,0 +1,29 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+#ifndef AMALLOC_D
+#define AMALLOC_D
+
+#include "config.h"
+
+#ifdef USE_AMALLOC
+
+extern void *amalloc(int);
+extern void *acalloc(int,int);
+extern void *arealloc(void*,int);
+extern void afree(void*);
+extern void adump();
+
+#define malloc amalloc
+#define calloc acalloc
+#define realloc arealloc
+#define free afree
+
+#else
+
+#define adump() (void)1
+
+#endif
+
+#endif/*AMALLOC_D*/
@@ -0,0 +1,28 @@
+/*
+ * configuration for markdown, generated Thu Feb 12 22:57:30 PST 2009
+ * by sekimura@liz
+ */
+#ifndef __AC_MARKDOWN_D
+#define __AC_MARKDOWN_D 1
+
+
+#define OS_LINUX 1
+#define DWORD unsigned long
+#define WORD unsigned short
+#define BYTE unsigned char
+#define HAVE_BASENAME 1
+#define HAVE_LIBGEN_H 1
+#define HAVE_PWD_H 1
+#define HAVE_GETPWUID 1
+#define HAVE_SRANDOM 1
+#define INITRNG(x) srandom((unsigned int)x)
+#define HAVE_RANDOM 1
+#define COINTOSS() (random()&1)
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_FCHDIR 1
+#define TABSTOP 4
+#define HAVE_MALLOC_H 1
+#define PATH_SED "/bin/sed"
+
+#endif/* __AC_MARKDOWN_D */
@@ -0,0 +1,68 @@
+/* two template types: STRING(t) which defines a pascal-style string
+ * of element (t) [STRING(char) is the closest to the pascal string],
+ * and ANCHOR(t) which defines a baseplate that a linked list can be
+ * built up from. [The linked list /must/ contain a ->next pointer
+ * for linking the list together with.]
+ */
+#ifndef _CSTRING_D
+#define _CSTRING_D
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "amalloc.h"
+
+/* expandable Pascal-style string.
+ */
+#define STRING(type) struct { type *text; int size, alloc; }
+
+#define CREATE(x) T(x) = (void*)(S(x) = (x).alloc = 0)
+#define EXPAND(x) (S(x)++)[(S(x) < (x).alloc) \
+ ? (T(x)) \
+ : (T(x) = T(x) ? realloc(T(x), sizeof T(x)[0] * ((x).alloc += 100)) \
+ : malloc(sizeof T(x)[0] * ((x).alloc += 100)) )]
+
+#define DELETE(x) (x).alloc ? (free(T(x)), S(x) = (x).alloc = 0) \
+ : ( S(x) = 0 )
+#define CLIP(t,i,sz) \
+ ( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \
+ (memmove(&T(t)[i], &T(t)[i+sz], (S(t)-(i+sz)+1)*sizeof(T(t)[0])), \
+ S(t) -= (sz)) : -1
+
+#define RESERVE(x, sz) T(x) = ((x).alloc > S(x) + (sz) \
+ ? T(x) \
+ : T(x) \
+ ? realloc(T(x), sizeof T(x)[0] * ((x).alloc = 100+(sz)+S(x))) \
+ : malloc(sizeof T(x)[0] * ((x).alloc = 100+(sz)+S(x))))
+#define SUFFIX(t,p,sz) \
+ memcpy(((S(t) += (sz)) - (sz)) + \
+ (T(t) = T(t) ? realloc(T(t), sizeof T(t)[0] * ((t).alloc += sz)) \
+ : malloc(sizeof T(t)[0] * ((t).alloc += sz))), \
+ (p), sizeof(T(t)[0])*(sz))
+
+#define PREFIX(t,p,sz) \
+ RESERVE( (t), (sz) ); \
+ if ( S(t) ) { memmove(T(t)+(sz), T(t), S(t)); } \
+ memcpy( T(t), (p), (sz) ); \
+ S(t) += (sz)
+
+/* reference-style links (and images) are stored in an array
+ */
+#define T(x) (x).text
+#define S(x) (x).size
+
+/* abstract anchor type that defines a list base
+ * with a function that attaches an element to
+ * the end of the list.
+ *
+ * the list base field is named .text so that the T()
+ * macro will work with it.
+ */
+#define ANCHOR(t) struct { t *text, *end; }
+
+#define ATTACH(t, p) ( (t).text ?( ((t).end->next = (p)), ((t).end = (p)) ) \
+ :( ((t).text = (t).end = (p)) ) )
+
+typedef STRING(char) Cstring;
+
+#endif/*_CSTRING_D*/
@@ -0,0 +1,86 @@
+package Text::Markdown::XS;
+
+use 5.010000;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+# Items to export into callers namespace by default. Note: do not export
+# names by default without a very good reason. Use EXPORT_OK instead.
+# Do not simply export all your public functions/methods/constants.
+
+# This allows declaration use Text::Markdown::XS ':all';
+# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
+# will save memory.
+our %EXPORT_TAGS = ( 'all' => [ qw(
+
+) ] );
+
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+
+our @EXPORT = qw(
+
+);
+
+our $VERSION = '0.01';
+
+require XSLoader;
+XSLoader::load('Text::Markdown::XS', $VERSION);
+
+# Preloaded methods go here.
+
+1;
+__END__
+# Below is stub documentation for your module. You'd better edit it!
+
+=head1 NAME
+
+Text::Markdown::XS - Perl extension for blah blah blah
+
+=head1 SYNOPSIS
+
+ use Text::Markdown::XS;
+ blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for Text::Markdown::XS, created by h2xs. It looks like the
+author of the extension was negligent enough to leave the stub
+unedited.
+
+Blah blah blah.
+
+=head2 EXPORT
+
+None by default.
+
+
+
+=head1 SEE ALSO
+
+Mention other useful documentation such as the documentation of
+related modules or operating system documentation (such as man pages
+in UNIX), or any relevant external documentation such as RFCs or
+standards.
+
+If you have a mailing list set up for your module, mention it here.
+
+If you have a web site set up for your module, mention it here.
+
+=head1 AUTHOR
+
+Masayoshi Sekimura, E<lt>sekimura@E<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2009 by Masayoshi Sekimura
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.0 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
Oops, something went wrong.

0 comments on commit 2c46fcb

Please sign in to comment.