From 13112984fd32d4684959a923497a9a476981283e Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 8 Aug 2010 17:37:46 +0000 Subject: * hyper/ex2ht.c (strPrefix): Be const-correct. * hyper/htinp.c (get_graph_output): Likewise. (print_paste): Likewise. (print_graph_paste): Likewise. * hyper/initx.c (get_color): Likewise. * hyper/keyin.c (handle_key): Likewise. * hyper/lex.c (token_table): Likewise. * hyper/macro.c (number): Likewise. * hyper/mem.c (alloc_page): Likewise. * hyper/parse-aux.c (make_special_page): Likewise. (is_number): Likewise. * hyper/parse-types.c (errmess): Likewise. * lib/sockio-c.c (oa_socket_read): Cast to second argument to appropriate type. (oa_socket_read_byte): Likewise. --- src/ChangeLog | 18 ++++++++++++++++++ src/hyper/ex2ht.c | 2 +- src/hyper/htinp.c | 12 +++++++----- src/hyper/hyper.h | 4 ++-- src/hyper/initx.c | 4 ++-- src/hyper/keyin.c | 2 +- src/hyper/lex.c | 4 ++-- src/hyper/macro.c | 14 +++++++------- src/hyper/mem.c | 2 +- src/hyper/node.h | 2 +- src/hyper/parse-aux.c | 8 ++++---- src/hyper/parse-types.c | 4 ++-- src/hyper/parse.h | 4 ++-- src/hyper/token.h | 4 ++-- src/lib/sockio-c.c | 4 ++-- src/lib/util.c | 1 + 16 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7cbde11f..a0b81b5c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2010-08-08 Gabriel Dos Reis + + * hyper/ex2ht.c (strPrefix): Be const-correct. + * hyper/htinp.c (get_graph_output): Likewise. + (print_paste): Likewise. + (print_graph_paste): Likewise. + * hyper/initx.c (get_color): Likewise. + * hyper/keyin.c (handle_key): Likewise. + * hyper/lex.c (token_table): Likewise. + * hyper/macro.c (number): Likewise. + * hyper/mem.c (alloc_page): Likewise. + * hyper/parse-aux.c (make_special_page): Likewise. + (is_number): Likewise. + * hyper/parse-types.c (errmess): Likewise. + * lib/sockio-c.c (oa_socket_read): Cast to second argument to + appropriate type. + (oa_socket_read_byte): Likewise. + 2010-08-01 Aleksej Saushev * hyper/event.c: Include before other system headers. diff --git a/src/hyper/ex2ht.c b/src/hyper/ex2ht.c index 48556777..a109339a 100644 --- a/src/hyper/ex2ht.c +++ b/src/hyper/ex2ht.c @@ -164,7 +164,7 @@ emitFooter(FILE *outFile) static char * -strPrefix(char* prefix, char *s) +strPrefix(const char* prefix, char *s) { while (*prefix != '\0' && *prefix == *s) { prefix++; diff --git a/src/hyper/htinp.c b/src/hyper/htinp.c index c4a62bd5..b2065b8e 100644 --- a/src/hyper/htinp.c +++ b/src/hyper/htinp.c @@ -60,8 +60,8 @@ static char * make_paste_file_name(char * buf , char * filename); static void make_the_input_file(UnloadedPage * page); static void make_input_file_from_page(HyperDocPage * page); static int inListAndNewer(char * inputFile , char * htFile); -static void print_paste(FILE * pfile , char * realcom , char * command , char * pagename , int com_type); -static void print_graph_paste(FILE * pfile , char * realcom , char * command , char * pagename , int com_type); +static void print_paste(FILE*, char* , char*, const char*, int); +static void print_graph_paste(FILE*, char*, char* , const char*, int); static void send_command(char * command , int com_type); #define MaxInputFiles 256 @@ -406,7 +406,7 @@ get_spad_output(FILE *pfile,char *command,int com_type) * health of the viewport. We do this after the (|close|). */ void -get_graph_output(char *command,char *pagename,int com_type) +get_graph_output(char* command, const char* pagename, int com_type) { int n, i; char buf[1024]; @@ -453,7 +453,8 @@ send_command(char *command,int com_type) } static void -print_paste(FILE *pfile,char *realcom,char *command,char *pagename,int com_type) +print_paste(FILE* pfile, char* realcom, char* command, + const char* pagename, int com_type) { fprintf(pfile, "\\begin{patch}{%sPatch%d}\n", pagename, example_number); fprintf(pfile, "\\begin{paste}{%sFull%d}{%sEmpty%d}\n", @@ -480,7 +481,8 @@ print_paste(FILE *pfile,char *realcom,char *command,char *pagename,int com_type) fflush(pfile); } static void -print_graph_paste(FILE *pfile,char *realcom,char *command,char *pagename,int com_type) +print_graph_paste(FILE* pfile, char* realcom, char* command, + const char* pagename, int com_type) { fprintf(pfile, "\\begin{patch}{%sPatch%d}\n", pagename, example_number); fprintf(pfile, "\\begin{paste}{%sFull%d}{%sEmpty%d}\n", diff --git a/src/hyper/hyper.h b/src/hyper/hyper.h index de108ea4..2abecbaf 100644 --- a/src/hyper/hyper.h +++ b/src/hyper/hyper.h @@ -74,7 +74,7 @@ extern IfNode * alloc_ifnode(void); extern InputBox * alloc_inputbox(void); extern LineStruct * alloc_inputline(int size); extern TextNode * alloc_node(void); -extern HyperDocPage * alloc_page(char * name); +extern HyperDocPage * alloc_page(const char * name); extern PasteNode * alloc_paste_node(char * name); extern RadioBoxes * alloc_rbs(void); extern void free_button_list(ButtonList * bl); @@ -105,7 +105,7 @@ extern void verify_record(void ); extern char * strCopy(char * s); extern void print_paste_line(FILE * pfile , char * str); extern void get_spad_output(FILE * pfile , char * command , int com_type); -extern void get_graph_output(char * command , char * pagename , int com_type); +extern void get_graph_output(char*, const char*, int); extern void add_buffer_to_sym(char * buffer , InputItem * sym); extern void dialog(XEvent * event , KeySym keysym , char * buffer); extern void draw_inputsymbol(InputItem * sym); diff --git a/src/hyper/initx.c b/src/hyper/initx.c index 45a9ff4d..c4d212dd 100644 --- a/src/hyper/initx.c +++ b/src/hyper/initx.c @@ -75,7 +75,7 @@ extern int gethostname(char *, int ); static void get_GCs(HDWindow * window); static int get_border_properties(void); -static int get_color(char * , char * , int, Colormap*); +static int get_color(const char* , const char* , int, Colormap*); static void ingItColors_and_fonts(void); static void load_font(XFontStruct * * font_info , char * fontname); static void mergeDatabases(void); @@ -897,7 +897,7 @@ change_text(int color, XFontStruct *font) */ static int -get_color(char *name, char *klass, int def, Colormap *map) +get_color(const char *name, const char *klass, int def, Colormap *map) { char fullname[256]; char fullclass[256]; diff --git a/src/hyper/keyin.c b/src/hyper/keyin.c index 9e0f35e8..b397d956 100644 --- a/src/hyper/keyin.c +++ b/src/hyper/keyin.c @@ -127,7 +127,7 @@ handle_key(XEvent *event) XComposeStatus compstatus; int charcount; int display_again = 0; - char *name; + const char *name; char *filename; /*char *head = "echo htadd -l ";*/ /*char *blank1 = " ";*/ diff --git a/src/hyper/lex.c b/src/hyper/lex.c index 3f703f4e..1b828a08 100644 --- a/src/hyper/lex.c +++ b/src/hyper/lex.c @@ -114,7 +114,7 @@ char sock_buf[1024]; /* buffer for socket input */ static HashTable tokenHashTable; /* hash table of parser tokens */ -char* token_table[] = { +const char* token_table[] = { "", /* Dummy token name */ "word", "page", @@ -476,7 +476,7 @@ get_token(void) last_token = 0; token.type = unget_toke.type; strcpy(buffer, unget_toke.id); - free(unget_toke.id); + free((char*) unget_toke.id); token.id = buffer + 1; if (token.type == EOF) return EOF; diff --git a/src/hyper/macro.c b/src/hyper/macro.c index cdabf8f8..596506c6 100644 --- a/src/hyper/macro.c +++ b/src/hyper/macro.c @@ -86,14 +86,14 @@ scan_HyperDoc(void) } int -number(char *str) +number(const char *str) { - char *t = str; - - while (*t) - if (!isdigit(*t++)) - return 0; - return 1; + const char *t = str; + + while (*t) + if (!isdigit(*t++)) + return 0; + return 1; } /* Parse a given macro given the pointer to the unlaoded macro ** */ diff --git a/src/hyper/mem.c b/src/hyper/mem.c index 1617e21d..0aca518b 100644 --- a/src/hyper/mem.c +++ b/src/hyper/mem.c @@ -376,7 +376,7 @@ free_cond(CondNode *cond) /* Allocate a new HyperDoc page */ HyperDocPage * -alloc_page(char *name) +alloc_page(const char *name) { HyperDocPage *page; diff --git a/src/hyper/node.h b/src/hyper/node.h index 43f4dc6b..38204487 100644 --- a/src/hyper/node.h +++ b/src/hyper/node.h @@ -255,7 +255,7 @@ typedef struct ButtonList { typedef struct HyperDocPage { short type; /* Normal, Quitbutton, Upbutton etc. */ - char *name; /* ID of page */ + const char *name; /* ID of page */ char *filename; /* The name of the file in which the page occurs, Null if not */ int scroll_off; /* The offset in the scrolling region */ diff --git a/src/hyper/parse-aux.c b/src/hyper/parse-aux.c index 27556058..30957cce 100644 --- a/src/hyper/parse-aux.c +++ b/src/hyper/parse-aux.c @@ -43,7 +43,7 @@ #include "hyper.h" static void read_ht_file(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash , FILE * db_fp , char * db_file); -static HyperDocPage * make_special_page(int type , char * name); +static HyperDocPage * make_special_page(int type , const char * name); extern int make_input_file; extern int gverify_dates; @@ -387,7 +387,7 @@ make_paste_window(PasteNode *paste) /* create a HyperDoc page structure with the given type and name */ static HyperDocPage * -make_special_page(int type, char *name) +make_special_page(int type, const char *name) { HyperDocPage *page = alloc_page(name); @@ -470,9 +470,9 @@ add_dependencies(void) /* Returns true iff the TextNode contains a single integer */ int -is_number(char * str) +is_number(const char * str) { - char *s; + const char *s; for (s = str; *s != '\0'; s++) { if (!(isdigit(*s) || *s == '-')) diff --git a/src/hyper/parse-types.c b/src/hyper/parse-types.c index 67bbc252..9f0ddeaf 100644 --- a/src/hyper/parse-types.c +++ b/src/hyper/parse-types.c @@ -61,7 +61,7 @@ boolean gInItems = FALSE; boolean gInOptional = FALSE; -static char *errmess[] = { +static const char* errmess[] = { "place holder", "parsing condition node", "unrecognized keyword" @@ -78,7 +78,7 @@ static char *errmess[] = { */ static void -htperror(char *msg, int erno) +htperror(const char* msg, int erno) { char obuff[256]; diff --git a/src/hyper/parse.h b/src/hyper/parse.h index eaddd9bf..3c9b90bd 100644 --- a/src/hyper/parse.h +++ b/src/hyper/parse.h @@ -79,11 +79,11 @@ extern int window_equal(Window * w1 , Window * w2); extern char * window_id(Window w); extern void read_ht_db(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash); extern int get_filename(void); -extern int is_number(char * str); +extern int is_number(const char * str); extern void parser_error(char * str); extern int get_where(void); extern void scan_HyperDoc(void); -extern int number(char * str); +extern int number(const char * str); extern ParameterList init_parameter_elem(int number); extern int push_parameters(ParameterList); extern int pop_parameters(void); diff --git a/src/hyper/token.h b/src/hyper/token.h index e840ec42..c9bdf121 100644 --- a/src/hyper/token.h +++ b/src/hyper/token.h @@ -51,7 +51,7 @@ typedef struct Token { int type; /* token type. One of those listed below */ - char *id; /* string value if type == Identifier */ + const char *id; /* string value if type == Identifier */ } Token; /* @@ -239,7 +239,7 @@ typedef enum openaxiom_token_kind { } openaxiom_token_kind; -extern char *token_table[]; +extern const char *token_table[]; /* places from which input may be read */ diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c index 365e88eb..853ecd91 100644 --- a/src/lib/sockio-c.c +++ b/src/lib/sockio-c.c @@ -390,7 +390,7 @@ oa_connect_ip_port_stream(const openaxiom_byte* addr, int prot, OPENAXIOM_EXPORT int oa_socket_read(openaxiom_socket sock, openaxiom_byte* buf, int size) { - return recv(sock, buf, size, 0); + return recv(sock, (char*) buf, size, 0); } /* Attempt to read a byte from scoket `sock'. @@ -412,7 +412,7 @@ oa_socket_read_byte(openaxiom_socket sock) OPENAXIOM_EXPORT int oa_socket_write(openaxiom_socket sock, const openaxiom_byte* buf, int size) { - return send(sock, buf, size, 0); + return send(sock, (const char*) buf, size, 0); } /* Send one byte to socket `sock'. */ diff --git a/src/lib/util.c b/src/lib/util.c index 47362f7e..1fee3d04 100644 --- a/src/lib/util.c +++ b/src/lib/util.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include "view.h" -- cgit v1.2.3