On Thu Mar 26 04:42:48 EDT 2009, lu...@proxima.alt.za wrote: > > Pick up the new code, it reads the key from /lib/gmapkey > > and gets the longditude and latitude the correct way round > > (as several people have told me. > > I use: > > lng=`{echo $here(2) | sed -e 's/^-(.*)/+\1/' -e 's/^([0-9])/-\1/'} > > Because double negatives (--) don't seem to cut it in the URL :-) > I imagine there's a better way, but rc programming is not my strong > suit. And I can't test now the simplification that drops the \1 from the > first term.
this was my approach. just remove any leading --. /n/dump/2009/0326/rc/bin/gmap:5,11 - /rc/bin/gmap:5,11 gmapkey = `{cat /lib/gmapkey} here = `{cat /lib/sky/here} lat = $here(1) - lng = -$here(2) + lng = `{echo -$here(2) | sed 's/^--//g'} if(~ $#gmapkey 0){ echo goto http://code.google.com/apis/maps/signup.html and get a google maps key (free) > I got caught by the fact that the space after -e is mandatory (why?) > and the first \1 belongs to me trying to figure out what I was doing > wrong. this is due to non-standard usage of ARGF. it might be a good idea to replace the continues between ARGBEGIN and ARGEND with break. currently ARGEND doesn't do anything, but one could imagine a different implementation that does. - erik ; diff -c sed.c /sys/src/cmd/ sed.c:203,209 - /sys/src/cmd//sed.c:203,208 void main(int argc, char **argv) { - char *p; int compfl; lnum = 0; sed.c:215,230 - /sys/src/cmd//sed.c:214,229 exits(0); ARGBEGIN{ case 'e': - if ((p = ARGF()) == nil) + if (argc <= 1) quit("missing pattern"); - newfile(P_ARG, p); + newfile(P_ARG, ARGF()); fcomp(); compfl = 1; continue; case 'f': - if ((p = ARGF()) == nil) + if(argc <= 1) quit("no pattern-file"); - newfile(P_FILE, p); + newfile(P_FILE, ARGF()); fcomp(); compfl = 1; continue;