From 3a4195e4293dce547f9fd671063d9b65ca14cc56 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 1 Apr 2013 01:53:29 +0000 Subject: More C cleanups --- src/clef/edible.c | 3 ++- src/graph/view2D/spadAction2d.c | 6 +++--- src/hyper/ex2ht.c | 3 ++- src/hyper/htadd.c | 3 ++- src/hyper/hthits.c | 3 ++- src/hyper/hyper.c | 4 +++- src/hyper/spadbuf.c | 4 +++- src/lib/cfuns-c.c | 2 ++ src/sman/session.c | 4 ++-- src/sman/sman.c | 2 +- src/sman/spadclient.c | 3 ++- 11 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/clef/edible.c b/src/clef/edible.c index dd07181b..71900805 100644 --- a/src/clef/edible.c +++ b/src/clef/edible.c @@ -127,6 +127,7 @@ char logpath[30]; int main(int argc, char *argv[]) { + using namespace OpenAxiom; fd_set rfds; /* the structure for the select call */ int code; /* return code from system calls */ char out_buff[MAXLINE]; /* from child and stdin */ @@ -137,7 +138,7 @@ main(int argc, char *argv[]) - putenv((char*) "LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); /* try to get a pseudoterminal to play with */ if (ptyopen(&contNum, &serverNum, serverPath) == -1) { diff --git a/src/graph/view2D/spadAction2d.c b/src/graph/view2D/spadAction2d.c index eafd4325..60789eb1 100644 --- a/src/graph/view2D/spadAction2d.c +++ b/src/graph/view2D/spadAction2d.c @@ -69,7 +69,7 @@ extern int viewAloned; int spadAction(void) { - int code,viewCommand; + int viewCommand; float f1,f2; int i1,i2,i3,viewGoAhead; static int ack = 1; @@ -121,7 +121,7 @@ spadAction(void) break; case closeAll2D: - code = check(write(Socket,&ack,intSize)); + check(write(Socket,&ack,intSize)); goodbye(-1); case ps2D: @@ -282,7 +282,7 @@ spadAction(void) ack++; - code = check(write(Socket,&ack,intSize)); + check(write(Socket,&ack,intSize)); return(0); } diff --git a/src/hyper/ex2ht.c b/src/hyper/ex2ht.c index bbb1db14..3637776a 100644 --- a/src/hyper/ex2ht.c +++ b/src/hyper/ex2ht.c @@ -267,9 +267,10 @@ exToHt(const char* filename) int main(int argc, char **argv) { + using namespace OpenAxiom; int i; - putenv("LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); if (argc == 1) { fprintf(stderr, "usage: %s exfile.ht ...\n", argv[0]); diff --git a/src/hyper/htadd.c b/src/hyper/htadd.c index d8c32a75..e28bd31d 100644 --- a/src/hyper/htadd.c +++ b/src/hyper/htadd.c @@ -91,6 +91,7 @@ int fresh = 0; int main(int argc, char **argv) { + using namespace OpenAxiom; /*int i;*/ char db_dir[256]; /* the directory where the db file is */ char dbfilename[256]; /* the database filename */ @@ -98,7 +99,7 @@ main(int argc, char **argv) char **fnames = filenames; short flag; /* flag for deleting or adding */ - putenv("LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); parse_args(argv, db_dir, filenames, &flag); diff --git a/src/hyper/hthits.c b/src/hyper/hthits.c index d2e2cfb9..0dd712c5 100644 --- a/src/hyper/hthits.c +++ b/src/hyper/hthits.c @@ -413,7 +413,8 @@ cmdline(int argc, char** argv) int main(int argc, char** argv) { - putenv("LC_ALL=C"); + using namespace OpenAxiom; + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); cmdline(argc, argv); regcomp(®_pattern, pattern, REG_NEWLINE); diff --git a/src/hyper/hyper.c b/src/hyper/hyper.c index e88f63f0..f306e0b8 100644 --- a/src/hyper/hyper.c +++ b/src/hyper/hyper.c @@ -52,6 +52,7 @@ #include #include "debug.h" +#include "cfuns.h" #include "sockio.h" #include "hyper.h" #include "lex.h" @@ -196,11 +197,12 @@ clean_socket(void ) int main(int argc, char **argv) { + using namespace OpenAxiom; int ret_status; /* Initialize some global values */ /* fprintf(stderr,"hyper:main:entered\n");*/ - putenv("LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); gArgc = argc; gArgv = argv; diff --git a/src/hyper/spadbuf.c b/src/hyper/spadbuf.c index e173b86f..18f28c0e 100644 --- a/src/hyper/spadbuf.c +++ b/src/hyper/spadbuf.c @@ -49,6 +49,7 @@ #include #include "halloc.h" #include "bsdsignal.h" +#include "cfuns.h" #include "sockio.h" #include "edible.h" #include "com.h" @@ -215,6 +216,7 @@ init_parent(void) int main(int argc,char ** argv) { + using namespace OpenAxiom; /* * Modified on 6/13/90 for the command line completion abiltities of * Since I am only calling this program from within spadint, I decided @@ -223,7 +225,7 @@ main(int argc,char ** argv) * spadbuf page_name [completion_ files] * */ - putenv("LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); if (argc < 2) { fprintf(stderr, "Usage : spadbuf page_name [completion_files] \n"); diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index 049d7305..1b75219e 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -595,6 +595,8 @@ oa_setenv(const char* var, const char* val) { #ifdef __WIN32__ return SetEnvironmentVariable(var, val); +#elif HAVE_DECL_SETENV + return !setenv(var, val, true); #else const int var_length = strlen(var); const int val_length = strlen(val); diff --git a/src/sman/session.c b/src/sman/session.c index 2a64dbc2..42c0ada4 100644 --- a/src/sman/session.c +++ b/src/sman/session.c @@ -466,13 +466,13 @@ fprintf(stderr,"rd=%u]\n",*((long *)rd.fds_bits)); int main(void) { - + using namespace OpenAxiom; #ifdef DEBUG2 /* delay for attaching with debugger before interesting things happen */ openaxiom_sleep(30); #endif - putenv("LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); /* spad_server connects to Lisp server socket read_SpadServer_command handles requests */ diff --git a/src/sman/sman.c b/src/sman/sman.c index bddbdfc3..1b2a243a 100644 --- a/src/sman/sman.c +++ b/src/sman/sman.c @@ -776,7 +776,7 @@ main(int argc, char *argv[]) command.root_dir = get_systemdir(argc, argv); process_options(&command, argc, argv); - putenv((char*) "LC_ALL=C"); + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); bsdSignal(SIGINT, SIG_IGN,RestartSystemCalls); init_term_io(); diff --git a/src/sman/spadclient.c b/src/sman/spadclient.c index dd1d6722..8d23e1d4 100644 --- a/src/sman/spadclient.c +++ b/src/sman/spadclient.c @@ -63,7 +63,8 @@ inter_handler(int sig) int main(void) { - putenv("LC_ALL=C"); + using namespace OpenAxiom; + oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); sock = connect_to_local_server(SessionServer, InterpWindow, Forever); bsdSignal(SIGINT, inter_handler,RestartSystemCalls); -- cgit v1.2.3