]> granicus.if.org Git - postgis/commitdiff
Convert all extern opt* variables to pgis_opt* variables to avoid clashes with system...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 22 Mar 2010 19:38:14 +0000 (19:38 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 22 Mar 2010 19:38:14 +0000 (19:38 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5450 b70326c6-7e19-0410-871a-916f4a2858ee

loader/getopt.c
loader/getopt.h
loader/pgsql2shp.c
loader/shp2pgsql-cli.c
loader/shp2pgsql-core.c
loader/shp2pgsql-gui.c

index 6d46712282201341a67b1964061fc7e3be236651..7c1145def6729690718449183e808cc60da5ef83 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 #define ERR(s, c)\
-  if(opterr){\
+  if(pgis_opterr){\
         char errbuf[2];\
         errbuf[0] = (char)c; errbuf[1] = '\n';\
         (void) write(2, argv[0], (unsigned)strlen(argv[0]));\
         (void) write(2, errbuf, 2);\
   }
 
-int     opterr = 1;
-int     optind = 1;
-int     optopt;
-char    *optarg;
+int     pgis_opterr = 1;
+int     pgis_optind = 1;
+int     pgis_optopt;
+char    *pgis_optarg;
 
 int
 pgis_getopt(int argc, char **argv, char *opts)
@@ -53,51 +53,51 @@ pgis_getopt(int argc, char **argv, char *opts)
 
        if (sp == 1)
        {
-               if (optind >= argc ||
-                       argv[optind][0] != '-' /* && argv[optind][0] != '/' */ ||
-                       argv[optind][1] == '\0')
+               if (pgis_optind >= argc ||
+                       argv[pgis_optind][0] != '-' /* && argv[pgis_optind][0] != '/' */ ||
+                       argv[pgis_optind][1] == '\0')
                {
                        return(EOF);
                }
-               else if (strcmp(argv[optind], "--") == 0)
+               else if (strcmp(argv[pgis_optind], "--") == 0)
                {
-                       optind++;
+                       pgis_optind++;
                        return(EOF);
                }
        }
-       optopt = c = argv[optind][sp];
+       pgis_optopt = c = argv[pgis_optind][sp];
        if (c == ':' || (cp=strchr(opts, c)) == 0)
        {
                ERR(": illegal option -- ", c);
-               if (argv[optind][++sp] == '\0')
+               if (argv[pgis_optind][++sp] == '\0')
                {
-                       optind++;
+                       pgis_optind++;
                        sp = 1;
                }
                return('?');
        }
        if (*++cp == ':')
        {
-               if (argv[optind][sp+1] != '\0')
-                       optarg = &argv[optind++][sp+1];
-               else if (++optind >= argc)
+               if (argv[pgis_optind][sp+1] != '\0')
+                       pgis_optarg = &argv[pgis_optind++][sp+1];
+               else if (++pgis_optind >= argc)
                {
                        ERR(": option requires an argument -- ", c);
                        sp = 1;
                        return('?');
                }
                else
-                       optarg = argv[optind++];
+                       pgis_optarg = argv[pgis_optind++];
                sp = 1;
        }
        else
        {
-               if (argv[optind][++sp] == '\0')
+               if (argv[pgis_optind][++sp] == '\0')
                {
                        sp = 1;
-                       optind++;
+                       pgis_optind++;
                }
-               optarg = NULL;
+               pgis_optarg = NULL;
        }
        return(c);
 }
index 49b32580b763b26092364562498e7b43a56ae77b..ba439d62467e257b559ded998d19769272cbbd20 100644 (file)
@@ -1,9 +1,9 @@
 /* declarations for getopt and envargs */
 
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern char *optarg;
+extern int pgis_opterr;
+extern int pgis_optind;
+extern int pgis_optopt;
+extern char *pgis_optarg;
 
 extern int pgis_getopt(int argc, char **argv, char *opts);
 extern void envargs(int *pargc, char ***pargv, char *envstr);
index 00b49e9fe3cd707256d99e33273540bc65a4c107..02b2c2d8a09024c66d856d90b3c3f3c64307d053 100644 (file)
@@ -1307,10 +1307,10 @@ parse_commandline(int ARGC, char **ARGV)
                        binary = 1;
                        break;
                case 'f':
-                       shp_file = optarg;
+                       shp_file = pgis_optarg;
                        break;
                case 'h':
-                       snprintf(buf + strlen(buf), 255, "host=%s ", optarg);
+                       snprintf(buf + strlen(buf), 255, "host=%s ", pgis_optarg);
                        break;
                case 'd':
                        dswitchprovided = 1;
@@ -1321,16 +1321,16 @@ parse_commandline(int ARGC, char **ARGV)
                        unescapedattrs = 1;
                        break;
                case 'u':
-                       snprintf(buf + strlen(buf), 255, "user=%s ", optarg);
+                       snprintf(buf + strlen(buf), 255, "user=%s ", pgis_optarg);
                        break;
                case 'p':
-                       snprintf(buf + strlen(buf), 255, "port=%s ", optarg);
+                       snprintf(buf + strlen(buf), 255, "port=%s ", pgis_optarg);
                        break;
                case 'P':
-                       snprintf(buf + strlen(buf), 255, "password=%s ", optarg);
+                       snprintf(buf + strlen(buf), 255, "password=%s ", pgis_optarg);
                        break;
                case 'g':
-                       geo_col_name = optarg;
+                       geo_col_name = pgis_optarg;
                        break;
                case 'k':
                        keep_fieldname_case = 1;
@@ -1343,15 +1343,15 @@ parse_commandline(int ARGC, char **ARGV)
        }
 
        curindex=0;
-       for (; optind<ARGC; optind++)
+       for (; pgis_optind<ARGC; pgis_optind++)
        {
                if (curindex == 0)
                {
-                       snprintf(buf + strlen(buf), 255, "dbname=%s", ARGV[optind]);
+                       snprintf(buf + strlen(buf), 255, "dbname=%s", ARGV[pgis_optind]);
                }
                else if (curindex == 1)
                {
-                       parse_table(ARGV[optind]);
+                       parse_table(ARGV[pgis_optind]);
 
                }
                curindex++;
index 22435f3150f552006e07329faecec68cd0fa1561..cc207a193c719771dd6d1b52551bf429ea1c329b 100644 (file)
@@ -92,9 +92,9 @@ main (int argc, char **argv)
                        break;
 
                case 's':
-                       if (optarg)
+                       if (pgis_optarg)
                        {
-                               sscanf(optarg, "%d", &(config->sr_id));
+                               sscanf(pgis_optarg, "%d", &(config->sr_id));
                        }
                        else
                        {
@@ -105,7 +105,7 @@ main (int argc, char **argv)
                        break;
 
                case 'g':
-                       config->geom = optarg;
+                       config->geom = pgis_optarg;
                        break;
 
                case 'k':
@@ -129,11 +129,11 @@ main (int argc, char **argv)
                        break;
 
                case 'W':
-                       config->encoding = optarg;
+                       config->encoding = pgis_optarg;
                        break;
 
                case 'N':
-                       switch (optarg[0])
+                       switch (pgis_optarg[0])
                        {
                        case 'a':
                                config->null_policy = POLICY_NULL_ABORT;
@@ -161,10 +161,10 @@ main (int argc, char **argv)
        }
 
        /* Determine the shapefile name from the next argument, if no shape file, exit. */
-       if (optind < argc)
+       if (pgis_optind < argc)
        {
-               config->shp_file = argv[optind];
-               optind++;
+               config->shp_file = argv[pgis_optind];
+               pgis_optind++;
        }
        else
        {
@@ -173,25 +173,25 @@ main (int argc, char **argv)
        }
 
        /* Determine the table and schema names from the next argument */
-       if (optind < argc)
+       if (pgis_optind < argc)
        {
                char *ptr;
 
-               ptr = strchr(argv[optind], '.');
+               ptr = strchr(argv[pgis_optind], '.');
 
                /* Schema qualified table name */
                if (ptr)
                {
-                       config->schema = malloc(strlen(argv[optind]) + 1);
-                       snprintf(config->schema, ptr - argv[optind] + 1, "%s", argv[optind]);
+                       config->schema = malloc(strlen(argv[pgis_optind]) + 1);
+                       snprintf(config->schema, ptr - argv[pgis_optind] + 1, "%s", argv[pgis_optind]);
 
-                       config->table = malloc(strlen(argv[optind]));
-                       snprintf(config->table, strlen(argv[optind]) - strlen(config->schema), "%s", ptr + 1);
+                       config->table = malloc(strlen(argv[pgis_optind]));
+                       snprintf(config->table, strlen(argv[pgis_optind]) - strlen(config->schema), "%s", ptr + 1);
                }
                else
                {
-                       config->table = malloc(strlen(argv[optind]) + 1);
-                       strcpy(config->table, argv[optind]);
+                       config->table = malloc(strlen(argv[pgis_optind]) + 1);
+                       strcpy(config->table, argv[pgis_optind]);
                }
        }
 
index ccac78c74d624bc4910538eaebb09aa444c4a1bb..adf7fe2ca97a5fe7b9b95958eff4acb5348d8e64 100644 (file)
@@ -407,6 +407,7 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr
        {
                lwcollection = lwcollection_construct(MULTILINETYPE, state->config->sr_id, NULL, obj->nParts, lwmultilinestrings);
                serialized_lwgeom = lwgeom_serialize(lwcollection_as_lwgeom(lwcollection));
+               
        }
        else
        {
index 75762071b31fa46708dbee2aa515d74559cae26f..cfc7f255d10984c648fc5e6fb62d04a83f13207a 100644 (file)
@@ -1212,19 +1212,19 @@ main(int argc, char *argv[])
                switch (c)
                {
                case 'U':
-                       conn->username = optarg;
+                       conn->username = pgis_optarg;
                        break;
                case 'p':
-                       conn->port = optarg;
+                       conn->port = pgis_optarg;
                        break;
                case 'W':
-                       conn->password = optarg;
+                       conn->password = pgis_optarg;
                        break;
                case 'd':
-                       conn->database = optarg;
+                       conn->database = pgis_optarg;
                        break;
                case 'h':
-                       conn->host = optarg;
+                       conn->host = pgis_optarg;
                        break;
                default:
                        usage();