? libtool
? x.patch
? doc/.dirstamp
? glade/.deps
? lib/gsl-extras/.deps
? lib/gsl-extras/.dirstamp
? lib/gtksheet/.deps
? lib/gtksheet/.dirstamp
? lib/linreg/.deps
? lib/linreg/.dirstamp
? src/data/.deps
? src/data/.dirstamp
? src/language/.deps
? src/language/.dirstamp
? src/language/control/.deps
? src/language/control/.dirstamp
? src/language/data-io/.deps
? src/language/data-io/.dirstamp
? src/language/dictionary/.deps
? src/language/dictionary/.dirstamp
? src/language/expressions/.deps
? src/language/expressions/.dirstamp
? src/language/lexer/.deps
? src/language/lexer/.dirstamp
? src/language/stats/.deps
? src/language/stats/.dirstamp
? src/language/tests/.deps
? src/language/tests/.dirstamp
? src/language/utilities/.deps
? src/language/utilities/.dirstamp
? src/language/xforms/.deps
? src/language/xforms/.dirstamp
? src/libpspp/.deps
? src/libpspp/.dirstamp
? src/math/.deps
? src/math/.dirstamp
? src/math/linreg/.deps
? src/math/linreg/.dirstamp
? src/math/ts/.deps
? src/math/ts/.dirstamp
? src/output/.deps
? src/output/.dirstamp
? src/output/charts/.deps
? src/output/charts/.dirstamp
? src/ui/.deps
? src/ui/.dirstamp
? src/ui/gui/.deps
? src/ui/gui/.dirstamp
? src/ui/gui/.libs
? src/ui/gui/libpsppire.la
? src/ui/gui/src_ui_gui_libpsppire_la-glade-register.lo
? src/ui/gui/x.patch
? src/ui/terminal/.deps
? src/ui/terminal/.dirstamp
? tests/formats/.deps
? tests/formats/.dirstamp
? tests/libpspp/.deps
? tests/libpspp/.dirstamp
? tests/libpspp/heap-test
Index: src/libpspp/str.c
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/str.c,v
retrieving revision 1.20
diff -b -w -U3 -r1.20 str.c
Index: src/ui/gui/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/automake.mk,v
retrieving revision 1.20
diff -b -w -U3 -r1.20 automake.mk
--- src/ui/gui/automake.mk	4 Jan 2007 08:15:27 -0000	1.20
+++ src/ui/gui/automake.mk	12 Jan 2007 04:47:10 -0000
@@ -93,6 +93,8 @@
 	src/ui/gui/syntax-editor.h \
 	src/ui/gui/syntax-editor-source.c \
 	src/ui/gui/syntax-editor-source.h \
+	src/ui/gui/syntax-string-source.c \
+	src/ui/gui/syntax-string-source.h \
 	src/ui/gui/val-labs-dialog.c \
 	src/ui/gui/val-labs-dialog.h \
 	src/ui/gui/var-sheet.c \
Index: src/ui/gui/data-editor.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-editor.c,v
retrieving revision 1.11
diff -b -w -U3 -r1.11 data-editor.c
--- src/ui/gui/data-editor.c	7 Jan 2007 04:04:00 -0000	1.11
+++ src/ui/gui/data-editor.c	12 Jan 2007 04:47:10 -0000
@@ -37,6 +37,7 @@
 
 #include "data-editor.h"
 #include "syntax-editor.h"
+#include "syntax-string-source.h"
 #include "window-manager.h"
 
 #include "psppire-data-store.h"
@@ -348,8 +349,6 @@
 }
 
 
-
-
 void
 new_data_window (GtkMenuItem *menuitem, gpointer parent)
 {
@@ -786,7 +785,6 @@
     }
 }
 
-
 static void
 weight_cases_dialog (GObject *o, gpointer data)
 {
@@ -816,20 +814,59 @@
 
   g_object_unref (xml);
 
-  if (response == GTK_RESPONSE_OK)
+  switch (response)
+    {
+    case GTK_RESPONSE_OK:
     {
       const GList *list = psppire_var_select_get_variables (select);
 
+	struct getl_interface *sss ;
+
       g_assert ( g_list_length (list) <= 1 );
 
       if ( list == NULL)
-	psppire_dict_set_weight_variable (select->dict, NULL);
+	  {
+	    sss = create_syntax_string_source ("WEIGHTS OFF.");
+	  }
       else
 	{
 	  struct variable *var = list->data;
 
-	  psppire_dict_set_weight_variable (select->dict, var);
+	    sss = create_syntax_string_source ("WEIGHT BY %s.\n",
+					       var_get_name (var));
+	  }
+
+	execute_syntax (sss);
 	}
+      break;
+    case PSPPIRE_RESPONSE_PASTE:
+      {
+	struct syntax_editor *se =  window_create (WINDOW_SYNTAX, NULL);
+
+	const GList *list = psppire_var_select_get_variables (select);
+
+	g_assert ( g_list_length (list) <= 1 );
+
+	if ( list == NULL)
+	  {
+	    gtk_text_buffer_insert_at_cursor (se->buffer, "WEIGHT OFF.", -1);
+	  }
+	else
+	  {
+	    struct variable *var = list->data;
+
+	    gchar *text = g_strdup_printf ("WEIGHT BY %s.",
+					   var_get_name (var));
+
+	    gtk_text_buffer_insert_at_cursor (se->buffer,
+					      text, -1);
+
+	    g_free (text);
+	  }
+      }
+      break;
+    default:
+      break;
     }
 }
 
Index: src/ui/gui/psppire-buttonbox.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-buttonbox.c,v
retrieving revision 1.1
diff -b -w -U3 -r1.1 psppire-buttonbox.c
--- src/ui/gui/psppire-buttonbox.c	4 Jan 2007 08:15:27 -0000	1.1
+++ src/ui/gui/psppire-buttonbox.c	12 Jan 2007 04:47:10 -0000
@@ -24,6 +24,12 @@
 #include "psppire-buttonbox.h"
 #include "psppire-dialog.h"
 
+#include <gettext.h>
+
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
 static void psppire_buttonbox_class_init          (PsppireButtonBoxClass *);
 static void psppire_buttonbox_init                (PsppireButtonBox      *);
 
@@ -89,6 +95,19 @@
 
 
 static void
+paste_button_clicked (GtkWidget *w, gpointer data)
+{
+  PsppireDialog *dialog;
+
+  dialog = PSPPIRE_DIALOG (gtk_widget_get_toplevel (w));
+
+  dialog->response = PSPPIRE_RESPONSE_PASTE;
+
+  psppire_dialog_close (dialog);
+}
+
+
+static void
 refresh_clicked (GtkWidget *w, gpointer data)
 {
   PsppireDialog *dialog;
@@ -109,6 +128,12 @@
   g_signal_connect (button, "clicked", G_CALLBACK (ok_button_clicked), NULL);
   gtk_widget_show (button);
 
+  button = gtk_button_new_with_mnemonic (_("_Paste"));
+  g_signal_connect (button, "clicked", G_CALLBACK (paste_button_clicked),
+		    NULL);
+  gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button);
+  gtk_widget_show (button);
+
   button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
   g_signal_connect (button, "clicked", G_CALLBACK (close_dialog), NULL);
   gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button);
Index: src/ui/gui/psppire-buttonbox.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-buttonbox.h,v
retrieving revision 1.1
diff -b -w -U3 -r1.1 psppire-buttonbox.h
--- src/ui/gui/psppire-buttonbox.h	4 Jan 2007 08:15:27 -0000	1.1
+++ src/ui/gui/psppire-buttonbox.h	12 Jan 2007 04:47:10 -0000
@@ -6,7 +6,6 @@
 #include <glib-object.h>
 #include <gtk/gtkvbbox.h>
 
-
 G_BEGIN_DECLS
 
 #define PSPPIRE_BUTTONBOX_TYPE            (psppire_button_box_get_type ())
Index: src/ui/gui/psppire-dialog.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dialog.h,v
retrieving revision 1.1
diff -b -w -U3 -r1.1 psppire-dialog.h
--- src/ui/gui/psppire-dialog.h	4 Jan 2007 08:15:27 -0000	1.1
+++ src/ui/gui/psppire-dialog.h	12 Jan 2007 04:47:10 -0000
@@ -6,6 +6,8 @@
 #include <glib-object.h>
 #include <gtk/gtkwindow.h>
 
+#define PSPPIRE_RESPONSE_PASTE 1
+
 
 G_BEGIN_DECLS
 
Index: src/ui/gui/psppire-dict.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.c,v
retrieving revision 1.23
diff -b -w -U3 -r1.23 psppire-dict.c
--- src/ui/gui/psppire-dict.c	7 Jan 2007 04:04:00 -0000	1.23
+++ src/ui/gui/psppire-dict.c	12 Jan 2007 04:47:10 -0000
@@ -684,14 +684,6 @@
 }
 
 
-void
-psppire_dict_set_weight_variable (PsppireDict *dict, struct variable *v)
-{
-  g_return_if_fail (v == NULL || var_is_numeric (v));
-  dict_set_weight (dict->dict, v);
-}
-
-
 struct variable *
 psppire_dict_get_weight_variable (const PsppireDict *dict)
 {
Index: src/ui/gui/psppire-dict.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.h,v
retrieving revision 1.14
diff -b -w -U3 -r1.14 psppire-dict.h
--- src/ui/gui/psppire-dict.h	4 Jan 2007 08:15:27 -0000	1.14
+++ src/ui/gui/psppire-dict.h	12 Jan 2007 04:47:10 -0000
@@ -104,7 +104,6 @@
 
 void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *);
 
-void psppire_dict_set_weight_variable (PsppireDict *, struct variable *);
 struct variable * psppire_dict_get_weight_variable (const PsppireDict *);
 
 
Index: src/ui/gui/psppire.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire.c,v
retrieving revision 1.34
diff -b -w -U3 -r1.34 psppire.c
--- src/ui/gui/psppire.c	10 Jan 2007 09:22:42 -0000	1.34
+++ src/ui/gui/psppire.c	12 Jan 2007 04:47:10 -0000
@@ -265,5 +265,36 @@
   gtk_icon_factory_add_default (factory);
 }
 
+#include <language/command.h>
+#include <data/procedure.h>
+#include <language/lexer/lexer.h>
+
+
+void
+execute_syntax (struct getl_interface *sss)
+{
+  struct lexer *lexer;
+  g_return_if_fail (proc_has_source (the_dataset));
+
+  lexer = lex_create (the_source_stream);
+
+  getl_append_source (the_source_stream, sss);
+
+  for (;;)
+    {
+      const struct dictionary *dict = dataset_dict (the_dataset);
+
+      int result = cmd_parse (lexer, the_dataset,
+			      dict_get_var_cnt (dict) > 0 ?
+			      CMD_STATE_DATA : CMD_STATE_INITIAL);
+
+      if (result == CMD_EOF || result == CMD_FINISH)
+	break;
+    }
+
+  getl_abort_noninteractive (the_source_stream);
+
+  lex_destroy (lexer);
+}
 
 
Index: src/ui/gui/syntax-editor-source.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/syntax-editor-source.c,v
retrieving revision 1.4
diff -b -w -U3 -r1.4 syntax-editor-source.c
--- src/ui/gui/syntax-editor-source.c	10 Jan 2007 09:22:42 -0000	1.4
+++ src/ui/gui/syntax-editor-source.c	12 Jan 2007 04:47:10 -0000
@@ -79,10 +79,8 @@
   if ( gtk_text_iter_compare (&ses->i, &ses->end) >= 0)
     return false;
 
-  gtk_text_buffer_get_iter_at_line ( ses->se->buffer,
-				     &next_line,
-				     1 + gtk_text_iter_get_line (&ses->i)
-				     );
+  next_line = ses->i;
+  gtk_text_iter_forward_line (&next_line);
 
   text = gtk_text_buffer_get_text (ses->se->buffer,
 				   &ses->i, &next_line,
Index: src/ui/gui/syntax-editor.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/syntax-editor.c,v
retrieving revision 1.13
diff -b -w -U3 -r1.13 syntax-editor.c
--- src/ui/gui/syntax-editor.c	10 Jan 2007 09:22:42 -0000	1.13
+++ src/ui/gui/syntax-editor.c	12 Jan 2007 04:47:10 -0000
@@ -212,24 +212,10 @@
 }
 
 static void
-execute_syntax (const struct syntax_editor *se, GtkTextIter start,
+editor_execute_syntax (const struct syntax_editor *se, GtkTextIter start,
 		GtkTextIter stop)
 {
-  g_return_if_fail (proc_has_source (the_dataset));
-
-  getl_append_source (the_source_stream,
-		      create_syntax_editor_source (se, start, stop));
-  for (;;)
-    {
-      const struct dictionary *dict = dataset_dict (the_dataset);
-      int result = cmd_parse (se->lexer, the_dataset,
-			      dict_get_var_cnt (dict) > 0 ?
-			      CMD_STATE_DATA : CMD_STATE_INITIAL);
-      if (result == CMD_EOF || result == CMD_FINISH)
-	break;
-    }
-
-  getl_abort_noninteractive (the_source_stream);
+  execute_syntax (create_syntax_editor_source (se, start, stop));
 }
 
 /* Parse and execute all the text in the buffer */
@@ -239,11 +225,10 @@
   GtkTextIter begin, end;
   struct syntax_editor *se = user_data;
 
-  gtk_text_buffer_get_iter_at_line (se->buffer, &begin, 0);
-  gtk_text_buffer_get_iter_at_line (se->buffer, &end, -1);
-
+  gtk_text_buffer_get_iter_at_offset (se->buffer, &begin, 0);
+  gtk_text_buffer_get_iter_at_offset (se->buffer, &end, -1);
 
-  execute_syntax (se, begin, end);
+  editor_execute_syntax (se, begin, end);
 }
 
 /* Parse and execute the currently selected text */
@@ -254,7 +239,7 @@
   struct syntax_editor *se = user_data;
 
   if ( gtk_text_buffer_get_selection_bounds (se->buffer, &begin, &end) )
-    execute_syntax (se, begin, end);
+    editor_execute_syntax (se, begin, end);
 }
 
 
@@ -281,7 +266,7 @@
   gtk_text_buffer_get_iter_at_line (se->buffer, &begin, line);
   gtk_text_buffer_get_iter_at_line (se->buffer, &end, line + 1);
 
-  execute_syntax (se, begin, end);
+  editor_execute_syntax (se, begin, end);
 }
 
 
@@ -310,7 +295,7 @@
   gtk_text_buffer_get_iter_at_line (se->buffer, &begin, line);
   gtk_text_buffer_get_iter_at_line (se->buffer, &end, -1);
 
-  execute_syntax (se, begin, end);
+  editor_execute_syntax (se, begin, end);
 }
 
 
Index: src/ui/gui/syntax-string-source.c
===================================================================
RCS file: src/ui/gui/syntax-string-source.c
diff -N src/ui/gui/syntax-string-source.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/ui/gui/syntax-string-source.c	12 Jan 2007 04:47:10 -0000
@@ -0,0 +1,128 @@
+/*
+  PSPPIRE --- A Graphical User Interface for PSPP
+  Copyright (C) 2007  Free Software Foundation
+
+  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., 51 Franklin Street, Fifth Floor, Boston, MA
+  02110-1301, USA. */
+
+
+#include <libpspp/getl.h>
+#include <libpspp/alloc.h>
+#include <libpspp/compiler.h>
+#include <libpspp/str.h>
+
+#include <stdlib.h>
+
+#include "syntax-string-source.h"
+
+struct syntax_string_source
+  {
+    struct getl_interface parent;
+    struct string buffer;
+    size_t posn;
+  };
+
+
+static bool
+always_false (const struct getl_interface *i UNUSED)
+{
+  return false;
+}
+
+/* Returns the name of the source */
+static const char *
+name (const struct getl_interface *i)
+{
+  const struct syntax_string_source *sss =
+    (const struct syntax_string_source *) i;
+
+  return NULL;
+}
+
+
+/* Returns the location within the source */
+static int
+location (const struct getl_interface *i)
+{
+  return -1;
+}
+
+
+static void
+close (struct getl_interface *i )
+{
+  struct syntax_string_source *sss = (struct syntax_string_source *) i;
+
+  ds_destroy (&sss->buffer);
+
+  free (sss);
+}
+
+
+
+static bool
+read_single_line (struct getl_interface *i,
+		  struct string *line,
+		  enum getl_syntax *syntax_rules)
+{
+  struct syntax_string_source *sss = (struct syntax_string_source *) i;
+
+  size_t next;
+
+  if ( sss->posn == -1)
+    return false;
+
+  next = ss_find_char (ds_substr (&sss->buffer,
+				  sss->posn, -1), '\n');
+
+  ds_assign_substring (line,
+		       ds_substr (&sss->buffer,
+				  sss->posn,
+				  next)
+		       );
+
+  if ( next != -1 )
+    sss->posn += next + 1; /* + 1 to skip newline */
+  else
+    sss->posn = -1; /* End of file encountered */
+
+  return true;
+}
+
+struct getl_interface *
+create_syntax_string_source (const char *format, ...)
+{
+  va_list args;
+
+  struct syntax_string_source *sss = xzalloc (sizeof *sss);
+
+  sss->posn = 0;
+
+  ds_init_empty (&sss->buffer);
+
+  va_start (args, format);
+  ds_put_vformat (&sss->buffer, format, args);
+  va_end (args);
+
+  sss->parent.interactive = always_false;
+  sss->parent.close = close;
+  sss->parent.read = read_single_line;
+
+  sss->parent.name = name;
+  sss->parent.location = location;
+
+
+  return (struct getl_interface *) sss;
+}
Index: src/ui/gui/syntax-string-source.h
===================================================================
RCS file: src/ui/gui/syntax-string-source.h
diff -N src/ui/gui/syntax-string-source.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/ui/gui/syntax-string-source.h	12 Jan 2007 04:47:10 -0000
@@ -0,0 +1,29 @@
+/*
+    PSPPIRE --- A Graphical User Interface for PSPP
+    Copyright (C) 2007  Free Software Foundation
+
+    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., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA. */
+
+#ifndef SYNTAX_STRING_SOURCE_H
+#define SYNTAX_STRING_SOURCE_H
+
+struct getl_interface;
+
+struct getl_interface *
+create_syntax_string_source (const char *fmt, ...);
+
+
+#endif
