diff options
author | dos-reis <gdr@axiomatics.org> | 2011-05-30 17:07:22 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-05-30 17:07:22 +0000 |
commit | 72d3df9188861d62e9c6e1a29a720d6dc0696d99 (patch) | |
tree | 4d33deaf2b78e62f66a037654a3dbdb665016ed6 /src | |
parent | f99ece56ccd39726097c11bb2f78f79c2ab340ef (diff) | |
download | open-axiom-72d3df9188861d62e9c6e1a29a720d6dc0696d99.tar.gz |
fix const-correctness in old C codes
Diffstat (limited to 'src')
-rw-r--r-- | src/include/edible.h | 2 | ||||
-rw-r--r-- | src/include/fnct_key.h | 2 | ||||
-rw-r--r-- | src/include/sockio.h | 2 | ||||
-rw-r--r-- | src/include/wct.h | 6 | ||||
-rw-r--r-- | src/lib/cfuns-c.c | 6 | ||||
-rw-r--r-- | src/lib/fnct_key.c | 11 | ||||
-rw-r--r-- | src/lib/sockio-c.c | 5 | ||||
-rw-r--r-- | src/lib/wct.c | 6 |
8 files changed, 19 insertions, 21 deletions
diff --git a/src/include/edible.h b/src/include/edible.h index 99340a5e..8af60c8f 100644 --- a/src/include/edible.h +++ b/src/include/edible.h @@ -103,7 +103,7 @@ extern int mode; /** One of the above # defines *****/ /** Here is the structure for storing bound pf-keys ***/ typedef struct Fkey { - char *str; + const char *str; short type; } fkey; diff --git a/src/include/fnct_key.h b/src/include/fnct_key.h index 812b62b6..9adda9c1 100644 --- a/src/include/fnct_key.h +++ b/src/include/fnct_key.h @@ -1,7 +1,7 @@ /* Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. All rights reserved. - Copyright (C) 2007-2010, Gabriel Dos Reis. + Copyright (C) 2007-2011, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/include/sockio.h b/src/include/sockio.h index c848c434..031809f2 100644 --- a/src/include/sockio.h +++ b/src/include/sockio.h @@ -82,7 +82,7 @@ struct openaxiom_sio { struct sockaddr_in i_addr; } addr; char *host_name; /* name of foreign host if type == AF_INET */ - size_t nbytes_pending; /* pending bytes for read. */ + int nbytes_pending; /* pending bytes for read. */ }; diff --git a/src/include/wct.h b/src/include/wct.h index bc7a3604..fd33c089 100644 --- a/src/include/wct.h +++ b/src/include/wct.h @@ -1,7 +1,7 @@ /* Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. All rights reserved. - Copyright (C) 2007-2010, Gabriel Dos Reis. + Copyright (C) 2007-2011, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,7 +37,7 @@ #define OPENAXIOM_wct_INCLUDED extern time_t ftime(char * ); -extern void fatal(char * , char * ); +extern void fatal(const char * , const char * ); extern off_t fsize(char * ); extern Wix * scanWct(Wct * , char * ); extern void reintern1Wct(Wct * ); @@ -48,7 +48,7 @@ extern void printTime(long * ); extern int skimString(char * , int , int , int ); extern int prChar(int ); extern Wct * reread1Wct(Wct * ); -extern void sfatal(char * ); +extern void sfatal(const char * ); extern Wct * read1Wct(char * ); extern Wct * nconcWct(Wct * , Wct * ); extern void sortWct(Wct * ); diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index a4ae8f39..f0b7aed7 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -2,7 +2,7 @@ Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. All rights reserved. - Copyright (C) 2007-2010, Gabriel Dos Reis. + Copyright (C) 2007-2011, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -160,7 +160,7 @@ directoryp(char *path) OPENAXIOM_C_EXPORT int make_path_from_file(char *s, char *t) { - char *pos = ""; + char *pos = NULL; char *c; /** simply copies the path name from t into s **/ @@ -209,7 +209,7 @@ make_path_from_file(char *s, char *t) static inline int axiom_has_write_access(const struct stat* file_info) { - int effetive_uid = geteuid(); + uid_t effetive_uid = geteuid(); if (effetive_uid == 0) return 1; diff --git a/src/lib/fnct_key.c b/src/lib/fnct_key.c index bac0fdb5..69498ec0 100644 --- a/src/lib/fnct_key.c +++ b/src/lib/fnct_key.c @@ -1,7 +1,7 @@ /* Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. All rights reserved. - Copyright (C) Gabriel Dos Reis. + Copyright (C) 2007-2011 Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ using namespace OpenAxiom; fkey function_key[13]; /** Strings which replace function keys when a key is hit ***/ -static char *defaulteditor = "clefedit"; +static const char *defaulteditor = "clefedit"; char editorfilename[100]; @@ -153,11 +153,8 @@ define_function_keys(void) } break; } - if (type != -1) { - (function_key[key]).str = - (char *) malloc(strlen(string) + 1); - sprintf((function_key[key]).str, "%s", string); - } + if (type != -1) + (function_key[key]).str = strdup(string); } } diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c index 31439c43..a29be625 100644 --- a/src/lib/sockio-c.c +++ b/src/lib/sockio-c.c @@ -105,17 +105,18 @@ int spad_server_number = -1; This is needed only for MS platforms. */ static int openaxiom_socket_module_loaded = 0; +#ifdef __WIN32__ /* Windows require some handshaking with the WinSock DLL before we can even think about talking about sockets. */ static void openaxiom_unload_socket_module(void) { -#ifdef __WIN32__ WSACleanup(); openaxiom_socket_module_loaded = 0; -#endif } +#endif + static void openaxiom_load_socket_module(void) diff --git a/src/lib/wct.c b/src/lib/wct.c index 200d9a3d..35cc01e9 100644 --- a/src/lib/wct.c +++ b/src/lib/wct.c @@ -1,7 +1,7 @@ /* Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. All rights reserved. - Copyright (C) Gabriel Dos Reis. + Copyright (C) 2007-2011 Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -463,13 +463,13 @@ reintern1Wct(Wct *pwct) } void -sfatal(char *s) +sfatal(const char *s) { fatal("%s", s); } void -fatal(char *fmt,char * s) +fatal(const char* fmt, const char* s) { static char fbuf[256]; |