$NetBSD: patch-bf,v 1.3 1999/11/26 06:09:01 itohy Exp $ --- wwwoffle.c.orig Fri Oct 15 18:26:54 1999 +++ wwwoffle.c Thu Nov 25 20:00:36 1999 @@ -245,7 +245,7 @@ if(!strcmp(argv[i],"-p")) { - char *colon; + char *colon, *escr, *escl; if(++i>=argc) {fprintf(stderr,"wwwoffle: The '-p' argument requires a hostname and optionally a port number.\n"); exit(1);} @@ -253,7 +253,7 @@ if(ConfigFile) {fprintf(stderr,"wwwoffle: The '-p' and '-c' options cannot be used together.\n"); exit(1);} - if((colon=strchr(argv[i],':'))) + if((colon=strrchr(argv[i],':'))) { *colon++=0; @@ -263,7 +263,14 @@ {fprintf(stderr,"wwwoffle: The port number %d '%s' is invalid.\n",port,argv[i]); exit(1);} } - host=argv[i]; + escl=strchr(argv[i],'['); + escr=strrchr(argv[i],']'); + if (escl && escr) { + host=escl+1; + *escr=0; + } + else + host=argv[i]; argv[i-1]=NULL; argv[i]=NULL; @@ -379,12 +386,12 @@ host=(char*)malloc(strlen(env)+1); strcpy(host,env); - if((colon1=strchr(host,':'))) + if((colon2=strrchr(host,':'))) { - *colon1=0; - if((colon2=strchr(colon1+1,':'))) + *colon2=0; + if((colon1=strchr(host,':'))) { - *colon2=0; + *colon1=0; if(action==Get || action==Output || action==OutputWithHeader) port=atoi(colon1+1); else