summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nohtml/conv.cpp39
-rw-r--r--nohtml/version.h2
2 files changed, 28 insertions, 13 deletions
diff --git a/nohtml/conv.cpp b/nohtml/conv.cpp
index accf524..10b382d 100644
--- a/nohtml/conv.cpp
+++ b/nohtml/conv.cpp
@@ -6,12 +6,14 @@
#endif
char* strip_html(char *src)
{
- wchar_t* buf=new wchar_t[strlen(src)+1];
- MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ int size = MultiByteToWideChar(CP_ACP, 0, src, -1, 0, 0);
+ wchar_t* buf=new wchar_t[size];
+ MultiByteToWideChar(CP_ACP, 0, src, -1,buf,size);
wchar_t* stripped_buf=strip_html(buf);
delete[] buf;
- char* dest=new char[wcslen(stripped_buf)+1];
- WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ size = WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1, 0, 0, NULL, NULL );
+ char* dest=new char[size];
+ WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1, dest, size, NULL, NULL );
delete[] stripped_buf;
return dest;
}
@@ -22,6 +24,7 @@ wchar_t* strip_html(wchar_t *src)
wchar_t *rptr;
wchar_t* dest=wcsldup(src,wcslen(src));
while ((ptr = wcsstr(dest,L"<P>")) != NULL || (ptr = wcsstr(dest, L"<p>")) != NULL) {
+ dest=renew(dest,wcslen(dest)+1,1);
memmove(ptr + 4, ptr + 3, wcslen(ptr + 3)*2 + 2);
*ptr = '\r';
*(ptr + 1) = '\n';
@@ -29,6 +32,7 @@ wchar_t* strip_html(wchar_t *src)
*(ptr + 3) = '\n';
}
while ((ptr = wcsstr(dest,L"</P>")) != NULL || (ptr = wcsstr(dest, L"</p>")) != NULL) {
+ dest=renew(dest,wcslen(dest)+1,1);
*ptr = L'\r';
*(ptr + 1) = L'\n';
*(ptr + 2) = L'\r';
@@ -152,6 +156,12 @@ wchar_t* strip_html(wchar_t *src)
ptrl = ptr;
}
ptrl = NULL;
+ while ((ptr = wcsstr(dest, L"&apos;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
+ *ptr = L'\'';
+ memmove(ptr + 1, ptr + 6, wcslen(ptr + 6)*2 + 2);
+ ptrl = ptr;
+ }
+ ptrl = NULL;
while ((ptr = wcsstr(dest, L"&amp;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
*ptr = L'&';
memmove(ptr + 1, ptr + 5, wcslen(ptr + 5)*2 + 2);
@@ -161,12 +171,14 @@ wchar_t* strip_html(wchar_t *src)
}
char* strip_carrots(char *src)// EAT!!!!!!!!!!!!!
{
- wchar_t* buf=new wchar_t[strlen(src)+1];
- MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ int size = MultiByteToWideChar(codepage, 0, src, -1, 0, 0);
+ wchar_t* buf=new wchar_t[size];
+ MultiByteToWideChar(codepage, 0, src, -1, buf, size);
wchar_t* stripped_buf=strip_carrots(buf);
delete[] buf;
- char* dest=new char[wcslen(stripped_buf)+1];
- WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ size = WideCharToMultiByte( codepage, 0, stripped_buf, -1, 0, 0, NULL, NULL );
+ char* dest=new char[size];
+ WideCharToMultiByte( codepage, 0, stripped_buf, -1, dest, size, NULL, NULL );
delete[] stripped_buf;
return dest;
}
@@ -212,14 +224,17 @@ char* strip_linebreaks(char *src)
dest[lstrlen(dest)]='\0';
return dest;
}
+
char* html_to_bbcodes(char *src)
{
- wchar_t* buf=new wchar_t[strlen(src)+1];
- MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ int size = MultiByteToWideChar(codepage, 0, src, -1, 0, 0);
+ wchar_t* buf=new wchar_t[size];
+ MultiByteToWideChar(codepage, 0, src, -1, 0, 0);
wchar_t* stripped_buf=html_to_bbcodes(buf);
delete[] buf;
- char* dest=new char[wcslen(stripped_buf)+1];
- WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ size = WideCharToMultiByte( codepage, 0, stripped_buf, -1, 0, 0, NULL, NULL );
+ char* dest=new char[size];
+ WideCharToMultiByte( codepage, 0, stripped_buf, -1, dest, size, NULL, NULL );
delete[] stripped_buf;
return dest;
}
diff --git a/nohtml/version.h b/nohtml/version.h
index 44d117d..1f8e70f 100644
--- a/nohtml/version.h
+++ b/nohtml/version.h
@@ -5,7 +5,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 2
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM