1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 02:00:26 +02:00

Make file/line/column fields of ports private

* libguile/ports-internal.h (scm_t_port_internal): Move file_name,
  line_number, and column_number here.
  (SCM_FILENAME, SCM_SET_FILENAME, SCM_LINUM, SCM_COL, SCM_INCLINE):
  (SCM_ZEROCOL, SCM_INCCOL, SCM_DECCOL, SCM_TABCOL): Make internal.
* libguile/ports.c (scm_c_make_port_with_encoding)
  (scm_set_port_line_x, scm_set_port_column_x): Adapt to change.
This commit is contained in:
Andy Wingo 2016-05-13 10:31:01 +02:00
parent 209d50c7d8
commit 8af64975be
3 changed files with 20 additions and 19 deletions

View file

@ -227,6 +227,12 @@ typedef struct scm_iconv_descriptors scm_t_iconv_descriptors;
struct scm_port_internal
{
scm_t_port pt;
/* Source location information. */
SCM file_name;
long line_number;
int column_number;
unsigned at_stream_start_for_bom_read : 1;
unsigned at_stream_start_for_bom_write : 1;
scm_t_iconv_descriptors *iconv_descriptors;
@ -239,6 +245,17 @@ typedef struct scm_port_internal scm_t_port_internal;
#define SCM_PORT_GET_INTERNAL(x) ((scm_t_port_internal*) SCM_PTAB_ENTRY(x))
#define SCM_FILENAME(x) (SCM_PORT_GET_INTERNAL(x)->file_name)
#define SCM_SET_FILENAME(x, n) (SCM_PORT_GET_INTERNAL(x)->file_name = (n))
#define SCM_LINUM(x) (SCM_PORT_GET_INTERNAL(x)->line_number)
#define SCM_COL(x) (SCM_PORT_GET_INTERNAL(x)->column_number)
#define SCM_INCLINE(port) do {SCM_LINUM (port) += 1; SCM_COL (port) = 0;} while (0)
#define SCM_ZEROCOL(port) do {SCM_COL (port) = 0;} while (0)
#define SCM_INCCOL(port) do {SCM_COL (port) += 1;} while (0)
#define SCM_DECCOL(port) do {if (SCM_COL (port) > 0) SCM_COL (port) -= 1;} while (0)
#define SCM_TABCOL(port) do {SCM_COL (port) += 8 - SCM_COL (port) % 8;} while (0)
typedef enum scm_t_port_rw_active {
SCM_PORT_NEITHER = 0,
SCM_PORT_READ = 1,