9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] more questions
@ 2001-03-28  7:54 Quinn Dunkan
  0 siblings, 0 replies; 6+ messages in thread
From: Quinn Dunkan @ 2001-03-28  7:54 UTC (permalink / raw)
  To: 9fans

A few anal questions:

Why does utflen() return an int instead of a long?

Should Brdline take a Rune as the delimiter?

isalpharune(2) claims that toupperrune and tolowerrune return ints, but they
return Runes.

9p(2) says that "the wstat function takes a fid and a new Dir structure for
it, as well as a bitmask specifying which fields to update".  The signature in
the struct Srv has no mention of a bitmask.  Is the documentation in error?



The following function, when called with 're = regcomp("(..):(..)")' and
's = "ab:34"' will print:

matching against 'ab:34'

However, when the first line after the '{' is changed from 'char *s, *src;' to
'char *s;', it will print:

matching against 'ab:34'
success

The match will succeed if 'char *s' is placed below 'Reprog *re', but it will fail
if placed below 'Resub matches[...]', or if it is at the top with 'Reprog *re' and
'Resub matches[...]' swapped.  It will always fail if another 'char *' (or plain
'char') is declared on the same line as it is (the name doesn't matter).
Another 'char *' being declared at the bottom makes the regexp succeed,
though.

// just a fragment
static int re_sub(lua_State *L)
{
	char *s, *src;
	Reprog *re;
	Resub matches[max_matches];

	if (lua_tag(L, 1) != re_tag)
		luaL_argerror(L, 1, "expected regexp object");
	re = (Reprog *) lua_touserdata(L, 1);
	s = luaL_check_string(L, 2);

	print("matching against '%s'\n", s);
	if (regexec(re, s, matches, max_matches) == 0) {
		lua_pushnil(L);
		return 1;
	}
	print("success\n");
	return 0;
}

I was under the impression that changing the order of one's variable
declarations should have no effect on the operation of the program.
I tried making a standalone function (called from C), but the problem went
away then.  Could it be a compiler bug?  It's hard to reduce since it's being
called from lua, but if it could be a real issue I'll try to track it down.



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [9fans] more questions
@ 2001-04-04 19:05 Quinn Dunkan
  0 siblings, 0 replies; 6+ messages in thread
From: Quinn Dunkan @ 2001-04-04 19:05 UTC (permalink / raw)
  To: 9fans


Correction:
A tarball with a few plan9 binaries that crash my kernel every time is at

http://www.ugcs.caltech.edu/~quinn/9crash.tgz

Sorry.


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [9fans] more questions
@ 2001-03-28 18:15 rob pike
  0 siblings, 0 replies; 6+ messages in thread
From: rob pike @ 2001-03-28 18:15 UTC (permalink / raw)
  To: 9fans

	Why does utflen() return an int instead of a long?
It should be long; fixed.

	Should Brdline take a Rune as the delimiter?
Probably, but it's a nasty change to make.

	isalpharune(2) claims that toupperrune and tolowerrune return ints, but they
	return Runes.
You're right; fixed.

-rob



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [9fans] more questions
@ 2001-03-28 10:21 rog
  2001-04-04  9:14 ` Quinn Dunkan
  0 siblings, 1 reply; 6+ messages in thread
From: rog @ 2001-03-28 10:21 UTC (permalink / raw)
  To: 9fans

i've been bitten by that regexp problem before.  your problem is that
the matches array is being used uninitialised.  as the documentation
says:

          If match[0].sp is nonzero on entry, regexec starts matching
          at that point within string. If match[0].ep is nonzero on
          entry, the last character matched is the one preceding that
          point.

in a larger program, your code would probably have broken... and then
you'd probably have found the problem!

  cheers,
    rog.



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [9fans] more questions
@ 2001-03-28  5:56 Russ Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Russ Cox @ 2001-03-28  5:56 UTC (permalink / raw)
  To: 9fans

the 9p(2) thing is an error.  it sounds like
an early version of 9p2000; probably i edited
the wrong manual.  

don't get too comfortable with 9p(2).  i changed
a bunch of stuff (including interfaces) when i
rewrote the library for 9p2000.  

in the lua code, what is max_matches?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-04-04 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-28  7:54 [9fans] more questions Quinn Dunkan
  -- strict thread matches above, loose matches on Subject: below --
2001-04-04 19:05 Quinn Dunkan
2001-03-28 18:15 rob pike
2001-03-28 10:21 rog
2001-04-04  9:14 ` Quinn Dunkan
2001-03-28  5:56 Russ Cox

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).