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

« back to all changes in this revision

Viewing changes to src/devices/grohtml/post-html.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:
28
28
#include "cset.h"
29
29
#include "html.h"
30
30
#include "html-text.h"
 
31
#include "encoding.h" // XXX: ukai
31
32
 
32
33
#include <time.h>
33
34
 
279
280
public:
280
281
  char_buffer();
281
282
  ~char_buffer();
 
283
#ifdef NIPPON
 
284
  char  *add_string(wchar *, unsigned int);
 
285
#endif
282
286
  char  *add_string(char *, unsigned int);
283
287
private:
284
288
  char_block *head;
299
303
  }
300
304
}
301
305
 
 
306
#ifdef NIPPON
 
307
char *char_buffer::add_string (wchar *s, unsigned int length)
 
308
{
 
309
  int i=0;
 
310
  unsigned int old_used;
 
311
 
 
312
  if (tail == 0) {
 
313
    tail = new char_block;
 
314
    head = tail;
 
315
  } else {
 
316
    if (tail->used + length*2 + 1 > char_block::SIZE) {
 
317
      tail->next = new char_block;
 
318
      tail       = tail->next;
 
319
    }
 
320
  }
 
321
  // at this point we have a tail which is ready for the string.
 
322
  if (tail->used + length*2 + 1 > char_block::SIZE) {
 
323
    fatal("need to increase char_block::SIZE");
 
324
  }
 
325
 
 
326
  old_used = tail->used;
 
327
  encoding_ostream_str eos(tail->buffer + tail->used, length*2);
 
328
  do {
 
329
    tail->used += encoding->put_wchar(s[i], eos);
 
330
    i++;
 
331
    length--;
 
332
  } while (length>0);
 
333
 
 
334
  // add terminating nul character
 
335
 
 
336
  tail->buffer[tail->used] = '\0';
 
337
  tail->used++;
 
338
 
 
339
  // and return start of new string
 
340
 
 
341
  return( &tail->buffer[old_used] );
 
342
}
 
343
#endif
 
344
 
302
345
char *char_buffer::add_string (char *s, unsigned int length)
303
346
{
304
347
  int i=0;
739
782
class page {
740
783
public:
741
784
                              page            (void);
 
785
#ifdef NIPPON
 
786
  void                        add            (style *s, wchar *string, unsigned int length,
 
787
                                              int line_number,
 
788
                                              int min_vertical, int min_horizontal,
 
789
                                              int max_vertical, int max_horizontal);
 
790
#else
 
791
 
742
792
  void                        add             (style *s, char *string, unsigned int length,
743
793
                                               int line_number,
744
794
                                               int min_vertical, int min_horizontal,
745
795
                                               int max_vertical, int max_horizontal);
 
796
#endif
746
797
  void                        add_html        (style *s, char *string, unsigned int length,
747
798
                                               int line_number,
748
799
                                               int min_vertical, int min_horizontal,
767
818
{
768
819
}
769
820
 
 
821
#ifdef NIPPON
 
822
void page::add (style *s, wchar *string, unsigned int length,
 
823
                int line_number,
 
824
                int min_vertical, int min_horizontal,
 
825
                int max_vertical, int max_horizontal)
 
826
#else
770
827
void page::add (style *s, char *string, unsigned int length,
771
828
                int line_number,
772
829
                int min_vertical, int min_horizontal,
773
830
                int max_vertical, int max_horizontal)
 
831
#endif
774
832
{
775
833
  if (length > 0) {
776
834
    text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
971
1029
  int                  no_of_printed_pages;
972
1030
  int                  paper_length;
973
1031
  enum                 { SBUF_SIZE = 8192 };
 
1032
#ifdef NIPPON
 
1033
  wchar                sbuf[SBUF_SIZE];
 
1034
#else
974
1035
  char                 sbuf[SBUF_SIZE];
 
1036
#endif
975
1037
  int                  sbuf_len;
976
1038
  int                  sbuf_start_hpos;
977
1039
  int                  sbuf_vpos;
1026
1088
  void  determine_diacritical_mark    (const char *name, const environment *env);
1027
1089
  int   sbuf_continuation             (unsigned char code, const char *name, const environment *env, int w);
1028
1090
  char *remove_last_char_from_sbuf    ();
 
1091
#ifdef NIPPON
 
1092
  int   seen_backwards_escape         (wchar *s, int l);
 
1093
#else
1029
1094
  int   seen_backwards_escape         (char *s, int l);
 
1095
#endif
1030
1096
  void  flush_page                    (void);
1031
1097
  void  troff_tag                     (text_glob *g);
1032
1098
  void  flush_globs                   (void);
1903
1969
  } else if (strcmp(fontname, "CR") == 0) {
1904
1970
    current_paragraph->done_tt();
1905
1971
    current_paragraph->done_pre();
 
1972
#ifdef NIPPON
 
1973
  } else if (strcmp(fontname, "G") == 0) {
 
1974
    current_paragraph->done_bold();
 
1975
#endif
1906
1976
  }
1907
1977
}
1908
1978
 
1929
1999
    }
1930
2000
    current_paragraph->do_tt();
1931
2001
  }
 
2002
#ifdef NIPPON
 
2003
  else if (strcmp(fontname, "M") == 0) {
 
2004
    current_paragraph->done_bold();
 
2005
    current_paragraph->done_italic();
 
2006
    current_paragraph->done_tt();
 
2007
  } else if (strcmp(fontname, "G") == 0) {
 
2008
    current_paragraph->do_bold();
 
2009
  }
 
2010
#endif
1932
2011
}
1933
2012
 
1934
2013
/*
2398
2477
 *  seen_backwards_escape - returns TRUE if we can see a escape at position i..l in s
2399
2478
 */
2400
2479
 
 
2480
#ifdef NIPPON
 
2481
int html_printer::seen_backwards_escape (wchar *s, int l)
 
2482
#else
2401
2483
int html_printer::seen_backwards_escape (char *s, int l)
 
2484
#endif
2402
2485
{
2403
2486
  /*
2404
2487
   *  this is tricky so it is broken into components for clarity
2652
2735
 
2653
2736
void html_printer::set_char(int i, font *f, const environment *env, int w, const char *name)
2654
2737
{
 
2738
#ifdef NIPPON
 
2739
  wchar code = f->get_code(i);
 
2740
#else
2655
2741
  unsigned char code = f->get_code(i);
 
2742
#endif
2656
2743
 
2657
2744
#if 0
2658
2745
  if (code == ' ') {
2873
2960
  program_name = argv[0];
2874
2961
  static char stderr_buf[BUFSIZ];
2875
2962
  setbuf(stderr, stderr_buf);
 
2963
  init_encoding_handler();
2876
2964
  int c;
2877
2965
  static const struct option long_options[] = {
2878
2966
    { "help", no_argument, 0, CHAR_MAX + 1 },