struct file_locator where; /* Used for reporting error messages. */
enum file_handle_mode mode; /* File mode. */
size_t length; /* Length of fixed-format records. */
+ size_t tab_width; /* Tab width, 0=do not expand tabs. */
};
/* Linked list of file handles. */
/* (specification)
"FILE HANDLE" (fh_):
name=string;
- recform=recform:fixed/!variable/spanned;
lrecl=integer;
- mode=mode:!character/image/binary/multipunch/_360.
+ tabwidth=integer "x>=0" "%s must be nonnegative";
+ mode=mode:!character/image.
*/
/* (declarations) */
/* (functions) */
{
case FH_CHARACTER:
handle->private->mode = MODE_TEXT;
+ if (cmd.sbc_tabwidth)
+ handle->private->tab_width = cmd.n_tabwidth;
+ else
+ handle->private->tab_width = 4;
break;
case FH_IMAGE:
handle->private->mode = MODE_BINARY;
handle->private->where.line_number = 0;
handle->private->mode = MODE_TEXT;
handle->private->length = 1024;
+ handle->private->tab_width = 4;
handle->ext = NULL;
handle->class = NULL;
if (token == T_ID)
handle = get_handle_with_name (tokid);
if (handle == NULL)
- handle = get_handle_for_filename (ds_value (&tokstr));
+ handle = get_handle_for_filename (ds_c_str (&tokstr));
if (handle == NULL)
{
- char *filename = ds_value (&tokstr);
+ char *filename = ds_c_str (&tokstr);
char *handle_name = xmalloc (strlen (filename) + 3);
sprintf (handle_name, "\"%s\"", filename);
handle = create_file_handle (handle_name, filename);
return handle->private->mode;
}
-/* Returns the width of a logical record on HANDLE. */
+/* Returns the width of a logical record on HANDLE. Applicable
+ only to MODE_BINARY files. */
size_t
handle_get_record_width (const struct file_handle *handle)
{
return handle->private->length;
}
+/* Returns the number of characters per tab stop for HANDLE, or
+ zero if tabs are not to be expanded. Applicable only to
+ MODE_TEXT files. */
+size_t
+handle_get_tab_width (const struct file_handle *handle)
+{
+ assert (handle != NULL);
+ return handle->private->tab_width;
+}
+
/*
Local variables:
mode: c