aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-26 19:41:11 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-26 19:41:11 +0200
commitb966497200b47ca5efb3a5853891ea4590927371 (patch)
tree45670cff2c4682f0d0c1b1e33c1dddadfe8d58d7 /c
parent547cbe578dcdb5aa5cfdac1cdb327f92bad21219 (diff)
downloadEpisodeBrowser-b966497200b47ca5efb3a5853891ea4590927371.tar.gz
Use 's' instead of 'str' for as prefix for managed strings.
Diffstat (limited to 'c')
-rw-r--r--c/common.cpp8
-rw-r--r--c/common.h2
-rw-r--r--c/datalistview.cpp10
-rw-r--r--c/episodelistview.cpp20
-rw-r--r--c/main.cpp8
-rw-r--r--c/pl.cpp4
-rw-r--r--c/pl.h4
7 files changed, 28 insertions, 28 deletions
diff --git a/c/common.cpp b/c/common.cpp
index ca8dfac..bc2d4af 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -56,14 +56,14 @@ Library::~Library()
}
/* Convert narrow unmanaged string to wide managed string. */
-std::wstring WstrFromSz(const char* sz, int iCp)
+std::wstring WsFromSz(const char* sz, int iCp)
{
int cbMultiByte = strlen(sz)+1;
int cchWideChar = MultiByteToWideChar(iCp, 0, sz, cbMultiByte, NULL, 0);
- std::wstring wstr(cchWideChar, 0);
- if (!MultiByteToWideChar(iCp, 0, sz, cbMultiByte, wstr.data(), cchWideChar))
+ std::wstring ws(cchWideChar, 0);
+ if (!MultiByteToWideChar(iCp, 0, sz, cbMultiByte, ws.data(), cchWideChar))
throw Win32Error(GetLastError());
- return wstr;
+ return ws;
}
/* Move message box to center of main window. */
diff --git a/c/common.h b/c/common.h
index 9efaf59..3a2d598 100644
--- a/c/common.h
+++ b/c/common.h
@@ -11,7 +11,7 @@
#define WA "A"
#endif
-std::wstring WstrFromSz(const char* sz, int iCp = CP_UTF8);
+std::wstring WsFromSz(const char* sz, int iCp = CP_UTF8);
int EBMessageBox(const wchar_t* wszText, const wchar_t* wszCaption, unsigned uType);
struct Win32Error : public std::exception
diff --git a/c/datalistview.cpp b/c/datalistview.cpp
index e64f89a..a091ace 100644
--- a/c/datalistview.cpp
+++ b/c/datalistview.cpp
@@ -56,21 +56,21 @@ void DataListView::ShowEpisode(const int iEpisode)
Query q (NULL, PL_predicate("episode_datum", iArity, "episode_data"), t);
for (int i = 0; q.NextSolution(); i++) {
- std::wstring wstrKey;
- std::wstring wstrValue;
+ std::wstring wsKey;
+ std::wstring wsValue;
- if (!(PlGet(t+1, &wstrKey) && PlGet(t+2, &wstrValue)))
+ if (!(PlGet(t+1, &wsKey) && PlGet(t+2, &wsValue)))
continue;
lviKey.mask = LVIF_TEXT;
lviKey.iItem = i;
lviKey.iSubItem = 0;
- lviKey.pszText = wstrKey.data();
+ lviKey.pszText = wsKey.data();
ListView_InsertItem(hWnd, &lviKey);
lviValue.iItem = i;
lviValue.iSubItem = 1;
- lviValue.pszText = wstrValue.data();
+ lviValue.pszText = wsValue.data();
ListView_SetItem(hWnd, &lviValue);
}
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 49e59d1..5aa8850 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -281,16 +281,16 @@ int CALLBACK EpisodeListView::SortProc(const LPARAM iItem1, const LPARAM iItem2,
case ELVSITITLE:
{
Mark m;
- char* sz1,* sz2;
+ std::wstring ws1, ws2;
int cch, cch1, cch2;
- if (!Pl("episode_data","episode_title",lvi1.lParam,&sz1))
+ if (!Pl("episode_data","episode_title",lvi1.lParam,&ws1))
return 0;
- if (!Pl("episode_data","episode_title",lvi2.lParam,&sz2))
+ if (!Pl("episode_data","episode_title",lvi2.lParam,&ws2))
return 0;
- cch1 = strlen(sz1);
- cch2 = strlen(sz2);
+ cch1 = wcslen(ws1.c_str());
+ cch2 = wcslen(ws2.c_str());
cch = cch1 > cch2? cch2: cch1;
- return iOrder*_strnicmp(sz1, sz2, cch);
+ return iOrder*_wcsnicmp(ws1.c_str(), ws2.c_str(), cch);
}
default:
return 0;
@@ -429,12 +429,12 @@ void EpisodeListView::Update()
/* Update episode name and rating. */
void EpisodeListView::UpdateItem(const LVITEM* const pLvi)
{
- std::wstring wstrName;
- if (!Pl("episode_data","episode_title",pLvi->lParam,&wstrName)) {
+ std::wstring wsName;
+ if (!Pl("episode_data","episode_title",pLvi->lParam,&wsName)) {
if (!Pl("episode_data","update_episode_data")) goto r;
- if (!Pl("episode_data","episode_title",pLvi->lParam,&wstrName)) goto r;
+ if (!Pl("episode_data","episode_title",pLvi->lParam,&wsName)) goto r;
}
- ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, wstrName.data());
+ ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, wsName.data());
int iRating;
r: if (!Pl("episode_data","episode_rating",pLvi->lParam,&iRating)) {
diff --git a/c/main.cpp b/c/main.cpp
index 00c9051..c3c555b 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -65,15 +65,15 @@ void OnTerminate() noexcept
try {
std::rethrow_exception(std::current_exception());
} catch (const term_t& t) {
- std::wstring wstr;
- if (PlString(t, &wstr))
- TerminateMsg(L"a Prolog exception", wstr.c_str());
+ std::wstring ws;
+ if (PlString(t, &ws))
+ TerminateMsg(L"a Prolog exception", ws.c_str());
else
TerminateMsg(L"a Prolog exception", NULL);
} catch (const Win32Error& e) {
TerminateMsg(L"a Windows error", e.WhatW());
} catch (const std::exception& e) {
- TerminateMsg(L"an exception", WstrFromSz(e.what()).c_str());
+ TerminateMsg(L"an exception", WsFromSz(e.what()).c_str());
} catch (...) {
TerminateMsg(L"an exception", NULL);
}
diff --git a/c/pl.cpp b/c/pl.cpp
index 0114454..6e71383 100644
--- a/c/pl.cpp
+++ b/c/pl.cpp
@@ -78,10 +78,10 @@ int Query::NextSolution()
}
/* Convert Prolog term to wide characters. */
-int PlString(const term_t t, std::wstring* const pWstr, const int iFlags)
+int PlString(const term_t t, std::wstring* const pWs, const int iFlags)
{
char* sz;
int r = PL_get_chars(t, &sz, iFlags);
- if (r) *pWstr = WstrFromSz(sz);
+ if (r) *pWs = WsFromSz(sz);
return r;
}
diff --git a/c/pl.h b/c/pl.h
index 5c67af6..4a5ea41 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -7,7 +7,7 @@
#include "common.h"
-int PlString(term_t t, std::wstring* pWstr, int iFlags = CVT_WRITE);
+int PlString(term_t t, std::wstring* pWs, int iFlags = CVT_WRITE);
struct Frame
{
@@ -76,7 +76,7 @@ inline int PlGet(term_t t, std::wstring* x) {
Mark m;
char* sz;
if (!PlGet(t, &sz)) return 0;
- *x = WstrFromSz(sz);
+ *x = WsFromSz(sz);
return 1; /* or catch potential exception from BstrFromSz? */
}