9fans archive / 2001 / 03 / 256 / prev next
From: Quinn Dunkan <quinn@env...>
Subject: [9fans] more questions
Date: Tue, 27 Mar 2001 23:54:53 -0800
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.