summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
Diffstat (limited to 'dimension')
-rw-r--r--dimension/common.prologue3
-rw-r--r--dimension/common.rules6
-rw-r--r--dimension/directives.rules9
-rw-r--r--dimension/lexer.l6
-rw-r--r--dimension/parse.c39
-rw-r--r--dimension/progressbar.c4
-rw-r--r--dimension/realize.c33
-rw-r--r--dimension/tokenize.c5
8 files changed, 38 insertions, 67 deletions
diff --git a/dimension/common.prologue b/dimension/common.prologue
index 4fdfcee..8bbeaea 100644
--- a/dimension/common.prologue
+++ b/dimension/common.prologue
@@ -65,8 +65,7 @@ dmnsn_new_astnode(dmnsn_astnode_type type, YYLTYPE lloc)
static void
dmnsn_copy_children(dmnsn_astnode dest, dmnsn_astnode src)
{
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(src.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(src.children); ++i) {
dmnsn_astnode node;
dmnsn_array_get(src.children, i, &node);
++*node.refcount;
diff --git a/dimension/common.rules b/dimension/common.rules
index 9a72b44..4644627 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -152,8 +152,7 @@ OBJECT: FINITE_SOLID_OBJECT
*modifiers = dmnsn_new_astnode(DMNSN_AST_OBJECT_MODIFIERS, @4);
dmnsn_copy_children(*modifiers, orig_modifiers);
- unsigned int i;
- for (i = 0; i < dmnsn_array_size($4.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size($4.children); ++i) {
dmnsn_astnode astnode;
dmnsn_array_get($4.children, i, &astnode);
++*astnode.refcount;
@@ -186,8 +185,7 @@ OBJECT: FINITE_SOLID_OBJECT
dmnsn_array_size($$.children) - 1,
&modifiers);
- unsigned int i;
- for (i = 0; i < dmnsn_array_size($4.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size($4.children); ++i) {
dmnsn_astnode astnode;
dmnsn_array_get($4.children, i, &astnode);
++*astnode.refcount;
diff --git a/dimension/directives.rules b/dimension/directives.rules
index e199fe3..84358f6 100644
--- a/dimension/directives.rules
+++ b/dimension/directives.rules
@@ -77,19 +77,18 @@ LANGUAGE_DIRECTIVE: "#include" STRING {
"Attempt to expand non-macro.");
dmnsn_delete_astnode($1);
- unsigned int nparams = dmnsn_array_size(node->children);
- unsigned int nparams_given = dmnsn_array_size($3.children);
+ size_t nparams = dmnsn_array_size(node->children);
+ size_t nparams_given = dmnsn_array_size($3.children);
if (nparams_given != nparams) {
dmnsn_diagnostic(@$, "wrong number of macro arguments"
- " (%u; should be %u)",
+ " (%zu; should be %zu)",
nparams_given, nparams);
dmnsn_delete_astnode($3);
YYERROR;
}
- unsigned int i;
- for (i = 0; i < nparams; ++i) {
+ for (size_t i = 0; i < nparams; ++i) {
dmnsn_astnode id, param;
dmnsn_array_get(node->children, i, &id);
dmnsn_array_get($3.children, i, &param);
diff --git a/dimension/lexer.l b/dimension/lexer.l
index 1abb4b8..6198fea 100644
--- a/dimension/lexer.l
+++ b/dimension/lexer.l
@@ -422,8 +422,7 @@ void
dmnsn_delete_tokens(dmnsn_array *tokens)
{
dmnsn_token token;
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(tokens); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(tokens); ++i) {
dmnsn_array_get(tokens, i, &token);
dmnsn_delete_token(token);
}
@@ -455,7 +454,6 @@ void
dmnsn_print_token_sexpr(FILE *file, const dmnsn_array *tokens)
{
dmnsn_token token;
- unsigned int i;
if (dmnsn_array_size(tokens) == 0) {
fprintf(file, "()");
@@ -464,7 +462,7 @@ dmnsn_print_token_sexpr(FILE *file, const dmnsn_array *tokens)
dmnsn_array_get(tokens, 0, &token);
dmnsn_print_token(file, token);
- for (i = 1; i < dmnsn_array_size(tokens); ++i) {
+ for (size_t i = 1; i < dmnsn_array_size(tokens); ++i) {
fprintf(file, " ");
dmnsn_array_get(tokens, i, &token);
dmnsn_print_token(file, token);
diff --git a/dimension/parse.c b/dimension/parse.c
index 802a3e5..da22cb2 100644
--- a/dimension/parse.c
+++ b/dimension/parse.c
@@ -44,8 +44,7 @@ dmnsn_delete_patricia_trie(dmnsn_patricia_trie *trie)
if (trie->leaf)
dmnsn_delete_astnode(trie->value);
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(trie->children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(trie->children); ++i) {
dmnsn_patricia_trie *subtrie;
dmnsn_array_get(trie->children, i, &subtrie);
dmnsn_delete_patricia_trie(subtrie);
@@ -289,8 +288,7 @@ dmnsn_declare_symbol(dmnsn_symbol_table *symtable,
void
dmnsn_undef_symbol(dmnsn_symbol_table *symtable, const char *id)
{
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(symtable); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(symtable); ++i) {
dmnsn_patricia_trie *trie;
dmnsn_array_get(symtable, dmnsn_array_size(symtable) - i - 1, &trie);
if (dmnsn_patricia_remove(trie, id))
@@ -303,8 +301,7 @@ dmnsn_find_symbol(dmnsn_symbol_table *symtable, const char *id)
{
dmnsn_astnode *symbol = NULL;
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(symtable); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(symtable); ++i) {
dmnsn_patricia_trie *trie;
dmnsn_array_get(symtable, dmnsn_array_size(symtable) - i - 1, &trie);
@@ -472,8 +469,7 @@ void
dmnsn_delete_astree(dmnsn_astree *astree)
{
if (astree) {
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astree); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astree); ++i) {
dmnsn_astnode node;
dmnsn_array_get(astree, i, &node);
dmnsn_delete_astnode(node);
@@ -518,8 +514,7 @@ dmnsn_vector_promote(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
if (astnode.type == DMNSN_AST_VECTOR) {
dmnsn_astnode component;
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_array_get(astnode.children, i, &component);
component = dmnsn_eval_scalar(component, symtable);
@@ -609,8 +604,6 @@ dmnsn_eval_zeroary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
static dmnsn_astnode
dmnsn_eval_unary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
{
- unsigned int i;
-
dmnsn_astnode rhs;
dmnsn_array_get(astnode.children, 0, &rhs);
rhs = dmnsn_eval(rhs, symtable);
@@ -684,7 +677,7 @@ dmnsn_eval_unary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_astnode op = dmnsn_copy_astnode(astnode);
dmnsn_array_resize(op.children, 1);
- for (i = 0; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 0; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_array_get(rhs.children, i, dmnsn_array_at(op.children, 0));
dmnsn_astnode temp = dmnsn_eval_unary(op, symtable);
dmnsn_array_set(ret.children, i, &temp);
@@ -957,8 +950,6 @@ dmnsn_eval_unary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
static dmnsn_astnode
dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
{
- unsigned int i;
-
dmnsn_astnode lhs, rhs;
dmnsn_array_get(astnode.children, 0, &lhs);
dmnsn_array_get(astnode.children, 1, &rhs);
@@ -998,7 +989,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_array_push(rewrite.children, &l);
dmnsn_array_push(rewrite.children, &r);
- for (i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_astnode temp = dmnsn_copy_astnode(astnode);
dmnsn_array_get(lhs.children, i, &l);
dmnsn_array_get(rhs.children, i, &r);
@@ -1031,7 +1022,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_array_push(rewrite.children, &l);
dmnsn_array_push(rewrite.children, &r);
- for (i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_astnode temp = dmnsn_copy_astnode(astnode);
dmnsn_array_get(lhs.children, i, &l);
dmnsn_array_get(rhs.children, i, &r);
@@ -1065,7 +1056,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_array_push(rewrite.children, &l);
dmnsn_array_push(rewrite.children, &r);
- for (i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_astnode temp = dmnsn_copy_astnode(astnode);
temp.type = DMNSN_AST_OR;
dmnsn_array_get(lhs.children, i, &l);
@@ -1100,7 +1091,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_array_push(rewrite.children, &l);
dmnsn_array_push(rewrite.children, &r);
- for (i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 1; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_astnode temp = dmnsn_copy_astnode(astnode);
temp.type = DMNSN_AST_OR;
dmnsn_array_get(lhs.children, i, &l);
@@ -1218,7 +1209,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_array_push(rewrite.children, &l);
dmnsn_array_push(rewrite.children, &r);
- for (i = 1; i < 3; ++i) {
+ for (size_t i = 1; i < 3; ++i) {
dmnsn_astnode temp = dmnsn_copy_astnode(astnode);
temp.type = DMNSN_AST_MUL;
dmnsn_array_get(lhs.children, i, &l);
@@ -1288,7 +1279,7 @@ dmnsn_eval_binary(dmnsn_astnode astnode, dmnsn_symbol_table *symtable)
dmnsn_astnode op = dmnsn_copy_astnode(astnode);
dmnsn_array_resize(op.children, 2);
- for (i = 0; i < DMNSN_VECTOR_NELEM; ++i) {
+ for (size_t i = 0; i < DMNSN_VECTOR_NELEM; ++i) {
dmnsn_array_get(lhs.children, i, dmnsn_array_at(op.children, 0));
dmnsn_array_get(rhs.children, i, dmnsn_array_at(op.children, 1));
dmnsn_astnode temp = dmnsn_eval_binary(op, symtable);
@@ -1780,13 +1771,12 @@ dmnsn_print_astnode(FILE *file, dmnsn_astnode astnode)
static void
dmnsn_print_astree(FILE *file, dmnsn_astnode astnode)
{
- unsigned int i;
dmnsn_astnode child;
if (astnode.children && dmnsn_array_size(astnode.children) > 0) {
fprintf(file, "(");
dmnsn_print_astnode(file, astnode);
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_array_get(astnode.children, i, &child);
fprintf(file, " ");
dmnsn_print_astree(file, child);
@@ -1801,7 +1791,6 @@ void
dmnsn_print_astree_sexpr(FILE *file, const dmnsn_astree *astree)
{
dmnsn_astnode astnode;
- unsigned int i;
if (dmnsn_array_size(astree) == 0) {
fprintf(file, "()");
@@ -1810,7 +1799,7 @@ dmnsn_print_astree_sexpr(FILE *file, const dmnsn_astree *astree)
dmnsn_array_get(astree, 0, &astnode);
dmnsn_print_astree(file, astnode);
- for (i = 1; i < dmnsn_array_size(astree); ++i) {
+ for (size_t i = 1; i < dmnsn_array_size(astree); ++i) {
fprintf(file, " ");
dmnsn_array_get(astree, i, &astnode);
dmnsn_print_astree(file, astnode);
diff --git a/dimension/progressbar.c b/dimension/progressbar.c
index 6abcbd6..a8bf11c 100644
--- a/dimension/progressbar.c
+++ b/dimension/progressbar.c
@@ -45,8 +45,8 @@ dmnsn_progressbar(const char *format, const dmnsn_progress *progress, ...)
width = ws.ws_col;
}
- unsigned int i, increments = width - (len % width);
- for (i = 0; i < increments; ++i) {
+ unsigned int increments = width - (len % width);
+ for (unsigned int i = 0; i < increments; ++i) {
dmnsn_wait_progress(progress, ((double)(i + 1))/increments);
printf(".");
diff --git a/dimension/realize.c b/dimension/realize.c
index 6771782..05eae07 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -190,8 +190,7 @@ dmnsn_realize_global_settings(dmnsn_astnode astnode, dmnsn_scene *scene)
dmnsn_assert(astnode.type == DMNSN_AST_GLOBAL_SETTINGS,
"Expected global settings.");
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode item, child;
dmnsn_array_get(astnode.children, i, &item);
@@ -228,8 +227,7 @@ dmnsn_realize_camera(dmnsn_astnode astnode)
dmnsn_camera *camera = NULL;
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode item;
dmnsn_array_get(astnode.children, i, &item);
@@ -410,8 +408,7 @@ dmnsn_realize_pigment_modifiers(dmnsn_astnode astnode, dmnsn_pigment *pigment)
dmnsn_assert(astnode.type == DMNSN_AST_PIGMENT_MODIFIERS,
"Expected pigment modifiers.");
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode modifier;
dmnsn_array_get(astnode.children, i, &modifier);
@@ -510,8 +507,7 @@ dmnsn_realize_reflection(dmnsn_astnode astnode)
dmnsn_astnode items;
dmnsn_array_get(astnode.children, 2, &items);
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(items.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(items.children); ++i) {
dmnsn_astnode item, child;
dmnsn_array_get(items.children, i, &item);
@@ -549,8 +545,7 @@ dmnsn_realize_finish(dmnsn_astnode astnode)
dmnsn_finish *reflection = NULL;
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode item, child;
dmnsn_array_get(astnode.children, i, &item);
@@ -621,8 +616,7 @@ dmnsn_realize_texture(dmnsn_astnode astnode)
dmnsn_texture *texture = dmnsn_new_texture();
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode item;
dmnsn_array_get(astnode.children, i, &item);
@@ -659,8 +653,7 @@ dmnsn_realize_interior(dmnsn_astnode astnode)
dmnsn_interior *interior = dmnsn_new_interior();
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode item, child;
dmnsn_array_get(astnode.children, i, &item);
@@ -687,8 +680,7 @@ dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object)
/* Save the pre-existing transformations */
dmnsn_matrix existing_trans = dmnsn_matrix_inverse(object->trans);
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode modifier;
dmnsn_array_get(astnode.children, i, &modifier);
@@ -746,8 +738,7 @@ dmnsn_realize_light_source_modifiers(dmnsn_astnode astnode, dmnsn_light *light)
dmnsn_assert(astnode.type == DMNSN_AST_OBJECT_MODIFIERS,
"Expected object modifiers.");
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(astnode.children); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astnode.children); ++i) {
dmnsn_astnode modifier;
dmnsn_array_get(astnode.children, i, &modifier);
@@ -899,7 +890,7 @@ dmnsn_realize_csg(dmnsn_astnode astnode, dmnsn_array *lights,
dmnsn_array_get(astnode.children, 0, &objects);
dmnsn_array_get(astnode.children, 1, &modifiers);
- unsigned int i;
+ size_t i;
dmnsn_object *csg = NULL;
for (i = 0; i < dmnsn_array_size(objects.children) && !csg; ++i) {
dmnsn_astnode onode;
@@ -1019,9 +1010,7 @@ dmnsn_realize_astree(const dmnsn_astree *astree)
*/
dmnsn_astnode astnode;
- unsigned int i;
-
- for (i = 0; i < dmnsn_array_size(astree); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(astree); ++i) {
dmnsn_array_get(astree, i, &astnode);
dmnsn_light *light;
diff --git a/dimension/tokenize.c b/dimension/tokenize.c
index 707d0df..efa1064 100644
--- a/dimension/tokenize.c
+++ b/dimension/tokenize.c
@@ -38,7 +38,7 @@ typedef struct dmnsn_token_buffer {
dmnsn_parse_location lloc;
dmnsn_array *buffered;
- unsigned int i;
+ size_t i;
struct dmnsn_token_buffer *prev;
@@ -67,8 +67,7 @@ dmnsn_delete_token_buffer(void *ptr)
{
dmnsn_token_buffer *tbuffer = ptr;
if (tbuffer) {
- unsigned int i;
- for (i = 0; i < dmnsn_array_size(tbuffer->buffered); ++i) {
+ for (size_t i = 0; i < dmnsn_array_size(tbuffer->buffered); ++i) {
dmnsn_buffered_token buffered;
dmnsn_array_get(tbuffer->buffered, i, &buffered);
free(buffered.lval.value);