summaryrefslogtreecommitdiff
path: root/Source/DOH
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DOH')
-rw-r--r--Source/DOH/base.c2
-rw-r--r--Source/DOH/doh.h8
-rw-r--r--Source/DOH/dohint.h2
-rw-r--r--Source/DOH/file.c8
-rw-r--r--Source/DOH/fio.c10
-rw-r--r--Source/DOH/string.c18
6 files changed, 25 insertions, 23 deletions
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index 15827f328..27a6b5dfa 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -631,7 +631,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
* DohWrite()
* ----------------------------------------------------------------------------- */
-int DohWrite(DOH *obj, void *buffer, int length) {
+int DohWrite(DOH *obj, const void *buffer, int length) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo;
if (DohCheck(obj)) {
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 766e12a34..bf1e50f4d 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
/* File methods */
-extern int DohWrite(DOHFile * obj, void *buffer, int length);
+extern int DohWrite(DOHFile * obj, const void *buffer, int length);
extern int DohRead(DOHFile * obj, void *buffer, int length);
extern int DohSeek(DOHFile * obj, long offset, int whence);
extern long DohTell(DOHFile * obj);
@@ -300,10 +300,10 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
* Files
* ----------------------------------------------------------------------------- */
-extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
+extern DOHFile *DohNewFile(const DOH *filename, const char *mode, DOHList *outfiles);
extern DOHFile *DohNewFileFromFile(FILE *f);
extern DOHFile *DohNewFileFromFd(int fd);
-extern void DohFileErrorDisplay(DOHString * filename);
+extern void DohFileErrorDisplay(const DOHString * filename);
extern int DohClose(DOH *file);
extern int DohCopyto(DOHFile * input, DOHFile * output);
@@ -355,7 +355,7 @@ extern void DohMemoryDebug(void);
#define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
#define Len DohLen
#define Data DohData
-#define Char (char *) Data
+#define Char (const char *) Data
#define Cmp DohCmp
#define Equal DohEqual
#define Setline DohSetline
diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h
index 1fc5eb7c9..446555ab3 100644
--- a/Source/DOH/dohint.h
+++ b/Source/DOH/dohint.h
@@ -44,7 +44,7 @@ typedef struct {
/* File methods */
typedef struct {
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
- int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
+ int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
int (*doh_putc) (DOH *obj, int ch); /* Put character */
int (*doh_getc) (DOH *obj); /* Get character */
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index 65c2336a4..eb438b0be 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -65,7 +65,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
* File_write()
* ----------------------------------------------------------------------------- */
-static int File_write(DOH *fo, void *buffer, int len) {
+static int File_write(DOH *fo, const void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
int ret = (int) fwrite(buffer, 1, len, f->filep);
@@ -231,10 +231,10 @@ static DohObjInfo DohFileType = {
* If newfiles is non-zero, the filename is added to the list of new files.
* ----------------------------------------------------------------------------- */
-DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) {
+DOH *DohNewFile(const DOH *filename, const char *mode, DOHList *newfiles) {
DohFile *f;
FILE *file;
- char *filen;
+ const char *filen;
filen = Char(filename);
file = fopen(filen, mode);
@@ -294,6 +294,6 @@ DOH *DohNewFileFromFd(int fd) {
* Display cause of one of the NewFile functions failing.
* ----------------------------------------------------------------------------- */
-void DohFileErrorDisplay(DOHString * filename) {
+void DohFileErrorDisplay(const DOHString * filename) {
Printf(stderr, "Unable to open file %s: %s\n", filename, strerror(errno));
}
diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c
index f544cee64..8271cbb18 100644
--- a/Source/DOH/fio.c
+++ b/Source/DOH/fio.c
@@ -328,19 +328,21 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
DohFree(stemp);
}
} else {
+ const char *enc_str = (const char*) doh;
if (!doh)
- doh = (char *) "";
+ enc_str = "";
if (strlen(encoder)) {
DOH *s = NewString(doh);
Seek(s, 0, SEEK_SET);
enc = encode(encoder, s);
Delete(s);
- doh = Char(enc);
+ enc_str = Char(enc);
} else {
enc = 0;
+ //enc_str = (const char*) doh;
}
- maxwidth = maxwidth + strlen(newformat) + strlen((char *) doh);
+ maxwidth = maxwidth + strlen(newformat) + strlen(enc_str);
*(fmt++) = 's';
*fmt = 0;
if ((maxwidth + 1) < OBUFLEN) {
@@ -348,7 +350,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
} else {
stemp = (char *) DohMalloc(maxwidth + 1);
}
- nbytes += sprintf(stemp, newformat, doh);
+ nbytes += sprintf(stemp, newformat, enc_str);
if (Writen(so, stemp, strlen(stemp)) < 0)
return -1;
if (stemp != obuffer) {
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 141cd58e8..9f0251f35 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -417,7 +417,7 @@ static int String_read(DOH *so, void *buffer, int len) {
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
-static int String_write(DOH *so, void *buffer, int len) {
+static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
String *s = (String *) ObjData(so);
s->hashkey = -1;
@@ -603,13 +603,13 @@ static char *end_quote(char *s) {
}
}
-static char *match_simple(char *base, char *s, char *token, int tokenlen) {
+static char *match_simple(char *base, char *s, const char *token, int tokenlen) {
(void) base;
(void) tokenlen;
return strstr(s, token);
}
-static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier(char *base, char *s, const char *token, int tokenlen) {
while (s) {
s = strstr(s, token);
if (!s)
@@ -628,7 +628,7 @@ static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
}
-static char *match_identifier_begin(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier_begin(char *base, char *s, const char *token, int tokenlen) {
while (s) {
s = strstr(s, token);
if (!s)
@@ -642,7 +642,7 @@ static char *match_identifier_begin(char *base, char *s, char *token, int tokenl
return 0;
}
-static char *match_identifier_end(char *base, char *s, char *token, int tokenlen) {
+static char *match_identifier_end(char *base, char *s, const char *token, int tokenlen) {
(void) base;
while (s) {
s = strstr(s, token);
@@ -657,7 +657,7 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
return 0;
}
-static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
+static int replace_simple(String *str, const char *token, const char *rep, int flags, int count, char *(*match) (char *, char *, const char *, int)) {
int tokenlen; /* Length of the token */
int replen; /* Length of the replacement */
int delta, expand = 0;
@@ -1148,9 +1148,9 @@ int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n)
}
char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2) {
- char *p1 = Char(s1);
- char *p2 = Char(s2);
- return p1 == 0 || p2 == 0 || *p2 == '\0' ? p1 : strstr(p1, p2);
+ const char *p1 = Char(s1);
+ const char *p2 = Char(s2);
+ return (char*) (p1 == 0 || p2 == 0 || *p2 == '\0' ? p1 : strstr(p1, p2));
}
char *DohStrchr(const DOHString_or_char *s1, int ch) {