From 7c7379c46fd51363a0e4f987afd0301618b3403d Mon Sep 17 00:00:00 2001 From: carl Date: Tue, 19 Feb 2019 00:33:54 +0800 Subject: [PATCH] Better ANSI C compatibility and portability - part 1: + Addition of function prototypes. + Change function definitions to ANSI C style. + Convert to sed scripts some shell scripts for better portability. + Reduce usage of em_path.h (TMPDIR is no longer hard coded) --- modules/src/em_mes/CMakeLists.txt | 37 +++++++++++++++++++++++++++++++ modules/src/em_mes/C_ms_com.c | 8 +++---- modules/src/em_mes/C_ms_ego.c | 9 +++----- modules/src/em_mes/C_ms_emx.c | 8 +++---- modules/src/em_mes/C_ms_err.c | 7 +++--- modules/src/em_mes/C_ms_flt.c | 7 +++--- modules/src/em_mes/C_ms_gto.c | 7 +++--- modules/src/em_mes/C_ms_opt.c | 7 +++--- modules/src/em_mes/C_ms_par.c | 8 +++---- modules/src/em_mes/C_ms_reg.c | 9 +++----- modules/src/em_mes/C_ms_src.c | 9 +++----- modules/src/em_mes/C_ms_stb.c | 10 +++------ modules/src/em_mes/C_ms_std.c | 10 +++------ 13 files changed, 73 insertions(+), 63 deletions(-) create mode 100644 modules/src/em_mes/CMakeLists.txt diff --git a/modules/src/em_mes/CMakeLists.txt b/modules/src/em_mes/CMakeLists.txt new file mode 100644 index 000000000..075cf9398 --- /dev/null +++ b/modules/src/em_mes/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required (VERSION 3.0) +project(em_mes) + + +set(SRC_C + C_ms_com.c + C_ms_ego.c + C_ms_emx.c + C_ms_err.c + C_ms_flt.c + C_ms_gto.c + C_ms_opt.c + C_ms_par.c + C_ms_reg.c + C_ms_src.c + C_ms_stb.c + C_ms_std.c +) + +set(INCLUDE_DIRS + . +) + + +add_library(${PROJECT_NAME} ${SRC_C}) +target_compile_definitions(${PROJECT_NAME} PUBLIC NORCSID=1) +target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRS}) + +target_link_libraries(${PROJECT_NAME} emheaders emh emk em_data) + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include +) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/em_mes.3 DESTINATION man OPTIONAL) diff --git a/modules/src/em_mes/C_ms_com.c b/modules/src/em_mes/C_ms_com.c index b6d22106d..328ba3f1c 100644 --- a/modules/src/em_mes/C_ms_com.c +++ b/modules/src/em_mes/C_ms_com.c @@ -6,12 +6,10 @@ #include #include -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_com(str) - char *str; +void C_ms_com(char* str) { C_mes_begin(ms_com); C_scon(str, (arith) (strlen(str) + 1)); diff --git a/modules/src/em_mes/C_ms_ego.c b/modules/src/em_mes/C_ms_ego.c index 1c9c5f776..0dcb27392 100644 --- a/modules/src/em_mes/C_ms_ego.c +++ b/modules/src/em_mes/C_ms_ego.c @@ -3,13 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_ego(hint, offs, siz, regno) - int hint, regno; - arith offs, siz; +void C_ms_ego(int hint, arith offs, arith siz, int regno) { C_mes_begin(ms_ego); C_cst((arith)hint); diff --git a/modules/src/em_mes/C_ms_emx.c b/modules/src/em_mes/C_ms_emx.c index e95dadd55..e4c908f3c 100644 --- a/modules/src/em_mes/C_ms_emx.c +++ b/modules/src/em_mes/C_ms_emx.c @@ -3,12 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_emx(wsiz, psiz) - arith wsiz, psiz; +void C_ms_emx(arith wsiz, arith psiz) { C_mes_begin(ms_emx); C_cst(wsiz); diff --git a/modules/src/em_mes/C_ms_err.c b/modules/src/em_mes/C_ms_err.c index df4880153..f6dfa82d7 100644 --- a/modules/src/em_mes/C_ms_err.c +++ b/modules/src/em_mes/C_ms_err.c @@ -3,11 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_err() +void C_ms_err(void) { C_mes_begin(ms_err); C_mes_end(); diff --git a/modules/src/em_mes/C_ms_flt.c b/modules/src/em_mes/C_ms_flt.c index 557cbbb2a..1f092ed68 100644 --- a/modules/src/em_mes/C_ms_flt.c +++ b/modules/src/em_mes/C_ms_flt.c @@ -3,11 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_flt() +void C_ms_flt(void) { C_mes_begin(ms_flt); C_mes_end(); diff --git a/modules/src/em_mes/C_ms_gto.c b/modules/src/em_mes/C_ms_gto.c index 29bbd1ee7..c6ba4c1cd 100644 --- a/modules/src/em_mes/C_ms_gto.c +++ b/modules/src/em_mes/C_ms_gto.c @@ -3,11 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_gto() +void C_ms_gto(void) { C_mes_begin(ms_gto); C_mes_end(); diff --git a/modules/src/em_mes/C_ms_opt.c b/modules/src/em_mes/C_ms_opt.c index 386d268bb..a80e9c812 100644 --- a/modules/src/em_mes/C_ms_opt.c +++ b/modules/src/em_mes/C_ms_opt.c @@ -3,11 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_opt() +void C_ms_opt(void) { C_mes_begin(ms_opt); C_mes_end(); diff --git a/modules/src/em_mes/C_ms_par.c b/modules/src/em_mes/C_ms_par.c index 7d7c39fe9..adb7c2fc8 100644 --- a/modules/src/em_mes/C_ms_par.c +++ b/modules/src/em_mes/C_ms_par.c @@ -3,12 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_par(nparams) - arith nparams; +void C_ms_par(arith nparams) { C_mes_begin(ms_par); C_cst(nparams); diff --git a/modules/src/em_mes/C_ms_reg.c b/modules/src/em_mes/C_ms_reg.c index c63063c84..7b1934385 100644 --- a/modules/src/em_mes/C_ms_reg.c +++ b/modules/src/em_mes/C_ms_reg.c @@ -3,13 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_reg(offs, siz, class, prior) - arith offs, siz; - int class, prior; +void C_ms_reg(arith offs, arith siz, int class, int prior) { C_mes_begin(ms_reg); C_cst(offs); diff --git a/modules/src/em_mes/C_ms_src.c b/modules/src/em_mes/C_ms_src.c index 583168140..d4556f6e8 100644 --- a/modules/src/em_mes/C_ms_src.c +++ b/modules/src/em_mes/C_ms_src.c @@ -6,13 +6,10 @@ #include #include -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_src(nlines, filnam) - int nlines; - char *filnam; +void C_ms_src(int nlines, char* filnam) { C_mes_begin(ms_src); C_cst((arith)nlines); diff --git a/modules/src/em_mes/C_ms_stb.c b/modules/src/em_mes/C_ms_stb.c index 430dea397..600b747dc 100644 --- a/modules/src/em_mes/C_ms_stb.c +++ b/modules/src/em_mes/C_ms_stb.c @@ -6,14 +6,10 @@ #include #include -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_stb_cst(s, e1, e2, e3) - char *s; - int e1, e2; - arith e3; +void C_ms_stb_cst(char* s, int e1, int e2, arith e3) { C_mes_begin(ms_stb); if (s) C_scon(s, (arith) (strlen(s)+1)); diff --git a/modules/src/em_mes/C_ms_std.c b/modules/src/em_mes/C_ms_std.c index 0399fa8ed..afc815147 100644 --- a/modules/src/em_mes/C_ms_std.c +++ b/modules/src/em_mes/C_ms_std.c @@ -6,14 +6,10 @@ #include #include -#include -#include +#include "em.h" +#include "em_mes.h" -void -C_ms_std(s, e1, l) - char *s; - int e1; - int l; +void C_ms_std(char* s, int e1, int l) { C_mes_begin(ms_std); if (s) C_scon(s, (arith) (strlen(s)+1)); -- 2.34.1