~ubuntu-branches/ubuntu/jaunty/cups/jaunty-proposed

« back to all changes in this revision

Viewing changes to debian/local/filters/pdf-filters/filter/fontembed/dynstring.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt, Till Kamppeter, Martin Pitt
  • Date: 2009-02-15 18:39:03 UTC
  • mfrom: (6.1.30 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090215183903-i0nhvqyqj4vyn52a
Tags: 1.3.9-13
[ Till Kamppeter ]
* debian/local/filters/pdf-filters/filter/imagetopdf.c: Added support for
  the new "fit-to-page" option (new, more intuitive name for "fitplot").
* debian/filters/pstopdf: Only apply paper size if the "fitplot" or the
  "fit-to-page" option is set.
* debian/local/filters/cpdftocps: Only the last digit of the number of
  copies was used (LP: #309314).
* debian/local/filters/pdf-filters/pdftopdf/pdftopdf.cxx: Do not preceed the
  PDF output with a newline (LP: #303691). Only impose the page size from
  the PPD file to all pages if the "fitplot" or the "fit-to-page" option is 
  set. This prevented from automatic paper tray switching to the correct paper
  sizes when a multiple-page-size document is printed (partial fix for
  LP: #310575).
* debian/patches/pdftops-cups-1.4.dpatch: Updated from CUPS 1.4 SVN. Contains
  fixes for multiple-page-size document printing (partial fix for
  LP: #310575).
* debian/patches/pdftops-dont_fail_on_cancel.dpatch: Removed, should be
  fixed in the new upstream version of pdftops.

[ Martin Pitt ]
* debian/patches/pdftops-cups-1.4.dpatch: Add definition of
  HAVE_PDFTOPS and CUPS_PDFTOPS, so that the filter actually gets
  again built with pdftops support. (Fixes Till's change from above).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "dynstring.h"
 
2
#include <stdarg.h>
 
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
#include <string.h>
 
6
#include <assert.h>
 
7
 
 
8
int dyn_init(DYN_STRING *ds,int reserve_size) // {{{
 
9
{
 
10
  assert(ds);
 
11
  assert(reserve_size>0);
 
12
 
 
13
  ds->len=0;
 
14
  ds->alloc=reserve_size;
 
15
  ds->buf=malloc(ds->alloc+1);
 
16
  if (!ds->buf) {
 
17
    fprintf(stderr,"Bad alloc: %m\n");
 
18
    assert(0);
 
19
    ds->len=-1;
 
20
    return -1;
 
21
  }
 
22
  return 0;
 
23
}
 
24
// }}}
 
25
 
 
26
void dyn_free(DYN_STRING *ds) // {{{
 
27
{
 
28
  assert(ds);
 
29
 
 
30
  ds->len=-1;
 
31
  ds->alloc=0;
 
32
  free(ds->buf);
 
33
  ds->buf=NULL;
 
34
}
 
35
// }}}
 
36
 
 
37
int dyn_ensure(DYN_STRING *ds,int free_space) // {{{
 
38
{
 
39
  assert(ds);
 
40
  assert(free_space);
 
41
 
 
42
  if (ds->len<0) {
 
43
    return -1;
 
44
  }
 
45
  if (ds->alloc - ds->len >= free_space) {
 
46
    return 0; // done
 
47
  }
 
48
  ds->alloc+=free_space;
 
49
  char *tmp=realloc(ds->buf,ds->alloc+1);
 
50
  if (!tmp) {
 
51
    ds->len=-1;
 
52
    fprintf(stderr,"Bad alloc: %m\n");
 
53
    assert(0);
 
54
    return -1;
 
55
  }
 
56
  ds->buf=tmp;
 
57
  return 0;
 
58
}
 
59
// }}}
 
60
 
 
61
inline int dyn_vprintf(DYN_STRING *ds,const char *fmt,va_list ap) // {{{
 
62
{
 
63
  assert(ds);
 
64
 
 
65
  int need,len=strlen(fmt)+100;
 
66
  va_list va;
 
67
 
 
68
  if (dyn_ensure(ds,len)==-1) {
 
69
    return -1;
 
70
  }
 
71
 
 
72
  while (1) {
 
73
    va_copy(va,ap);
 
74
    need=vsnprintf(ds->buf+ds->len,ds->alloc-ds->len+1,fmt,va);
 
75
    va_end(va);
 
76
    if (need==-1) {
 
77
      len+=100;
 
78
    } else if (need>=len) {
 
79
      len=need;
 
80
    } else {
 
81
      ds->len+=need;
 
82
      break;
 
83
    }
 
84
    if (dyn_ensure(ds,len)==-1) {
 
85
      return -1;
 
86
    }
 
87
  }
 
88
  return 0;
 
89
}
 
90
// }}}
 
91
 
 
92
int dyn_printf(DYN_STRING *ds,const char *fmt,...) // {{{
 
93
{
 
94
  va_list va;
 
95
  int ret;
 
96
 
 
97
  va_start(va,fmt);
 
98
  ret=dyn_vprintf(ds,fmt,va);
 
99
  va_end(va);
 
100
 
 
101
  return ret;
 
102
}
 
103
// }}}
 
104