[passepartout] fixed all warnings
- From: Sven Herzberg <herzi src gnome org>
- To: svn-commits-list gnome org
- Subject: [passepartout] fixed all warnings
- Date: Sun, 12 Apr 2009 14:21:24 -0400 (EDT)
commit 972956a7d52c02c989ba36b72a21a91c51fbbf58
Author: Sven Herzberg <herzi lanedo com>
Date: Sun Apr 12 16:31:17 2009 +0200
fixed all warnings
* src/fonts/fontmanager.cc: properly terminate the argument list
* src/fonts/freetype.cc: make sure the compiler knows that tmp cannot be unused
* src/pptout/Makefile.am,
* src/pptout/icons.c,
* src/pptout/icons.h: added C sources for the icons
* src/pptout/icons/broken.xpm,
* src/pptout/icons/missing.xpm,
* src/pptout/icons/wait.xpm: remove the static
* src/pptout/viewent.cc: use the new icons code
* src/ps/pdf.cc: don't return a reference
* src/ps/pfb2pfa.cc: properly initialize c
* src/ps/type42.cc,
* src/util/processman.cc,
* src/util/stringutil.cc,
* src/util/test_cmdline.cc: use const for constant strings
* src/util/test_stringutil.cc: fix the order of initialization
---
src/fonts/fontmanager.cc | 2 +-
src/fonts/freetype.cc | 3 ++-
src/pptout/Makefile.am | 10 ++++++++--
src/pptout/icons.c | 6 ++++++
src/pptout/icons.h | 14 ++++++++++++++
src/pptout/icons/broken.xpm | 2 +-
src/pptout/icons/missing.xpm | 2 +-
src/pptout/icons/wait.xpm | 2 +-
src/pptout/viewent.cc | 5 ++---
src/ps/pdf.cc | 2 +-
src/ps/pfb2pfa.cc | 2 +-
src/ps/type42.cc | 2 +-
src/util/processman.cc | 8 ++++----
src/util/stringutil.cc | 4 ++--
src/util/test_cmdline.cc | 34 ++++++++++++++++------------------
src/util/test_stringutil.cc | 2 +-
16 files changed, 62 insertions(+), 38 deletions(-)
diff --git a/src/fonts/fontmanager.cc b/src/fonts/fontmanager.cc
index 11b9aae..38ace6d 100644
--- a/src/fonts/fontmanager.cc
+++ b/src/fonts/fontmanager.cc
@@ -94,7 +94,7 @@ FontManager::FontManager() {
if(!FcInit())
throw std::runtime_error("Failed to initialize fontconfig");
FcPattern *pat = FcPatternCreate();
- FcObjectSet *os = FcObjectSetBuild(FC_FILE, 0);
+ FcObjectSet *os = FcObjectSetBuild(FC_FILE, NULL);
FcFontSet *fs = FcFontList(0, pat, os);
if(os)
FcObjectSetDestroy(os);
diff --git a/src/fonts/freetype.cc b/src/fonts/freetype.cc
index 3a6cce5..816abc9 100644
--- a/src/fonts/freetype.cc
+++ b/src/fonts/freetype.cc
@@ -6,6 +6,7 @@
#include "util/warning.h"
#include <cassert>
#include FT_TRUETYPE_TABLES_H
+#include <glib.h>
FT_Library font::FTMetrics::library = 0;
@@ -146,7 +147,7 @@ int font::FTMetrics::getBBox(int idx) const {
case 1: tmp = face->bbox.yMin; break;
case 2: tmp = face->bbox.xMax; break;
case 3: tmp = face->bbox.yMax; break;
- default: break;
+ default: g_assert_not_reached(); break;
}
// convert to postscript font units (em/1000)
return (1000 * tmp) / int(face->units_per_EM);
diff --git a/src/pptout/Makefile.am b/src/pptout/Makefile.am
index 6f2287f..7a25f05 100644
--- a/src/pptout/Makefile.am
+++ b/src/pptout/Makefile.am
@@ -4,7 +4,11 @@ EXTRA_DIST = NOTES
bin_PROGRAMS = passepartout
-dist_noinst_HEADERS = aboutdialog.h config.h preferencesdialog.h \
+dist_noinst_HEADERS=\
+ aboutdialog.h \
+ config.h \
+ icons.h \
+ preferencesdialog.h \
docpropsdialog.h docview.h groupmeta.h imagemeta.h \
pagemeta.h inspiration.h metabase.h pagesel.h \
docmeta.h viewent.h groupviewent.h postscriptviewent.h \
@@ -18,7 +22,9 @@ BUILT_SOURCES=\
authors.cc \
$(NULL)
-passepartout_SOURCES = inspiration.cc streamdialog.cc pagesel.cc \
+passepartout_SOURCES=\
+ icons.c \
+ inspiration.cc streamdialog.cc pagesel.cc \
aboutdialog.cc docmeta.cc printdialog.cc viewent.cc \
groupviewent.cc postscriptviewent.cc pageviewent.cc \
rasterviewent.cc textviewent.cc docview.cc window.cc \
diff --git a/src/pptout/icons.c b/src/pptout/icons.c
new file mode 100644
index 0000000..ee9a354
--- /dev/null
+++ b/src/pptout/icons.c
@@ -0,0 +1,6 @@
+#include "icons.h"
+
+#include "icons/broken.xpm"
+#include "icons/missing.xpm"
+#include "icons/wait.xpm"
+
diff --git a/src/pptout/icons.h b/src/pptout/icons.h
new file mode 100644
index 0000000..7f1d5e9
--- /dev/null
+++ b/src/pptout/icons.h
@@ -0,0 +1,14 @@
+#ifndef ICONS_H
+#define ICONS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+extern char* broken_xpm[];
+extern char* missing_xpm[];
+extern char* wait_xpm[];
+
+G_END_DECLS
+
+#endif /* ICONS_H */
diff --git a/src/pptout/icons/broken.xpm b/src/pptout/icons/broken.xpm
index 70dd49a..023bf2e 100644
--- a/src/pptout/icons/broken.xpm
+++ b/src/pptout/icons/broken.xpm
@@ -1,5 +1,5 @@
/* XPM */
-static char * broken_xpm[] = {
+char * broken_xpm[] = {
/* width height num_colors chars_per_pixel */
"16 16 3 1",
/* colors */
diff --git a/src/pptout/icons/missing.xpm b/src/pptout/icons/missing.xpm
index 9b18c2a..94eee65 100644
--- a/src/pptout/icons/missing.xpm
+++ b/src/pptout/icons/missing.xpm
@@ -1,5 +1,5 @@
/* XPM */
-static char * missing_xpm[] = {
+char * missing_xpm[] = {
/* width height num_colors chars_per_pixel */
"16 16 2 1",
/* colors */
diff --git a/src/pptout/icons/wait.xpm b/src/pptout/icons/wait.xpm
index c46ec61..35406f0 100644
--- a/src/pptout/icons/wait.xpm
+++ b/src/pptout/icons/wait.xpm
@@ -1,5 +1,5 @@
/* XPM */
-static char * wait_xpm[] = {
+char * wait_xpm[] = {
/* width height num_colors chars_per_pixel */
"16 16 5 1",
/* colors */
diff --git a/src/pptout/viewent.cc b/src/pptout/viewent.cc
index efa4719..6b940ba 100644
--- a/src/pptout/viewent.cc
+++ b/src/pptout/viewent.cc
@@ -3,9 +3,8 @@
///
#include "viewent.h"
#include <gdkmm.h>
-#include "icons/broken.xpm"
-#include "icons/missing.xpm"
-#include "icons/wait.xpm"
+
+#include "icons.h"
namespace {
ArtVpathDash dash_style;
diff --git a/src/ps/pdf.cc b/src/ps/pdf.cc
index 95896e9..eb5ef1d 100644
--- a/src/ps/pdf.cc
+++ b/src/ps/pdf.cc
@@ -213,7 +213,7 @@ namespace PDF {
return name;
}
- const std::string& registerFont(PDF::Document::FontWithName fwn) {
+ const std::string registerFont(PDF::Document::FontWithName fwn) {
Dictionary::Ptr res = get(Resources::FONTS, "Font");
res->set_entry(fwn.second, fwn.first);
return fwn.second;
diff --git a/src/ps/pfb2pfa.cc b/src/ps/pfb2pfa.cc
index caf85dd..73a986b 100644
--- a/src/ps/pfb2pfa.cc
+++ b/src/ps/pfb2pfa.cc
@@ -29,7 +29,7 @@ void PS::pfb2pfa(std::istream &in, std::ostream &out,
if(blockstart == std::ostream::pos_type(-1)) blockstart = 0;
if(type == 1) { // ascii
- unsigned char c;
+ unsigned char c = 0;
for(long i = 0; i < length; i++) {
c = in.get();
if(c == '\r')
diff --git a/src/ps/type42.cc b/src/ps/type42.cc
index 378101d..e58c165 100644
--- a/src/ps/type42.cc
+++ b/src/ps/type42.cc
@@ -11,7 +11,7 @@
namespace {
// starts from 32, goes to 126
- char *ascii_encoding[] = {
+ char const *ascii_encoding[] = {
"space", "exclam", "quotedbl",
"numbersign", "dollar", "percent",
"ampersand", "quoteright", "parenleft",
diff --git a/src/util/processman.cc b/src/util/processman.cc
index 58a036d..f554e4b 100644
--- a/src/util/processman.cc
+++ b/src/util/processman.cc
@@ -38,13 +38,13 @@ ProcessRecord::ProcessRecord(const std::string& line)
tmp[command_line.length()] = 0;
/// \todo We shouldn't really need an extra sh (it's just for managing io
// redirects, which we should get rid of anyway) ...
- char *argv[4] = {"sh", "-c", tmp, 0};
+ char const *argv[4] = {"sh", "-c", tmp, 0};
assert(filedesc::move(STDIN_FILENO, ifiledes[0]) == 0);
assert(filedesc::move(STDOUT_FILENO, ofiledes[1]) == 0);
close(ifiledes[1]); close(ofiledes[0]);
/// \todo Close all file descriptors above 2!
- execve("/bin/sh", argv, environ);
+ execve("/bin/sh", const_cast<char* const*>(argv), environ);
delete[] tmp;
exit(127);
}
@@ -163,8 +163,8 @@ int ProcessManager::system(std::string command) {
if(pid == 0) {
char *tmp = new char[command.length() + 1];
command.copy(tmp, std::string::npos); tmp[command.length()] = 0;
- char *argv[4] = {"sh", "-c", tmp, 0};
- execve("/bin/sh", argv, environ);
+ char const *argv[4] = {"sh", "-c", tmp, 0};
+ execve("/bin/sh", const_cast<char* const*>(argv), environ);
delete[] tmp;
exit(127);
}
diff --git a/src/util/stringutil.cc b/src/util/stringutil.cc
index 55647c1..d2cae61 100644
--- a/src/util/stringutil.cc
+++ b/src/util/stringutil.cc
@@ -77,11 +77,11 @@ std::string to_roman(int num) {
throw std::runtime_error("The number " + tostr(num) + " could not "
"be converted to a roman numeral");
char symbols[] = "??mdclxvi"; char *sym_off = symbols;
- char *reps[] = {"", "2", "22", "222", "21", "1", "12", "122", "1222", "20"};
+ char const *reps[] = {"", "2", "22", "222", "21", "1", "12", "122", "1222", "20"};
std::string result;
int order = 1000;
for(int i = 3; i >= 0; i--) {
- char *rep = reps[num / order];
+ char const *rep = reps[num / order];
while(*rep) {result += sym_off[*rep - '0']; rep++;}
num %= order; order /= 10; sym_off++; sym_off++;
}
diff --git a/src/util/test_cmdline.cc b/src/util/test_cmdline.cc
index 9e3bd4d..086db80 100644
--- a/src/util/test_cmdline.cc
+++ b/src/util/test_cmdline.cc
@@ -4,7 +4,7 @@
#include "cmdline.h"
#include "testbed/testbed.hh"
-std::string join_strings(char **argv) {
+std::string join_strings(char const **argv) {
std::string tmp;
for(int i = 1; argv[i]; i++)
tmp += std::string(" ") + argv[i];
@@ -12,7 +12,7 @@ std::string join_strings(char **argv) {
}
struct TestCmdLine: public TestCase {
- TestCmdLine(char **argv, bool expect_failure = false)
+ TestCmdLine(char const **argv, bool expect_failure = false)
: TestCase("CmdLine '" + join_strings(argv) + "'"),
_argv(argv), _expect_failure(expect_failure)
{}
@@ -21,16 +21,14 @@ struct TestCmdLine: public TestCase {
int argc = 0;
for(; _argv[argc]; argc++);
// std::cerr << argc << std::endl;
- CmdLine cmdline(argc, _argv);
- const int p = cmdline.add_option(CmdLine::Option('p'));
- const int f =
- cmdline.add_option(CmdLine::Option('f', "foo",
- CmdLine::Option::REQ_PARAM));
- const int b =
- cmdline.add_option(CmdLine::Option('b', "bar",
- CmdLine::Option::OPT_PARAM));
- const int n = cmdline.add_option(CmdLine::Option('n', "nisse"));
- const int lisa = cmdline.add_option(CmdLine::Option(0, "lisa"));
+ CmdLine cmdline(argc, const_cast<char**>(_argv));
+ cmdline.add_option(CmdLine::Option('p'));
+ cmdline.add_option(CmdLine::Option('f', "foo",
+ CmdLine::Option::REQ_PARAM));
+ cmdline.add_option(CmdLine::Option('b', "bar",
+ CmdLine::Option::OPT_PARAM));
+ cmdline.add_option(CmdLine::Option('n', "nisse"));
+ cmdline.add_option(CmdLine::Option(0, "lisa"));
// using namespace std;
try {
CmdLine::ParsedOptions opts = cmdline.parse();
@@ -51,25 +49,25 @@ struct TestCmdLine: public TestCase {
}
}
- char **_argv;
+ char const **_argv;
bool _expect_failure;
};
namespace {
- char *a1[] = {"fooprog", "-pbn", "file", "-ffoo",
+ char const *a1[] = {"fooprog", "-pbn", "file", "-ffoo",
"-f", "foo", "--foo=foo",
"--", "-x", "--junk", 0};
TestCmdLine t1(a1);
- char *a2[] = {"fooprog", "-x", 0};
+ char const *a2[] = {"fooprog", "-x", 0};
TestCmdLine t2(a2, true);
- char *a3[] = {"fooprog", "--nisse", "--lisa", "--bar=bar", "--bar", 0};
+ char const *a3[] = {"fooprog", "--nisse", "--lisa", "--bar=bar", "--bar", 0};
TestCmdLine t3(a3);
- char *a4[] = {"fooprog", "--lisa=foo", 0};
+ char const *a4[] = {"fooprog", "--lisa=foo", 0};
TestCmdLine t4(a4, true);
- char *a5[] = {"fooprog", "--kurt", 0};
+ char const *a5[] = {"fooprog", "--kurt", 0};
TestCmdLine t5(a5, true);
}
diff --git a/src/util/test_stringutil.cc b/src/util/test_stringutil.cc
index b8c3b6b..1e66b36 100644
--- a/src/util/test_stringutil.cc
+++ b/src/util/test_stringutil.cc
@@ -51,8 +51,8 @@ public:
}
private:
- const std::string roman_;
const int num_;
+ const std::string roman_;
const bool expect_failure_;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]