~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/svg/svg-color.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# include "config.h"
18
18
#endif
19
19
 
20
 
#include "svg-color.h"
21
 
#include "svg-icc-color.h"
 
20
#include <cstdlib>
 
21
#include <cstdio> // sprintf
 
22
#include <cstring>
 
23
#include <string>
22
24
#include <cassert>
23
25
#include <math.h>
24
26
#include <glib/gmem.h>
 
27
#include <glib.h> // g_assert
25
28
#include <glib/gmessages.h>
26
29
#include <glib/gstrfuncs.h>
27
30
#include <glib/ghash.h>
28
31
#include <glib/gutils.h>
29
 
#include <cstdio> // sprintf
30
32
#include <errno.h>
 
33
 
31
34
#include "strneq.h"
 
35
#include "prefs-utils.h"
 
36
#include "svg-color.h"
 
37
#include "svg-icc-color.h"
 
38
 
32
39
using std::sprintf;
33
40
 
34
41
struct SPSVGColor {
235
242
            *end_ptr = str + i;
236
243
        }
237
244
    } else if (strneq(str, "rgb(", 4)) {
238
 
        gboolean hasp, hasd;
 
245
        bool hasp, hasd;
239
246
        gchar *s, *e;
240
247
        gdouble r, g, b;
241
248
 
242
249
        s = (gchar *) str + 4;
243
 
        hasp = FALSE;
244
 
        hasd = FALSE;
 
250
        hasp = false;
 
251
        hasd = false;
245
252
 
246
253
        r = g_ascii_strtod(s, &e);
247
254
        if (s == e) return def;
248
255
        s = e;
249
256
        if (*s == '%') {
250
 
            hasp = TRUE;
 
257
            hasp = true;
251
258
            s += 1;
252
259
        } else {
253
 
            hasd = TRUE;
 
260
            hasd = true;
254
261
        }
255
262
        while (*s && g_ascii_isspace(*s)) s += 1;
256
263
        if (*s != ',') return def;
260
267
        if (s == e) return def;
261
268
        s = e;
262
269
        if (*s == '%') {
263
 
            hasp = TRUE;
 
270
            hasp = true;
264
271
            s += 1;
265
272
        } else {
266
 
            hasd = TRUE;
 
273
            hasd = true;
267
274
        }
268
275
        while (*s && g_ascii_isspace(*s)) s += 1;
269
276
        if (*s != ',') return def;
273
280
        if (s == e) return def;
274
281
        s = e;
275
282
        if (*s == '%') {
276
 
            hasp = TRUE;
 
283
            hasp = true;
277
284
            s += 1;
278
285
        } else {
279
 
            hasd = TRUE;
 
286
            hasd = true;
280
287
        }
281
288
        while(*s && g_ascii_isspace(*s)) s += 1;
282
289
        if (*s != ')') {
409
416
        strcpy(buf, src);
410
417
    }
411
418
 
412
 
    assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
 
419
    // assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
413
420
}
414
421
 
415
422
/**
425
432
    g_assert(8 <= buflen);
426
433
 
427
434
    unsigned const rgb24 = rgba32 >> 8;
428
 
    rgb24_to_css(buf, rgb24);
 
435
    if (prefs_get_int_attribute("options.svgoutput", "usenamedcolors", 0)) {
 
436
        rgb24_to_css(buf, rgb24);
 
437
    } else {
 
438
        g_snprintf(buf, buflen, "#%06x", rgb24);
 
439
    }
429
440
}
430
441
 
431
442
static GHashTable *
476
487
                // Name must start with a certain type of character
477
488
                good = false;
478
489
            } else {
479
 
                while ( g_ascii_isdigit(*str) || g_ascii_islower(*str) || (*str == '-') ) {
 
490
                while ( g_ascii_isdigit(*str) || g_ascii_isalpha(*str) || (*str == '-') ) {
480
491
                    if ( dest ) {
481
492
                        dest->colorProfile += *str;
482
493
                    }