further mirtoconfification and cleanup
authormirabilos <t.glaser@tarent.de>
Fri, 19 Jul 2019 23:02:24 +0000 (01:02 +0200)
committermirabilos <mirabilos@evolvis.org>
Fri, 19 Jul 2019 23:02:24 +0000 (01:02 +0200)
13 files changed:
TODO
contrib/xmindpath/main.c
draw.c
image/imlib_loader.c
image/path.c
image/send.c
mgp.c
mgp.h
parse.c
print.c
scanner.l
x11.c
x11dummy.c

diff --git a/TODO b/TODO
index cd72dbb..88a689d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -170,7 +170,34 @@ draw.c: mgp.h
 globals.c: mgp.h ctlwords.c
 grammar.y: mgp.h
 image/dither.c: image/image.h
+image/imagetypes.c: image/image.h image/imagetypes.h
+image/imlib_loader.c: image/image.h
+image/misc.c: image/image.h
+image/new.c: image/image.h
+image/path.c: image/xloadimage.h
+image/reduce.c: image/image.h
+image/send.c: mgp.h
+image/value.c: image/image.h
+image/zoom.c: image/image.h
+mgp.c: mgp.h
+parse.c: mgp.h
+plist.c: mgp.h
+postscript.c: mgp.h
+print.c: mgp.h
+scanner.l: mgp.h y.tab.h
+unimap.c: mgp.h
+x11.c: mgp.h
+x11dummy.c: mgp.h
+
+image/xloadimage.h ← image/image.h
+mgp.h ← image/xloadimage.h ctlwords.h
 
 both time.h and sys/time.h
 HAVE_SETREUID setreuid setregid
+HAVE_ICONV iconv.h
+HAVE_FCNTL_H
+HAVE_LOCALE_H
 HAVE_STRING_H
+HAVE_SYS_WAIT_H
+HAVE_TERMIOS_H
+HAVE_UNISTD_H
index 2c55a55..38cb146 100644 (file)
@@ -308,7 +308,7 @@ daemonuid()
        if (uidswapped == 0)
                return;
 
-#ifdef HAVE_SETREUID
+#if HAVE_SETREUID
        setreuid(uid, euid);
        setregid(gid, egid);
 #else
@@ -326,7 +326,7 @@ useruid()
        if (uidswapped == 1)
                return;
 
-#ifdef HAVE_SETREUID
+#if HAVE_SETREUID
        setregid(egid, gid);
        setreuid(euid, uid);
 #else
diff --git a/draw.c b/draw.c
index 65f44f4..f205a15 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -4379,7 +4379,7 @@ xft_draw_fragment(state, p, len, registry, charset16)
        char buf16[1024], *p16;
        char out16[1024], *o16;
        size_t ileft, oleft;
-#ifdef HAVE_ICONV
+#if HAVE_ICONV
        static iconv_t icv[3];
 #endif
 
@@ -4398,7 +4398,7 @@ xft_draw_fragment(state, p, len, registry, charset16)
        if (!(xft_font = xft_setfont(fontname, char_size[caching], registry))) return NULL;
 
        if (charset16) {
-#ifdef HAVE_ICONV
+#if HAVE_ICONV
                for (i = 0; i < 3; i ++) {
                        if (!strncmp(registry, rtab[i], 3)) break;
                }
index d635547..edb2bbf 100644 (file)
@@ -84,25 +84,8 @@ Image *imLoad(char *fullname, char *name, unsigned int verbose)
                        *rgb_ptr++ = argb_data[i] & 0xFF;         /* blue */
                }
        }
-#if 0
-       /*
-        * bug fix for transparent gif handling
-        * suggested by Jose Geraldo Alves Brito Neto <jgabrito@iq.usp.br>
-        */
-       if ((shape.r >=0) && (shape.g >= 0) && (shape.b >= 0))
-         image->trans = \
-           ((shape.r & 0xff) << 16) |
-           ((shape.g & 0xff) <<  8) |
-           ((shape.b & 0xff) <<  0);
-#endif
-
        image->title = dupString(name);
-#if 0
-       Imlib_kill_image(id, im);
-#else
        regist_imdata(name, im, image);
-#endif
-
        return image;
 }
 
@@ -135,15 +118,10 @@ Pixmap pixmap_fromimimage(imimage, width, height, window)
        Window window;
 {
        static Pixmap pixmap;
-#if 0
-       Imlib_render(id, imimage, width, height);
-       pixmap = Imlib_move_image(id, imimage);
-#else
+
        imlib_context_set_image (imimage);
        imlib_context_set_drawable (window);
        imlib_render_pixmaps_for_whole_image_at_size(&pixmap, NULL, width, height);
-#endif
-
        return pixmap;
 }
 
index 531631b..db98309 100644 (file)
@@ -16,7 +16,7 @@
 #include <pwd.h>
 #endif
 #include <errno.h>
-#if 1 /* SYSV */
+#if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <stdlib.h>
@@ -133,9 +133,6 @@ void loadPathsAndExts()
     readPathsAndExts(buf);
     return; /* don't read system file if user has one */
   }
-#ifdef SYSPATHFILE
-  readPathsAndExts(SYSPATHFILE);
-#endif
 }
 
 static int fileIsOk(fullname, sbuf)
@@ -164,30 +161,15 @@ int findImage(name, fullname)
    */
   if (! stat(fullname, &sbuf))
       return(fileIsOk(fullname, &sbuf));
-#ifndef NO_COMPRESS
-  strcat(fullname, ".Z");
-  if (! stat(fullname, &sbuf))
-      return(fileIsOk(fullname, &sbuf));
-#endif
 
   for (p= 0; p < NumPaths; p++) {
     sprintf(fullname, "%s/%s", Paths[p], name);
     if (! stat(fullname, &sbuf))
       return(fileIsOk(fullname, &sbuf));
-#ifndef NO_COMPRESS
-    strcat(fullname, ".Z");
-    if (! stat(fullname, &sbuf))
-#endif
-      return(fileIsOk(fullname, &sbuf));
     for (e= 0; e < NumExts; e++) {
       sprintf(fullname, "%s/%s%s", Paths[p], name, Exts[e]);
       if (! stat(fullname, &sbuf))
        return(fileIsOk(fullname, &sbuf));
-#ifndef NO_COMPRESS
-      strcat(fullname, ".Z");
-      if (! stat(fullname, &sbuf))
-       return(fileIsOk(fullname, &sbuf));
-#endif
     }
   }
 
@@ -195,11 +177,6 @@ int findImage(name, fullname)
     sprintf(fullname, "%s%s", name, Exts[e]);
     if (! stat(fullname, &sbuf))
       return(fileIsOk(fullname, &sbuf));
-#ifndef NO_COMPRESS
-    strcat(fullname, ".Z");
-    if (! stat(fullname, &sbuf))
-      return(fileIsOk(fullname, &sbuf));
-#endif
   }
   errno= ENOENT; /* file not found */
   return(-1);
index b00b7a0..44daf65 100644 (file)
@@ -10,9 +10,6 @@
 #define XLIB_ILLEGAL_ACCESS
 
 #include "../mgp.h"
-#if 0
-#include "xloadimage.h"
-#endif
 
 static int GotError;
 
diff --git a/mgp.c b/mgp.c
index 3328f01..5008694 100644 (file)
--- a/mgp.c
+++ b/mgp.c
@@ -27,7 +27,7 @@
  */
 
 #include "mgp.h"
-#ifdef HAVE_LOCALE_H
+#if HAVE_LOCALE_H
 #include <locale.h>
 #endif
 #include <fcntl.h>
diff --git a/mgp.h b/mgp.h
index abd751f..ce264ae 100644 (file)
--- a/mgp.h
+++ b/mgp.h
@@ -37,7 +37,7 @@
 #elif HAVE_TIME_H
 #include <time.h>
 #endif
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
 # include <unistd.h>
 #endif
 #include <string.h>
 #include FT_FREETYPE_H
 #include <fontconfig/fontconfig.h>
 #include <X11/Xft/Xft.h>
-#ifdef HAVE_ICONV
+#if HAVE_ICONV
 #include <iconv.h>
 #endif
 #include "image/xloadimage.h"
 
-#ifdef HAVE_TERMIOS_H
+#if HAVE_TERMIOS_H
 #define        TTY_KEYINPUT
 #else
 #undef TTY_KEYINPUT
diff --git a/parse.c b/parse.c
index 21008d2..d3d9ae7 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -27,7 +27,7 @@
  */
 
 #include "mgp.h"
-#ifdef HAVE_FCNTL_H
+#if HAVE_FCNTL_H
 # include <fcntl.h>
 #endif
 
@@ -49,11 +49,8 @@ extern int n_errors;
 extern struct ctrl *root;
 extern char *yyfilename;
 extern int yylineno;
-/* Prevent warning if -Wall.  */
-#ifdef __GNUC__
-extern void lex_init(u_char *);
-extern int yyparse (void);
-#endif
+extern void lex_init(char *);
+extern int yyparse(void);
 
 static int filterval = 0;
 
@@ -277,9 +274,6 @@ read_rc(fp, filename)
        char *filename;
 {
        char buf[BUFSIZ];
-#if 0
-       struct ctrl *cp;
-#endif
        int lineno;
 
        if (2 <= parse_debug)
@@ -314,26 +308,6 @@ read_rc(fp, filename)
                }
 
                switch (root->ct_op) {
-#if 0
-               case CTL_DEFFONT:
-                       /* safety check */
-                       for (cp = root; cp; cp = cp->ct_next) {
-                               if (cp->ct_op == CTL_FONT) {
-                                       fprintf(stderr,
-"%s:%d: %%font used in %%deffont, which is disallowed\n",
-                                               filename, lineno);
-                                       exit(-1);
-                               }
-                       }
-
-                       if (define_font(root) < 0) {
-                               fprintf(stderr, "%s:%d: could not define "
-                                       "font \"%s\"\n", filename, lineno,
-                                       root->ctc_value);
-                               exit(-1);
-                       }
-                       break;
-#endif
                case CTL_NOOP:
                        /* done in grammar.y */
                        break;
@@ -741,22 +715,6 @@ command:
                                 * page struct.
                                 */
                                ch = &page_control[*page][*line];
-
-#if 0
-                               if (!line_cont &&
-                                   (/* cp->ct_op == CTL_IMAGE || */
-                                    cp->ct_op == CTL_BAR)) {
-                                       struct ctrl *cp1;
-                                       cp1 = ctlalloc1(CTL_LINESTART);
-                                       if (cp1) {
-                                               if (!*ch)
-                                                       *ch = cp1;
-                                               else
-                                                       ctlappend(*ch, cp1);
-                                       }
-                               }
-#endif
-
                                if (!*ch)
                                        *ch = cp;
                                else
@@ -786,14 +744,12 @@ command:
                        /*
                         * clear escape sequences
                         */
-#if 1
                        if (clear_esc(buf) == NULL) {
                                fprintf(stderr, "%s:%d: unknown escape"
                                                " sequence\n",
                                                filename, lineno);
                                exit(-1);
                        }
-#endif
 
                        cp = parse_text(buf, *page);
                        if (cp) {
@@ -811,11 +767,6 @@ command:
 
        /* Treat as we've seen pagebreak.  See the above comment for detail. */
        page_attribute[*page].pg_linenum = *line;
-#if 0
-       *page = *page + 1;
-       *line = 0;
-#endif
-
        maxpage = *page;
 }
 
@@ -1330,13 +1281,6 @@ thirdpass()
                                }
                        }
 
-#if 0
-                       /* insert CTL_TAB items into CTL_LINESTART */
-                       if (tab_control[tab_depth]) {
-                               ctlinsert(&cp1->ct_next,
-                                   ctlcopy(tab_control[tab_depth]));
-                       }
-#else
                        if (tab_control[tab_depth]) {
                                ch = &page_control[page][l];
                                for (cpt = tab_control[tab_depth]; cpt; cpt = cpt->ct_next){
@@ -1350,7 +1294,6 @@ thirdpass()
                                                ctlinsert(ch, ctlcopy1(cpt));
                                }
                        }
-#endif
 
                        /* special: style escape */
                        if (p && *p == '&') {
diff --git a/print.c b/print.c
index b80cdbc..e1c0e8d 100644 (file)
--- a/print.c
+++ b/print.c
@@ -27,7 +27,7 @@
  */
 
 #include "mgp.h"
-#ifdef HAVE_LOCALE_H
+#if HAVE_LOCALE_H
 #include <locale.h>
 #endif
 
@@ -638,13 +638,8 @@ print_init()
        for (p = aligns; *p; p++) {
                fprintf(fp, "/%snewlinecheck {\n", *p);
                fprintf(fp, "  currentpoint pop add XMARGIN XBODY add gt {\n");
-#if 1
                fprintf(fp, "    NL %sdefxpos xpos ypos charsize 2 div sub moveto\n",
                        *p);
-#else
-               fprintf(fp, "    NL %sdefxpos xpos ypos charsize sub moveto\n",
-                       *p);
-#endif
                fprintf(fp, "  } if\n");
                fprintf(fp, "} bind def\n");
        }
@@ -693,13 +688,8 @@ print_pageinit(page)
        window_width  = paper->width - paper_xmargin * 2;
        window_height = paper->height - paper_ymargin * 2;
        fprintf(fp, "%%%%Page: %d %d\n", page, page);
-#if 1 /*XXX*/
        fprintf(fp, "/ypos YMARGIN -1 mul 4 sub def\n");
        fprintf(fp, "/xpos 0 def\n");
-#else
-       fprintf(fp, "/ypos YMARGIN -1 mul def\n");
-       fprintf(fp, "/xpos XMARGIN def\n");
-#endif
        fprintf(fp, "initcharsize\n");
        if (!colorps)
                fprintf(fp, "90 rotate newpath writebox\n");
@@ -1021,10 +1011,6 @@ line_end()
                        fprintf(fp, "%d add\n", textpool[i].xsiz);
                        continue;
                }
-#if 0
-               loadfont(textpool[i].font, textpool[i].charset);
-#endif
-
                fprintf(fp, "%d setcharsize %d %s %s calcy\n",
                        textpool[i].size, textpool[i].size,
                        fontstring(textpool[i].font),
@@ -1089,9 +1075,6 @@ line_end()
 
        for (i = 0; i < ntextpool; i++) {
                if (textpool[i].text) {
-#if 0
-                       loadfont(textpool[i].font, textpool[i].charset);
-#endif
                        fprintf(fp, "%d %s 1 copy stringwidth pop ",
                                textpool[i].size,
                                fontstring(textpool[i].font));
@@ -1147,25 +1130,13 @@ line_end()
                if (mgp_flag & FL_VERBOSE)
                        fprintf(fp, "%% emit the content of imagepool\n");
                cp1 = imagepool[i].image;
-#if 0
-               if (!cp1) {
-                       fprintf(fp, "/xpos xpos%d def xpos ypos moveto\n",
-                               imagepool[i].target_text);
-                       continue;
-               }
-               image_load_print(cp1->ctm_fname, cp1->ctm_numcolor,
-                       cp1->ctm_ximagesize, cp1->ctm_yimagesize, 0,
-                       cp1->ctm_zoomflag);
-               fprintf(fp, "%d setimgsize\n", imagepool[i].ysiz);      /*XXX*/
-#else
                if (cp1) {
                        image_load_print(cp1->ctm_fname, cp1->ctm_numcolor,
                                cp1->ctm_ximagesize, cp1->ctm_yimagesize, 0,
                                cp1->ctm_zoomflag, cp1->ctm_rotate);
                }
-       fprintf(fp, "/xpos xpos%d def xpos ypos moveto\n",
-           imagepool[i].target_text);
-#endif
+               fprintf(fp, "/xpos xpos%d def xpos ypos moveto\n",
+                   imagepool[i].target_text);
 
        }
        nimagepool = 0;
@@ -1376,14 +1347,6 @@ print_string(data, pfx)
                        continue;
                }
 
-#if 0
-               if (!kanji && isspace(p[0])) {
-                       p++;
-                       linewidth +=
-                       continue;
-               }
-#endif
-
                if (kanji) {
                        for (q = p + 2; 0x21 <= q[0] && q[0] <= 0x7e; q += 2) {
                                code2 = q[0] * 256 + q[1];
@@ -1457,11 +1420,7 @@ print_fragment(data, len, kanjimode, pfx)
        /* by A.Ito 14 Jul. 2000 */
        /* placeholder */
        imagepool[nimagepool].image = NULL;
-#if 1
        imagepool[nimagepool].target_text = ntextpool-1;
-#else
-       imagepool[nimagepool].target_text = nimagepool;
-#endif
        nimagepool++;
 }
 
@@ -1807,21 +1766,6 @@ image_load_print(filename, numcolor, ximagesize, yimagesize, backflag, zoomflag,
        if (numcolor)
                myimage = reduce(myimage, numcolor, verbose);
 
-#if 0
-       if (ximagesize != 0 && yimagesize != 0) {
-               if (!zoomflag) {
-                       xzoomrate = (float) window_width * ximagesize / width;
-                       yzoomrate = (float) window_height * yimagesize / height;
-               } else {
-                       xzoomrate = (float) ximagesize;
-                       yzoomrate = (float) yimagesize;
-               }
-               image = myimage;
-               myimage = zoom(image, xzoomrate, yzoomrate, verbose);
-               freeImage(image);
-       } else
-               xzoomrate = yzoomrate = 100.0;
-#else
        xzoomrate = (float) ximagesize;
        yzoomrate = (float) yimagesize;
        state.width = window_width;
@@ -1833,7 +1777,6 @@ image_load_print(filename, numcolor, ximagesize, yimagesize, backflag, zoomflag,
        freeImage(image);
        width = myimage->width;
        height = myimage->height;
-#endif
 
        if (! (ximageinfo= imageToXImage(display, screen, visual, depth,
                        myimage, 0, 0, 0, verbose))) {
@@ -2101,23 +2044,6 @@ print_eps(epsfp, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag)
        ximagesize = (!ximagesize ? 100 : ximagesize);
        yimagesize = (!yimagesize ? 100 : yimagesize);
 
-#if 0
-       /* scaling factor */
-       switch (zoomflag) {
-       case 0: /* relative to screen size */
-               xscale = (double)window_width * ximagesize / width / 100;
-               yscale = (double)window_height * yimagesize / height / 100;
-               break;
-       case 1: /* relative to the loaded image */
-               xscale = (double)ximagesize / 100;
-               yscale = (double)yimagesize / 100;
-               break;
-       case 2: /* relative to screen pixels: don't know how to handle */
-               xscale = 1.0;
-               yscale = 1.0;
-               break;
-       }
-#else
        xzoomrate = (float) ximagesize;
        yzoomrate = (float) yimagesize;
        state.width = window_width;
@@ -2126,7 +2052,6 @@ print_eps(epsfp, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag)
                width, height);
        xscale = xzoomrate / 100.0;
        yscale = yzoomrate / 100.0;
-#endif
 
        /* scaled image size */
        swidth = (int)(xscale * width);
@@ -2330,9 +2255,6 @@ found:
                char fonttype;
 
                switch (ctrl) {
-#if 0
-               case CTL_XFONT: fonttype = 'x'; break;
-#endif
                case CTL_XFONT2: fonttype = 'x'; break;
 
                case CTL_PSFONT: fonttype = 'p'; break;
index 04f5559..202e4b7 100644 (file)
--- a/scanner.l
+++ b/scanner.l
@@ -61,34 +61,28 @@ static inline int xdtoi(int);
 #ifdef FLEX_SCANNER
 #define YY_NO_UNPUT
 #undef YY_INPUT
-#define YY_INPUT(buf, result, max)\
- {\
-       char *src = in_buffer;\
-       int i;\
-\
-       if (*src == 0)\
-               result = YY_NULL;\
-       else {\
-               for (i = 0; *src && i < max; ++i)\
-                       buf[i] = *src++;\
-               in_buffer += i;\
-               result = i;\
-       }\
+#define YY_INPUT(buf, result, max)                     \
+ {                                                     \
+       char *src = in_buffer;                          \
+       int i;                                          \
+                                                       \
+       if (*src == 0)                                  \
+               result = YY_NULL;                       \
+       else {                                          \
+               for (i = 0; *src && i < max; ++i)       \
+                       buf[i] = *src++;                \
+               in_buffer += i;                         \
+               result = i;                             \
+       }                                               \
  }
 #else
 #undef getc
 #define getc(fp)  (*in_buffer == 0 ? EOF : *in_buffer++)
 #endif
 
-/*#define yylval mgp_lval*/
 extern YYSTYPE yylval;
 extern int n_errors;
-#ifdef HAVE_STDARG_H
-/* GCC complains if we declare this function in traditional style */
 extern void yyerror(char *, ...);
-#else
-extern void yyerror(char *);
-#endif
 
 static char *in_buffer;
 %}
diff --git a/x11.c b/x11.c
index 7e54f7f..53ea80d 100644 (file)
--- a/x11.c
+++ b/x11.c
@@ -272,17 +272,6 @@ init_win2()
 
        XMapRaised(display, window);
 
-#if 0
-#if 0
-       if (!(mgp_flag & FL_OVER))
-#else
-       if (0 <= window_x && 0 <= window_y)
-#endif
-               XMoveWindow(display, window, window_x, window_y);
-
-       XFlush(display);
-#endif
-
        gc_pl = XCreateGC(display, window, 0, 0);
        gc_plrev = XCreateGC(display, window, 0, 0);
        gc_pta = XCreateGC(display, window, 0, 0);
@@ -387,7 +376,7 @@ get_color(colorname, value)
        screen = DefaultScreen(display);
 /*XXX*/
        if (strcasecmp(colorname, "darkblue") == 0)
-               colorname = "#00008b";
+               colorname = "#00008B";
        if (XAllocNamedColor(display, colormap, colorname, &c1, &c0) == 0)
                return -1;
        if (value)
index 80c92ed..91423b7 100644 (file)
@@ -78,18 +78,6 @@ finish_win()
        XCloseDisplay(display);
 }
 
-#if 0
-int
-get_color(colorname, value)
-       char *colorname;
-       u_long *value;
-{
-       if (*value)
-               *value = 0;
-       return 0;       /*ok*/
-}
-#endif
-
 int
 get_color(colorname, value)
        char *colorname;
@@ -101,7 +89,7 @@ get_color(colorname, value)
        colormap = DefaultColormap(display, screen);
 /*XXX*/
        if (strcasecmp(colorname, "darkblue") == 0)
-               colorname = "#00008b";
+               colorname = "#00008B";
        if (XAllocNamedColor(display, colormap, colorname, &c1, &c0) == 0)
                return -1;
        if (value)