59 |
struct file_handle *fh; /* File handle. */ |
struct file_handle *fh; /* File handle. */ |
60 |
FILE *file; /* File stream. */ |
FILE *file; /* File stream. */ |
61 |
char cc; /* Current character. */ |
char cc; /* Current character. */ |
62 |
unsigned char *trans; /* 256-byte character set translation table. */ |
char *trans; /* 256-byte character set translation table. */ |
|
|
|
63 |
int var_cnt; /* Number of variables. */ |
int var_cnt; /* Number of variables. */ |
64 |
int weight_index; /* 0-based index of weight variable, or -1. */ |
int weight_index; /* 0-based index of weight variable, or -1. */ |
65 |
int *widths; /* Variable widths, 0 for numeric. */ |
int *widths; /* Variable widths, 0 for numeric. */ |
341 |
|
|
342 |
/* Reads a string and returns a copy of it allocated from R's |
/* Reads a string and returns a copy of it allocated from R's |
343 |
pool. */ |
pool. */ |
344 |
static unsigned char * |
static char * |
345 |
read_pool_string (struct pfm_reader *r) |
read_pool_string (struct pfm_reader *r) |
346 |
{ |
{ |
347 |
char string[256]; |
char string[256]; |
355 |
{ |
{ |
356 |
/* portable_to_local[PORTABLE] translates the given portable |
/* portable_to_local[PORTABLE] translates the given portable |
357 |
character into the local character set. */ |
character into the local character set. */ |
358 |
static const unsigned char portable_to_local[256] = |
static const char portable_to_local[256] = |
359 |
{ |
{ |
360 |
" " |
" " |
361 |
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ." |
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ." |
363 |
" " |
" " |
364 |
}; |
}; |
365 |
|
|
366 |
unsigned char *trans; |
char *trans; |
367 |
int i; |
int i; |
368 |
|
|
369 |
/* Read and ignore vanity splash strings. */ |
/* Read and ignore vanity splash strings. */ |
410 |
static void |
static void |
411 |
read_version_data (struct pfm_reader *r, struct pfm_read_info *info) |
read_version_data (struct pfm_reader *r, struct pfm_read_info *info) |
412 |
{ |
{ |
413 |
|
static char empty_string[] = ""; |
414 |
char *date, *time, *product, *author, *subproduct; |
char *date, *time, *product, *author, *subproduct; |
415 |
int i; |
int i; |
416 |
|
|
419 |
error (r, "Unrecognized version code `%c'.", r->cc); |
error (r, "Unrecognized version code `%c'.", r->cc); |
420 |
date = read_pool_string (r); |
date = read_pool_string (r); |
421 |
time = read_pool_string (r); |
time = read_pool_string (r); |
422 |
product = match (r, '1') ? read_pool_string (r) : (unsigned char *) ""; |
product = match (r, '1') ? read_pool_string (r) : empty_string; |
423 |
author = match (r, '2') ? read_pool_string (r) : (unsigned char *) ""; |
author = match (r, '2') ? read_pool_string (r) : empty_string; |
424 |
subproduct |
subproduct = match (r, '3') ? read_pool_string (r) : empty_string; |
|
= match (r, '3') ? read_pool_string (r) : (unsigned char *) ""; |
|
425 |
|
|
426 |
/* Validate file. */ |
/* Validate file. */ |
427 |
if (strlen (date) != 8) |
if (strlen (date) != 8) |