X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-handle-def.c;h=5d807ab9a0a5a5b9867836bd62e9daf9ae494281;hb=d0371553a98cd169353bf6d211e375e5ffc3a3bd;hp=0f6b142a72cd170758b59912ecfa48dc47cc81fb;hpb=1881aaf56cd19765028c365e11ec0c97cc9d0320;p=pspp-builds.git diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 0f6b142a..5d807ab9 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -49,6 +49,7 @@ struct file_handle /* FH_REF_FILE only. */ char *file_name; /* File name as provided by user. */ enum fh_mode mode; /* File mode. */ + enum legacy_encoding encoding;/* File encoding. */ /* FH_REF_FILE and FH_REF_INLINE only. */ size_t record_width; /* Length of fixed-format records. */ @@ -234,6 +235,7 @@ fh_create_file (const char *id, const char *file_name, handle->mode = properties->mode; handle->record_width = properties->record_width; handle->tab_width = properties->tab_width; + handle->encoding = properties->encoding; return handle; } @@ -254,7 +256,7 @@ const struct fh_properties * fh_default_properties (void) { static const struct fh_properties default_properties - = {FH_MODE_TEXT, 1024, 4}; + = {FH_MODE_TEXT, 1024, 4, LEGACY_NATIVE}; return &default_properties; } @@ -322,6 +324,14 @@ fh_get_tab_width (const struct file_handle *handle) return handle->tab_width; } +/* Returns the encoding of characters read from HANDLE. */ +enum legacy_encoding +fh_get_legacy_encoding (const struct file_handle *handle) +{ + assert (handle->referent & (FH_REF_FILE | FH_REF_INLINE)); + return (handle->referent == FH_REF_FILE ? handle->encoding : LEGACY_NATIVE); +} + /* Returns the scratch file handle associated with HANDLE. Applicable to only FH_REF_SCRATCH files. */ struct scratch_handle *