~ubuntu-branches/ubuntu/dapper/groff/dapper

« back to all changes in this revision

Viewing changes to src/devices/grops/ps.cc

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2002-03-17 04:11:50 UTC
  • Revision ID: james.westby@ubuntu.com-20020317041150-em69nkqd2qw26v96
Tags: 1.17.2-15.woody.1
* New Danish debconf translation (thanks, Rune B. Broberg;
  closes: #131092).
* New French debconf translation (thanks, Philippe Batailler;
  closes: #138515).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "stringclass.h"
24
24
#include "cset.h"
25
25
#include "nonposix.h"
 
26
#include "encoding.h"
26
27
 
27
28
#include "ps.h"
28
29
#include <time.h>
35
36
 
36
37
extern "C" const char *Version_string;
37
38
 
 
39
static int paperlength = 0;
38
40
static int landscape_flag = 0;
39
41
static int manual_feed_flag = 0;
40
42
static int ncopies = 1;
191
193
  return *this;
192
194
}
193
195
 
 
196
#ifdef NIPPON
 
197
ps_output &ps_output::put_string(const wchar *s, int n)
 
198
#else
194
199
ps_output &ps_output::put_string(const char *s, int n)
 
200
#endif
195
201
{
196
202
  int len = 0;
197
203
  int i;
198
204
  for (i = 0; i < n; i++) {
 
205
#ifdef NIPPON
 
206
    wchar c = s[i];
 
207
#else
199
208
    char c = s[i];
 
209
#endif
200
210
    if (is_ascii(c) && csprint(c)) {
201
211
      if (c == '(' || c == ')' || c == '\\')
202
212
        len += 2;
222
232
        putc('\n', fp);
223
233
        col = 0;
224
234
      }
 
235
#ifdef  NIPPON
 
236
      encoding_ostream_fp eos(fp, "%02x");
 
237
      int nb = encoding->put_wchar(s[i], eos);
 
238
      col += nb * 2;
 
239
#else
225
240
      fprintf(fp, "%02x", s[i] & 0377);
226
241
      col += 2;
 
242
#endif
227
243
    }
228
244
    putc('>', fp);
229
245
    col++;
423
439
    else if (!bflag)
424
440
      broken_flags = atoi(arg);
425
441
  }
 
442
  if (strcmp(command, "paperfile") == 0) {
 
443
    if (arg == 0)
 
444
      error_with_file_and_line(filename, lineno,
 
445
                               "`paperfile' command requires an argument");
 
446
    else if (font::paperlength == 0) {
 
447
      errno = 0;
 
448
      FILE *paper_file = fopen(arg, "r");
 
449
      if (paper_file == 0) {
 
450
        error("can't open `%1'", arg);
 
451
        return;
 
452
      }
 
453
      char paper_file_buf[1024];
 
454
      if ( fgets( paper_file_buf, 1024, paper_file)) {
 
455
        int l = strlen(paper_file_buf) - 1;
 
456
        if ( paper_file_buf[l] == '\n' )
 
457
          paper_file_buf[l] = 0;
 
458
        if ( strcasecmp(paper_file_buf, "a4") == 0)
 
459
                paperlength = 841890;
 
460
//      else if ( strcasecmp(paper_file_buf, "letter") == 0)
 
461
//              paperlength = 792000;
 
462
//      else
 
463
//        error_with_file_and_line(filename, lineno,
 
464
//                                 "unknown paper size in file `%1'", arg);
 
465
        else
 
466
                paperlength = 792000;
 
467
      } else
 
468
          error_with_file_and_line(filename, lineno,
 
469
                                   "error in content of paper file `%1'", arg);
 
470
      fclose( paper_file);
 
471
    }
 
472
  }
426
473
}
427
474
 
428
475
struct style {
465
512
  int paper_length;
466
513
  int equalise_spaces;
467
514
  enum { SBUF_SIZE = 256 };
 
515
#ifdef  NIPPON
 
516
  wchar sbuf[SBUF_SIZE];
 
517
#else
468
518
  char sbuf[SBUF_SIZE];
 
519
#endif
469
520
  int sbuf_len;
470
521
  int sbuf_start_hpos;
471
522
  int sbuf_vpos;
553
604
  res = r;
554
605
  out.set_fixed_point(point);
555
606
  space_char_index = font::name_to_index("space");
556
 
  paper_length = font::paperlength;
 
607
  if ( paperlength )
 
608
    paper_length = paperlength;
 
609
  else
 
610
    paper_length = font::paperlength;
557
611
  if (paper_length == 0)
558
612
    paper_length = 11*font::res;
559
613
  equalise_spaces = font::res >= 72000;
579
633
{
580
634
  if (i == space_char_index || invis_count > 0)
581
635
    return;
 
636
#ifdef  NIPPON
 
637
  wchar code = f->get_code(i);
 
638
#else
582
639
  unsigned char code = f->get_code(i);
 
640
#endif
583
641
  style sty(f, env->size, env->height, env->slant);
584
642
  if (sty.slant != 0) {
585
643
    if (sty.slant > 80 || sty.slant < -80) {
1485
1543
  string env;
1486
1544
  static char stderr_buf[BUFSIZ];
1487
1545
  setbuf(stderr, stderr_buf);
 
1546
  init_encoding_handler();
1488
1547
  int c;
1489
1548
  static const struct option long_options[] = {
1490
1549
    { "help", no_argument, 0, CHAR_MAX + 1 },