9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: lucio@proxima.alt.za, 9fans@9fans.net
Subject: Re: [9fans] new toy - gmap
Date: Thu, 26 Mar 2009 09:35:01 -0400	[thread overview]
Message-ID: <41acb85011976d492e4910cd3c8927e4@quanstro.net> (raw)
In-Reply-To: <edd56c0e508ab35523f6419fc89307f5@proxima.alt.za>

On Thu Mar 26 04:42:48 EDT 2009, lucio@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;



  reply	other threads:[~2009-03-26 13:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-13  0:05 Steve Simon
2009-03-13 18:27 ` Akshat Kumar
2009-03-13 20:09   ` Steve Simon
2009-03-13 20:37     ` Akshat Kumar
2009-03-13 22:44       ` Bruce Ellis
2009-03-13 22:59         ` J.R. Mauro
2009-03-13 23:11           ` LiteStar numnums
2009-03-13 23:12             ` David Leimbach
2009-03-13 23:15               ` Bruce Ellis
2009-03-13 23:11           ` David Leimbach
2009-03-13 23:17             ` J.R. Mauro
2009-03-13 23:21               ` Bruce Ellis
2009-03-13 23:23               ` LiteStar numnums
2009-03-13 23:26                 ` Bruce Ellis
2009-03-13 23:45                   ` J.R. Mauro
2009-03-13 18:54 ` hiro
2009-03-13 23:46 ` blstuart
2009-03-13 23:52   ` Anthony Sorace
2009-03-13 23:58     ` blstuart
2009-03-14  0:22       ` erik quanstrom
2009-03-14  4:25         ` Bruce Ellis
2009-03-13 23:54   ` Steve Simon
2009-03-14  0:03     ` blstuart
2009-03-14  0:28     ` J.R. Mauro
2009-03-26  6:29     ` lucio
2009-03-26 13:35       ` erik quanstrom [this message]
2009-03-16 10:08 ` Balwinder S Dheeman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41acb85011976d492e4910cd3c8927e4@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    --cc=lucio@proxima.alt.za \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).