Recode Dialog: Stringify the variable label
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 14 Mar 2012 18:56:30 +0000 (19:56 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 14 Mar 2012 18:56:30 +0000 (19:56 +0100)
Ensure that the generated syntax has quotes around the variable label,
in case the label happens to contain spaces or other metacharacters.

src/ui/gui/recode-dialog.c

index 97a25cf2326ca6ef4f4376cece000bccefadaaaf..012b2f26c1689b394edf039f85178d479a5ea100 100644 (file)
@@ -1078,8 +1078,15 @@ generate_syntax (const struct recode_dialog *rd)
       while (g_hash_table_iter_next (&iter, (void**) &var, (void**) &nlp))
        {
          if (nlp->label)
-           g_string_append_printf (str, "\nVARIABLE LABELS %s %s.",
-                                   nlp->name, nlp->label);
+           {
+             struct string sl;
+             ds_init_empty (&sl);
+             syntax_gen_string (&sl, ss_cstr (nlp->label));
+             g_string_append_printf (str, "\nVARIABLE LABELS %s %s.",
+                                     nlp->name, ds_cstr (&sl));
+
+             ds_destroy (&sl);
+           }
        }
     }