Changeset: 7c6da1a985ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7c6da1a985ec
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/mal_client.h
monetdb5/mal/mal_import.c
monetdb5/mal/mal_parser.c
sql/server/sql_scan.c
sql/server/sql_scan.h
Branch: default
Log Message:
More size_t.
diffs (283 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2191,7 +2191,7 @@ str generatorRef;
MALfcn getAddress(str fcnname);
str getArgDefault(MalBlkPtr mb, InstrPtr p, int idx);
ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k);
-int getAtomIndex(const char *nme, int len, int deftpe);
+int getAtomIndex(const char *nme, size_t len, int deftpe);
lng getBatSpace(BAT *b);
int getBitConstant(MalBlkPtr mb, bit val);
int getBlockBegin(MalBlkPtr mb, int pc);
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -40,7 +40,7 @@ enum clientmode {
*/
typedef struct CLIENT_INPUT {
bstream *fdin;
- int yycur;
+ size_t yycur;
int listing;
char *prompt;
struct CLIENT_INPUT *next;
@@ -90,7 +90,7 @@ typedef struct CLIENT {
*/
str srcFile; /* NULL for stdin, or file name */
bstream *fdin;
- int yycur; /* the scanners current position */
+ size_t yycur; /* the scanners current position */
/*
* Keeping track of instructions executed is a valuable tool for
* script processing and debugging. It can be changed at runtime
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -154,7 +154,7 @@ malInclude(Client c, str name, int listi
str p;
bstream *oldfdin = c->fdin;
- int oldyycur = c->yycur;
+ size_t oldyycur = c->yycur;
int oldlisting = c->listing;
enum clientmode oldmode = c->mode;
int oldblkmode = c->blkmode;
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -154,7 +154,7 @@ skipSpace(Client cntxt)
}
static inline void
-advance(Client cntxt, int length)
+advance(Client cntxt, size_t length)
{
cntxt->yycur += length;
skipSpace(cntxt);
@@ -202,7 +202,7 @@ idLength(Client cntxt)
{
str s,t;
int len = 0;
-
+
skipSpace(cntxt);
s = CURRENT(cntxt);
t = s;
@@ -226,10 +226,10 @@ idLength(Client cntxt)
}
/* Simple type identifiers can not be marked with a type variable. */
-static int
+static size_t
typeidLength(Client cntxt)
{
- int l;
+ size_t l;
char id[IDLENGTH], *t= id;
str s;
skipSpace(cntxt);
@@ -646,9 +646,11 @@ handleInts:
* scope.
* Additional information, such as a repetition factor,
* encoding tables, or type dependency should be modeled as properties.
+ *
+ * It would make more sense for tpe parameter to be an int, but simpleTypeId
returns a size_t
*/
static int
-typeAlias(Client cntxt, int tpe)
+typeAlias(Client cntxt, size_t tpe)
{
int t;
@@ -673,7 +675,8 @@ typeAlias(Client cntxt, int tpe)
static int
simpleTypeId(Client cntxt)
{
- int l, tpe;
+ int tpe;
+ size_t l;
nextChar(cntxt);
l = typeidLength(cntxt);
@@ -682,7 +685,7 @@ simpleTypeId(Client cntxt)
cntxt->yycur--; /* keep it */
return -1;
}
- tpe = getAtomIndex(CURRENT(cntxt), (size_t) l, -1);
+ tpe = getAtomIndex(CURRENT(cntxt), l, -1);
if (tpe < 0) {
parseError(cntxt, "Type identifier expected\n");
cntxt->yycur -= l; /* keep it */
@@ -695,8 +698,9 @@ simpleTypeId(Client cntxt)
static int
parseTypeId(Client cntxt, int defaultType)
{
- int i = TYPE_any, tt, kt = 0;
+ int i = TYPE_any, kt = 0;
char *s = CURRENT(cntxt);
+ size_t tt;
if (s[0] == ':' && s[1] == 'b' && s[2] == 'a' && s[3] == 't' && s[4] ==
'[') {
/* parse :bat[:oid,:type] */
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -600,7 +600,7 @@ utf8_putchar(struct scanner *lc, int ch)
}
static inline int
-scanner_read_more(struct scanner *lc, int n)
+scanner_read_more(struct scanner *lc, size_t n)
{
bstream *b = lc->rs;
bool more = false;
@@ -632,8 +632,7 @@ scanner_getc(struct scanner *lc)
{
bstream *b = lc->rs;
unsigned char *s = NULL;
- int c;
- int n, m, mask;
+ int c, m, n, mask;
if (scanner_read_more(lc, 1) == EOF) {
lc->errstr = "end of input stream";
@@ -657,7 +656,7 @@ scanner_getc(struct scanner *lc)
goto error;
}
- if (scanner_read_more(lc, n) == EOF)
+ if (scanner_read_more(lc, (size_t) n) == EOF)
return EOF;
s = (unsigned char *) b->buf + b->pos + lc->yycur;
@@ -707,7 +706,7 @@ scanner_string(mvc *c, int quote, bool e
lc->started = 1;
while (cur != EOF) {
- unsigned int pos = (int)rs->pos + lc->yycur;
+ size_t pos = rs->pos + lc->yycur;
while ((((cur = rs->buf[pos++]) & 0x80) == 0) && cur && (cur !=
quote || escape)) {
if (escapes && cur == '\\')
@@ -715,7 +714,7 @@ scanner_string(mvc *c, int quote, bool e
else
escape = false;
}
- lc->yycur = pos - (int)rs->pos;
+ lc->yycur = pos - rs->pos;
/* check for quote escaped quote: Obscure SQL Rule */
/* TODO also handle double "" */
if (cur == quote && rs->buf[pos] == quote) {
@@ -758,9 +757,9 @@ scanner_body(mvc *c)
bool escape = false;
lc->started = 1;
- assert(rs->buf[(int)rs->pos + lc->yycur-1] == '{');
+ assert(rs->buf[rs->pos + lc->yycur-1] == '{');
while (cur != EOF) {
- unsigned int pos = (int)rs->pos + lc->yycur;
+ size_t pos = rs->pos + lc->yycur;
while ((((cur = rs->buf[pos++]) & 0x80) == 0) && cur && (blk ||
escape)) {
if (cur != '\\')
@@ -770,7 +769,7 @@ scanner_body(mvc *c)
blk += cur =='{';
blk -= cur =='}';
}
- lc->yycur = pos - (int)rs->pos;
+ lc->yycur = pos - rs->pos;
assert(pos <= rs->len + 1);
if (blk == 0 && !escape){
lc->yycur--; /* go back to current (possibly
invalid) char */
@@ -796,7 +795,7 @@ keyword_or_ident(mvc * c, int cur)
{
struct scanner *lc = &c->scanner;
keyword *k = NULL;
- int s;
+ size_t s;
lc->started = 1;
utf8_putchar(lc, cur);
@@ -1202,7 +1201,8 @@ valid_ident(const char *restrict s, char
}
static inline int
-sql_get_next_token(YYSTYPE *yylval, void *parm) {
+sql_get_next_token(YYSTYPE *yylval, void *parm)
+{
mvc *c = (mvc*)parm;
struct scanner *lc = &c->scanner;
int token = 0, cur = 0;
@@ -1229,7 +1229,7 @@ sql_get_next_token(YYSTYPE *yylval, void
return EOF;
token = tokenize(c, cur);
- yylval->sval = (lc->rs->buf + (int)lc->rs->pos + lc->yysval);
+ yylval->sval = (lc->rs->buf + lc->rs->pos + lc->yysval);
/* This is needed as ALIAS and aTYPE get defined too late, see
sql_keyword.h */
@@ -1308,13 +1308,13 @@ sqllex(YYSTYPE * yylval, void *parm)
int token;
mvc *c = (mvc *) parm;
struct scanner *lc = &c->scanner;
- int pos;
+ size_t pos;
/* store position for when view's query ends */
- pos = (int)lc->rs->pos + lc->yycur;
+ pos = lc->rs->pos + lc->yycur;
token = sql_get_next_token(yylval, parm);
-
+
if (token == NOT) {
int next = sqllex(yylval, parm);
@@ -1342,14 +1342,13 @@ sqllex(YYSTYPE * yylval, void *parm)
} else if (token == SCOLON) {
/* ignore semi-colon(s) following a semi-colon */
if (lc->yylast == SCOLON) {
- int prev = lc->yycur;
+ size_t prev = lc->yycur;
while ((token = sql_get_next_token(yylval, parm)) ==
SCOLON)
prev = lc->yycur;
/* skip the skipped stuff also in the buffer */
lc->rs->pos += prev;
lc->yycur -= prev;
- assert(lc->yycur >= 0);
}
}
diff --git a/sql/server/sql_scan.h b/sql/server/sql_scan.h
--- a/sql/server/sql_scan.h
+++ b/sql/server/sql_scan.h
@@ -21,19 +21,17 @@ struct scanner {
stream *log;
int yynext; /* next token, lr(1) isn't powerful enough for
sql */
- int yylast; /* previous token, to detect superfluous
semi-colons */
- int yysval; /* start of current token */
+ size_t yylast; /* previous token, to detect superfluous semi-colons */
+ size_t yysval; /* start of current token */
int yyval; /* current token */
- int yycur; /* next char in the queue */
+ size_t yycur; /* next char in the queue */
char yybak; /* sometimes it's needed to write an EOS marker
*/
- int as; /* start of query part of view's etc */
+ size_t as; /* start of query part of view's etc */
int key; /* query hash */
- int started; /* found at least one token */
+ int started; /* found at least one token */
prot mode; /* which mode (line (1,N), blocked) */
- char *schema; /* Keep schema name of create statement,
- needed AUTO_INCREMENT, SERIAL */
- char *errstr; /* error message from the bowels of
- * the scanner */
+ char *schema; /* Keep schema name of create statement, needed
AUTO_INCREMENT, SERIAL */
+ char *errstr; /* error message from the bowels of the scanner */
};
#define QUERY(scanner) (scanner.rs->buf+scanner.rs->pos)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list