hrbrmstr
8 years ago
No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
9 changed files with
625 additions and
689 deletions
-
README.Rmd
-
README.md
-
src/alloc.cpp
-
src/lexer.c
-
src/sprtf.cpp
-
src/streamio.c
-
src/tidylib.c
|
|
@ -32,20 +32,6 @@ The following functions are implemented: |
|
|
|
|
|
|
|
- `tidy_html` : Clean up gnarly HTML/XML |
|
|
|
|
|
|
|
### TODO |
|
|
|
|
|
|
|
Fix: |
|
|
|
|
|
|
|
```{text} |
|
|
|
* checking compiled code ... WARNING |
|
|
|
File ‘htmltidy/libs/htmltidy.so’: |
|
|
|
Found ‘___stderrp’, possibly from ‘stderr’ (C) |
|
|
|
Objects: ‘alloc.o’, ‘streamio.o’, ‘tidylib.o’ |
|
|
|
Found ‘___stdoutp’, possibly from ‘stdout’ (C) |
|
|
|
Objects: ‘sprtf.o’, ‘tidylib.o’ |
|
|
|
Found ‘_exit’, possibly from ‘exit’ (C) |
|
|
|
Objects: ‘alloc.o’, ‘sprtf.o’ |
|
|
|
``` |
|
|
|
|
|
|
|
### Installation |
|
|
|
|
|
|
|
|
|
@ -17,21 +17,6 @@ The following functions are implemented: |
|
|
|
|
|
|
|
- `tidy_html` : Clean up gnarly HTML/XML |
|
|
|
|
|
|
|
### TODO |
|
|
|
|
|
|
|
Fix: |
|
|
|
|
|
|
|
``` text |
|
|
|
* checking compiled code ... WARNING |
|
|
|
File ‘htmltidy/libs/htmltidy.so’: |
|
|
|
Found ‘___stderrp’, possibly from ‘stderr’ (C) |
|
|
|
Objects: ‘alloc.o’, ‘streamio.o’, ‘tidylib.o’ |
|
|
|
Found ‘___stdoutp’, possibly from ‘stdout’ (C) |
|
|
|
Objects: ‘sprtf.o’, ‘tidylib.o’ |
|
|
|
Found ‘_exit’, possibly from ‘exit’ (C) |
|
|
|
Objects: ‘alloc.o’, ‘sprtf.o’ |
|
|
|
``` |
|
|
|
|
|
|
|
### Installation |
|
|
|
|
|
|
|
``` r |
|
|
|
|
|
@ -1,3 +1,5 @@ |
|
|
|
#include <Rcpp.h> |
|
|
|
|
|
|
|
/* alloc.c -- Default memory allocation routines.
|
|
|
|
|
|
|
|
(c) 1998-2006 (W3C) MIT, ERCIM, Keio University |
|
|
@ -44,14 +46,7 @@ static void TIDY_CALL defaultPanic( TidyAllocator* ARG_UNUSED(allocator), ctmbst |
|
|
|
if ( g_panic ) |
|
|
|
g_panic( msg ); |
|
|
|
else |
|
|
|
{ |
|
|
|
/* 2 signifies a serious error */ |
|
|
|
fprintf( stderr, "Fatal error: %s\n", msg ); |
|
|
|
#ifdef _DEBUG |
|
|
|
assert(0); |
|
|
|
#endif |
|
|
|
exit(2); |
|
|
|
} |
|
|
|
Rcpp::stop("Fatal memory error"); |
|
|
|
} |
|
|
|
|
|
|
|
static void* TIDY_CALL defaultAlloc( TidyAllocator* allocator, size_t size ) |
|
|
@ -1000,9 +1000,6 @@ void TY_(AddCharToLexer)( Lexer *lexer, uint c ) |
|
|
|
err = TY_(EncodeCharToUTF8Bytes)( c, buf, NULL, &count ); |
|
|
|
if (err) |
|
|
|
{ |
|
|
|
#if 0 && defined(_DEBUG)
|
|
|
|
fprintf( stderr, "lexer UTF-8 encoding error for U+%x : ", c ); |
|
|
|
#endif |
|
|
|
/* replacement character 0xFFFD encoded as UTF-8 */ |
|
|
|
buf[0] = (byte) 0xEF; |
|
|
|
buf[1] = (byte) 0xBF; |
|
|
|
|
|
@ -1,3 +1,5 @@ |
|
|
|
#include <Rcpp.h> |
|
|
|
|
|
|
|
/*
|
|
|
|
* SPRTF - Log output utility |
|
|
|
* |
|
|
@ -156,8 +158,7 @@ int open_log_file( void ) |
|
|
|
outfile = fopen(logfile, mode); |
|
|
|
if( outfile == 0 ) { |
|
|
|
outfile = (FILE *)-1; |
|
|
|
sprtf("ERROR: Failed to open log file [%s] ...\n", logfile); |
|
|
|
exit(1); /* failed */ |
|
|
|
Rcpp::stop("Failed to open log file"); |
|
|
|
return 0; /* failed */ |
|
|
|
} |
|
|
|
return 1; /* success */ |
|
|
@ -299,16 +300,15 @@ static void oi( char * psin ) |
|
|
|
if( w != len ) { |
|
|
|
fclose(outfile); |
|
|
|
outfile = (FILE *)-1; |
|
|
|
sprtf("WARNING: Failed write to log file [%s] ...\n", logfile); |
|
|
|
exit(1); |
|
|
|
Rcpp::stop("Failed write to log file"); |
|
|
|
} else if (addflush) { |
|
|
|
fflush( outfile ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if( addstdout ) { |
|
|
|
fwrite( ps, 1, len, stdout ); |
|
|
|
} |
|
|
|
// if( addstdout ) {
|
|
|
|
// fwrite( ps, 1, len, stdout );
|
|
|
|
// }
|
|
|
|
#ifdef ADD_LISTVIEW |
|
|
|
if (add2listview) { |
|
|
|
LVInsertItem(ps); |
|
|
@ -75,20 +75,11 @@ static StreamOut stdoutStreamOut = |
|
|
|
|
|
|
|
StreamOut* TY_(StdErrOutput)(void) |
|
|
|
{ |
|
|
|
if ( stderrStreamOut.sink.sinkData == 0 ) |
|
|
|
stderrStreamOut.sink.sinkData = stderr; |
|
|
|
// if ( stderrStreamOut.sink.sinkData == 0 )
|
|
|
|
// stderrStreamOut.sink.sinkData = stderr;
|
|
|
|
return &stderrStreamOut; |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 |
|
|
|
StreamOut* TY_(StdOutOutput)(void) |
|
|
|
{ |
|
|
|
if ( stdoutStreamOut.sink.sinkData == 0 ) |
|
|
|
stdoutStreamOut.sink.sinkData = stdout; |
|
|
|
return &stdoutStreamOut; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
void TY_(ReleaseStreamOut)( TidyDocImpl *doc, StreamOut* out ) |
|
|
|
{ |
|
|
|
if ( out && out != &stderrStreamOut && out != &stdoutStreamOut ) |
|
|
|
|
|
@ -1081,35 +1081,17 @@ int tidyDocSaveStdout( TidyDocImpl* doc ) |
|
|
|
int status = 0; |
|
|
|
uint outenc = cfg( doc, TidyOutCharEncoding ); |
|
|
|
uint nl = cfg( doc, TidyNewline ); |
|
|
|
StreamOut* out = TY_(FileOutput)( doc, stdout, outenc, nl ); |
|
|
|
// StreamOut* out = TY_(FileOutput)( doc, stdout, outenc, nl );
|
|
|
|
|
|
|
|
#if !defined(NO_SETMODE_SUPPORT) |
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(OS2_OS) |
|
|
|
oldstdoutmode = setmode( fileno(stdout), _O_BINARY ); |
|
|
|
oldstderrmode = setmode( fileno(stderr), _O_BINARY ); |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
if ( 0 == status ) |
|
|
|
status = tidyDocSaveStream( doc, out ); |
|
|
|
// if ( 0 == status )
|
|
|
|
// status = tidyDocSaveStream( doc, out );
|
|
|
|
|
|
|
|
fflush(stdout); |
|
|
|
fflush(stderr); |
|
|
|
// fflush(stdout);
|
|
|
|
// fflush(stderr);
|
|
|
|
|
|
|
|
#if !defined(NO_SETMODE_SUPPORT) |
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(OS2_OS) |
|
|
|
if ( oldstdoutmode != -1 ) |
|
|
|
oldstdoutmode = setmode( fileno(stdout), oldstdoutmode ); |
|
|
|
if ( oldstderrmode != -1 ) |
|
|
|
oldstderrmode = setmode( fileno(stderr), oldstderrmode ); |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
TidyDocFree( doc, out ); |
|
|
|
// TidyDocFree( doc, out );
|
|
|
|
return status; |
|
|
|
} |
|
|
|
|
|
|
|