Silence a bunch of PREFast warnings

Originally committed to SVN as r6162.
This commit is contained in:
Thomas Goyne 2011-12-26 22:20:49 +00:00
parent bddd4fc714
commit 7adbe07b4e
23 changed files with 101 additions and 117 deletions

View File

@ -65,9 +65,8 @@ namespace {
void put_array(json::Object &obj, const std::string &path, const char *element_key, std::vector<T> const& value) {
json::Array array;
for (typename std::vector<T>::const_iterator it = value.begin(); it != value.end(); ++it) {
json::Object obj;
obj[element_key] = *it;
array.push_back(obj);
array.push_back(json::Object());
static_cast<json::Object&>(array.back())[element_key] = *it;
}
put_option(obj, path, array);

View File

@ -303,10 +303,9 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
if (data.empty()) return;
// Group
AssEntry *entry = NULL;
wxString origGroup = group;
static wxString keepGroup;
if (!keepGroup.IsEmpty()) group = keepGroup;
if (!keepGroup.empty()) group = keepGroup;
if (outGroup) *outGroup = group;
wxString lowGroup = group.Lower();
@ -355,7 +354,7 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
keepGroup.Clear();
group = origGroup;
lowGroup = group.Lower();
entry = attach;
Line.push_back(attach);
attach = NULL;
}
@ -365,34 +364,24 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
}
}
}
// Dialogue
else if (lowGroup == "[events]") {
if (data.StartsWith("Dialogue:") || data.StartsWith("Comment:")) {
AssDialogue *diag = new AssDialogue(data,version);
//diag->ParseASSTags();
entry = diag;
entry->group = group;
if (data.StartsWith("Dialogue:") || data.StartsWith("Comment:"))
Line.push_back(new AssDialogue(data,version));
else if (data.StartsWith("Format:"))
Line.push_back(new AssEntry("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text", group));
else
Line.push_back(new AssEntry(data, group));
}
else if (data.StartsWith("Format:")) {
entry = new AssEntry("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text");
entry->group = group;
}
}
// Style
else if (lowGroup == "[v4+ styles]") {
if (data.StartsWith("Style:")) {
AssStyle *style = new AssStyle(data,version);
entry = style;
entry->group = group;
if (data.StartsWith("Style:"))
Line.push_back(new AssStyle(data,version));
else if (data.StartsWith("Format:"))
Line.push_back(new AssEntry("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding", group));
else
Line.push_back(new AssEntry(data, group));
}
if (data.StartsWith("Format:")) {
entry = new AssEntry("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding");
entry->group = group;
}
}
// Script info
else if (lowGroup == "[script info]") {
// Comment
@ -420,19 +409,12 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
}
// Everything
entry = new AssEntry(data);
entry->group = group;
Line.push_back(new AssEntry(data, group));
}
// Common entry
if (entry == NULL) {
entry = new AssEntry(data);
entry->group = group;
// Unrecognized group
else {
Line.push_back(new AssEntry(data, group));
}
// Insert the line
Line.push_back(entry);
return;
}
void AssFile::Clear() {

View File

@ -363,7 +363,7 @@ std::vector<wxString> tokenize(const wxString &text) {
return paramList;
}
void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::iterator proto) {
void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::iterator proto_it) {
Clear();
// Tokenize text, attempting to find all parameters
@ -371,14 +371,14 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
size_t totalPars = paramList.size();
int parsFlag = 1 << (totalPars - 1); // Get optional parameters flag
// vector (i)clip is the second clip prototype in the list
// vector (i)clip is the second clip proto_ittype in the list
if ((Name == "\\clip" || Name == "\\iclip") && totalPars != 4) {
++proto;
++proto_it;
}
unsigned curPar = 0;
for (size_t n = 0; n < proto->params.size(); n++) {
AssOverrideParamProto *curproto = &proto->params[n];
for (size_t n = 0; n < proto_it->params.size(); n++) {
AssOverrideParamProto *curproto = &proto_it->params[n];
// Create parameter
AssOverrideParameter *newparam = new AssOverrideParameter;

View File

@ -66,32 +66,32 @@ AssColor::AssColor (const wxColour &color) {
/// @brief Parse from SSA/ASS
/// @param value
void AssColor::Parse(const wxString value) {
if (value.Len() > 0 && value[0] == '#') {
void AssColor::Parse(wxString const& value) {
if (value.size() > 0 && value[0] == '#') {
// HTML colour
SetWXColor(wxColor(value));
return;
}
// Prepare
char c,ostr[12];
unsigned long outval;
char ostr[12];
int oindex = 11;
bool ishex = false;
ostr[11] = 0;
for(unsigned char i = value.Len(); i > 0 && oindex >= 0; i--) {
c=value[i - 1];
for(size_t i = value.size(); i > 0 && oindex >= 0; i--) {
unsigned char c = value[i - 1];
if (isxdigit(c) || c == '-') {
ostr[--oindex] = c;
if (c>='A') ishex = true;
if (c >= 'A')
ishex = true;
}
else if (c == 'H' || c == 'h') ishex = true;
else if (c == 'H' || c == 'h')
ishex = true;
}
outval=strtoul(ostr+oindex,0,ishex?16:10);
unsigned long outval = strtoul(ostr + oindex, 0, ishex ? 16 : 10);
r = outval & 0xFF;
g = (outval>>8) & 0xFF;
b = (outval>>16) & 0xFF;

View File

@ -60,7 +60,7 @@ struct AssColor {
wxColor GetWXColor(); // Return as a wxColor
void SetWXColor(const wxColor &color); // Sets from a wxColor
void Parse(const wxString value); // Parse SSA or ASS-style color
void Parse(wxString const& value); // Parse SSA or ASS-style color
wxString GetASSFormatted(bool alpha,bool stripped=false,bool isStyle=false) const; // Gets color formated in ASS format
wxString GetSSAFormatted() const;
};

View File

@ -73,21 +73,21 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
{
using std::tr1::bind;
wxSizer *main_sizer = new wxBoxSizer(wxHORIZONTAL);
cancel_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_cancel_16));
cancel_button->SetToolTip(_("Discard all uncommitted splits"));
cancel_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, bind(&AudioKaraoke::CancelSplit, this));
main_sizer->Add(cancel_button);
accept_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_accept_16));
accept_button->SetToolTip(_("Commit splits"));
accept_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, bind(&AudioKaraoke::AcceptSplit, this));
main_sizer->Add(accept_button);
split_area = new wxPanel(this);
main_sizer->Add(split_area, wxSizerFlags(1).Expand());
wxSizer *main_sizer = new wxBoxSizer(wxHORIZONTAL);
main_sizer->Add(cancel_button);
main_sizer->Add(accept_button);
main_sizer->Add(split_area, wxSizerFlags(1).Expand());
SetSizerAndFit(main_sizer);
/// @todo subscribe

View File

@ -150,7 +150,7 @@ public:
void GetAudio(void *buf, int64_t start, int64_t count) const {
if (count == 0) return;
bool not_end = start + count < num_samples;
int not_end = start + count < num_samples;
int64_t src_count = count / 2;
source->GetAudio(buf, start / 2, src_count + not_end);

View File

@ -306,16 +306,8 @@ class RiffWavPCMAudioProvider : public PCMAudioProvider {
// either way, as the fields can depend on the compression.
};
/// @brief DOCME
/// @param str1[]
/// @param str2[]
/// @return
///
static bool CheckFourcc(const char str1[], const char str2[])
static bool CheckFourcc(const char (&str1)[4], const char (&str2)[5])
{
assert(str1);
assert(str2);
return
(str1[0] == str2[0]) &&
(str1[1] == str2[1]) &&

View File

@ -362,8 +362,10 @@ namespace Automation4 {
dia->Effect = get_string_field(L, "effect", "dialogue");
dia->Text = get_string_field(L, "text", "dialogue");
}
else
else {
luaL_error(L, "Found line with unknown class: %s", lclass.utf8_str().data());
return 0;
}
if (result->group.empty())
result->group = section;

View File

@ -135,7 +135,7 @@ static void insert_subtitle_at_video(agi::Context *c, bool after) {
// Insert it
c->subsGrid->BeginBatch();
c->subsGrid->InsertLine(def, n, after);
c->subsGrid->SelectRow(n + after);
c->subsGrid->SelectRow(n + (int)after);
c->subsGrid->SetActiveLine(def);
c->subsGrid->EndBatch();
}

View File

@ -1034,6 +1034,8 @@ wxBitmap *DialogColorPicker::MakeGBSpectrum()
unsigned char *ospec, *spec;
ospec = spec = (unsigned char *)malloc(256*256*3);
if (!spec) throw std::bad_alloc();
for (int g = 0; g < 256; g++) {
for (int b = 0; b < 256; b++) {
*spec++ = cur_color.Red();
@ -1052,6 +1054,8 @@ wxBitmap *DialogColorPicker::MakeRBSpectrum()
unsigned char *ospec, *spec;
ospec = spec = (unsigned char *)malloc(256*256*3);
if (!spec) throw std::bad_alloc();
for (int r = 0; r < 256; r++) {
for (int b = 0; b < 256; b++) {
*spec++ = r;
@ -1070,6 +1074,8 @@ wxBitmap *DialogColorPicker::MakeRGSpectrum()
unsigned char *ospec, *spec;
ospec = spec = (unsigned char *)malloc(256*256*3);
if (!spec) throw std::bad_alloc();
for (int r = 0; r < 256; r++) {
for (int g = 0; g < 256; g++) {
*spec++ = r;
@ -1088,6 +1094,8 @@ wxBitmap *DialogColorPicker::MakeHSSpectrum()
unsigned char *ospec, *spec;
ospec = spec = (unsigned char *)malloc(256*256*3);
if (!spec) throw std::bad_alloc();
int l = hsl_input[2]->GetValue();
for (int h = 0; h < 256; h++) {
@ -1111,6 +1119,7 @@ wxBitmap *DialogColorPicker::MakeSVSpectrum()
unsigned char *ospec, *spec;
ospec = spec = (unsigned char *)malloc(256*256*3);
if (!spec) throw std::bad_alloc();
int h = hsv_input[0]->GetValue();
unsigned char maxr, maxg, maxb;

View File

@ -278,12 +278,11 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
// Normal
else {
int textPos = tempPos;
wxString src = Text->Mid(tempPos);
if (!matchCase) src.MakeLower();
int tempPos = src.Find(LookFor);
if (tempPos != -1) {
pos = textPos+tempPos;
int textPos = src.Find(LookFor);
if (textPos != -1) {
pos = tempPos+textPos;
found = true;
matchLen = LookFor.Length();
}

View File

@ -282,6 +282,8 @@ static wxString GetSystemLanguage()
// Try using Win 6+ functions if available
HMODULE kernel32 = LoadLibraryW(L"kernel32.dll");
if (!kernel32)
goto getsyslang_fallback;
PGetUserPreferredUILanguages gupuil = (PGetUserPreferredUILanguages)GetProcAddress(kernel32, "GetUserPreferredUILanguages");
if (gupuil)
{
@ -309,6 +311,7 @@ getsyslang_fallback:
res = wxString::Format("x-win%04x", langid);
}
if (kernel32)
FreeModule(kernel32);
return res;

View File

@ -411,7 +411,7 @@ namespace menu {
void GetMenuBar(std::string const& name, wxFrame *window, agi::Context *c) {
menu_items const& items = get_menu(name);
CommandMenuBar *menu = new CommandMenuBar(c);
std::auto_ptr<CommandMenuBar> menu(new CommandMenuBar(c));
for (menu_items::const_iterator it = items.begin(); it != items.end(); ++it) {
std::string submenu, disp;
read_entry(*it, "submenu", &submenu);
@ -426,9 +426,9 @@ namespace menu {
}
}
window->SetMenuBar(menu);
window->Bind(wxEVT_MENU_OPEN, &CommandManager::OnMenuOpen, &menu->cm);
window->Bind(wxEVT_COMMAND_MENU_SELECTED, &CommandManager::OnMenuClick, &menu->cm);
window->SetMenuBar(menu.release());
}
wxMenu *GetMenu(std::string const& name, agi::Context *c) {

View File

@ -85,10 +85,12 @@ static void read_subtitles(agi::ProgressSink *ps, MatroskaFile *file, MkvStdIO *
// Read to temp
if (frameSize > readBufSize) {
delete readBuf;
delete[] readBuf;
readBufSize = frameSize * 2;
readBuf = new char[readBufSize];
}
else if (frameSize == 0)
continue;
fseek(input->fp, filePos, SEEK_SET);
fread(readBuf, 1, frameSize, input->fp);
@ -121,7 +123,7 @@ static void read_subtitles(agi::ProgressSink *ps, MatroskaFile *file, MkvStdIO *
ps->SetProgress(startTime / timecodeScaleLow, totalTime);
}
delete readBuf;
delete[] readBuf;
// Insert into file
wxString group = "[Events]";

View File

@ -101,6 +101,7 @@ static void font_button(Preferences *parent, wxTextCtrl *name, wxSpinCtrl *size)
OptionPage::OptionPage(wxTreebook *book, Preferences *parent, wxString name, int style)
: wxScrolled<wxPanel>(book, -1, wxDefaultPosition, wxDefaultSize, wxVSCROLL)
, sizer(new wxBoxSizer(wxVERTICAL))
, parent(parent)
{
if (style & PAGE_SUB)
@ -112,8 +113,6 @@ OptionPage::OptionPage(wxTreebook *book, Preferences *parent, wxString name, int
SetScrollbars(0, 20, 0, 50);
else
SetScrollbars(0, 0, 0, 0);
sizer = new wxBoxSizer(wxVERTICAL);
}
template<class T>

View File

@ -742,7 +742,7 @@ void SubsEditBox::SetTag(wxString tag, wxString value, bool atEnd) {
shift += 2;
line->ParseASSTags();
}
else {
else if(ovr) {
wxString alt;
if (tag == "\\c") alt = "\\1c";
// Remove old of same
@ -769,6 +769,9 @@ void SubsEditBox::SetTag(wxString tag, wxString value, bool atEnd) {
line->UpdateText();
}
else
assert(false);
TextEdit->SetTextTo(line->Text);
if (!atEnd) TextEdit->SetSelectionU(selstart+shift,selend+shift);
TextEdit->SetFocus();

View File

@ -429,16 +429,13 @@ void SubsTextEditCtrl::UpdateCallTip(wxStyledTextEvent &) {
wxString text = GetText();
// Find the start and end of current tag
wxChar curChar = 0;
wxChar prevChar = 0;
int depth = 0;
int inDepth = 0;
int tagStart = -1;
int tagEnd = -1;
for (unsigned int i=0;i<text.Length()+1;i++) {
// Get character
if (i<text.Length()) curChar = text[i];
else curChar = 0;
wxChar curChar = i < text.size() ? text[i] : 0;
// Change depth
if (curChar == '{') {

View File

@ -113,13 +113,11 @@ void MicroDVDSubtitleFormat::ReadFile(wxString const& filename, wxString const&
text.Replace("|", "\\N");
AssDialogue *line = new AssDialogue;
line->group = "[Events]";
line->Style = "Default";
line->Start = fps.TimeAtFrame(f1, agi::vfr::START);
line->End = fps.TimeAtFrame(f2, agi::vfr::END);
line->Text = text;
Line->push_back(line);
AssDialogue *diag = new AssDialogue;
diag->Start = fps.TimeAtFrame(f1, agi::vfr::START);
diag->End = fps.TimeAtFrame(f2, agi::vfr::END);
diag->Text = text;
Line->push_back(diag);
}
}
}

View File

@ -229,12 +229,14 @@ void TTXTSubtitleFormat::WriteHeader(wxXmlNode *root) {
root = node;
// Write font table
node = new wxXmlNode(wxXML_ELEMENT_NODE, "FontTable");
root->AddChild(node);
wxXmlNode *subNode = new wxXmlNode(wxXML_ELEMENT_NODE, "FontTableEntry");
subNode->AddAttribute("fontName", "Sans");
subNode->AddAttribute("fontID", "1");
node->AddChild(subNode);
root->AddChild(node);
// Write text box
node = new wxXmlNode(wxXML_ELEMENT_NODE, "TextBox");
@ -255,23 +257,20 @@ void TTXTSubtitleFormat::WriteHeader(wxXmlNode *root) {
void TTXTSubtitleFormat::WriteLine(wxXmlNode *root, AssDialogue *line) {
// If it doesn't start at the end of previous, add blank
wxXmlNode *node, *subNode;
if (prev && prev->End != line->Start) {
node = new wxXmlNode(wxXML_ELEMENT_NODE, "TextSample");
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, "TextSample");
node->AddAttribute("sampleTime", "0" + prev->End.GetASSFormated(true));
node->AddAttribute("xml:space", "preserve");
subNode = new wxXmlNode(wxXML_TEXT_NODE, "", "");
node->AddChild(subNode);
root->AddChild(node);
node->AddChild(new wxXmlNode(wxXML_TEXT_NODE, "", ""));
}
// Generate and insert node
node = new wxXmlNode(wxXML_ELEMENT_NODE, "TextSample");
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, "TextSample");
node->AddAttribute("sampleTime", "0" + line->Start.GetASSFormated(true));
node->AddAttribute("xml:space", "preserve");
subNode = new wxXmlNode(wxXML_TEXT_NODE, "", line->Text);
node->AddChild(subNode);
root->AddChild(node);
node->AddChild(new wxXmlNode(wxXML_TEXT_NODE, "", line->Text));
// Set as previous
prev = line;

View File

@ -97,15 +97,15 @@ namespace {
/// Populate the toolbar with buttons
void Populate() {
json::Object const& root = get_root();
json::Object::const_iterator it = root.find(name);
if (it == root.end()) {
json::Object::const_iterator root_it = root.find(name);
if (root_it == root.end()) {
// Toolbar names are all hardcoded so this should never happen
throw agi::InternalError("Toolbar named " + name + " not found.", 0);
}
int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt();
json::Array const& arr = it->second;
json::Array const& arr = root_it->second;
commands.reserve(arr.size());
bool needs_onidle = false;

View File

@ -119,7 +119,7 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString filename) try
}
AVISTREAMINFO avis;
if (AVIStreamInfo(ppavi,&avis,sizeof(avis))) {
if (FAILED(AVIStreamInfo(ppavi,&avis,sizeof(avis)))) {
warning = "Unable to read keyframes from AVI file:\nCould not get stream information.";
goto stream_release;
}

View File

@ -490,7 +490,7 @@ void VisualToolBase::GetLineRotation(AssDialogue *diag, float &rx, float &ry, fl
ry = tag->front()->Get<float>(ry);
if (param_vec tag = find_tag(diag, "\\frz"))
rz = tag->front()->Get<float>(rz);
else if (param_vec tag = find_tag(diag, "\\fr"))
else if (tag = find_tag(diag, "\\fr"))
rz = tag->front()->Get<float>(rz);
}