From 2ec247f3d869c8d5e64f469f12f8b1bed6daede0 Mon Sep 17 00:00:00 2001 From: Anders Lindh Olsson <anders.lindholsson@ess.eu> Date: Wed, 1 Dec 2021 17:32:05 +0100 Subject: [PATCH] Apply pre-commit --- require-ess/src/asprintf.c | 2 +- require-ess/src/dbLoadTemplate.h | 2 +- require-ess/src/dbLoadTemplate.y | 10 +++++----- require-ess/src/dbLoadTemplate_lex.l | 2 +- require-ess/src/expr.c | 4 ++-- require-ess/src/runScript.c | 22 +++++++++++----------- require-ess/src/strdup.c | 2 +- require-ess/src/version.h | 2 +- require-ess/test/testscript | 4 ++-- require-ess/tools/README.md | 1 - require-ess/tools/expandDBD.tcl | 4 ++-- 11 files changed, 27 insertions(+), 28 deletions(-) diff --git a/require-ess/src/asprintf.c b/require-ess/src/asprintf.c index 4981b74f..68495340 100644 --- a/require-ess/src/asprintf.c +++ b/require-ess/src/asprintf.c @@ -29,7 +29,7 @@ int vasprintf(char** pbuffer, const char* format, va_list ap) #ifdef va_copy va_end(ap2); #endif - + if (len <= 0) { fprintf(stderr, "vasprintf: error calculating needed size\n"); diff --git a/require-ess/src/dbLoadTemplate.h b/require-ess/src/dbLoadTemplate.h index 0e96e749..509047b8 100644 --- a/require-ess/src/dbLoadTemplate.h +++ b/require-ess/src/dbLoadTemplate.h @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* dbLoadTemplate.h */ diff --git a/require-ess/src/dbLoadTemplate.y b/require-ess/src/dbLoadTemplate.y index 04cd2026..aeb8e133 100644 --- a/require-ess/src/dbLoadTemplate.y +++ b/require-ess/src/dbLoadTemplate.y @@ -4,7 +4,7 @@ * Copyright (c) 2006 UChicago, as Operator of Argonne * National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* for vasprintf */ @@ -47,7 +47,7 @@ extern void dbLoadRecords(const char*, const char*); #endif #if (EPICS_VERSION*10000+EPICS_REVISION*100+EPICS_MODIFICATION>=31600) -#define dbmfStrdup(s) dbmfStrdup((char*)s) +#define dbmfStrdup(s) dbmfStrdup((char*)s) #endif static int line_num; @@ -348,9 +348,9 @@ variable_definition: WORD EQUALS WORD ; %% - + #include "dbLoadTemplate_lex.c" - + static int yyerror(char* str) { if (str) @@ -369,7 +369,7 @@ int dbLoadTemplate(const char *sub_file, const char *cmd_collect, const char *pa int i; line_num = 1; - + if (!sub_file || !*sub_file) { fprintf(stderr, "must specify variable substitution file\n"); return -1; diff --git a/require-ess/src/dbLoadTemplate_lex.l b/require-ess/src/dbLoadTemplate_lex.l index 7dc673d7..10d160a6 100644 --- a/require-ess/src/dbLoadTemplate_lex.l +++ b/require-ess/src/dbLoadTemplate_lex.l @@ -2,7 +2,7 @@ * Copyright (c) 2006 UChicago, as Operator of Argonne * National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ newline "\n" diff --git a/require-ess/src/expr.c b/require-ess/src/expr.c index 38ae8fe3..9c8ac42d 100644 --- a/require-ess/src/expr.c +++ b/require-ess/src/expr.c @@ -77,7 +77,7 @@ static long ipow(long base, long exp) { long val; if (exp == 2) return base*base; - if (exp == 3) return base*base*base; + if (exp == 3) return base*base*base; if (exp == 1) return base; if (exp == 0) return 1; if (exp < 0) return 0; @@ -114,7 +114,7 @@ struct {char str[4]; int pr;} ops[] = { enum op { op_none, - op_pow, + op_pow, op_mul,op_div,op_mod, op_plus,op_minus, op_lshift,op_urshift,op_rshift, diff --git a/require-ess/src/runScript.c b/require-ess/src/runScript.c index 0595b72b..e771e2ae 100644 --- a/require-ess/src/runScript.c +++ b/require-ess/src/runScript.c @@ -46,13 +46,13 @@ int runScript(const char* filename, const char* args) int status = 0; char* old_MODULE = NULL; char* old_MODULE_DIR = NULL; - + if (!filename) { fprintf(stderr, "Usage: runScript filename [macro=value,...]\n"); return -1; } - + if (macCreateHandle(&mac,(const char*[]){ "", "environ", NULL, NULL }) != 0) goto error; macSuppressWarning(mac, 1); @@ -80,7 +80,7 @@ int runScript(const char* filename, const char* args) char* fullname; const char* path = getenv("SCRIPT_PATH"); int dirlen; - + for (dirname = path; dirname != NULL; dirname = end) { end = strchr(dirname, OSI_PATH_LIST_SEPARATOR[0]); @@ -90,7 +90,7 @@ int runScript(const char* filename, const char* args) else dirlen = (int)strlen(dirname); if (dirlen == 0) continue; /* ignore empty path elements */ if (dirname[dirlen-1] == OSI_PATH_SEPARATOR[0]) dirlen--; - asprintf(&fullname, "%.*s" OSI_PATH_SEPARATOR "%s", + asprintf(&fullname, "%.*s" OSI_PATH_SEPARATOR "%s", dirlen, dirname, filename); if (runScriptDebug) printf("runScript: trying %s\n", fullname); @@ -101,7 +101,7 @@ int runScript(const char* filename, const char* args) } } if (file == NULL) { perror(filename); return errno; } - + /* save some environments variables */ SAVEENV(MODULE); SAVEENV(MODULE_DIR); @@ -136,7 +136,7 @@ int runScript(const char* filename, const char* args) p = line_exp; while (isspace((unsigned char)*p)) p++; if (*p == 0 || *p == '#') continue; - + /* find local variable assignments */ if ((x = strpbrk(p, "=(, \t\n\r")) != NULL && *x=='=') { @@ -186,7 +186,7 @@ void afterInitHook(initHookState state) { struct cmditem *item; - if (state != + if (state != #ifdef INCinitHooksh /* old: without iocPause etc */ initHookAfterInterruptAccept @@ -223,7 +223,7 @@ static struct cmditem *newItem(char* cmd, int type) { fprintf(stderr, "afterInit can only be used before iocInit\n"); return NULL; - } + } if (first_time) { first_time = 0; @@ -246,7 +246,7 @@ int afterInit(char* cmd, char* a1, char* a2, char* a3, char* a4, char* a5, char* { struct cmditem *item = newItem(cmd, 0); if (!item) return -1; - + item->x.a[0] = cmd; item->x.a[1] = a1; item->x.a[2] = a2; @@ -271,7 +271,7 @@ static const iocshFuncDef runScriptDef = { &(iocshArg) { "filename", iocshArgString }, &(iocshArg) { "substitutions", iocshArgString }, }}; - + static void runScriptFunc(const iocshArgBuf *args) { runScript(args[0].sval, args[1].sval); @@ -281,7 +281,7 @@ static const iocshFuncDef afterInitDef = { "afterInit", 1, (const iocshArg *[]) { &(iocshArg) { "commandline", iocshArgArgv }, }}; - + static void afterInitFunc(const iocshArgBuf *args) { int i, n; diff --git a/require-ess/src/strdup.c b/require-ess/src/strdup.c index bc708537..310518e4 100644 --- a/require-ess/src/strdup.c +++ b/require-ess/src/strdup.c @@ -12,7 +12,7 @@ char *strndup(const char *s, size_t n) { size_t l; char *d; - + l = strlen(s); if (n > l) n = l; d = malloc(n+1); diff --git a/require-ess/src/version.h b/require-ess/src/version.h index f404c8de..185c2c53 100644 --- a/require-ess/src/version.h +++ b/require-ess/src/version.h @@ -9,4 +9,4 @@ typedef struct semver_t { void cleanup_semver(semver_t *s); -int parse_semver(const char *version, semver_t *s); \ No newline at end of file +int parse_semver(const char *version, semver_t *s); diff --git a/require-ess/test/testscript b/require-ess/test/testscript index 4e262c17..b4b2d4ca 100644 --- a/require-ess/test/testscript +++ b/require-ess/test/testscript @@ -12,7 +12,7 @@ x=10+3, 10-3, 10*3, 10/3, 10%3, 10**3 x=7**-2 7**-1 7**0 7**1 7**2 7**3 7**4 7**5 7**6 # $(x) should be: 0 0 1 7 49 343 2401 16807 117649 -x=%x -10<<2, %x -10>>2, %x -10>>>2 +x=%x -10<<2, %x -10>>2, %x -10>>>2 # $(x) should be: ffffffffffffffd8, fffffffffffffffd, 3ffffffffffffffd x=%x 0xaa & 0x0f, %x 0xaa | 0x0f, %x 0xaa ^ 0x0f @@ -27,7 +27,7 @@ x=20<20 20<=20 20==20 20>=20 20>20 20<=>20 20<?20 20>?20 20?<20 20?>20 x=20<10 20<=10 20==10 20>=10 20>10 20<=>10 20<?10 20>?10 20?<10 20?>10 # $(x) should be: 0 0 0 1 1 1 10 20 1 0 -x= (0|0)(0|1)(1|0)(1|1) (0&0)(0&1)(1&0)(1&1) (0^0)(0^1)(1^0)(1^1) +x= (0|0)(0|1)(1|0)(1|1) (0&0)(0&1)(1&0)(1&1) (0^0)(0^1)(1^0)(1^1) # $(x) should be: 0111 0001 0110 x=1*2*3+4*5*6-7-8 diff --git a/require-ess/tools/README.md b/require-ess/tools/README.md index 4794efeb..f22f0c81 100644 --- a/require-ess/tools/README.md +++ b/require-ess/tools/README.md @@ -16,4 +16,3 @@ $ iocsh.bash e3_local/cmds/iocStats.cmd In this case, ```E3_CMD_TOP``` is defined as ```"${HOME}/e3_local/cmds"``` ```E3_IOCSH_TOP``` is defined as ```"${HOME}"``` - diff --git a/require-ess/tools/expandDBD.tcl b/require-ess/tools/expandDBD.tcl index bf9ae8f7..3cd4bc78 100755 --- a/require-ess/tools/expandDBD.tcl +++ b/require-ess/tools/expandDBD.tcl @@ -38,7 +38,7 @@ proc opendbd {name} { scanmatch $global_context {^[ \t]*(#|%|$)} { continue -} +} if {$recordtypes} { scanmatch $global_context {include[ \t]+"?((.*)Record.dbd)"?} { @@ -96,7 +96,7 @@ proc includeFile {context filename} { #puts "#include $filename from $FileName($matchInfo(handle))" scanfile $context $file close $file -} +} foreach filename $argv { global filesDone quiet -- GitLab