Skip to content

Commit

Permalink
Wstr => WStr
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed May 23, 2024
1 parent 430d1cf commit bf87c65
Show file tree
Hide file tree
Showing 38 changed files with 158 additions and 158 deletions.
18 changes: 9 additions & 9 deletions src/AppTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void SaveCallstackLogs() {
#if 0
// cache because calculating md5 of the whole executable
// might be relatively expensive
static AutoFreeWstr gAppMd5;
static AutoFreeWStr gAppMd5;

// return hex version of md5 of app's executable
// nullptr if there was an error
Expand All @@ -534,7 +534,7 @@ static const WCHAR* Md5OfAppExe() {
CalcMD5Digest(d.data, d.size(), md5);

AutoFree md5HexA(_MemToHex(&md5));
AutoFreeWstr md5Hex = strconv::Utf8ToWchar(md5HexA.AsView());
AutoFreeWStr md5Hex = strconv::Utf8ToWchar(md5HexA.AsView());
d.Free();
return md5Hex.StealData();
}
Expand All @@ -544,7 +544,7 @@ static const WCHAR* Md5OfAppExe() {
// locally or using pre-release builds (both cases where
// exe and its md5 changes frequently)
void RemoveMd5AppDataDirectories() {
AutoFreeWstr extractedDir = PathForFileInAppDataDir(L"extracted");
AutoFreeWStr extractedDir = PathForFileInAppDataDir(L"extracted");
if (extractedDir.empty()) {
return;
}
Expand All @@ -554,12 +554,12 @@ void RemoveMd5AppDataDirectories() {
return;
}

AutoFreeWstr md5App = Md5OfAppExe();
AutoFreeWStr md5App = Md5OfAppExe();
if (md5App.empty()) {
return;
}

AutoFreeWstr md5Dir = path::Join(extractedDir.data, md5App.data);
AutoFreeWStr md5Dir = path::Join(extractedDir.data, md5App.data);

for (auto& dir : dirs) {
const WCHAR* s = dir.data();
Expand All @@ -575,18 +575,18 @@ void RemoveMd5AppDataDirectories() {
const WCHAR* ExractUnrarDll() {
RemoveMd5AppDataDirectories();

AutoFreeWstr extractedDir = PathForFileInAppDataDir(L"extracted");
AutoFreeWStr extractedDir = PathForFileInAppDataDir(L"extracted");
if (extractedDir.empty()) {
return nullptr;
}

AutoFreeWstr md5App = Md5OfAppExe();
AutoFreeWStr md5App = Md5OfAppExe();
if (md5App.empty()) {
return nullptr;
}

AutoFreeWstr md5Dir = path::Join(extractedDir.data, md5App.data);
AutoFreeWstr dllPath = path::Join(md5Dir.data, unrarFileName);
AutoFreeWStr md5Dir = path::Join(extractedDir.data, md5App.data);
AutoFreeWStr dllPath = path::Join(md5Dir.data, unrarFileName);

if (file::Exists(dllPath.data)) {
const WCHAR* ret = dllPath.data;
Expand Down
2 changes: 1 addition & 1 deletion src/Caption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ static void MenuBarAsPopupMenu(MainWindow* win, int x, int y) {
continue;
}
mii.cch++;
AutoFreeWstr subMenuName(AllocArray<WCHAR>(mii.cch));
AutoFreeWStr subMenuName(AllocArray<WCHAR>(mii.cch));
mii.dwTypeData = subMenuName;
GetMenuItemInfo(win->menu, i, TRUE, &mii);
AppendMenuW(popup, MF_POPUP | MF_STRING, (UINT_PTR)mii.hSubMenu, subMenuName);
Expand Down
26 changes: 13 additions & 13 deletions src/ChmFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ char* ChmFile::SmartToUtf8(const char* s, uint overrideCP) const {
return strconv::ToMultiByte(s, codepage, CP_UTF8);
}

WCHAR* ChmFile::SmartToWstr(const char* text) const {
return strconv::StrToWstr(text, codepage);
WCHAR* ChmFile::SmartToWStr(const char* text) const {
return strconv::StrToWStr(text, codepage);
}

static char* GetCharZ(const ByteSlice& d, size_t off) {
Expand Down Expand Up @@ -371,16 +371,16 @@ void ChmFile::GetAllPaths(StrVec* v) const {
static bool VisitChmTocItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp, int level) {
CrashIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li));

AutoFreeWstr name, local;
AutoFreeWStr name, local;
for (el = el->GetChildByTag(Tag_Param); el; el = el->next) {
if (Tag_Param != el->tag) {
continue;
}
AutoFreeWstr attrName(el->GetAttribute("name"));
AutoFreeWstr attrVal(el->GetAttribute("value"));
AutoFreeWStr attrName(el->GetAttribute("name"));
AutoFreeWStr attrVal(el->GetAttribute("value"));
if (attrName && attrVal && cp != CP_CHM_DEFAULT) {
AutoFreeStr bytes = strconv::WstrToCodePage(CP_CHM_DEFAULT, attrVal);
attrVal.Set(strconv::StrToWstr(bytes.Get(), cp));
AutoFreeStr bytes = strconv::WStrToCodePage(CP_CHM_DEFAULT, attrVal);
attrVal.Set(strconv::StrToWStr(bytes.Get(), cp));
}
if (!attrName || !attrVal) {
/* ignore incomplete/unneeded <param> */;
Expand Down Expand Up @@ -421,16 +421,16 @@ static bool VisitChmIndexItem(EbookTocVisitor* visitor, HtmlElement* el, uint cp
CrashIf(el->tag != Tag_Object || level > 1 && (!el->up || el->up->tag != Tag_Li));

StrVec references;
AutoFreeWstr keyword, name;
AutoFreeWStr keyword, name;
for (el = el->GetChildByTag(Tag_Param); el; el = el->next) {
if (Tag_Param != el->tag) {
continue;
}
AutoFreeWstr attrName(el->GetAttribute("name"));
AutoFreeWstr attrVal(el->GetAttribute("value"));
AutoFreeWStr attrName(el->GetAttribute("name"));
AutoFreeWStr attrVal(el->GetAttribute("value"));
if (attrName && attrVal && cp != CP_CHM_DEFAULT) {
AutoFreeStr bytes = strconv::WstrToCodePage(CP_CHM_DEFAULT, attrVal);
attrVal.Set(strconv::StrToWstr(bytes.Get(), cp));
AutoFreeStr bytes = strconv::WStrToCodePage(CP_CHM_DEFAULT, attrVal);
attrVal.Set(strconv::StrToWStr(bytes.Get(), cp));
}
if (!attrName || !attrVal) {
/* ignore incomplete/unneeded <param> */;
Expand Down Expand Up @@ -513,7 +513,7 @@ static bool WalkBrokenChmTocOrIndex(EbookTocVisitor* visitor, HtmlParser& p, uin

HtmlElement* el = p.FindElementByName("body");
while ((el = p.FindElementByName("object", el)) != nullptr) {
AutoFreeWstr type(el->GetAttribute("type"));
AutoFreeWStr type(el->GetAttribute("type"));
if (!str::EqI(type, L"text/sitemap")) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ChmFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ChmFile {
char* ResolveTopicID(unsigned int id) const;

char* SmartToUtf8(const char* text, uint overrideCP = 0) const;
WCHAR* SmartToWstr(const char* text) const;
WCHAR* SmartToWStr(const char* text) const;

TempStr GetPropertyTemp(const char* name) const;
const char* GetHomePath() const;
Expand Down
14 changes: 7 additions & 7 deletions src/EbookDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ bool EpubDoc::Load() {
tocPath.Set(str::Join(contentPath, s));
isNcxToc = true;
}
AutoFreeWstr readingDir(node->GetAttribute("page-progression-direction"));
AutoFreeWStr readingDir(node->GetAttribute("page-progression-direction"));
if (readingDir) {
isRtlDoc = str::EqI(readingDir, L"rtl");
}
Expand Down Expand Up @@ -649,7 +649,7 @@ bool EpubDoc::ParseNavToc(const char* data, size_t dataLen, const char* pagePath
}
auto itemText = ToWStrTemp(text.Get());
str::NormalizeWSInPlace(itemText);
AutoFreeWstr itemSrc;
AutoFreeWStr itemSrc;
if (href) {
href.Set(NormalizeURL(href, pagePath));
itemSrc.Set(strconv::FromHtmlUtf8(href, str::Len(href)));
Expand All @@ -676,7 +676,7 @@ bool EpubDoc::ParseNcxToc(const char* data, size_t dataLen, const char* pagePath
return false;
}

AutoFreeWstr itemText, itemSrc;
AutoFreeWStr itemText, itemSrc;
int level = 0;
while ((tok = parser.Next()) != nullptr && !tok->IsError() &&
(!tok->IsEndTag() || !tok->NameIsNS("navMap", EPUB_NCX_NS))) {
Expand Down Expand Up @@ -1014,7 +1014,7 @@ bool Fb2Doc::HasToc() const {
}

bool Fb2Doc::ParseToc(EbookTocVisitor* visitor) const {
AutoFreeWstr itemText;
AutoFreeWStr itemText;
bool inTitle = false;
int titleCount = 0;
int level = 0;
Expand Down Expand Up @@ -1042,7 +1042,7 @@ bool Fb2Doc::ParseToc(EbookTocVisitor* visitor) const {
}
inTitle = false;
} else if (inTitle && tok->IsText()) {
AutoFreeWstr text(strconv::FromHtmlUtf8(tok->s, tok->sLen));
AutoFreeWStr text(strconv::FromHtmlUtf8(tok->s, tok->sLen));
if (str::IsEmpty(itemText.Get())) {
itemText.Set(text.StealData());
} else {
Expand Down Expand Up @@ -1642,8 +1642,8 @@ bool TxtDoc::ParseToc(EbookTocVisitor* visitor) {
parser.Parse(htmlData.AsByteSlice(), CP_UTF8);
HtmlElement* el = nullptr;
while ((el = parser.FindElementByName("b", el)) != nullptr) {
AutoFreeWstr title(el->GetAttribute("title"));
AutoFreeWstr id(el->GetAttribute("id"));
AutoFreeWStr title(el->GetAttribute("title"));
AutoFreeWStr id(el->GetAttribute("id"));
int level = 1;
if (str::IsDigit(*title)) {
const WCHAR* dot = SkipDigits(title);
Expand Down
2 changes: 1 addition & 1 deletion src/EngineDjVu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ bool EngineDjVu::ExtractPageText(miniexp_t item, str::WStr& extracted, Vec<Rect>
AppendNewline(extracted, coords, lineSep);
}
const char* content = miniexp_to_str(str);
WCHAR* value = ToWstr(content);
WCHAR* value = ToWStr(content);
if (value) {
size_t len = str::Len(value);
// TODO: split the rectangle into individual parts per glyph
Expand Down
8 changes: 4 additions & 4 deletions src/EngineEbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ PageText EngineEbook::ExtractPageText(int pageNo) {
}
insertSpace = false;
{
AutoFreeWstr s(strconv::FromHtmlUtf8(i.str.s, i.str.len));
AutoFreeWStr s(strconv::FromHtmlUtf8(i.str.s, i.str.len));
content.Append(s);
size_t len = str::Len(s);
double cwidth = 1.0 * bbox.dx / len;
Expand All @@ -428,7 +428,7 @@ PageText EngineEbook::ExtractPageText(int pageNo) {
}
insertSpace = false;
{
AutoFreeWstr s(strconv::FromHtmlUtf8(i.str.s, i.str.len));
AutoFreeWStr s(strconv::FromHtmlUtf8(i.str.s, i.str.len));
content.Append(s);
size_t len = str::Len(s);
double cwidth = 1.0 * bbox.dx / len;
Expand Down Expand Up @@ -1470,7 +1470,7 @@ class ChmHtmlCollector : public EbookTocVisitor {
char* GetHtml() {
// first add the homepage
const char* index = doc->GetHomePath();
AutoFreeWstr urlW(doc->SmartToWstr(index));
AutoFreeWStr urlW(doc->SmartToWStr(index));
char* url = ToUtf8Temp(urlW);
Visit(nullptr, url, 0);

Expand All @@ -1485,7 +1485,7 @@ class ChmHtmlCollector : public EbookTocVisitor {
if (*path == '/') {
path++;
}
urlW.Set(ToWstr(path));
urlW.Set(ToWStr(path));
url = ToUtf8Temp(urlW);
Visit(nullptr, url, -1);
}
Expand Down
12 changes: 6 additions & 6 deletions src/EngineMupdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ static float FzRectOverlap(fz_rect r1, RectF r2f) {
return (isect.x1 - isect.x0) * (isect.y1 - isect.y0) / ((r1.x1 - r1.x0) * (r1.y1 - r1.y0));
}

static WCHAR* PdfToWstr(fz_context* ctx, pdf_obj* obj) {
static WCHAR* PdfToWStr(fz_context* ctx, pdf_obj* obj) {
char* s = pdf_new_utf8_from_pdf_string_obj(ctx, obj);
WCHAR* res = ToWstr(s);
WCHAR* res = ToWStr(s);
fz_free(ctx, s);
return res;
}
Expand Down Expand Up @@ -2052,7 +2052,7 @@ bool EngineMupdf::LoadFromStream(fz_stream* stm, const char* nameHint, PasswordU
// note: such passwords aren't portable when stored as Unicode text
if (!ok && GetACP() != 1252) {
AutoFreeStr pwd_ansi = str::Dup(pwd.Get());
AutoFreeWstr pwd_cp1252(strconv::StrToWstr(pwd_ansi.Get(), 1252));
AutoFreeWStr pwd_cp1252(strconv::StrToWStr(pwd_ansi.Get(), 1252));
pwdA = ToUtf8(pwd_cp1252);
ok = fz_authenticate_password(ctx, _doc, pwdA.Get());
}
Expand Down Expand Up @@ -2335,7 +2335,7 @@ bool EngineMupdf::FinishLoading() {
static NO_INLINE IPageDestination* DestFromAttachment(EngineMupdf* engine, fz_outline* outline) {
PageDestination* dest = new PageDestination();
dest->kind = kindDestinationAttachment;
// WCHAR* path = ToWstr(outline->uri);
// WCHAR* path = ToWStr(outline->uri);
dest->name = str::Dup(outline->title);
// page is really a stream number
dest->value = str::Format("%s:%d", engine->FilePath(), outline->page.page);
Expand All @@ -2353,7 +2353,7 @@ TocItem* EngineMupdf::BuildTocTree(TocItem* parent, fz_outline* outline, int& id
WCHAR* nameW = nullptr;
if (outline->title) {
// must convert to Unicode because PdfCleanString() doesn't work on utf8
nameW = ToWstr(outline->title);
nameW = ToWStr(outline->title);
PdfCleanStringInPlace(nameW);
name = ToUtf8(nameW);
str::Free(nameW);
Expand Down Expand Up @@ -3418,7 +3418,7 @@ TempStr EngineMupdf::GetPropertyTemp(const char* name) {
if (!obj) {
return nullptr;
}
WCHAR* ws = PdfToWstr(ctx, obj);
WCHAR* ws = PdfToWStr(ctx, obj);
PdfCleanStringInPlace(ws);
TempStr res = ToUtf8Temp(ws);
str::Free(ws);
Expand Down
2 changes: 1 addition & 1 deletion src/EnginePs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static char* GetGhostscriptPath() {

// if Ghostscript isn't found in the Registry, try finding it in the %PATH%
DWORD size = GetEnvironmentVariableW(L"PATH", nullptr, 0);
AutoFreeWstr envpath(AllocArray<WCHAR>(size + 1));
AutoFreeWStr envpath(AllocArray<WCHAR>(size + 1));
if (size == 0) {
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/HtmlFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct HtmlFormatterArgs {
// we start parsing from htmlStr + reparseIdx
int reparseIdx = 0;

AutoFreeWstr fontName;
AutoFreeWStr fontName;
};

class HtmlPullParser;
Expand Down Expand Up @@ -233,7 +233,7 @@ class HtmlFormatter {
float lineSpacing = 0;
float spaceDx = 0;
Graphics* gfx = nullptr; // for measuring text
AutoFreeWstr defaultFontName;
AutoFreeWStr defaultFontName;
float defaultFontSize = 0;
Allocator* textAllocator = nullptr;
mui::ITextRender* textMeasure = nullptr;
Expand Down
10 changes: 5 additions & 5 deletions src/MobiDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ bool MobiDoc::ParseHeader() {
logf("DRM is unsupported\n");
// load an empty document and display a warning
compressionType = COMPRESSION_UNSUPPORTED_DRM;
char* v = strconv::WstrToCodePage(mobiHdr.textEncoding, L"DRM");
char* v = strconv::WStrToCodePage(mobiHdr.textEncoding, L"DRM");
AddProp(props, kPropUnsupportedFeatures, v);
str::Free(v);
}
Expand Down Expand Up @@ -929,7 +929,7 @@ bool MobiDoc::HasToc() {
if (!attr) {
continue;
}
AutoFreeWstr val(strconv::FromHtmlUtf8(attr->val, attr->valLen));
AutoFreeWStr val(strconv::FromHtmlUtf8(attr->val, attr->valLen));
attr = tok->GetAttrByName("filepos");
if (!str::EqI(val, L"toc") || !attr) {
continue;
Expand All @@ -949,8 +949,8 @@ bool MobiDoc::ParseToc(EbookTocVisitor* visitor) {
return false;
}

AutoFreeWstr itemText;
AutoFreeWstr itemLink;
AutoFreeWStr itemText;
AutoFreeWStr itemLink;
int itemLevel = 0;

// there doesn't seem to be a standard for Mobi ToCs, so we try to
Expand All @@ -959,7 +959,7 @@ bool MobiDoc::ParseToc(EbookTocVisitor* visitor) {
HtmlToken* tok;
while ((tok = parser.Next()) != nullptr && !tok->IsError()) {
if (itemLink && tok->IsText()) {
AutoFreeWstr linkText(strconv::FromHtmlUtf8(tok->s, tok->sLen));
AutoFreeWStr linkText(strconv::FromHtmlUtf8(tok->s, tok->sLen));
if (itemText) {
itemText.Set(str::Join(itemText, L" ", linkText));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/PdfSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ int SyncTex::RebuildIndexIfNeeded() {
TempStr syncPathTemp = str::DupTemp(syncFilePath.Get());
Repeat:
TempWStr ws = ToWStrTemp(syncPathTemp);
AutoFreeStr pathAnsi = strconv::WstrToAnsi(ws);
AutoFreeStr pathAnsi = strconv::WStrToAnsi(ws);
scanner = synctex_scanner_new_with_output_file(pathAnsi, nullptr, 1);
if (scanner) {
logfa("synctex_scanner_new_with_output_file: ok for pathAnsi '%s'\n", pathAnsi.Get());
Expand Down
Loading

0 comments on commit bf87c65

Please sign in to comment.