Changeset 62389


Ignore:
Timestamp:
Oct 26, 2014, 1:23:32 PM (10 years ago)
Author:
mmetz
Message:

Vlib: fix r12350, sync Vect_check_input_output_name() to Vect_open_new()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/lib/vector/Vlib/legal_vname.c

    r62023 r62389  
    1919   \brief  Check if output is legal vector name.
    2020
    21    Rule:  [A-Za-z][A-Za-z0-9_@]*
     21   Rule:  [A-Za-z][A-Za-z0-9_]*
    2222
    2323   Check also for SQL keywords.
     
    2626
    2727   \return 1 OK
    28    \return -1 if name does not start with letter A..Za..z or if name does not continue with A..Za..z0..9_@
     28   \return -1 if name does not start with letter A..Za..z or if name does not continue with A..Za..z0..9_
    2929 */
    3030
     
    5555    for (s++; *s; s++)
    5656        if (!((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z') ||
    57               (*s >= '0' && *s <= '9') || *s == '_') || *s == '@') {
     57              (*s >= '0' && *s <= '9') || *s == '_')) {
    5858            G_warning(_("Illegal vector map name <%s>. Character '%c' not allowed."),
    5959                      buf, *s);
     
    9191{
    9292    const char *mapset;
    93     char nm[GNAME_MAX], ms[GMAPSET_MAX];
     93    char inm[GNAME_MAX], ims[GMAPSET_MAX];
     94    char onm[GNAME_MAX], oms[GMAPSET_MAX];
     95
     96    /* check for fully-qualified map name */
     97    if (G_name_is_fully_qualified(output, onm, oms)) {
     98        if (strcmp(oms, G_mapset()) != 0) {
     99            if (error == G_FATAL_EXIT) {
     100                G_fatal_error(_("Output vector map name <%s> is not in the current mapset (%s)"),
     101                              output, G_mapset());
     102            }
     103            else if (error == G_FATAL_PRINT) {
     104                G_warning(_("Output vector map name <%s> is not in the current mapset (%s)"),
     105                          output, G_mapset());
     106                return 1;
     107            }
     108            else {                      /* GV_FATAL_RETURN */
     109                return 1;
     110            }
     111        }
     112        output = onm;
     113    }
    94114
    95115    if (Vect_legal_filename(output) == -1) {
    96116        if (error == G_FATAL_EXIT) {
    97             G_fatal_error(_("Output vector map name <%s> is not valid map name"),
     117            G_fatal_error(_("Output vector map name <%s> is not SQL compliant"),
    98118                          output);
    99119        }
    100120        else if (error == G_FATAL_PRINT) {
    101             G_warning(_("Output vector map name <%s> is not valid map name"),
     121            G_warning(_("Output vector map name <%s> is not SQL compliant"),
    102122                      output);
    103123            return 1;
     
    108128    }
    109129
    110     if (G_name_is_fully_qualified(input, nm, ms)) {
    111         if (strcasecmp(ms, "ogr") != 0)
     130    if (G_name_is_fully_qualified(input, inm, ims)) {
     131        if (strcasecmp(ims, "ogr") != 0)
    112132            mapset = G_find_vector2(input, "");
    113133        else
    114             mapset = ms;
     134            mapset = ims;
    115135    }
    116136    else
     
    131151
    132152    if (strcmp(mapset, G_mapset()) == 0) {
    133         const char *in;
    134 
    135         if (G_name_is_fully_qualified(input, nm, ms)) {
    136             in = nm;
    137         }
    138         else {
    139             in = input;
     153        if (G_name_is_fully_qualified(input, inm, ims)) {
     154            input = inm;
    140155        }
    141156
    142         if (strcmp(in, output) == 0) {
     157        if (strcmp(input, output) == 0) {
    143158            if (error == G_FATAL_EXIT) {
    144159                G_fatal_error(_("Output vector map <%s> is used as input"),
Note: See TracChangeset for help on using the changeset viewer.