gimp r26925 - in trunk: . plug-ins/script-fu



Author: mitch
Date: Thu Sep 11 13:33:58 2008
New Revision: 26925
URL: http://svn.gnome.org/viewvc/gimp?rev=26925&view=rev

Log:
2008-09-11  Michael Natterer  <mitch gimp org>

	* plug-ins/script-fu/script-fu-regex.[ch]: namespace, copyright
	headers, indentation, formatting, everything...

	* plug-ins/script-fu/scheme-wrapper.c: changed accordingly. Some
	formatting cleanup here too.



Modified:
   trunk/ChangeLog
   trunk/plug-ins/script-fu/scheme-wrapper.c
   trunk/plug-ins/script-fu/script-fu-regex.c
   trunk/plug-ins/script-fu/script-fu-regex.h

Modified: trunk/plug-ins/script-fu/scheme-wrapper.c
==============================================================================
--- trunk/plug-ins/script-fu/scheme-wrapper.c	(original)
+++ trunk/plug-ins/script-fu/scheme-wrapper.c	Thu Sep 11 13:33:58 2008
@@ -104,64 +104,65 @@
   { NULL, 0 }
 };
 
-/* The following constants are deprecated. They are */
-/* included to keep backwards compatability with    */
-/* older scripts used with version 2.0 of GIMP.     */
+/* The following constants are deprecated. They are
+ * included to keep backwards compatability with
+ * older scripts used with version 2.0 of GIMP.
+ */
 struct named_constant const old_constants[] =
 {
-  { "NORMAL",       GIMP_NORMAL_MODE       },
-  { "DISSOLVE",     GIMP_DISSOLVE_MODE     },
-  { "BEHIND",       GIMP_BEHIND_MODE       },
-  { "MULTIPLY",     GIMP_MULTIPLY_MODE     },
-  { "SCREEN",       GIMP_SCREEN_MODE       },
-  { "OVERLAY",      GIMP_OVERLAY_MODE      },
-  { "DIFFERENCE",   GIMP_DIFFERENCE_MODE   },
-  { "ADDITION",     GIMP_ADDITION_MODE     },
-  { "SUBTRACT",     GIMP_SUBTRACT_MODE     },
-  { "DARKEN-ONLY",  GIMP_DARKEN_ONLY_MODE  },
-  { "LIGHTEN-ONLY", GIMP_LIGHTEN_ONLY_MODE },
-  { "HUE",          GIMP_HUE_MODE          },
-  { "SATURATION",   GIMP_SATURATION_MODE   },
-  { "COLOR",        GIMP_COLOR_MODE        },
-  { "VALUE",        GIMP_VALUE_MODE        },
-  { "DIVIDE",       GIMP_DIVIDE_MODE       },
-
-  { "BLUR",         GIMP_BLUR_CONVOLVE     },
-  { "SHARPEN",      GIMP_SHARPEN_CONVOLVE  },
-
-  { "WHITE-MASK",     GIMP_ADD_WHITE_MASK     },
-  { "BLACK-MASK",     GIMP_ADD_BLACK_MASK     },
-  { "ALPHA-MASK",     GIMP_ADD_ALPHA_MASK     },
-  { "SELECTION-MASK", GIMP_ADD_SELECTION_MASK },
-  { "COPY-MASK",      GIMP_ADD_COPY_MASK      },
-
-  { "ADD",          GIMP_CHANNEL_OP_ADD       },
-  { "SUB",          GIMP_CHANNEL_OP_SUBTRACT  },
-  { "REPLACE",      GIMP_CHANNEL_OP_REPLACE   },
-  { "INTERSECT",    GIMP_CHANNEL_OP_INTERSECT },
-
-  { "FG-BG-RGB",    GIMP_FG_BG_RGB_MODE       },
-  { "FG-BG-HSV",    GIMP_FG_BG_HSV_MODE       },
-  { "FG-TRANS",     GIMP_FG_TRANSPARENT_MODE  },
-  { "CUSTOM",       GIMP_CUSTOM_MODE          },
-
-  { "FG-IMAGE-FILL",    GIMP_FOREGROUND_FILL  },
-  { "BG-IMAGE-FILL",    GIMP_BACKGROUND_FILL  },
-  { "WHITE-IMAGE-FILL", GIMP_WHITE_FILL       },
-  { "TRANS-IMAGE-FILL", GIMP_TRANSPARENT_FILL },
-
-  { "APPLY",        GIMP_MASK_APPLY   },
-  { "DISCARD",      GIMP_MASK_DISCARD },
-
-  { "HARD",         GIMP_BRUSH_HARD },
-  { "SOFT",         GIMP_BRUSH_SOFT },
-
-  { "CONTINUOUS",   GIMP_PAINT_CONSTANT    },
-  { "INCREMENTAL",  GIMP_PAINT_INCREMENTAL },
-
-  { "HORIZONTAL",   GIMP_ORIENTATION_HORIZONTAL },
-  { "VERTICAL",     GIMP_ORIENTATION_VERTICAL   },
-  { "UNKNOWN",      GIMP_ORIENTATION_UNKNOWN    },
+  { "NORMAL",               GIMP_NORMAL_MODE       },
+  { "DISSOLVE",             GIMP_DISSOLVE_MODE     },
+  { "BEHIND",               GIMP_BEHIND_MODE       },
+  { "MULTIPLY",             GIMP_MULTIPLY_MODE     },
+  { "SCREEN",               GIMP_SCREEN_MODE       },
+  { "OVERLAY",              GIMP_OVERLAY_MODE      },
+  { "DIFFERENCE",           GIMP_DIFFERENCE_MODE   },
+  { "ADDITION",             GIMP_ADDITION_MODE     },
+  { "SUBTRACT",             GIMP_SUBTRACT_MODE     },
+  { "DARKEN-ONLY",          GIMP_DARKEN_ONLY_MODE  },
+  { "LIGHTEN-ONLY",         GIMP_LIGHTEN_ONLY_MODE },
+  { "HUE",                  GIMP_HUE_MODE          },
+  { "SATURATION",           GIMP_SATURATION_MODE   },
+  { "COLOR",                GIMP_COLOR_MODE        },
+  { "VALUE",                GIMP_VALUE_MODE        },
+  { "DIVIDE",               GIMP_DIVIDE_MODE       },
+
+  { "BLUR",                 GIMP_BLUR_CONVOLVE     },
+  { "SHARPEN",              GIMP_SHARPEN_CONVOLVE  },
+
+  { "WHITE-MASK",           GIMP_ADD_WHITE_MASK     },
+  { "BLACK-MASK",           GIMP_ADD_BLACK_MASK     },
+  { "ALPHA-MASK",           GIMP_ADD_ALPHA_MASK     },
+  { "SELECTION-MASK",       GIMP_ADD_SELECTION_MASK },
+  { "COPY-MASK",            GIMP_ADD_COPY_MASK      },
+
+  { "ADD",                  GIMP_CHANNEL_OP_ADD       },
+  { "SUB",                  GIMP_CHANNEL_OP_SUBTRACT  },
+  { "REPLACE",              GIMP_CHANNEL_OP_REPLACE   },
+  { "INTERSECT",            GIMP_CHANNEL_OP_INTERSECT },
+
+  { "FG-BG-RGB",            GIMP_FG_BG_RGB_MODE       },
+  { "FG-BG-HSV",            GIMP_FG_BG_HSV_MODE       },
+  { "FG-TRANS",             GIMP_FG_TRANSPARENT_MODE  },
+  { "CUSTOM",               GIMP_CUSTOM_MODE          },
+
+  { "FG-IMAGE-FILL",        GIMP_FOREGROUND_FILL  },
+  { "BG-IMAGE-FILL",        GIMP_BACKGROUND_FILL  },
+  { "WHITE-IMAGE-FILL",     GIMP_WHITE_FILL       },
+  { "TRANS-IMAGE-FILL",     GIMP_TRANSPARENT_FILL },
+
+  { "APPLY",                GIMP_MASK_APPLY   },
+  { "DISCARD",              GIMP_MASK_DISCARD },
+
+  { "HARD",                 GIMP_BRUSH_HARD },
+  { "SOFT",                 GIMP_BRUSH_SOFT },
+
+  { "CONTINUOUS",           GIMP_PAINT_CONSTANT    },
+  { "INCREMENTAL",          GIMP_PAINT_INCREMENTAL },
+
+  { "HORIZONTAL",           GIMP_ORIENTATION_HORIZONTAL },
+  { "VERTICAL",             GIMP_ORIENTATION_VERTICAL   },
+  { "UNKNOWN",              GIMP_ORIENTATION_UNKNOWN    },
 
   { "LINEAR",               GIMP_GRADIENT_LINEAR               },
   { "BILINEAR",             GIMP_GRADIENT_BILINEAR             },
@@ -175,11 +176,11 @@
   { "SPIRAL-CLOCKWISE",     GIMP_GRADIENT_SPIRAL_CLOCKWISE     },
   { "SPIRAL-ANTICLOCKWISE", GIMP_GRADIENT_SPIRAL_ANTICLOCKWISE },
 
-  { "VALUE-LUT",      GIMP_HISTOGRAM_VALUE },
-  { "RED-LUT",        GIMP_HISTOGRAM_RED   },
-  { "GREEN-LUT",      GIMP_HISTOGRAM_GREEN },
-  { "BLUE-LUT",       GIMP_HISTOGRAM_BLUE  },
-  { "ALPHA-LUT",      GIMP_HISTOGRAM_ALPHA },
+  { "VALUE-LUT",            GIMP_HISTOGRAM_VALUE },
+  { "RED-LUT",              GIMP_HISTOGRAM_RED   },
+  { "GREEN-LUT",            GIMP_HISTOGRAM_GREEN },
+  { "BLUE-LUT",             GIMP_HISTOGRAM_BLUE  },
+  { "ALPHA-LUT",            GIMP_HISTOGRAM_ALPHA },
 
   { NULL, 0 }
 };
@@ -239,7 +240,7 @@
   sc.tracing = 1;
 #endif
 
-  sc.vptr->load_string (&sc, (char *)expr);
+  sc.vptr->load_string (&sc, (char *) expr);
 
   return sc.retcode;
 }
@@ -247,8 +248,8 @@
 const gchar *
 ts_get_success_msg (void)
 {
-  if (sc.vptr->is_string(sc.value))
-    return sc.vptr->string_value(sc.value);
+  if (sc.vptr->is_string (sc.value))
+    return sc.vptr->string_value (sc.value);
 
   return "Success";
 }
@@ -278,7 +279,7 @@
 
   /* Initialize the TinyScheme extensions */
   init_ftx (&sc);
-  init_re (&sc);
+  script_fu_regex_init (&sc);
 
   /* register in the interpreter the gimp functions and types. */
   init_constants ();
@@ -343,7 +344,7 @@
   symbol = sc.vptr->mk_symbol (&sc, "SF-RUN-MODE");
   sc.vptr->scheme_define (&sc, sc.global_env, symbol,
                           sc.vptr->mk_integer (&sc, run_mode));
-  sc.vptr->setimmutable(symbol);
+  sc.vptr->setimmutable (symbol);
 }
 
 static void     convert_string                   (gchar     *str);

Modified: trunk/plug-ins/script-fu/script-fu-regex.c
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-regex.c	(original)
+++ trunk/plug-ins/script-fu/script-fu-regex.c	Thu Sep 11 13:33:58 2008
@@ -1,8 +1,30 @@
-/* re.c */
-/* Henry Spencer's implementation of Regular Expressions,
-   used for TinyScheme */
-/* Refurbished by Stephen Gildea */
-/* Ported to GRegex by Michael Natterer */
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Based on re.c
+ *
+ * Henry Spencer's implementation of Regular Expressions,
+ * used for TinyScheme
+ *
+ * Refurbished by Stephen Gildea
+ *
+ * Ported to GRegex and de-uglified by Michael Natterer
+ */
 
 #include "config.h"
 
@@ -10,6 +32,8 @@
 #include "script-fu-regex.h"
 
 
+/*  local function prototypes  */
+
 static pointer foreign_re_match (scheme  *sc,
                                  pointer  args);
 static void    set_vector_elem  (pointer  vec,
@@ -17,24 +41,10 @@
                                  pointer  newel);
 
 
-#if 0
-static char* utilities=";; return the substring of STRING matched in MATCH-VECTOR, \n"
-";; the Nth subexpression match (default 0).\n"
-"(define (re-match-nth string match-vector . n)\n"
-"  (let ((n (if (pair? n) (car n) 0)))\n"
-"    (substring string (car (vector-ref match-vector n))\n"
-"                    (cdr (vector-ref match-vector n)))))\n"
-"(define (re-before-nth string match-vector . n)\n"
-"  (let ((n (if (pair? n) (car n) 0)))\n"
-"    (substring string 0 (car (vector-ref match-vector n)))))\n"
-"(define (re-after-nth string match-vector . n)\n"
-"  (let ((n (if (pair? n) (car n) 0)))\n"
-"    (substring string (cdr (vector-ref match-vector n))\n"
-"             (string-length string))))\n";
-#endif
+/*  public functions  */
 
 void
-init_re (scheme *sc)
+script_fu_regex_init (scheme *sc)
 {
   sc->vptr->scheme_define (sc,
                            sc->global_env,
@@ -42,10 +52,28 @@
                            sc->vptr->mk_foreign_func(sc, foreign_re_match));
 
 #if 0
-  sc->vptr->load_string (sc,utilities);
+  sc->vptr->load_string
+    (sc,
+     ";; return the substring of STRING matched in MATCH-VECTOR,\n"
+     ";; the Nth subexpression match (default 0).\n"
+     "\n"
+     "(define (re-match-nth string match-vector . n)\n"
+     "  (let ((n (if (pair? n) (car n) 0)))\n"
+     "    (substring string (car (vector-ref match-vector n))\n"
+     "                      (cdr (vector-ref match-vector n)))))\n"
+     "(define (re-before-nth string match-vector . n)\n"
+     "  (let ((n (if (pair? n) (car n) 0)))\n"
+     "    (substring string 0 (car (vector-ref match-vector n)))))\n"
+     "(define (re-after-nth string match-vector . n)\n"
+     "  (let ((n (if (pair? n) (car n) 0)))\n"
+     "    (substring string (cdr (vector-ref match-vector n))\n"
+     "                      (string-length string))))\n");
 #endif
 }
 
+
+/*  private functions  */
+
 static pointer
 foreign_re_match (scheme  *sc,
                   pointer  args)

Modified: trunk/plug-ins/script-fu/script-fu-regex.h
==============================================================================
--- trunk/plug-ins/script-fu/script-fu-regex.h	(original)
+++ trunk/plug-ins/script-fu/script-fu-regex.h	Thu Sep 11 13:33:58 2008
@@ -1,2 +1,26 @@
-/* This function gets called when TinyScheme is initializing the extension */
-void init_re (scheme *sc);
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SCRIPT_FU_REGEX_H__
+#define __SCRIPT_FU_REGEX_H__
+
+
+void   script_fu_regex_init (scheme *sc);
+
+
+#endif /* __SCRIPT_FU_REGEX_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]