summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2014-11-17 15:33:04 -0800
committerBruce Dawson <brucedawson@google.com>2014-11-17 15:33:04 -0800
commitcf19caadfa3e7e01d3412d83540e8492b52b31d7 (patch)
treef100f6946c18e387b6a0eaf14b396e79d564ac9c
parent9ae02acf2f33fc68a6f3c00c3ad86e15725b8941 (diff)
downloadpdfium-cf19caadfa3e7e01d3412d83540e8492b52b31d7.tar.xz
Removing unnecessary casts from wchar_t* to wchar_t*, by various names.
Remove casts that merely cast from wchar_t* to wchar_t*. Sometimes the types or casts are FX_LPCWSTR but the idea is the same. Excess casts can (and have) hidden bugs so removing these may prevent future problems. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/730993002
-rw-r--r--core/include/fxcrt/fx_string.h2
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp4
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h2
-rw-r--r--fpdfsdk/src/javascript/Field.cpp4
-rw-r--r--fpdfsdk/src/javascript/global.cpp2
-rw-r--r--fpdfsdk/src/javascript/util.cpp16
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp10
7 files changed, 20 insertions, 20 deletions
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index 26b04b70fa..364c510f73 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -597,7 +597,7 @@ private:
}
};
typedef const CFX_WideStringC& FX_WSTR;
-#define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
+#define FX_WSTRC(wstr) CFX_WideStringC(wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
struct CFX_StringDataW {
long m_nRefs;
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 3a13d59054..0827fb6f34 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -586,7 +586,7 @@ FX_STRSIZE CFX_WideString::Find(FX_LPCWSTR lpszSub, FX_STRSIZE nStart) const
if (nLength < 1 || nStart > nLength) {
return -1;
}
- FX_LPCWSTR lpsz = (FX_LPCWSTR)FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
+ FX_LPCWSTR lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
}
FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const
@@ -598,7 +598,7 @@ FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const
if (nStart >= nLength) {
return -1;
}
- FX_LPCWSTR lpsz = (FX_LPCWSTR)FXSYS_wcschr(m_pData->m_String + nStart, ch);
+ FX_LPCWSTR lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch);
return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
}
void CFX_WideString::TrimRight(FX_LPCWSTR lpszTargetList)
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 108c1e23ee..62a8d1417e 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -626,7 +626,7 @@ if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntim
int size = sizeof(ArrayContent) / sizeof(FX_LPCWSTR);\
\
CJS_Array array(pRuntime);\
-for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,(FX_LPCWSTR)ArrayContent[i]));\
+for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]));\
\
CJS_PropValue prop(pRuntime);\
prop << array;\
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 73a4e0a959..a84599298e 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -149,7 +149,7 @@ void Field::ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &
return;
}
std::wstring suffixal = strFieldNameParsed.substr(iStart+1);
- iControlNo = FXSYS_wtoi((FX_LPCWSTR)suffixal.c_str());
+ iControlNo = FXSYS_wtoi(suffixal.c_str());
if (iControlNo == 0)
{
int iStart;
@@ -194,7 +194,7 @@ FX_BOOL Field::AttachField(Document* pDocument, const CFX_WideString& csFieldNam
{
std::wstring strFieldName;
int iControlNo = -1;
- ParseFieldName((wchar_t*)(FX_LPCWSTR)swFieldNameTemp, strFieldName, iControlNo);
+ ParseFieldName((FX_LPCWSTR)swFieldNameTemp, strFieldName, iControlNo);
if (iControlNo == -1) return FALSE;
m_FieldName = strFieldName.c_str();
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 295a8d49af..03bdd5b575 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -341,7 +341,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari
CFX_WideString ws = JS_ToString(JS_GetArrayElemnet(pKeyList, i));
CFX_ByteString sKey = ws.UTF8Encode();
- v8::Handle<v8::Value> v = JS_GetObjectElement(isolate, pObj, (const wchar_t*)(FX_LPCWSTR)ws);
+ v8::Handle<v8::Value> v = JS_GetObjectElement(isolate, pObj, (FX_LPCWSTR)ws);
FXJSVALUETYPE vt = GET_VALUE_TYPE(v);
switch (vt)
{
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index 1e5c75188a..d2813f5083 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -182,23 +182,23 @@ FX_BOOL util::printf(OBJ_METHOD_PARAMS)
switch (ParstDataType(&c_strFormat))
{
case UTIL_INT:
- strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(int)params[iIndex]);
+ strSegment.Format(c_strFormat.c_str(),(int)params[iIndex]);
break;
case UTIL_DOUBLE:
- strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(double)params[iIndex]);
+ strSegment.Format(c_strFormat.c_str(),(double)params[iIndex]);
break;
case UTIL_STRING:
- strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(FX_LPCWSTR)params[iIndex].operator CFX_WideString());
+ strSegment.Format(c_strFormat.c_str(),(FX_LPCWSTR)params[iIndex].operator CFX_WideString());
break;
default:
- strSegment.Format(L"%S", (FX_LPCWSTR)c_strFormat.c_str());
+ strSegment.Format(L"%S", c_strFormat.c_str());
break;
}
- c_strResult += (wchar_t*)strSegment.GetBuffer(strSegment.GetLength()+1);
+ c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1);
}
c_strResult.erase(c_strResult.begin());
- vRet = (FX_LPCWSTR)c_strResult.c_str();
+ vRet = c_strResult.c_str();
return TRUE;
}
@@ -271,7 +271,7 @@ FX_BOOL util::printd(OBJ_METHOD_PARAMS)
}
else if (p1.GetType() == VT_string)
{
- std::basic_string<wchar_t> cFormat = (wchar_t*)(FX_LPCWSTR)p1.operator CFX_WideString();
+ std::basic_string<wchar_t> cFormat = (FX_LPCWSTR)p1.operator CFX_WideString();
bool bXFAPicture = false;
if (iSize > 2)
@@ -365,7 +365,7 @@ FX_BOOL util::printd(OBJ_METHOD_PARAMS)
wchar_t buf[64] = {0};
strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
- vRet = (FX_LPCWSTR)cFormat.c_str();
+ vRet = cFormat.c_str();
//rtRet = strFormat.GetBuffer(strFormat.GetLength()+1);
return TRUE;
}
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 5eb9873f5c..7d1226e234 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -93,7 +93,7 @@ int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sMethodName);
+ CFX_WideString ws = CFX_WideString(sMethodName);
CFX_ByteString bsMethodName = ws.UTF8Encode();
CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
@@ -113,7 +113,7 @@ int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t*
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sPropName);
+ CFX_WideString ws = CFX_WideString(sPropName);
CFX_ByteString bsPropertyName = ws.UTF8Encode();
CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
@@ -153,7 +153,7 @@ int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sC
CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
if(!pArray) return 0;
- CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sConstName);
+ CFX_WideString ws = CFX_WideString(sConstName);
CFX_ByteString bsConstName = ws.UTF8Encode();
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0;
@@ -188,7 +188,7 @@ int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sMethodName);
+ CFX_WideString ws = CFX_WideString(sMethodName);
CFX_ByteString bsMethodName = ws.UTF8Encode();
v8::Local<v8::FunctionTemplate> funTempl = v8::FunctionTemplate::New(isolate, pMethodCall);
@@ -212,7 +212,7 @@ int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8:
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sConstName);
+ CFX_WideString ws = CFX_WideString(sConstName);
CFX_ByteString bsConst= ws.UTF8Encode();
v8::Local<v8::ObjectTemplate> objTemp;