From d90e046851b2097f6b0f6289d81a0246a36fceb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 23 Oct 1999 23:35:37 +0000 Subject: [PATCH] some changes to get fewer warnings when using strict ansi compilers git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@235 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 46 +++++++++++++++++++++++++++++++++++++++ Makefile.am | 3 ++- acinclude.m4 | 32 +++++---------------------- images/arrows.xbm | 6 ++--- images/bop.xbm | 2 +- images/brel.xbm | 2 +- images/dots.xbm | 2 +- images/greek.xbm | 4 ++-- images/misc.xbm | 2 +- images/varsz.xbm | 2 +- src/bmtable.C | 16 ++++++++------ src/bmtable.h | 2 +- src/mathed/math_panel.C | 4 ++-- src/mathed/math_panel.h | 2 +- src/mathed/math_symbols.C | 6 ++--- src/support/lyxstring.h | 17 ++++++++++----- 16 files changed, 91 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffed178dd2..2beac3fe65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,49 @@ +1999-10-24 Lars Gullik Bjønnes + + * src/support/lyxstring.h: comment out the three private + operators, when compiling with string ansi conforming compilers + they make problems. + + * src/mathed/math_symbols.C (AddBitmap): change 6th arg to be + unsigned char *. + (pixmapFromBitmapData): change type of bdata to be unsigned char * + (pixmapFromBitmapData): add a reinterpret_cast in the call to + XCreateImage + + * src/mathed/math_panel.h: change 6th arg to AddBitmap to be + unsigned char * + + * src/mathed/math_panel.C (create_math_panel): remove explicit + casts + + * src/bmtable.h: change last paramter to fl_set_bmtable_data to be + unsigned char *. + + * src/bmtable.C (struct BMTABLE_SPEC): make bdata unsigned char * + (draw_bitmaptable): add a reinterpret_cast to sp->bdata in the call + to XCreatePixmapFromBitmapData + (fl_set_bmtable_data): change the last argument to be unsigned + char * + (fl_set_bmtable_file): change bdata to unsinged char *, change bw + and bh to be unsigned int, remove explicit casts in call to + XReadBitmapFileData. + + * images/arrows.xbm: made the arrays unsigned char * + * images/varsz.xbm: ditto + * images/misc.xbm: ditto + * images/greek.xbm: ditto + * images/dots.xbm: ditto + * images/brel.xbm: ditto + * images/bop.xbm: ditto + + * Makefile.am (MAINTAINERCLEANFILES): added po/POTFILES.in + + * acinclude.m4 (LYX_GXX_STRENGHT_REDUCE): removed. + (LYX_PROG_CXX): added -pedantic to g++ compile options when + with-warnings, removed the __STRING_ANSI__ hack, seems to not be + needed. + (LYX_CXX_CHEADERS): added to the test. + 1999-10-23 Lars Gullik Bjønnes * src/lyx_cb.C (addNewlineAndDepth): changed to use string::append. diff --git a/Makefile.am b/Makefile.am index 795b8b2de9..31a18b010a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = foreign DISTCLEANFILES= *.orig *.rej *~ *.bak lyx.1 core -MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure development/lyx.spec +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure \ + development/lyx.spec po/POTFILES.in SUBDIRS = intl po src lib EXTRA_DIST = ANNOUNCE CHANGES INSTALL.OS2 INSTALL.autoconf README.OS2 \ diff --git a/acinclude.m4 b/acinclude.m4 index 6272722dc5..00a7fc73d9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -185,9 +185,7 @@ dnl Check the version of g++ CXXFLAGS="$lyx_opt" fi if test $with_warnings = yes ; then - CXXFLAGS="$CXXFLAGS -ansi -Wall" - # a small hack to avoid problems with headers - echo '#undef __STRICT_ANSI__' >>confdefs.h + CXXFLAGS="$CXXFLAGS -ansi -pedantic -Wall" fi else GXX= @@ -195,28 +193,6 @@ else fi ])dnl -dnl We do not use this one anymore. -dnl AC_DEFUN(LYX_GXX_STRENGTH_REDUCE,[ -dnl #check for the strength reduction bug of gcc -dnl if test x$GXX = xyes && test $cross_compiling = no ; then -dnl AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug, -dnl AC_TRY_RUN([ -dnl int main(void) { -dnl static int Array[[3]]; -dnl unsigned int B = 3; -dnl int i; -dnl for(i=0; i class k { }; AC_MSG_RESULT([$ac_partial_specialization]) ]) + dnl Usage: LYX_CXX_NAMESPACES : checks whether the C++ compiler dnl has a correct namespace handling and define CXX_WORKING_NAMESPACES dnl if true. This macro does not do a thourough test, but it should be @@ -413,11 +390,13 @@ if test $lyx_cv_cxx_namespace = yes ; then [Define if your C++ compiler has correct support for namespaces]) fi]) + dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler dnl provides wrappers for C headers and use our alternate version otherwise. AC_DEFUN(LYX_CXX_CHEADERS,[ AC_CACHE_CHECK(for C headers wrappers,lyx_cv_cxx_cheaders, [AC_TRY_CPP([ +#include #include #include #include @@ -657,6 +636,7 @@ AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [ ac_cv_target_system_type="$target" ]) + dnl We use this until autoconf fixes its version. AC_DEFUN(LYX_FUNC_SELECT_ARGTYPES, [AC_MSG_CHECKING([types of arguments for select()]) diff --git a/images/arrows.xbm b/images/arrows.xbm index e2661a0a08..e258322213 100644 --- a/images/arrows.xbm +++ b/images/arrows.xbm @@ -1,6 +1,6 @@ #define arrow_width 185 #define arrow_height 143 -static char arrow_bits[] = { +static unsigned char arrow_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -232,7 +232,7 @@ static char arrow_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe}; #define darrow_width 73 #define darrow_height 73 -static char darrow_bits[] = { +static unsigned char darrow_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00, @@ -284,7 +284,7 @@ static char darrow_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe}; #define larrow_width 103 #define larrow_height 126 -static char larrow_bits[] = { +static unsigned char larrow_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/images/bop.xbm b/images/bop.xbm index 06a47622a8..d4b43979f2 100644 --- a/images/bop.xbm +++ b/images/bop.xbm @@ -1,6 +1,6 @@ #define bop_width 118 #define bop_height 259 -static char bop_bits[] = { +static unsigned char bop_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0, diff --git a/images/brel.xbm b/images/brel.xbm index ea4d2617c1..b67d064ecd 100644 --- a/images/brel.xbm +++ b/images/brel.xbm @@ -1,6 +1,6 @@ #define brel_width 123 #define brel_height 291 -static char brel_bits[] = { +static unsigned char brel_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/images/dots.xbm b/images/dots.xbm index 38a2e6333d..a5520abbf0 100644 --- a/images/dots.xbm +++ b/images/dots.xbm @@ -1,6 +1,6 @@ #define dots_width 72 #define dots_height 18 -static char dots_bits[] = { +static unsigned char dots_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/images/greek.xbm b/images/greek.xbm index 2f18f9cbd0..ce4e98645a 100644 --- a/images/greek.xbm +++ b/images/greek.xbm @@ -1,6 +1,6 @@ #define Greek_width 182 #define Greek_height 60 -static char Greek_bits[] = { +static unsigned char Greek_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -96,7 +96,7 @@ static char Greek_bits[] = { }; #define greek_width 199 #define greek_height 132 -static char greek_bits[] = { +static unsigned char greek_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/images/misc.xbm b/images/misc.xbm index 12652a0479..ce861e978a 100644 --- a/images/misc.xbm +++ b/images/misc.xbm @@ -1,6 +1,6 @@ #define misc_width 150 #define misc_height 193 -static char misc_bits[] = { +static unsigned char misc_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/images/varsz.xbm b/images/varsz.xbm index 7c22870a44..7f6d55c170 100644 --- a/images/varsz.xbm +++ b/images/varsz.xbm @@ -1,6 +1,6 @@ #define varsz_width 110 #define varsz_height 192 -static char varsz_bits[] = { +static unsigned char varsz_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00, diff --git a/src/bmtable.C b/src/bmtable.C index bf0b0f9842..ffc064d2b3 100644 --- a/src/bmtable.C +++ b/src/bmtable.C @@ -24,7 +24,7 @@ typedef struct { int dx, dy; /* Size of each item */ int bx, by; /* Bitmap's position */ int bw, bh; /* Bitmap dimensions */ - char* bdata; /* Bitmap data */ + unsigned char * bdata; /* Bitmap data */ int maxi; /* Number of items */ int i; /* Current position */ int mousebut; /* mouse button pushed */ @@ -89,7 +89,8 @@ static void draw_bitmaptable(FL_OBJECT *ob) if (sp->bdata) { if (!sp->pix) { sp->pix = XCreatePixmapFromBitmapData(fl_display, fl_winget(), - sp->bdata, sp->bw, sp->bh, + reinterpret_cast(sp->bdata), + sp->bw, sp->bh, fl_get_flcolor(ob->lcol), fl_get_flcolor(ob->col1), DefaultDepth(fl_display, DefaultScreen(fl_display))); XFlush(fl_display); @@ -224,7 +225,7 @@ extern "C" int handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx, * The user could change these later. See below. */ void fl_set_bmtable_data(FL_OBJECT *ob, int nx, int ny, int bw, int bh, - char *bdata) + unsigned char * bdata) { BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec; if (sp) { @@ -285,11 +286,12 @@ void fl_set_bmtable_pixmap_data(FL_OBJECT *ob, int nx, int ny, void fl_set_bmtable_file(FL_OBJECT *ob, int nx, int ny, char const *filename) { - int bw, bh, xh, yh; - char *bdata; + int xh, yh; + unsigned int bw, bh; + unsigned char *bdata; - if(XReadBitmapFileData(filename, (unsigned int *) &bw, (unsigned int *) &bh, - (unsigned char **) &bdata, &xh, &yh)==BitmapSuccess) + if(XReadBitmapFileData(filename, &bw, &bh, + &bdata, &xh, &yh)==BitmapSuccess) fl_set_bmtable_data(ob, nx, ny, bw, bh, bdata); XFlush(fl_display); } diff --git a/src/bmtable.h b/src/bmtable.h index edb340d453..85e9fdb43c 100644 --- a/src/bmtable.h +++ b/src/bmtable.h @@ -47,7 +47,7 @@ int fl_get_bmtable_numb(FL_OBJECT *ob); void fl_set_bmtable(FL_OBJECT *, int pushed, int pos); /** Number of columns and rows, and the background bitmap */ -void fl_set_bmtable_data(FL_OBJECT *, int, int, int, int , char *); +void fl_set_bmtable_data(FL_OBJECT *, int, int, int, int , unsigned char *); /// void fl_set_bmtable_pixmap_data(FL_OBJECT *, int, int, char **); /// diff --git a/src/mathed/math_panel.C b/src/mathed/math_panel.C index 959de23252..7b9f4161d6 100644 --- a/src/mathed/math_panel.C +++ b/src/mathed/math_panel.C @@ -276,7 +276,7 @@ FD_panel *create_math_panel( ) fl_set_button(fd_delim->left, 1); fl_set_pixmap_data(fd_delim->pix, delim0); fl_set_bmtable_data(fd_delim->menu,6,4,delim_width,delim_height, - (char*)delim_bits); + delim_bits); fl_set_bmtable_maxitems(fd_delim->menu, 23); fl_set_pixmap_data(fd_panel->sqrt, sqrt); @@ -297,7 +297,7 @@ FD_panel *create_math_panel( ) fl_set_input_filter(fd_matrix->halign, align_filter); fl_set_bmtable_data(fd_deco->menu,3,3,deco_width,deco_height, - (char*)deco_bits); + deco_bits); fl_set_bmtable_maxitems(fd_deco->menu, 8); fd_delim->left->u_ldata = 0; diff --git a/src/mathed/math_panel.h b/src/mathed/math_panel.h index 64d4de183a..14553ba560 100644 --- a/src/mathed/math_panel.h +++ b/src/mathed/math_panel.h @@ -66,7 +66,7 @@ protected: /// FL_OBJECT* AddBitmap(int id, int nx, int ny, int bw, int bh, - char* data, Bool vert=True); // Why Bool? + unsigned char* data, Bool vert=True); // Why Bool? /// void Create(); /// diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index f3dfd3a451..c3a0bc56d3 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -180,7 +180,7 @@ void BitmapMenu::Show() { } FL_OBJECT* -BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, char* data, Bool vert) +BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* data, Bool vert) { if (i>=nb) return 0; @@ -457,7 +457,7 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) if (id>=0) break; } if (i<6 && id>=0) { - char *bdata = 0; + unsigned char *bdata = 0; int w = 0, h = 0, dw = 0, dh = 0; lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl; @@ -524,7 +524,7 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) int ww = w/dw, hh = h/dh, x, y; XImage *xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0, - bdata, w, h, 8, 0); + reinterpret_cast(bdata), w, h, 8, 0); xima->byte_order = LSBFirst; xima->bitmap_bit_order = LSBFirst; x = (id % dw)*ww; diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index 91df64af7b..9c6df4bdef 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -522,12 +522,17 @@ public: //@} private: - /// - lyxstring & operator+(int); - /// - lyxstring & operator=(int); - /// - lyxstring & operator+=(int); + // These three operators can be used to discover erronous use of + // ints and strings. However a conforming C++ compiler will flag + // a lot of char operations as abmbigous when they are compiled + // in. Use them for debugging only (or perhaps not even then.) + // Lgb. + // + //lyxstring & operator+(int); + // + //lyxstring & operator=(int); + // + //lyxstring & operator+=(int); /// Forward declaration of the string representation struct Srep;