From 365b6bf765a25e6cab087491fd2a5416499256ef Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 4 Mar 2009 18:20:11 +0100 Subject: fix const related warnings reported by gcc 4.3.3 (via Kapil Hari Paranjape) --- src/GsWidget.cxx | 16 ++++++---------- src/Postscript.H | 25 ++++++++++--------------- src/Postscript.cxx | 8 ++++---- src/flpsed.cxx | 10 +++++----- src/util.c | 2 +- src/util.h | 4 ++-- 6 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx index 79f1083..dbf7340 100644 --- a/src/GsWidget.cxx +++ b/src/GsWidget.cxx @@ -285,7 +285,8 @@ int GsWidget::fd_copy(int to, int from, size_t len) { } void GsWidget::exec_gs() { - char *argv[16]; + const char * const argv[] = {"gs", "-dSAFER", "-dQUIET", + "-sDEVICE=x11alpha", "-dNOPLATFONTS", "-dNOPAUSE", "-", NULL}; char gvenv[256]; int d_null = open("/dev/null", O_WRONLY); @@ -295,15 +296,10 @@ void GsWidget::exec_gs() { (int) fl_xid(window()), (int) offscreen); putenv(gvenv); - argv[0] = "gs"; - argv[1] = "-dSAFER"; - argv[2] = "-dQUIET"; - argv[3] = "-sDEVICE=x11alpha"; - argv[4] = "-dNOPLATFONTS"; - argv[5] = "-dNOPAUSE"; - argv[6] = "-"; - argv[7] = NULL; - execvp(argv[0], argv); + + // const cast is necessary because of execvp declaration, see: + // http://www.opengroup.org/onlinepubs/000095399/functions/exec.html + execvp(argv[0], const_cast(argv)); perror("exec"); fprintf(stderr, "Please install ghostscript and make sure 'gs' " "is in the PATH.\n"); diff --git a/src/Postscript.H b/src/Postscript.H index b598d54..06f1515 100644 --- a/src/Postscript.H +++ b/src/Postscript.H @@ -41,17 +41,12 @@ class PSWriter { protected: PSEditModel *pse; - char * pos_format; - - char * size_format; - - char * text_format; - - char * color_format; - - char * glyph_format; - - char * tag_format; + const char * pos_format; + const char * size_format; + const char * text_format; + const char * color_format; + const char * glyph_format; + const char * tag_format; void write_string(FILE *out, char *s); @@ -61,9 +56,9 @@ class PSWriter { int write_text(FILE *out, PSEditText *t); - virtual char *ps_header(); + virtual const char *ps_header(); - virtual char *ps_trailer(); + virtual const char *ps_trailer(); public: PSWriter(PSEditModel *p); @@ -74,9 +69,9 @@ class PSWriter { class PSLevel1Writer : public PSWriter { protected: - char *ps_header(); + const char *ps_header(); - char *ps_trailer(); + const char *ps_trailer(); public: PSLevel1Writer(PSEditModel *p); diff --git a/src/Postscript.cxx b/src/Postscript.cxx index 70a8991..532c2ee 100644 --- a/src/Postscript.cxx +++ b/src/Postscript.cxx @@ -362,17 +362,17 @@ int PSWriter::write_text(FILE *out, PSEditText *t) { return 0; } -char * PSWriter::ps_header() { +const char * PSWriter::ps_header() { return ""; } -char * PSWriter::ps_trailer() { +const char * PSWriter::ps_trailer() { return ""; } PSLevel1Writer::PSLevel1Writer(PSEditModel *p) : PSWriter(p) {}; -char * PSLevel1Writer::ps_header() { +const char * PSLevel1Writer::ps_header() { return "/PSEditWidgetPageCount 0 def\n" "/PSEditWidgetPC 0 def\n" @@ -387,6 +387,6 @@ char * PSLevel1Writer::ps_header() { "} ifelse\n"; } -char * PSLevel1Writer::ps_trailer() { +const char * PSLevel1Writer::ps_trailer() { return "grestore PSEditWidgetshowpage} def\n"; } diff --git a/src/flpsed.cxx b/src/flpsed.cxx index a00b9b4..deffd73 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -128,7 +128,7 @@ void page_sel_fill() { void open_file(char *file) { FILE *p; int status; - char *args[32]; + const char *args[5]; pid_t pid; char *dot = strrchr(file, '.'); @@ -139,7 +139,7 @@ void open_file(char *file) { args[2] = "-"; args[3] = NULL; - p = pexecvp("pdftops", args, &pid, "r"); + p = pexecvp("pdftops", const_cast(args), &pid, "r"); if (p) { psed_p->open_file(p); @@ -183,7 +183,7 @@ void export_pdf_cb() { char *file; FILE *p; int status; - char *args[32]; + const char *args[5]; pid_t pid; file = fl_file_chooser("Open File?", "*.pdf", NULL); @@ -195,7 +195,7 @@ void export_pdf_cb() { signal(SIGPIPE, SIG_IGN); - p = pexecvp("ps2pdf", args, &pid, "w"); + p = pexecvp("ps2pdf", const_cast(args), &pid, "w"); if (p) { psed_p->save(p); @@ -319,7 +319,7 @@ Fl_Choice *size_c; Fl_Button *color_b; static struct { - char *label; + const char *label; int size; } text_sizes[] = { {"8", 8}, diff --git a/src/util.c b/src/util.c index 48b09ca..8b18398 100644 --- a/src/util.c +++ b/src/util.c @@ -12,7 +12,7 @@ #include "util.h" FILE * -pexecvp(const char *file, char *const argv[], pid_t *pid, char *type) { +pexecvp(const char *file, char *const argv[], pid_t *pid, const char *type) { FILE *iop; int pdes[2]; diff --git a/src/util.h b/src/util.h index 7362139..1277a25 100644 --- a/src/util.h +++ b/src/util.h @@ -14,8 +14,8 @@ extern "C" { #endif - FILE * - pexecvp(const char *file, char *const argv[], pid_t *pid, char *type); + FILE * pexecvp(const char *file, char *const argv[], + pid_t *pid, const char *type); #ifdef __cplusplus } -- cgit v1.2.3