- /* The file handle extension record. */
- struct pfm_fhuser_ext *ext;
-
- /* Check whether the file is already open. */
- if (h->class == &pfm_r_class)
- {
- ext = h->ext;
- return ext->dict;
- }
- else if (h->class != NULL)
- {
- msg (ME, _("Cannot read file %s as portable file: already opened "
- "for %s."),
- fh_handle_name (h), h->class->name);
- return NULL;
- }
-
- msg (VM (1), _("%s: Opening portable-file handle %s for reading."),
- fh_handle_filename (h), fh_handle_name (h));
-
- /* Open the physical disk file. */
- ext = xmalloc (sizeof (struct pfm_fhuser_ext));
- ext->file = fopen (h->norm_fn, "rb");
- if (ext->file == NULL)
+ struct pfm_reader *r = NULL;
+
+ *dict = dict_create ();
+ if (!fh_open (fh, "portable file", "rs"))
+ goto error;
+
+ /* Create and initialize reader. */
+ r = xmalloc (sizeof *r);
+ r->fh = fh;
+ r->file = fopen (handle_get_filename (r->fh), "rb");
+ r->weight_index = -1;
+ r->trans = NULL;
+ r->var_cnt = 0;
+ r->widths = NULL;
+ r->value_cnt = 0;
+ r->bp = NULL;
+
+ /* Check that file open succeeded, prime reading. */
+ if (r->file == NULL)