+/* Allocate the pointer TEXT and fill it with text representing the
+ long variable name buffer. SIZE will contain the size of TEXT.
+ TEXT must be freed by the caller when no longer required.
+*/
+void
+dict_get_varname_block(const struct dictionary *dict, char **text, int *size)
+{
+ char *buf = 0;
+ int bufsize = 0;
+ struct hsh_iterator hi;
+ struct name_table_entry *nte;
+ short first = 1;
+
+ for ( nte = hsh_first(dict->long_name_tab, &hi);
+ nte;
+ nte = hsh_next(dict->long_name_tab, &hi))
+ {
+ bufsize += strlen(nte->name) + strlen(nte->longname) + 2;
+ buf = xrealloc(buf, bufsize + 1);
+ if ( first )
+ strcpy(buf, "");
+ first = 0;
+
+ strcat(buf, nte->name);
+ strcat(buf, "=");
+ strcat(buf, nte->longname);
+ strcat(buf, "\t");
+ }
+
+ if ( bufsize > 0 )
+ {
+ /* Loose the final delimiting TAB */
+ buf[bufsize]='\0';
+ bufsize--;
+ }
+
+ *text = buf;
+ *size = bufsize;
+}
+
+
+/* Add a new entry into the dictionary's long name table, and update the
+ corresponding varible with the relevant long name.
+*/
+void
+dict_add_longvar_entry(struct dictionary *d,
+ const char *name,
+ const char *longname)
+{
+ struct variable *v;
+ assert ( name ) ;
+ assert ( longname );
+ struct name_table_entry *nte = xmalloc (sizeof (struct name_table_entry));
+ nte->longname = strdup(longname);
+ nte->name = strdup(name);
+
+
+ /* Look up the name in name_tab */
+ v = hsh_find ( d->name_tab, name);
+ if ( !v )
+ {
+ msg (FE, _("The entry \"%s\" in the variable name map, has no corresponding variable"), name);
+ return ;
+ }
+ assert ( 0 == strcmp(v->name, name) );
+ v->longname = nte->longname;
+
+ hsh_insert(d->long_name_tab, nte);
+
+
+}
+
+/* Destroys the aux data for every variable in D, by calling
+ var_clear_aux() for each variable. */
+void
+dict_clear_aux (struct dictionary *d)
+{
+ int i;
+
+ assert (d != NULL);
+
+ for (i = 0; i < d->var_cnt; i++)
+ var_clear_aux (d->var[i]);
+}
+