From b23194dfae53ec747d9a5591b60fe265496dff59 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 5 Mar 2015 15:19:00 -0300 Subject: [PATCH] Fix several warnings in MSVC, clang, and gcc --- src/app/color.cpp | 2 +- src/app/commands/cmd_palette_editor.cpp | 2 +- src/app/commands/cmd_remove_frame_tag.cpp | 1 - src/app/commands/cmd_sprite_properties.cpp | 2 +- src/app/commands/cmd_sprite_size.cpp | 4 +- .../filters/convolution_matrix_stock.cpp | 3 +- src/app/document_exporter.cpp | 2 +- src/app/document_range_ops.cpp | 4 +- src/app/file/ase_format.cpp | 1 + src/app/file/fli/fli.cpp | 18 ++--- src/app/file/fli_format.cpp | 2 + src/app/file/tga_format.cpp | 10 +-- src/app/ini_file_tests.cpp | 12 +-- src/app/ui/editor/standby_state.cpp | 2 - src/app/ui/file_selector.cpp | 5 +- src/app/ui/news_listbox.cpp | 6 +- src/app/ui/tabs.cpp | 16 ---- src/app/util/autocrop.cpp | 2 +- src/app/util/autocrop.h | 4 +- src/app/util/pic_file.cpp | 3 +- src/base/convert_to.cpp | 4 +- src/base/file_handle_tests.cpp | 26 ++++--- src/base/memory.cpp | 11 ++- src/doc/algo.cpp | 5 +- src/doc/algorithm/rotate.cpp | 2 +- src/doc/cels_range.h | 1 - src/doc/frame_tag.cpp | 2 +- src/doc/image_iterator.h | 10 +-- src/doc/mask.cpp | 5 +- src/gfx/region.cpp | 6 +- src/she/win/clipboard.cpp | 4 - src/ui/clipboard_win.h | 8 +- src/ui/grid_ui_tests.cpp | 2 +- src/ui/scroll_bar.cpp | 4 +- third_party/giflib/lib/dgif_lib.c | 43 ++++++----- third_party/giflib/lib/egif_lib.c | 73 ++++++++++--------- third_party/giflib/lib/quantize.c | 16 ++-- 37 files changed, 152 insertions(+), 171 deletions(-) diff --git a/src/app/color.cpp b/src/app/color.cpp index c34ad3c11..8ce03c946 100644 --- a/src/app/color.cpp +++ b/src/app/color.cpp @@ -119,7 +119,7 @@ Color Color::fromString(const std::string& str) if (str.find("rgb{") == 0 || str.find("hsv{") == 0) { int c = 0, table[3] = { 0, 0, 0 }; - int i = 4, j; + std::string::size_type i = 4, j; while ((j = str.find_first_of(",}", i)) != std::string::npos) { std::string element = str.substr(i, j - i); diff --git a/src/app/commands/cmd_palette_editor.cpp b/src/app/commands/cmd_palette_editor.cpp index ff4eee0f3..4762cde46 100644 --- a/src/app/commands/cmd_palette_editor.cpp +++ b/src/app/commands/cmd_palette_editor.cpp @@ -354,7 +354,7 @@ void PaletteEntryEditor::setColor(const app::Color& color) else if (j-i+1 == i2-i) { m_entryLabel.setTextf(" Range: %d-%d", i, j); } - else if (i == entries.size()) { + else if (i == int(entries.size())) { m_entryLabel.setText(" No Entry"); } else { diff --git a/src/app/commands/cmd_remove_frame_tag.cpp b/src/app/commands/cmd_remove_frame_tag.cpp index 483cda1a9..7af58e49c 100644 --- a/src/app/commands/cmd_remove_frame_tag.cpp +++ b/src/app/commands/cmd_remove_frame_tag.cpp @@ -47,7 +47,6 @@ bool RemoveFrameTagCommand::onEnabled(Context* context) void RemoveFrameTagCommand::onExecute(Context* context) { ContextWriter writer(context); - Document* document(writer.document()); Sprite* sprite(writer.sprite()); frame_t frame = writer.frame(); diff --git a/src/app/commands/cmd_sprite_properties.cpp b/src/app/commands/cmd_sprite_properties.cpp index f509914df..1673500cb 100644 --- a/src/app/commands/cmd_sprite_properties.cpp +++ b/src/app/commands/cmd_sprite_properties.cpp @@ -137,7 +137,7 @@ void SpritePropertiesCommand::onExecute(Context* context) // If the transparent color index has changed, we update the // property in the sprite. int index = color_button->getColor().getIndex(); - if (index != sprite->transparentColor()) { + if (color_t(index) != sprite->transparentColor()) { Transaction transaction(writer.context(), "Set Transparent Color"); DocumentApi api = writer.document()->getApi(transaction); api.setSpriteTransparentColor(sprite, index); diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index b95e92b9b..b69f29c78 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -75,8 +75,10 @@ protected: DocumentApi api = m_writer.document()->getApi(transaction); int cels_count = 0; - for (Cel* cel : m_sprite->uniqueCels()) + for (Cel* cel : m_sprite->uniqueCels()) { // TODO add size() member function to CelsRange + (void)cel; ++cels_count; + } // For each cel... int progress = 0; diff --git a/src/app/commands/filters/convolution_matrix_stock.cpp b/src/app/commands/filters/convolution_matrix_stock.cpp index 7142c5055..087eaf42e 100644 --- a/src/app/commands/filters/convolution_matrix_stock.cpp +++ b/src/app/commands/filters/convolution_matrix_stock.cpp @@ -56,7 +56,7 @@ void ConvolutionMatrixStock::reloadStock() "convmatr.gen", "convmatr.def", NULL }; char *s, buf[256], leavings[4096]; - int i, c, x, y, w, h, div, bias; + int i, x, y, w, h, div, bias; SharedPtr matrix; std::string name; @@ -109,7 +109,6 @@ void ConvolutionMatrixStock::reloadStock() if (*buf != '{') break; - c = 0; div = 0; for (y=0; ysetColor(doc::rgba(r, g, b, 255)); tag->setName(name); + tag->setAniDir((AniDir)aniDir); frameTags->add(tag); } } diff --git a/src/app/file/fli/fli.cpp b/src/app/file/fli/fli.cpp index 9ce780722..aec4402f8 100644 --- a/src/app/file/fli/fli.cpp +++ b/src/app/file/fli/fli.cpp @@ -116,7 +116,7 @@ void fli_write_header(FILE *f, s_fli_header *fli_header) fli_write_short(f, fli_header->flags); /* 14 */ if (fli_header->magic == HEADER_FLI) { /* FLI saves speed in 1/70s */ - fli_write_short(f, fli_header->speed / 14); /* 16 */ + fli_write_short(f, (unsigned short)fli_header->speed / 14); /* 16 */ } else { if (fli_header->magic == HEADER_FLC) { /* FLC saves speed in 1/1000s */ @@ -375,8 +375,8 @@ int fli_write_color_2(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap } if (cnt_col>0) { num_packets++; - fli_write_char(f, cnt_skip); - fli_write_char(f, cnt_col); + fli_write_char(f, (unsigned char)cnt_skip); + fli_write_char(f, (unsigned char)cnt_col); while (cnt_col>0) { fli_write_char(f, cmap[col_start++]); fli_write_char(f, cmap[col_start++]); @@ -510,7 +510,7 @@ void fli_write_brun(FILE *f, s_fli_header *fli_header, unsigned char *framebuf) tc=0; } bc++; - fli_write_char(f, pc); + fli_write_char(f, (unsigned char)pc); fli_write_char(f, linebuf[xc]); t1=xc+pc; } else { @@ -533,7 +533,7 @@ void fli_write_brun(FILE *f, s_fli_header *fli_header, unsigned char *framebuf) } lineend=ftell(f); fseek(f, linepos, SEEK_SET); - fli_write_char(f, bc); + fli_write_char(f, (unsigned char)bc); fseek(f, lineend, SEEK_SET); } @@ -626,7 +626,7 @@ void fli_write_lc(FILE *f, s_fli_header *fli_header, unsigned char *old_framebuf while ((linebuf[xc]==old_linebuf[xc]) && (xcwidth) && (sc<255)) { xc++; sc++; } - fli_write_char(f, sc); + fli_write_char(f, (unsigned char)sc); cc=1; while ((linebuf[xc]==linebuf[xc+cc]) && ((xc+cc)width) && (cc<120)) { cc++; @@ -650,14 +650,14 @@ void fli_write_lc(FILE *f, s_fli_header *fli_header, unsigned char *old_framebuf tc++; } while ((tc<120) && (cc<9) && (sc<4) && ((xc+tc)width)); bc++; - fli_write_char(f, tc); + fli_write_char(f, (unsigned char)tc); fwrite(linebuf+xc, tc, 1, f); xc+=tc; } } lineend=ftell(f); fseek(f, linepos, SEEK_SET); - fli_write_char(f, bc); + fli_write_char(f, (unsigned char)bc); fseek(f, lineend, SEEK_SET); } @@ -719,7 +719,7 @@ void fli_read_lc_2(FILE *f, s_fli_header *fli_header, unsigned char *old_framebu xc+=ps << 1; } } - if (lpf) pos[xc]=lpn; + if (lpf) pos[xc]=(unsigned char)lpn; yc++; } } diff --git a/src/app/file/fli_format.cpp b/src/app/file/fli_format.cpp index 512c52ef6..54a5e51e1 100644 --- a/src/app/file/fli_format.cpp +++ b/src/app/file/fli_format.cpp @@ -69,7 +69,9 @@ bool FliFormat::onLoad(FileOp* fop) int c, w, h; frame_t frpos_in; frame_t frpos_out; +#ifdef USE_LINK int index = 0; // TODO this is used to create linked cels +#endif // Open the file to read in binary mode FileHandle f(open_file_with_exception(fop->filename, "rb")); diff --git a/src/app/file/tga_format.cpp b/src/app/file/tga_format.cpp index 4dacbff0c..519c95270 100644 --- a/src/app/file/tga_format.cpp +++ b/src/app/file/tga_format.cpp @@ -192,8 +192,8 @@ bool TgaFormat::onLoad(FileOp* fop) unsigned char image_id[256], image_palette[256][3], rgb[4]; unsigned char id_length, palette_type, image_type, palette_entry_size; unsigned char bpp, descriptor_bits; - short unsigned int first_color, palette_colors; - short unsigned int left, top, image_width, image_height; + short unsigned int palette_colors; + short unsigned int image_width, image_height; unsigned int c, i, x, y, yc; int compressed; @@ -202,11 +202,11 @@ bool TgaFormat::onLoad(FileOp* fop) id_length = fgetc(f); palette_type = fgetc(f); image_type = fgetc(f); - first_color = fgetw(f); + fgetw(f); // first_color palette_colors = fgetw(f); palette_entry_size = fgetc(f); - left = fgetw(f); - top = fgetw(f); + fgetw(f); // "left" field + fgetw(f); // "top" field image_width = fgetw(f); image_height = fgetw(f); bpp = fgetc(f); diff --git a/src/app/ini_file_tests.cpp b/src/app/ini_file_tests.cpp index 6dabbc685..3a4bb20bf 100644 --- a/src/app/ini_file_tests.cpp +++ b/src/app/ini_file_tests.cpp @@ -19,18 +19,18 @@ TEST(IniFile, Basic) set_config_file("_test.ini"); - EXPECT_EQ(false, get_config_bool("A", "a", false)); - EXPECT_EQ(true, get_config_bool("A", "b", true)); - EXPECT_EQ(0, get_config_bool("B", "a", 0)); - EXPECT_EQ(1, get_config_bool("B", "b", 1)); + EXPECT_FALSE(get_config_bool("A", "a", false)); + EXPECT_TRUE(get_config_bool("A", "b", true)); + EXPECT_FALSE(get_config_bool("B", "a", 0)); + EXPECT_TRUE(get_config_bool("B", "b", 1)); set_config_bool("A", "a", true); set_config_bool("A", "b", false); set_config_int("B", "a", 2); set_config_int("B", "b", 3); - EXPECT_EQ(true, get_config_bool("A", "a", false)); - EXPECT_EQ(false, get_config_bool("A", "b", true)); + EXPECT_TRUE(get_config_bool("A", "a", false)); + EXPECT_FALSE(get_config_bool("A", "b", true)); EXPECT_EQ(2, get_config_int("B", "a", 0)); EXPECT_EQ(3, get_config_int("B", "b", 1)); } diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index 77d4420f0..e55004f89 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -419,8 +419,6 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT base::UniquePtr tmpImage(NewImageFromMask(editor->getDocumentLocation())); gfx::Point origin = document->mask()->bounds().getOrigin(); int opacity = 255; - Sprite* sprite = editor->sprite(); - Layer* layer = editor->layer(); PixelsMovementPtr pixelsMovement( new PixelsMovement(UIContext::instance(), editor->getDocumentLocation(), diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp index e40772d44..f797b6d13 100644 --- a/src/app/ui/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -483,7 +483,6 @@ void FileSelector::updateLocation() IFileItem* fileItem = currentFolder; std::list locations; int selected_index = -1; - int newItem; while (fileItem != NULL) { locations.push_front(fileItem); @@ -518,8 +517,8 @@ void FileSelector::updateLocation() // Add paths from recent files list { - newItem = m_location->addItem(""); - newItem = m_location->addItem("-------- Recent Paths --------"); + m_location->addItem(""); + m_location->addItem("-------- Recent Paths --------"); RecentFiles::const_iterator it = App::instance()->getRecentFiles()->paths_begin(); RecentFiles::const_iterator end = App::instance()->getRecentFiles()->paths_end(); diff --git a/src/app/ui/news_listbox.cpp b/src/app/ui/news_listbox.cpp index 2cd8f4a3d..f2610d19b 100644 --- a/src/app/ui/news_listbox.cpp +++ b/src/app/ui/news_listbox.cpp @@ -182,8 +182,8 @@ protected: }; NewsListBox::NewsListBox() - : m_loader(nullptr) - , m_timer(250, this) + : m_timer(250, this) + , m_loader(nullptr) { m_timer.Tick.connect(&NewsListBox::onTick, this); @@ -266,8 +266,6 @@ void NewsListBox::parseFile(const std::string& filename) TiXmlElement* titleXml = itemXml->FirstChildElement("title"); TiXmlElement* descXml = itemXml->FirstChildElement("description"); TiXmlElement* linkXml = itemXml->FirstChildElement("link"); - TiXmlElement* guidXml = itemXml->FirstChildElement("guid"); - TiXmlElement* pubDateXml = itemXml->FirstChildElement("pubDate"); std::string link = linkXml->GetText(); std::string title = titleXml->GetText(); diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp index 4bac0b3ab..5ff40b5e4 100644 --- a/src/app/ui/tabs.cpp +++ b/src/app/ui/tabs.cpp @@ -357,7 +357,6 @@ void Tabs::onPaint(PaintEvent& ev) int startX = m_border*guiscale(); double t = double(m_ani_t)/double(m_ani_T); - Tab* prevTab = nullptr; // For each tab... int i = 0; @@ -375,7 +374,6 @@ void Tabs::onPaint(PaintEvent& ev) drawTab(g, box, tab, 0, (tab == m_hot), false); box.x = box.x2(); - prevTab = tab; ++i; } @@ -449,8 +447,6 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int dy, box.w = ui::guiscale()*8; SkinTheme* theme = static_cast(this->getTheme()); - gfx::Color text_color; - gfx::Color face_color; int clipTextRightSide; gfx::Rect closeBox = getTabCloseButtonBounds(tab, box); @@ -461,17 +457,6 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int dy, clipTextRightSide = closeBox.w; } - // Selected - if (selected) { - text_color = theme->colors.tabActiveText(); - face_color = theme->colors.tabActiveFace(); - } - // Non-selected - else { - text_color = theme->colors.tabNormalText(); - face_color = theme->colors.tabNormalFace(); - } - skin::Style::State state; if (selected) state += skin::Style::active(); if (hover) state += skin::Style::hover(); @@ -590,7 +575,6 @@ void Tabs::calculateHot() if (m_isDragging) return; - SkinTheme* theme = static_cast(this->getTheme()); gfx::Rect rect = getBounds(); gfx::Rect box(rect.x+m_border*guiscale(), rect.y, 0, rect.h-1); gfx::Point mousePos = ui::get_mouse_position(); diff --git a/src/app/util/autocrop.cpp b/src/app/util/autocrop.cpp index 6b39f4a85..85e6a8f97 100644 --- a/src/app/util/autocrop.cpp +++ b/src/app/util/autocrop.cpp @@ -19,7 +19,7 @@ namespace app { using namespace doc; bool get_shrink_rect(int *x1, int *y1, int *x2, int *y2, - Image *image, int refpixel) + Image *image, color_t refpixel) { #define SHRINK_SIDE(u_begin, u_op, u_final, u_add, \ v_begin, v_op, v_final, v_add, U, V, var) \ diff --git a/src/app/util/autocrop.h b/src/app/util/autocrop.h index 8ddf94e2c..e60960aa6 100644 --- a/src/app/util/autocrop.h +++ b/src/app/util/autocrop.h @@ -9,6 +9,8 @@ #define APP_UTIL_AUTOCROP_H_INCLUDED #pragma once +#include "doc/color.h" + namespace doc { class Image; } @@ -16,7 +18,7 @@ namespace doc { namespace app { bool get_shrink_rect(int* x1, int* y1, int* x2, int* y2, - doc::Image *image, int refpixel); + doc::Image *image, doc::color_t refpixel); bool get_shrink_rect2(int* x1, int* y1, int* x2, int* y2, doc::Image* image, doc::Image* regimage); diff --git a/src/app/util/pic_file.cpp b/src/app/util/pic_file.cpp index 93e257df5..4c82d3898 100644 --- a/src/app/util/pic_file.cpp +++ b/src/app/util/pic_file.cpp @@ -28,7 +28,6 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette) { base::UniquePtr image; int size, compression; - int image_size; int block_size; int block_type; int version; @@ -51,7 +50,7 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette) *y = ((short)base::fgetw(f)); // Y offset bpp = std::fgetc(f); // bits per pixel (must be 8) compression = std::fgetc(f); // compression flag (must be 0) - image_size = base::fgetl(f); // image size (in bytes) + base::fgetl(f); // image size (in bytes) std::fgetc(f); // reserved if (bpp != 8 || compression != 0) { diff --git a/src/base/convert_to.cpp b/src/base/convert_to.cpp index c007736cc..68a53df11 100644 --- a/src/base/convert_to.cpp +++ b/src/base/convert_to.cpp @@ -71,8 +71,8 @@ template<> std::string convert_to(const Sha1& from) template<> Version convert_to(const std::string& from) { Version result; - int i = 0; - int j = 0; + std::string::size_type i = 0; + std::string::size_type j = 0; while (j != std::string::npos) { j = from.find('.', i); std::string digitString = from.substr(i, j - i); diff --git a/src/base/file_handle_tests.cpp b/src/base/file_handle_tests.cpp index 1c3775ccb..002ac37a4 100644 --- a/src/base/file_handle_tests.cpp +++ b/src/base/file_handle_tests.cpp @@ -12,16 +12,18 @@ #include -#ifdef _WIN32 -#include -#else -#include -#endif - using namespace base; #ifdef _MSC_VER -#pragma warning (disable: 4996) + #define posix_open _open + #define posix_close _close + #define posix_read _read + #define posix_write _write +#else + #define posix_open open + #define posix_close close + #define posix_read read + #define posix_write write #endif TEST(FileHandle, Descriptors) @@ -37,23 +39,23 @@ TEST(FileHandle, Descriptors) // Create file. ASSERT_NO_THROW({ int fd = open_file_descriptor_with_exception(fn, "wb"); - close(fd); + posix_close(fd); }); // Truncate file. ASSERT_NO_THROW({ int fd = open_file_descriptor_with_exception(fn, "wb"); - EXPECT_EQ(6, write(fd, "hello", 6)); - close(fd); + EXPECT_EQ(6, posix_write(fd, "hello", 6)); + posix_close(fd); }); // Read. ASSERT_NO_THROW({ int fd = open_file_descriptor_with_exception(fn, "rb"); std::vector buf(6); - EXPECT_EQ(6, read(fd, &buf[0], 6)); + EXPECT_EQ(6, posix_read(fd, &buf[0], 6)); EXPECT_EQ("hello", std::string(&buf[0])); - close(fd); + posix_close(fd); }); ASSERT_NO_THROW({ diff --git a/src/base/memory.cpp b/src/base/memory.cpp index c922a921d..882bb50ba 100644 --- a/src/base/memory.cpp +++ b/src/base/memory.cpp @@ -1,5 +1,5 @@ // Aseprite Base Library -// Copyright (c) 2001-2014 David Capello +// Copyright (c) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -16,11 +16,6 @@ #include "base/mutex.h" #include "base/scoped_lock.h" -// It is used so MSVC doesn't complain about deprecated POSIX names. -#ifdef _MSC_VER -#pragma warning(disable:4996) -#endif - using namespace std; #if !defined MEMLEAK // Without leak detection @@ -52,7 +47,11 @@ void base_free(void* mem) char* base_strdup(const char* string) { assert(string != NULL); +#ifdef _MSC_VER + return _strdup(string); +#else return strdup(string); +#endif } #else // With leak detection diff --git a/src/doc/algo.cpp b/src/doc/algo.cpp index fc4d97e02..d4ef8dda2 100644 --- a/src/doc/algo.cpp +++ b/src/doc/algo.cpp @@ -523,9 +523,8 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double in_x) { + double out_x, old_x, old_dx, old_dy; int npts; - double out_x, old_dx, old_x; - double out_y, old_dy; /* Derivatives of x(t) and y(t). */ double x, dx, ddx, dddx; @@ -572,7 +571,6 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1, y = y0; out_x = x0; - out_y = y0; old_x = x0; old_dx = dx; @@ -589,7 +587,6 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1, y += dy; out_x = x; - out_y = y; if (out_x > in_x) { dx = old_dx + (dx-old_dx) * (in_x-old_x) / (out_x-old_x); dy = old_dy + (dy-old_dy) * (in_x-old_x) / (out_x-old_x); diff --git a/src/doc/algorithm/rotate.cpp b/src/doc/algorithm/rotate.cpp index 4f9df7d89..2682f148d 100644 --- a/src/doc/algorithm/rotate.cpp +++ b/src/doc/algorithm/rotate.cpp @@ -233,7 +233,7 @@ public: void feedLine(Image* spr, int spr_x, int spr_y) { ASSERT(m_it != m_end); - int c = spr->getPixel(spr_x, spr_y); + color_t c = spr->getPixel(spr_x, spr_y); if (c != m_mask_color) *m_it = c; ++m_it; diff --git a/src/doc/cels_range.h b/src/doc/cels_range.h index 3644090a9..d14e20ba0 100644 --- a/src/doc/cels_range.h +++ b/src/doc/cels_range.h @@ -58,7 +58,6 @@ namespace doc { private: iterator m_begin, m_end; - Flags m_flags; }; } // namespace doc diff --git a/src/doc/frame_tag.cpp b/src/doc/frame_tag.cpp index 71ce50e4a..0dda32285 100644 --- a/src/doc/frame_tag.cpp +++ b/src/doc/frame_tag.cpp @@ -16,8 +16,8 @@ FrameTag::FrameTag(frame_t from, frame_t to) : Object(ObjectType::FrameTag) , m_from(from) , m_to(to) - , m_name("Tag") , m_color(rgba(0, 0, 0, 255)) + , m_name("Tag") { } diff --git a/src/doc/image_iterator.h b/src/doc/image_iterator.h index b525dd80f..dafec7eab 100644 --- a/src/doc/image_iterator.h +++ b/src/doc/image_iterator.h @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2001-2014 David Capello +// Copyright (c) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -209,7 +209,7 @@ namespace doc { } bool operator==(int b) const { - return (color_t(*this) == b); + return (color_t(*this) == color_t(b)); } bool operator==(color_t b) const { @@ -221,7 +221,7 @@ namespace doc { } bool operator!=(int b) const { - return (color_t(*this) != b); + return (color_t(*this) != color_t(b)); } bool operator!=(color_t b) const { @@ -241,7 +241,7 @@ namespace doc { }; inline bool operator==(int a, const BitPixelAccess& b) { - return (a == color_t(b)); + return (color_t(a) == color_t(b)); } inline bool operator==(color_t a, const BitPixelAccess& b) { @@ -249,7 +249,7 @@ namespace doc { } inline bool operator!=(int a, const BitPixelAccess& b) { - return (a != color_t(b)); + return (color_t(a) != color_t(b)); } inline bool operator!=(color_t a, const BitPixelAccess& b) { diff --git a/src/doc/mask.cpp b/src/doc/mask.cpp index 527f3b7e3..623136a03 100644 --- a/src/doc/mask.cpp +++ b/src/doc/mask.cpp @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2001-2014 David Capello +// Copyright (c) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -308,9 +308,10 @@ void Mask::crop(const Image *image) } int beg_x1, beg_y1, beg_x2, beg_y2; - int c, x1, y1, x2, y2, old_color; + int c, x1, y1, x2, y2; int done_count = 0; int done; + color_t old_color; if (!m_bitmap) return; diff --git a/src/gfx/region.cpp b/src/gfx/region.cpp index bf8ed87c0..10e72153f 100644 --- a/src/gfx/region.cpp +++ b/src/gfx/region.cpp @@ -153,9 +153,9 @@ bool Region::contains(const PointT& pt) const Region::Overlap Region::contains(const Rect& rect) const { static_assert( - Out == PIXMAN_REGION_OUT && - In == PIXMAN_REGION_IN && - Part == PIXMAN_REGION_PART, "Pixman constants have changed"); + int(Out) == int(PIXMAN_REGION_OUT) && + int(In) == int(PIXMAN_REGION_IN) && + int(Part) == int(PIXMAN_REGION_PART), "Pixman constants have changed"); pixman_box32 box = { rect.x, rect.y, rect.x2(), rect.y2() }; return (Region::Overlap)pixman_region32_contains_rectangle(&m_region, &box); diff --git a/src/she/win/clipboard.cpp b/src/she/win/clipboard.cpp index 0e087639c..6a9d488bd 100644 --- a/src/she/win/clipboard.cpp +++ b/src/she/win/clipboard.cpp @@ -14,10 +14,6 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4996) // To avoid MSVC warning about std::copy() with unsafe arguments -#endif - namespace she { void ClipboardWin32::dispose() diff --git a/src/ui/clipboard_win.h b/src/ui/clipboard_win.h index 57c2574e9..696f0680e 100644 --- a/src/ui/clipboard_win.h +++ b/src/ui/clipboard_win.h @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2001-2014 David Capello +// Copyright (C) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -9,12 +9,8 @@ #include #include -#ifdef _MSC_VER -#pragma warning(disable:4996) // To void MSVC warning about std::copy() with unsafe arguments -#endif - namespace { - + void get_system_clipboard_text(std::string& text) { if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { diff --git a/src/ui/grid_ui_tests.cpp b/src/ui/grid_ui_tests.cpp index 9b3da1844..bb62f2eba 100644 --- a/src/ui/grid_ui_tests.cpp +++ b/src/ui/grid_ui_tests.cpp @@ -117,7 +117,7 @@ TEST(JGrid, SameWidth2x1Grid) // // 2 (separator) // _|_ -// / \ +// | | // 10 2 0 2 10 // +---+-------+ // | 1 | 2 | 10 diff --git a/src/ui/scroll_bar.cpp b/src/ui/scroll_bar.cpp index ee9e06207..4b87b3159 100644 --- a/src/ui/scroll_bar.cpp +++ b/src/ui/scroll_bar.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2001-2013 David Capello +// Copyright (C) 2001-2013, 2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -138,10 +138,8 @@ bool ScrollBar::onProcessMessage(Message* msg) gfx::Point mousePos = static_cast(msg)->position(); View* view = static_cast(getParent()); int pos, len, bar_size, viewport_size; - int old_pos; getScrollBarInfo(&pos, &len, &bar_size, &viewport_size); - old_pos = pos; if (bar_size > len) { Point scroll = view->getViewScroll(); diff --git a/third_party/giflib/lib/dgif_lib.c b/third_party/giflib/lib/dgif_lib.c index 331d88a53..e2eb8271f 100644 --- a/third_party/giflib/lib/dgif_lib.c +++ b/third_party/giflib/lib/dgif_lib.c @@ -12,15 +12,20 @@ two modules will be linked. Preserve this property! #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #ifdef _WIN32 -#include -#endif /* _WIN32 */ + #include + #define posix_open _open + #define posix_close _close + #define posix_fdopen _fdopen +#else + #include + #define posix_open open + #define posix_close close + #define posix_fdopen fdopen +#endif #include "gif_lib.h" #include "gif_lib_private.h" @@ -54,7 +59,7 @@ DGifOpenFileName(const char *FileName, int *Error) int FileHandle; GifFileType *GifFile; - if ((FileHandle = open(FileName, O_RDONLY)) == -1) { + if ((FileHandle = posix_open(FileName, O_RDONLY)) == -1) { if (Error != NULL) *Error = D_GIF_ERR_OPEN_FAILED; return NULL; @@ -81,7 +86,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) if (GifFile == NULL) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; - (void)close(FileHandle); + posix_close(FileHandle); return NULL; } @@ -95,7 +100,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) if (Private == NULL) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; - (void)close(FileHandle); + posix_close(FileHandle); free((char *)GifFile); return NULL; } @@ -103,7 +108,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif /* _WIN32 */ - f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ + f = posix_fdopen(FileHandle, "rb"); /* Make it into a stream: */ /*@-mustfreeonly@*/ GifFile->Private = (void *)Private; @@ -256,7 +261,7 @@ DGifGetScreenDesc(GifFileType *GifFile) SortFlag = (Buf[0] & 0x08) != 0; BitsPerPixel = (Buf[0] & 0x07) + 1; GifFile->SBackGroundColor = Buf[1]; - GifFile->AspectByte = Buf[2]; + GifFile->AspectByte = Buf[2]; if (Buf[0] & 0x80) { /* Do we have global color map? */ int i; @@ -373,7 +378,7 @@ DGifGetImageDesc(GifFileType *GifFile) } /* Get the image local color map: */ - for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) { + for (i = 0; i < (unsigned int)GifFile->Image.ColorMap->ColorCount; i++) { if (READ(GifFile, Buf, 3) != 3) { GifFreeMapObject(GifFile->Image.ColorMap); GifFile->Error = D_GIF_ERR_READ_FAILED; @@ -983,7 +988,7 @@ DGifDecompressInput(GifFileType *GifFile, int *Code) GifFile->Error = D_GIF_ERR_IMAGE_DEFECT; return GIF_ERROR; } - + while (Private->CrntShiftState < Private->RunningBits) { /* Needs to get more bytes from input stream for next code: */ if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) { @@ -1096,19 +1101,19 @@ DGifSlurp(GifFileType *GifFile) if (sp->ImageDesc.Interlace) { int i, j; - /* - * The way an interlaced image should be read - + /* + * The way an interlaced image should be read - * offsets and jumps... */ int InterlacedOffset[] = { 0, 4, 2, 1 }; int InterlacedJumps[] = { 8, 8, 4, 2 }; /* Need to perform 4 passes on the image */ for (i = 0; i < 4; i++) - for (j = InterlacedOffset[i]; + for (j = InterlacedOffset[i]; j < sp->ImageDesc.Height; j += InterlacedJumps[i]) { - if (DGifGetLine(GifFile, - sp->RasterBits+j*sp->ImageDesc.Width, + if (DGifGetLine(GifFile, + sp->RasterBits+j*sp->ImageDesc.Width, sp->ImageDesc.Width) == GIF_ERROR) return GIF_ERROR; } @@ -1133,7 +1138,7 @@ DGifSlurp(GifFileType *GifFile) /* Create an extension block with our data */ if (ExtData != NULL) { if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount, - &GifFile->ExtensionBlocks, + &GifFile->ExtensionBlocks, ExtFunction, ExtData[0], &ExtData[1]) == GIF_ERROR) return (GIF_ERROR); @@ -1145,7 +1150,7 @@ DGifSlurp(GifFileType *GifFile) if (ExtData != NULL) if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount, &GifFile->ExtensionBlocks, - CONTINUE_EXT_FUNC_CODE, + CONTINUE_EXT_FUNC_CODE, ExtData[0], &ExtData[1]) == GIF_ERROR) return (GIF_ERROR); } diff --git a/third_party/giflib/lib/egif_lib.c b/third_party/giflib/lib/egif_lib.c index e909311eb..bf77cc1e5 100644 --- a/third_party/giflib/lib/egif_lib.c +++ b/third_party/giflib/lib/egif_lib.c @@ -8,9 +8,6 @@ two modules will be linked. Preserve this property! *****************************************************************************/ -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #include @@ -18,10 +15,17 @@ two modules will be linked. Preserve this property! #include #ifdef _WIN32 -#include + #include + #define posix_open _open + #define posix_close _close + #define posix_fdopen _fdopen #else -#include -#endif /* _WIN32 */ + #include + #include + #define posix_open open + #define posix_close close + #define posix_fdopen fdopen +#endif #include #include "gif_lib.h" @@ -37,8 +41,8 @@ static const GifPixelType CodeMask[] = { static int EGifPutWord(int Word, GifFileType * GifFile); static int EGifSetupCompress(GifFileType * GifFile); static int EGifCompressLine(GifFileType * GifFile, GifPixelType * Line, - int LineLen); -static int EGifCompressOutput(GifFileType * GifFile, int Code); + const int LineLen); +static int EGifCompressOutput(GifFileType * GifFile, const int Code); static int EGifBufferedOutput(GifFileType * GifFile, GifByteType * Buf, int c); @@ -60,11 +64,11 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error) GifFileType *GifFile; if (TestExistence) - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL, - S_IREAD | S_IWRITE); + FileHandle = posix_open(FileName, O_WRONLY | O_CREAT | O_EXCL, + S_IREAD | S_IWRITE); else - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC, - S_IREAD | S_IWRITE); + FileHandle = posix_open(FileName, O_WRONLY | O_CREAT | O_TRUNC, + S_IREAD | S_IWRITE); if (FileHandle == -1) { if (Error != NULL) @@ -73,7 +77,7 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error) } GifFile = EGifOpenFileHandle(FileHandle, Error); if (GifFile == (GifFileType *) NULL) - (void)close(FileHandle); + (void)posix_close(FileHandle); return GifFile; } @@ -117,7 +121,7 @@ EGifOpenFileHandle(const int FileHandle, int *Error) _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif /* _WIN32 */ - f = fdopen(FileHandle, "wb"); /* Make it into a stream: */ + f = posix_fdopen(FileHandle, "wb"); /* Make it into a stream: */ GifFile->Private = (void *)Private; Private->FileHandle = FileHandle; @@ -192,7 +196,7 @@ EGifGetGifVersion(GifFileType *GifFile) GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; int i, j; - /* + /* * Bulletproofing - always write GIF89 if we need to. * Note, we don't clear the gif89 flag here because * users of the sequential API might have called EGifSetGifVersion() @@ -219,7 +223,7 @@ EGifGetGifVersion(GifFileType *GifFile) || function == APPLICATION_EXT_FUNC_CODE) Private->gif89 = true; } - + if (Private->gif89) return GIF89_STAMP; else @@ -228,7 +232,7 @@ EGifGetGifVersion(GifFileType *GifFile) /****************************************************************************** Set the GIF version. In the extremely unlikely event that there is ever - another version, replace the bool argument with an enum in which the + another version, replace the bool argument with an enum in which the GIF87 value is 0 (numerically the same as bool false) and the GIF89 value is 1 (numerically the same as bool true). That way we'll even preserve object-file compatibility! @@ -243,7 +247,7 @@ void EGifSetGifVersion(GifFileType *GifFile, const bool gif89) /****************************************************************************** All writes to the GIF should go through this. ******************************************************************************/ -static int InternalWrite(GifFileType *GifFileOut, +static int InternalWrite(GifFileType *GifFileOut, const unsigned char *buf, size_t len) { GifFilePrivateType *Private = (GifFilePrivateType*)GifFileOut->Private; @@ -471,8 +475,9 @@ EGifPutLine(GifFileType * GifFile, GifPixelType *Line, int LineLen) Put one pixel (Pixel) into GIF file. ******************************************************************************/ int -EGifPutPixel(GifFileType *GifFile, GifPixelType Pixel) +EGifPutPixel(GifFileType *GifFile, const GifPixelType _Pixel) { + GifPixelType Pixel = _Pixel; GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; if (!IS_WRITEABLE(Private)) { @@ -563,7 +568,7 @@ EGifPutExtensionLeader(GifFileType *GifFile, const int ExtCode) Put extension block data (see GIF manual) into a GIF file. ******************************************************************************/ int -EGifPutExtensionBlock(GifFileType *GifFile, +EGifPutExtensionBlock(GifFileType *GifFile, const int ExtLen, const void *Extension) { @@ -662,7 +667,7 @@ size_t EGifGCBToExtension(const GraphicsControlBlock *GCB, Replace the Graphics Control Block for a saved image, if it exists. ******************************************************************************/ -int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB, +int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB, GifFileType *GifFile, int ImageIndex) { int i; @@ -710,7 +715,7 @@ EGifPutCode(GifFileType *GifFile, int CodeSize, const GifByteType *CodeBlock) } /* No need to dump code size as Compression set up does any for us: */ - /* + /* * Buf = CodeSize; * if (InternalWrite(GifFile, &Buf, 1) != 1) { * GifFile->Error = E_GIF_ERR_WRITE_FAILED; @@ -893,7 +898,7 @@ EGifCompressLine(GifFileType *GifFile, while (i < LineLen) { /* Decode LineLen items. */ Pixel = Line[i++]; /* Get next pixel from stream. */ - /* Form a new unique key to search hash table for the code combines + /* Form a new unique key to search hash table for the code combines * CrntCode as Prefix string with Pixel as postfix char. */ NewKey = (((uint32_t) CrntCode) << 8) + Pixel; @@ -1049,9 +1054,9 @@ EGifBufferedOutput(GifFileType *GifFile, ******************************************************************************/ static int -EGifWriteExtensions(GifFileType *GifFileOut, - ExtensionBlock *ExtensionBlocks, - int ExtensionBlockCount) +EGifWriteExtensions(GifFileType *GifFileOut, + ExtensionBlock *ExtensionBlocks, + int ExtensionBlockCount) { if (ExtensionBlocks) { ExtensionBlock *ep; @@ -1074,9 +1079,9 @@ EGifWriteExtensions(GifFileType *GifFileOut, } int -EGifSpew(GifFileType *GifFileOut) +EGifSpew(GifFileType *GifFileOut) { - int i, j; + int i, j; if (EGifPutScreenDesc(GifFileOut, GifFileOut->SWidth, @@ -1096,7 +1101,7 @@ EGifSpew(GifFileType *GifFileOut) if (sp->RasterBits == NULL) continue; - if (EGifWriteExtensions(GifFileOut, + if (EGifWriteExtensions(GifFileOut, sp->ExtensionBlocks, sp->ExtensionBlockCount) == GIF_ERROR) return (GIF_ERROR); @@ -1111,8 +1116,8 @@ EGifSpew(GifFileType *GifFileOut) return (GIF_ERROR); if (sp->ImageDesc.Interlace) { - /* - * The way an interlaced image should be written - + /* + * The way an interlaced image should be written - * offsets and jumps... */ int InterlacedOffset[] = { 0, 4, 2, 1 }; @@ -1120,11 +1125,11 @@ EGifSpew(GifFileType *GifFileOut) int k; /* Need to perform 4 passes on the images: */ for (k = 0; k < 4; k++) - for (j = InterlacedOffset[k]; + for (j = InterlacedOffset[k]; j < SavedHeight; j += InterlacedJumps[k]) { - if (EGifPutLine(GifFileOut, - sp->RasterBits + j * SavedWidth, + if (EGifPutLine(GifFileOut, + sp->RasterBits + j * SavedWidth, SavedWidth) == GIF_ERROR) return (GIF_ERROR); } diff --git a/third_party/giflib/lib/quantize.c b/third_party/giflib/lib/quantize.c index e5d4a5906..56ab2924a 100644 --- a/third_party/giflib/lib/quantize.c +++ b/third_party/giflib/lib/quantize.c @@ -129,7 +129,7 @@ GifQuantizeBuffer(unsigned int Width, free((char *)ColorArrayEntries); return GIF_ERROR; } - if (NewColorMapSize < *ColorMapSize) { + if ((int)NewColorMapSize < *ColorMapSize) { /* And clear rest of color map: */ for (i = NewColorMapSize; i < *ColorMapSize; i++) OutputColorMap[i].Red = OutputColorMap[i].Green = @@ -138,7 +138,7 @@ GifQuantizeBuffer(unsigned int Width, /* Average the colors in each entry to be the color to be used in the * output color map, and plug it into the output color map itself. */ - for (i = 0; i < NewColorMapSize; i++) { + for (i = 0; i < (int)NewColorMapSize; i++) { if ((j = NewColorSubdiv[i].NumEntries) > 0) { QuantizedColor = NewColorSubdiv[i].QuantizedColors; Red = Green = Blue = 0; @@ -149,9 +149,9 @@ GifQuantizeBuffer(unsigned int Width, Blue += QuantizedColor->RGB[2]; QuantizedColor = QuantizedColor->Pnext; } - OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j; - OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j; - OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j; + OutputColorMap[i].Red = (GifByteType)((Red << (8 - BITS_PER_PRIM_COLOR)) / j); + OutputColorMap[i].Green = (GifByteType)((Green << (8 - BITS_PER_PRIM_COLOR)) / j); + OutputColorMap[i].Blue = (GifByteType)((Blue << (8 - BITS_PER_PRIM_COLOR)) / j); } } @@ -225,7 +225,7 @@ SubdivColorMap(NewColorMapType * NewColorSubdiv, /* Sort all elements in that entry along the given axis and split at * the median. */ SortArray = (QuantizedColorType **)malloc( - sizeof(QuantizedColorType *) * + sizeof(QuantizedColorType *) * NewColorSubdiv[Index].NumEntries); if (SortArray == NULL) return GIF_ERROR; @@ -235,14 +235,14 @@ SubdivColorMap(NewColorMapType * NewColorSubdiv, SortArray[j] = QuantizedColor; /* - * Because qsort isn't stable, this can produce differing + * Because qsort isn't stable, this can produce differing * results for the order of tuples depending on platform * details of how qsort() is implemented. * * We mitigate this problem by sorting on all three axes rather * than only the one specied by SortRGBAxis; that way the instability * can only become an issue if there are multiple color indices - * referring to identical RGB tuples. Older versions of this + * referring to identical RGB tuples. Older versions of this * sorted on only the one axis. */ qsort(SortArray, NewColorSubdiv[Index].NumEntries,