corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject [21/63] [abbrv] [partial] incubator-corinthia git commit: Moved 3rdparty to platform This is the first part of isolating 3rdparty within platform. The idea is that only platform.h should be used outside platform platform.h might contain includes to inter
Date Tue, 30 Dec 2014 14:44:45 GMT
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.c
----------------------------------------------------------------------
diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.c
deleted file mode 100644
index 3205536..0000000
--- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-  clean.c -- clean up misuse of presentation markup
-
-  (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
-  See tidy.h for the copyright notice.
-
-  Filters from other formats such as Microsoft Word
-  often make excessive use of presentation markup such
-  as font tags, B, I, and the align attribute. By applying
-  a set of production rules, it is straight forward to
-  transform this to use CSS.
-
-  Some rules replace some of the children of an element by
-  style properties on the element, e.g.
-
-  <p><b>...</b></p> -> <p style="font-weight: bold">...</p>
-
-  Such rules are applied to the element's content and then
-  to the element itself until none of the rules more apply.
-  Having applied all the rules to an element, it will have
-  a style attribute with one or more properties. 
-
-  Other rules strip the element they apply to, replacing
-  it by style properties on the contents, e.g.
-  
-  <dir><li><p>...</li></dir> -> <p style="margin-left
1em">...
-      
-  These rules are applied to an element before processing
-  its content and replace the current element by the first
-  element in the exposed content.
-
-  After applying both sets of rules, you can replace the
-  style attribute by a class value and style rule in the
-  document head. To support this, an association of styles
-  and class names is built.
-
-  A naive approach is to rely on string matching to test
-  when two property lists are the same. A better approach
-  would be to first sort the properties before matching.
-
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "tidy-int.h"
-#include "gdoc.h"
-#include "lexer.h"
-#include "parser.h"
-#include "tags.h"
-#include "attrs.h"
-#include "message.h"
-#include "tmbstr.h"
-#include "utf8.h"
-
-/*
-  Extricate "element", replace it by its content and delete it.
-*/
-static void DiscardContainer( TidyDocImpl* doc, Node *element, Node **pnode)
-{
-    if (element->content)
-    {
-        Node *node, *parent = element->parent;
-
-        element->last->next = element->next;
-
-        if (element->next)
-        {
-            element->next->prev = element->last;
-        }
-        else
-            parent->last = element->last;
-
-        if (element->prev)
-        {
-            element->content->prev = element->prev;
-            element->prev->next = element->content;
-        }
-        else
-            parent->content = element->content;
-
-        for (node = element->content; node; node = node->next)
-            node->parent = parent;
-
-        *pnode = element->content;
-
-        element->next = element->content = NULL;
-        TY_(FreeNode)(doc, element);
-    }
-    else
-    {
-        *pnode = TY_(DiscardElement)(doc, element);
-    }
-}
-
-static void CleanNode( TidyDocImpl* doc, Node *node )
-{
-    Node *child, *next;
-
-    if (node->content)
-    {
-        for (child = node->content; child != NULL; child = next)
-        {
-            next = child->next;
-
-            if (TY_(nodeIsElement)(child))
-            {
-                if (nodeIsSTYLE(child))
-                    TY_(DiscardElement)(doc, child);
-                if (nodeIsP(child) && !child->content)
-                    TY_(DiscardElement)(doc, child);
-                else if (nodeIsSPAN(child))
-                    DiscardContainer( doc, child, &next);
-                else if (nodeIsA(child) && !child->content)
-                 {
-                    AttVal *id = TY_(GetAttrByName)( child, "name" );
-
-                    if (id)
-                        TY_(RepairAttrValue)( doc, child->parent, "id", id->value );
-
-                    TY_(DiscardElement)(doc, child);
-                }
-                else
-                {
-                    if (child->attributes)
-                        TY_(DropAttrByName)( doc, child, "class" );
-
-                    CleanNode(doc, child);
-                }
-            }
-        }
-    }
-}
-
-/* insert meta element to force browser to recognize doc as UTF8 */
-static void SetUTF8( TidyDocImpl* doc )
-{
-    Node *head = TY_(FindHEAD)( doc );
-
-    if (head)
-    {
-        Node *node = TY_(InferredTag)(doc, TidyTag_META);
-        TY_(AddAttribute)( doc, node, "http-equiv", "Content-Type" );
-        TY_(AddAttribute)( doc, node, "content", "text/html; charset=UTF-8" );
-        TY_(InsertNodeAtStart)( head, node );
-    }
-}
-
-/* clean html exported by Google Docs
-
-    - strip the script element, as the style sheet is a mess
-    - strip class attributes
-    - strip span elements, leaving their content in place
-    - replace <a name=...></a> by id on parent element
-    - strip empty <p> elements
-*/
-void TY_(CleanGoogleDocument)( TidyDocImpl* doc )
-{
-    /* placeholder.  CleanTree()/CleanNode() will not
-    ** zap root element 
-    */
-    CleanNode( doc, &doc->root );
-    SetUTF8( doc );
-}
-
-/*
- * local variables:
- * mode: c
- * indent-tabs-mode: nil
- * c-basic-offset: 4
- * eval: (c-set-offset 'substatement-open 0)
- * end:
- */

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.h
----------------------------------------------------------------------
diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.h
deleted file mode 100644
index b8bd9f5..0000000
--- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/gdoc.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __GDOC_H__
-#define __GDOC_H__
-
-/* gdoc.h -- clean up html exported by Google Docs
-
-  (c) 2012 (W3C) MIT, ERCIM, Keio University
-  See tidy.h for the copyright notice.
-
-  - strip the script element, as the style sheet is a mess
-  - strip class attributes
-  - strip span elements, leaving their content in place
-  - replace <a name=...></a> by id on parent element
-  - strip empty <p> elements
-
-*/
-
-void TY_(CleanGoogleDocument)( TidyDocImpl* doc );
-
-#endif /* __GDOC_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.c
----------------------------------------------------------------------
diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.c
deleted file mode 100644
index 262a4b6..0000000
--- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* iconvtc.c -- Interface to iconv transcoding routines
-
-  (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
-  See tidy.h for the copyright notice.
-
-*/
-
-#include "tidy.h"
-#include "forward.h"
-#include "streamio.h"
-
-#ifdef TIDY_ICONV_SUPPORT
-
-#include <iconv.h>
-
-/* maximum number of bytes for a single character */
-#define TC_INBUFSIZE  16
-
-/* maximum number of characters per byte sequence */
-#define TC_OUTBUFSIZE 16
-
-Bool IconvInitInputTranscoder(void)
-{
-    return no;
-}
-
-void IconvUninitInputTranscoder(void)
-{
-    return;
-}
-
-int IconvGetChar(byte firstByte, StreamIn * in, uint * bytesRead)
-{
-    iconv_t cd;
-    TidyInputSource * source;
-    char inbuf[TC_INBUFSIZE] = { 0 };
-    char outbuf[TC_OUTBUFSIZE] = { 0 };
-    size_t inbufsize = 0;
-
-    assert( in != NULL );
-    assert( &in->source != NULL );
-    assert( bytesRead != NULL );
-    assert( in->iconvptr != 0 );
-
-    cd = (iconv_t)in->iconvptr;
-    source = &in->source;
-
-    inbuf[inbufsize++] = (char)firstByte;
-    
-    while(inbufsize < TC_INBUFSIZE)
-    {
-        char * outbufptr = (char*)outbuf;
-        char * inbufptr = (char*)inbuf;
-        size_t readNow = inbufsize;
-        size_t writeNow = TC_OUTBUFSIZE;
-        size_t result = 0;
-        int iconv_errno = 0;
-        int nextByte = EndOfStream;
-
-        result = iconv(cd, (const char**)&inbufptr, &readNow, (char**)&outbufptr,
&writeNow);
-        iconv_errno = errno;
-
-        if (result != (size_t)(-1))
-        {
-            int c;
-
-            /* create codepoint from UTF-32LE octets */
-            c = (unsigned char)outbuf[0];
-            c += (unsigned char)outbuf[1] << 8;
-            c += (unsigned char)outbuf[2] << 16;
-            c += (unsigned char)outbuf[3] << 32;
-
-            /* set number of read bytes */
-            *bytesRead = inbufsize;
-
-            return c;
-        }
-
-        assert( iconv_errno != EILSEQ ); /* broken multibyte sequence */
-        assert( iconv_errno != E2BIG );  /* not enough memory         */
-        assert( iconv_errno == EINVAL ); /* incomplete sequence       */
-
-        /* we need more bytes */
-        nextByte = source->getByte(source->sourceData);
-
-        if (nextByte == EndOfStream)
-        {
-            /* todo: error message for broken stream? */
-
-            *bytesRead = inbufsize;
-            return EndOfStream;
-        }
-
-        inbuf[inbufsize++] = (char)nextByte;
-    }
-
-    /* No full character found after reading TC_INBUFSIZE bytes, */
-    /* give up to read this stream, it's obviously unreadable.   */
-
-    /* todo: error message for broken stream? */
-    return EndOfStream;
-}
-
-#endif /* TIDY_ICONV_SUPPORT */

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.h
----------------------------------------------------------------------
diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.h
deleted file mode 100644
index 1965ca0..0000000
--- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/iconvtc.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __ICONVTC_H__
-#define __ICONVTC_H__
-#ifdef TIDY_ICONV_SUPPORT
-
-/* iconvtc.h -- Interface to iconv transcoding routines
-
-  (c) 1998-2003 (W3C) MIT, ERCIM, Keio University
-  See tidy.h for the copyright notice.
-
-*/
-
-
-#endif /* TIDY_ICONV_SUPPORT */
-#endif /* __ICONVTC_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/istack.c
----------------------------------------------------------------------
diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/istack.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/istack.c
deleted file mode 100644
index 3ba58ab..0000000
--- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/istack.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/* istack.c -- inline stack for compatibility with Mosaic
-
-  (c) 1998-2006 (W3C) MIT, ERCIM, Keio University
-  See tidy.h for the copyright notice.
-
-*/
-
-#include "tidy-int.h"
-#include "lexer.h"
-#include "attrs.h"
-#include "streamio.h"
-#include "tmbstr.h"
-
-/* duplicate attributes */
-AttVal *TY_(DupAttrs)( TidyDocImpl* doc, AttVal *attrs)
-{
-    AttVal *newattrs;
-
-    if (attrs == NULL)
-        return attrs;
-
-    newattrs = TY_(NewAttribute)(doc);
-    *newattrs = *attrs;
-    newattrs->next = TY_(DupAttrs)( doc, attrs->next );
-    newattrs->attribute = TY_(tmbstrdup)(doc->allocator, attrs->attribute);
-    newattrs->value = TY_(tmbstrdup)(doc->allocator, attrs->value);
-    newattrs->dict = TY_(FindAttribute)(doc, newattrs);
-    newattrs->asp = attrs->asp ? TY_(CloneNode)(doc, attrs->asp) : NULL;
-    newattrs->php = attrs->php ? TY_(CloneNode)(doc, attrs->php) : NULL;
-    return newattrs;
-}
-
-static Bool IsNodePushable( Node *node )
-{
-    if (node->tag == NULL)
-        return no;
-
-    if (!(node->tag->model & CM_INLINE))
-        return no;
-
-    if (node->tag->model & CM_OBJECT)
-        return no;
-
-    return yes;
-}
-
-/*
-  push a copy of an inline node onto stack
-  but don't push if implicit or OBJECT or APPLET
-  (implicit tags are ones generated from the istack)
-
-  One issue arises with pushing inlines when
-  the tag is already pushed. For instance:
-
-      <p><em>text
-      <p><em>more text
-
-  Shouldn't be mapped to
-
-      <p><em>text</em></p>
-      <p><em><em>more text</em></em>
-*/
-void TY_(PushInline)( TidyDocImpl* doc, Node *node )
-{
-    Lexer* lexer = doc->lexer;
-    IStack *istack;
-
-    if (node->implicit)
-        return;
-
-    if ( !IsNodePushable(node) )
-        return;
-
-    if ( !nodeIsFONT(node) && TY_(IsPushed)(doc, node) )
-        return;
-
-    /* make sure there is enough space for the stack */
-    if (lexer->istacksize + 1 > lexer->istacklength)
-    {
-        if (lexer->istacklength == 0)
-            lexer->istacklength = 6;   /* this is perhaps excessive */
-
-        lexer->istacklength = lexer->istacklength * 2;
-        lexer->istack = (IStack *)TidyDocRealloc(doc, lexer->istack,
-                            sizeof(IStack)*(lexer->istacklength));
-    }
-
-    istack = &(lexer->istack[lexer->istacksize]);
-    istack->tag = node->tag;
-
-    istack->element = TY_(tmbstrdup)(doc->allocator, node->element);
-    istack->attributes = TY_(DupAttrs)( doc, node->attributes );
-    ++(lexer->istacksize);
-}
-
-static void PopIStack( TidyDocImpl* doc )
-{
-    Lexer* lexer = doc->lexer;
-    IStack *istack;
-    AttVal *av;
-
-    --(lexer->istacksize);
-    istack = &(lexer->istack[lexer->istacksize]);
-
-    while (istack->attributes)
-    {
-        av = istack->attributes;
-        istack->attributes = av->next;
-        TY_(FreeAttribute)( doc, av );
-    }
-    TidyDocFree(doc, istack->element);
-}
-
-static void PopIStackUntil( TidyDocImpl* doc, TidyTagId tid )
-{
-    Lexer* lexer = doc->lexer;
-    IStack *istack;
-
-    while (lexer->istacksize > 0)
-    {
-        PopIStack( doc );
-        istack = &(lexer->istack[lexer->istacksize]);
-        if ( istack->tag->id == tid )
-            break;
-    }
-}
-
-/* pop inline stack */
-void TY_(PopInline)( TidyDocImpl* doc, Node *node )
-{
-    Lexer* lexer = doc->lexer;
-
-    if (node)
-    {
-        if ( !IsNodePushable(node) )
-            return;
-
-        /* if node is </a> then pop until we find an <a> */
-        if ( nodeIsA(node) )
-        {
-            PopIStackUntil( doc, TidyTag_A );
-            return;
-        }
-    }
-
-    if (lexer->istacksize > 0)
-    {
-        PopIStack( doc );
-
-        /* #427822 - fix by Randy Waki 7 Aug 00 */
-        if (lexer->insert >= lexer->istack + lexer->istacksize)
-            lexer->insert = NULL;
-    }
-}
-
-Bool TY_(IsPushed)( TidyDocImpl* doc, Node *node )
-{
-    Lexer* lexer = doc->lexer;
-    int i;
-
-    for (i = lexer->istacksize - 1; i >= 0; --i)
-    {
-        if (lexer->istack[i].tag == node->tag)
-            return yes;
-    }
-
-    return no;
-}
-
-/*
-   Test whether the last element on the stack has the same type than "node".
-*/
-Bool TY_(IsPushedLast)( TidyDocImpl* doc, Node *element, Node *node )
-{
-    Lexer* lexer = doc->lexer;
-
-    if ( element && !IsNodePushable(element) )
-        return no;
-
-    if (lexer->istacksize > 0) {
-        if (lexer->istack[lexer->istacksize - 1].tag == node->tag) {
-            return yes;
-        }
-    }
-
-    return no;
-}
-
-/*
-  This has the effect of inserting "missing" inline
-  elements around the contents of blocklevel elements
-  such as P, TD, TH, DIV, PRE etc. This procedure is
-  called at the start of ParseBlock. when the inline
-  stack is not empty, as will be the case in:
-
-    <i><h1>italic heading</h1></i>
-
-  which is then treated as equivalent to
-
-    <h1><i>italic heading</i></h1>
-
-  This is implemented by setting the lexer into a mode
-  where it gets tokens from the inline stack rather than
-  from the input stream.
-*/
-int TY_(InlineDup)( TidyDocImpl* doc, Node* node )
-{
-    Lexer* lexer = doc->lexer;
-    int n;
-
-    if ((n = lexer->istacksize - lexer->istackbase) > 0)
-    {
-        lexer->insert = &(lexer->istack[lexer->istackbase]);
-        lexer->inode = node;
-    }
-
-    return n;
-}
-
-/*
- defer duplicates when entering a table or other
- element where the inlines shouldn't be duplicated
-*/
-void TY_(DeferDup)( TidyDocImpl* doc )
-{
-    doc->lexer->insert = NULL;
-    doc->lexer->inode = NULL;
-}
-
-Node *TY_(InsertedToken)( TidyDocImpl* doc )
-{
-    Lexer* lexer = doc->lexer;
-    Node *node;
-    IStack *istack;
-    uint n;
-
-    /* this will only be NULL if inode != NULL */
-    if (lexer->insert == NULL)
-    {
-        node = lexer->inode;
-        lexer->inode = NULL;
-        return node;
-    }
-
-    /*
-      If this is the "latest" node then update
-      the position, otherwise use current values
-    */
-
-    if (lexer->inode == NULL)
-    {
-        lexer->lines = doc->docIn->curline;
-        lexer->columns = doc->docIn->curcol;
-    }
-
-    node = TY_(NewNode)(doc->allocator, lexer);
-    node->type = StartTag;
-    node->implicit = yes;
-    node->start = lexer->txtstart;
-    /* #431734 [JTidy bug #226261 (was 126261)] - fix by Gary Peskin 20 Dec 00 */ 
-    node->end = lexer->txtend; /* was : lexer->txtstart; */
-    istack = lexer->insert;
-
-#if 0 && defined(_DEBUG)
-    if ( lexer->istacksize == 0 )
-        fprintf( stderr, "0-size istack!\n" );
-#endif
-
-    node->element = TY_(tmbstrdup)(doc->allocator, istack->element);
-    node->tag = istack->tag;
-    node->attributes = TY_(DupAttrs)( doc, istack->attributes );
-
-    /* advance lexer to next item on the stack */
-    n = (uint)(lexer->insert - &(lexer->istack[0]));
-
-    /* and recover state if we have reached the end */
-    if (++n < lexer->istacksize)
-        lexer->insert = &(lexer->istack[n]);
-    else
-        lexer->insert = NULL;
-
-    return node;
-}
-
-
-/*
-   We have two CM_INLINE elements pushed ... the first is closing,
-   but, like the browser, the second should be retained ...
-   Like <b>bold <i>bold and italics</b> italics only</i>
-   This function switches the tag positions on the stack,
-   returning 'yes' if both were found in the expected order.
-*/
-Bool TY_(SwitchInline)( TidyDocImpl* doc, Node* element, Node* node )
-{
-    Lexer* lexer = doc->lexer;
-    if ( lexer
-         && element && element->tag
-         && node && node->tag
-         && TY_(IsPushed)( doc, element )
-         && TY_(IsPushed)( doc, node ) 
-         && ((lexer->istacksize - lexer->istackbase) >= 2) )
-    {
-        /* we have a chance of succeeding ... */
-        int i;
-        for (i = (lexer->istacksize - lexer->istackbase - 1); i >= 0; --i)
-        {
-            if (lexer->istack[i].tag == element->tag) {
-                /* found the element tag - phew */
-                IStack *istack1 = &lexer->istack[i];
-                IStack *istack2 = NULL;
-                --i; /* back one more, and continue */
-                for ( ; i >= 0; --i)
-                {
-                    if (lexer->istack[i].tag == node->tag)
-                    {
-                        /* found the element tag - phew */
-                        istack2 = &lexer->istack[i];
-                        break;
-                    }
-                }
-                if ( istack2 )
-                {
-                    /* perform the swap */
-                    IStack tmp_istack = *istack2;
-                    *istack2 = *istack1;
-                    *istack1 = tmp_istack;
-                    return yes;
-                }
-            }
-        }
-    }
-    return no;
-}
-
-/*
-  We want to push a specific a specific element on the stack,
-  but it may not be the last element, which InlineDup()
-  would handle. Return yes, if found and inserted.
-*/
-Bool TY_(InlineDup1)( TidyDocImpl* doc, Node* node, Node* element )
-{
-    Lexer* lexer = doc->lexer;
-    int n, i;
-    if ( element
-         && (element->tag != NULL)
-         && ((n = lexer->istacksize - lexer->istackbase) > 0) )
-    {
-        for ( i = n - 1; i >=0; --i ) {
-            if (lexer->istack[i].tag == element->tag) {
-                /* found our element tag - insert it */
-                lexer->insert = &(lexer->istack[i]);
-                lexer->inode = node;
-                return yes;
-            }
-        }
-    }
-    return no;
-}
-
-/*
- * local variables:
- * mode: c
- * indent-tabs-mode: nil
- * c-basic-offset: 4
- * eval: (c-set-offset 'substatement-open 0)
- * end:
- */


Mime
View raw message