~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to raster/r.colors/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
static char **rules;
33
33
static int nrules;
34
34
 
 
35
static int cmp(const void *aa, const void *bb)
 
36
{
 
37
    char *const *a = (char *const *)aa;
 
38
    char *const *b = (char *const *)bb;
 
39
    
 
40
    return strcmp(*a, *b);
 
41
}
 
42
 
35
43
static void scan_rules(void)
36
44
{
37
45
    char path[GPATH_MAX];
46
54
    rules[nrules++] = G_store("grey.eq");
47
55
    rules[nrules++] = G_store("grey.log");
48
56
    rules[nrules++] = G_store("rules");
 
57
 
 
58
    qsort(rules, nrules, sizeof(char *), cmp);
49
59
}
50
60
 
51
61
static char *rules_list(void)
273
283
    if (interactive && (style || rules || cmap))
274
284
        G_fatal_error(_("Interactive mode is incompatible with \"color\", \"rules\", and \"raster\" options"));
275
285
 
276
 
    if ((style && (cmap || rules)) || (cmap && rules))
277
 
        G_fatal_error(_("\"color\", \"rules\", and \"raster\" options are mutually exclusive"));
 
286
    if ((style && (cmap || rules)) || (cmap && rules)) {
 
287
        if ((style && rules && !cmap) && strcmp(style, "rules") == 0)
 
288
            style = NULL;
 
289
        else
 
290
            G_fatal_error(
 
291
                _("\"color\", \"rules\", and \"raster\" options are mutually exclusive"));
 
292
    }
278
293
 
279
294
    /* handle rules="-" (from stdin) by translating that to colors=rules */
280
 
    /* this method should not be ported to GRASS 7 where color=rules DNE */
 
295
    /* this method should not be ported to GRASS 7 verbatim, as color=rules DNE */
281
296
    if (rules && strcmp(rules, "-") == 0) {
282
297
        style = G_store("rules");
283
298
        rules = NULL;
305
320
    /*if (have_colors >= 0)
306
321
       G_free_colors(&colors); */
307
322
 
308
 
    if (have_colors > 0 && !overwrite)
309
 
        exit(EXIT_SUCCESS);
 
323
    if (have_colors > 0 && !overwrite) {
 
324
        G_warning(_("Color table exists. Exiting."));
 
325
        exit(EXIT_FAILURE);
 
326
    }
310
327
 
311
328
    G_suppress_warnings(0);
312
329