9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Quinn Dunkan <quinn@envy.ugcs.caltech.edu>
To: 9fans@cse.psu.edu
Subject: [9fans] more questions
Date: Tue, 27 Mar 2001 23:54:53 -0800	[thread overview]
Message-ID: <200103280754.XAA00562@tammananny.tiger> (raw)

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.



             reply	other threads:[~2001-03-28  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-28  7:54 Quinn Dunkan [this message]
  -- 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

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=200103280754.XAA00562@tammananny.tiger \
    --to=quinn@envy.ugcs.caltech.edu \
    --cc=9fans@cse.psu.edu \
    /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).