17 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
18 |
02111-1307, USA. */ |
02111-1307, USA. */ |
19 |
|
|
20 |
#include <config.h> |
#include "config.h" |
21 |
#include "error.h" |
#include "error.h" |
22 |
#include <ctype.h> |
#include <ctype.h> |
23 |
#include <errno.h> |
#include <errno.h> |
34 |
#include "misc.h" |
#include "misc.h" |
35 |
#include "settings.h" |
#include "settings.h" |
36 |
#include "str.h" |
#include "str.h" |
37 |
|
#include "val.h" |
38 |
#include "var.h" |
#include "var.h" |
39 |
#include "vfm.h" |
#include "vfm.h" |
40 |
|
|
41 |
|
|
42 |
/* List of variable names. */ |
/* List of variable names. */ |
43 |
struct varname |
struct varname |
44 |
{ |
{ |
45 |
struct varname *next; |
struct varname *next; |
46 |
char name[9]; |
char name[SHORT_NAME_LEN + 1]; |
47 |
}; |
}; |
48 |
|
|
49 |
/* Represents a FLIP input program. */ |
/* Represents a FLIP input program. */ |
206 |
|
|
207 |
/* Add numeric extensions until acceptable. */ |
/* Add numeric extensions until acceptable. */ |
208 |
{ |
{ |
209 |
int len = (int) strlen (name); |
const int len = (int) strlen (name); |
210 |
char n[9]; |
char n[SHORT_NAME_LEN + 1]; |
211 |
int i; |
int i; |
212 |
|
|
213 |
for (i = 1; i < 10000000; i++) |
for (i = 1; i < 10000000; i++) |
244 |
for (i = 0; i < flip->case_cnt; i++) |
for (i = 0; i < flip->case_cnt; i++) |
245 |
{ |
{ |
246 |
struct variable *v; |
struct variable *v; |
247 |
char s[9]; |
char s[SHORT_NAME_LEN + 1]; |
248 |
|
|
249 |
sprintf (s, "VAR%03d", i); |
sprintf (s, "VAR%03d", i); |
250 |
v = dict_create_var_assert (default_dict, s, 0); |
v = dict_create_var_assert (default_dict, s, 0); |
285 |
|
|
286 |
/* Write variable names as first case. */ |
/* Write variable names as first case. */ |
287 |
for (i = 0; i < flip->var_cnt; i++) |
for (i = 0; i < flip->var_cnt; i++) |
288 |
st_bare_pad_copy (info->output_buf[i].s, flip->var[i]->name, 8); |
st_bare_pad_copy (info->output_buf[i].s, flip->var[i]->name, MAX_SHORT_STRING); |
289 |
if (fwrite (info->output_buf, sizeof *info->output_buf, |
if (fwrite (info->output_buf, sizeof *info->output_buf, |
290 |
flip->var_cnt, flip->file) != (size_t) flip->var_cnt) |
flip->var_cnt, flip->file) != (size_t) flip->var_cnt) |
291 |
msg (FE, _("Error writing FLIP file: %s."), strerror (errno)); |
msg (FE, _("Error writing FLIP file: %s."), strerror (errno)); |
323 |
{ |
{ |
324 |
char name[INT_DIGITS + 2]; |
char name[INT_DIGITS + 2]; |
325 |
sprintf (name, "V%d", (int) f); |
sprintf (name, "V%d", (int) f); |
326 |
strncpy (v->name, name, 8); |
strncpy (v->name, name, SHORT_NAME_LEN); |
327 |
name[8] = 0; |
name[SHORT_NAME_LEN] = 0; |
328 |
} |
} |
329 |
} |
} |
330 |
else |
else |
331 |
{ |
{ |
332 |
int width = min (flip->new_names->width, 8); |
int width = min (flip->new_names->width, MAX_SHORT_STRING); |
333 |
memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]), |
memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]), |
334 |
width); |
width); |
335 |
v->name[width] = 0; |
v->name[width] = 0; |