summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2006-08-29 18:04:11 +0000
committerStef Walter <stef@thewalter.net>2006-08-29 18:04:11 +0000
commitfd2e875c5fb0c7aa5e550d41dad4a6794df8d078 (patch)
tree2e20f50eb11d11ac72500c9d3897e8f8b602cc78
parent9a41a6510a2aad8e0d07097c81f54c968b0fd99b (diff)
compiler warnings when compiling rep
-rw-r--r--ChangeLog1
-rw-r--r--common/compat.h6
-rw-r--r--common/usuals.h2
-rw-r--r--lib/compile.c7
-rw-r--r--lib/execute.c20
-rw-r--r--lib/priv.h2
-rw-r--r--lib/rlib.c5
-rw-r--r--src/rep.c3
8 files changed, 25 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index d5b291c..0143f12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
Version 2.3.3
- Add --enable-debug compile mode
- Fix endless loop on 0 length files
+ - Fix compiler warnings
Version 2.3.2e
- Use <stdlib.h> instead of <malloc.h>
diff --git a/common/compat.h b/common/compat.h
index 86a9e04..bd6078a 100644
--- a/common/compat.h
+++ b/common/compat.h
@@ -20,6 +20,8 @@
#ifndef _COMPAT_H_
#define _COMPAT_H_
+#define _GNU_SOURCE
+
/* Force use of win32 configuration if compiling there */
#ifdef _WIN32
#include "../config.win32.h"
@@ -156,7 +158,9 @@ extern int optind, opterr, optopt;
int getopt(int nargc, char* const* nargv, const char* ostr);
#endif
-#ifndef HAVE_ERR_H
+#ifdef HAVE_ERR_H
+#include <err.h>
+#else
#include <stdarg.h>
void err_set_file(void *fp);
void err_set_exit(void (*ef)(int));
diff --git a/common/usuals.h b/common/usuals.h
index d09fd72..5bd7b98 100644
--- a/common/usuals.h
+++ b/common/usuals.h
@@ -20,6 +20,8 @@
#ifndef __USUALS_H__20000613
#define __USUALS_H__20000613
+#define _GNU_SOURCE
+
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
diff --git a/lib/compile.c b/lib/compile.c
index b0cd818..651bd70 100644
--- a/lib/compile.c
+++ b/lib/compile.c
@@ -406,7 +406,7 @@ static void pushValues(compilecontext* ctx, bool forward, ...)
size_t cur = 0;
va_start(ap, forward);
- while(len = va_arg(ap, size_t))
+ while((len = va_arg(ap, size_t)))
{
if(cur + len > VAL_BUF)
{
@@ -623,9 +623,8 @@ bool isEscaped(const char* str, const char* posi)
char* splitTagMatch(r_script* script, char* regexp)
{
char* second = regexp;
- while(second = strchr(second, kTagDelim))
+ while((second = strchr(second, kTagDelim)))
{
- uint escs = 0;
if(!isEscaped(regexp, second))
{
second[0] = '\0';
@@ -939,7 +938,7 @@ int compileStatement(r_script* script, compilecontext* ctx)
compileSpace(ctx);
/* Check for a delimiter */
- if(delim = strchr(kValidDelim, *(ctx->in)))
+ if((delim = strchr(kValidDelim, *(ctx->in))))
{
ctx->in++;
end = ctx->in;
diff --git a/lib/execute.c b/lib/execute.c
index 0662849..5e67b5b 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -236,7 +236,7 @@ void* dataGetValue(data* dat, void* key)
struct dat* d;
ASSERT_PTR(dat);
- if(d = _dataFind(dat, key))
+ if((d = _dataFind(dat, key)))
return d->value;
return NULL;
@@ -252,7 +252,7 @@ bool dataSetValue(data* dat, void* key, void* value)
if(!_dataAllocate(dat))
return false;
- if(d = _dataFind(dat, key))
+ if((d = _dataFind(dat, key)))
{
d->value = value;
}
@@ -374,7 +374,7 @@ struct vari* _variablesFind(variables* vars, const char* name)
}
/* If not found then look up in the Environment */
- if(val = getenv(name))
+ if((val = getenv(name)))
return _variablesNew(vars, name, val, strlen(val));
return NULL;
@@ -442,7 +442,7 @@ bool variablesClear(variables* vars, const char* name)
{
struct vari* v;
ASSERT_PTR(vars);
- if(v = _variablesFind(vars, name))
+ if((v = _variablesFind(vars, name)))
starclr(v->value);
return true;
@@ -485,7 +485,7 @@ static char* _escapeString(const char* string)
while((pos += strcspn(string + pos, kSpecialChars)) < len)
cnt++, pos++;
- if(buff = (char*)malloc(sizeof(char) * (len + cnt + 1)))
+ if((buff = (char*)malloc(sizeof(char) * (len + cnt + 1))))
{
pos = 0;
strcpy(buff, string);
@@ -502,7 +502,6 @@ static char* _escapeString(const char* string)
int variablesSubstitute(variables* vars, r_stream* stream, r_script* script,
char** pstr, bool mode)
{
- size_t len = strlen(*pstr);
char* next = *pstr;
struct internal_state* state = stream->state;
@@ -584,7 +583,7 @@ int variablesSubstitute(variables* vars, r_stream* stream, r_script* script,
next[len] = 0;
/* Do we have this variable? */
- if(v = _variablesFind(vars, next + 1))
+ if((v = _variablesFind(vars, next + 1)))
value = v->value;
else
value = "\0\0";
@@ -638,7 +637,7 @@ int variablesSubstitute(variables* vars, r_stream* stream, r_script* script,
next = strrep(next, 0, starnext(value) ? "|" : "");
}
- while(value = starnext(value));
+ while((value = starnext(value)));
/* Add closing parentheses if needed */
next = strrep(next, 0, multi ? ")" : "");
@@ -683,7 +682,7 @@ bool variablesHasVars(const char* string)
{
const char* cur = string;
- if(cur = strchr(cur, '%'))
+ if((cur = strchr(cur, '%')))
{
if(!isEscaped(string, cur))
return true;
@@ -1109,7 +1108,6 @@ int vmExecute(r_stream* stream, r_script* script)
/* These are the registers passed to PCRE */
int pcreregs[MAX_REGS * 3];
- int num_regs = 0;
/* And over here we have the stack */
uint* vmStack = NULL;
@@ -1268,7 +1266,7 @@ int vmExecute(r_stream* stream, r_script* script)
* - We use the op header pointer as key to the pcre struct
* - And the pcre struct pointer as the key to the pcre_extra struct
*/
- if(re = (pcre*)dataGetValue(&(state->working), header))
+ if((re = (pcre*)dataGetValue(&(state->working), header)))
{
/* This prevents the freeing of stuff below */
cache = true;
diff --git a/lib/priv.h b/lib/priv.h
index d671fd7..ada6845 100644
--- a/lib/priv.h
+++ b/lib/priv.h
@@ -96,7 +96,7 @@ bool vmInit(r_stream* stream);
void vmClean(r_stream* stream);
void vmFree(r_stream* stream);
-static const char* kValidIdentifier = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
+#define kValidIdentifier "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
#define USE_STACK_VARS
diff --git a/lib/rlib.c b/lib/rlib.c
index 5b308d3..7396160 100644
--- a/lib/rlib.c
+++ b/lib/rlib.c
@@ -37,7 +37,6 @@
int rlibInit(r_stream* stream, long options)
{
- byte* op = NULL;
int i, j;
struct internal_state* state;
@@ -282,7 +281,7 @@ void rlibFree(r_stream* stream, r_script* script)
if(stream)
{
- if(state = stream->state)
+ if((state = stream->state))
{
/* Let execution free it's stuff */
vmFree(stream);
@@ -456,7 +455,7 @@ int repInit(r_context* ctx)
}
#ifdef _DEBUG
-static void* memstr(void* mem, size_t sz, const char* str)
+void* memstr(void* mem, size_t sz, const char* str)
{
size_t len = strlen(str);
const char* t;
diff --git a/src/rep.c b/src/rep.c
index aec5220..6cc0849 100644
--- a/src/rep.c
+++ b/src/rep.c
@@ -295,7 +295,8 @@ int main(int argc, char* argv[])
/* Give some stats */
if(ret == 0 && g_showStatus)
- fprintf(stderr, "\n[%d replacements in %d files]\n", g_totalReplaces, g_totalFiles);
+ fprintf(stderr, "\n[%d replacements in %d files]\n",
+ (int)g_totalReplaces, (int)g_totalFiles);
/* Done! */
return ret <= 0 ? 0 : ret;