summaryrefslogtreecommitdiff
path: root/xgps.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-05-20 16:41:51 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-05-20 16:41:51 +0000
commita777ee947925c8e50727a123c0bad72b6ee0814a (patch)
treefa3e2b531d509f556a22cffdb5934d515f135e99 /xgps.c
parent34a41422fa9485a5f463a14e66b0ebe3b5c242e3 (diff)
downloadgpsd-a777ee947925c8e50727a123c0bad72b6ee0814a.tar.gz
Dynamic SHM segment allocation.
Diffstat (limited to 'xgps.c')
-rw-r--r--xgps.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/xgps.c b/xgps.c
index c9b14212..f3c73153 100644
--- a/xgps.c
+++ b/xgps.c
@@ -361,7 +361,7 @@ static char *get_resource(Widget w, char *name, char *default_value)
int main(int argc, char *argv[])
{
int option;
- char *colon1, *colon2, *device = NULL, *server = NULL, *port = DEFAULT_GPSD_PORT;
+ char *arg, *colon1, *colon2, *device = NULL, *server = NULL, *port = DEFAULT_GPSD_PORT;
char *su, *au;
char *err_str = NULL;
@@ -400,14 +400,21 @@ altunits_ok:;
}
}
if (optind < argc) {
- server = strdup(argv[optind]);
- colon1 = strchr(server, ':');
+ arg = strdup(argv[optind]);
+ colon1 = strchr(arg, ':');
+ server = arg;
if (colon1 != NULL) {
- server[colon1 - server] = '\0';
- port = strdup(colon1 + 1);
- colon2 = strchr(server, ':');
+ if (colon1 == arg)
+ server = NULL;
+ else
+ *colon1 = '\0';
+ port = colon1 + 1;
+ colon2 = strchr(port, ':');
if (colon2 != NULL) {
- port[colon2 - port] = '\0';
+ if (colon2 == port)
+ port = NULL;
+ else
+ *colon2 = '\0';
device = colon2 + 1;
}
}