Skip to content

Commit

Permalink
Merge pull request #8 from sodero/master
Browse files Browse the repository at this point in the history
Sync with sodero/InstallerLG
  • Loading branch information
gareth-smyth authored Jun 22, 2020
2 parents 6576b2a + 3f66a5b commit fdf2467
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language:
jobs:
include:
- stage: Cppcheck
script: cd src && for f in *.c; do cppcheck $f; done
script: cd src && cppcheck --error-exitcode=1 --enable=all --suppress=missingInclude --suppress=unusedFunction --suppress=ConfigurationNotChecked --suppress=knownConditionTrueFalse .
- stage: Test
script: make -C build smoke || (cat build/err.tmp.* 2> /dev/null && false)
- stage: Valgrind
Expand Down
10 changes: 4 additions & 6 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@ endif
#---------------------------------------------------------------------------------#
# OS
#---------------------------------------------------------------------------------#
ifeq ($(OS),Linux)
CWRN = -Wall -Wextra -Werror
ifeq ($(OS),Linux)
CGEN = -g -std=c99
CDEF = -D_DEFAULT_SOURCE -D_GNU_SOURCE
else
ifeq ($(OS),Darwin)
CGEN = -g -std=c99
CWRN += -Werror -Weverything -Wno-format-nonliteral -Wno-padded
else
ifeq ($(OS),Windows_NT)
CC = x86_64-w64-mingw32-gcc.exe
CWRN = -Wall -Wextra -Werror
CGEN = -g -std=c99
CDEF = -D_DEFAULT_SOURCE -D_GNU_SOURCE -D__USE_MINGW_ANSI_STDIO
else
CC ?= gcc
AMIGA = true
CWRN = -Wall -Wextra -Wno-pointer-sign
CWRN += -Wno-pointer-sign
CGEN = -Os -std=gnu99 -DAMIGA
LDLIBS = -ldebug
ifeq ($(OS),MorphOS)
Expand Down Expand Up @@ -63,7 +61,7 @@ $(EXE): $(OBJ) parser.o lexer.o
$(CC) $^ -o $@ $(LDLIBS)

parser.o: parser.c
$(CC) $(CINC) $(CDEF) $(CGEN) -c $< -DYYERROR_VERBOSE
$(CC) $(CFLAGS) -c $< -DYYERROR_VERBOSE

lexer.o: lexer.c
$(CC) $(CINC) $(CDEF) $(CGEN) -c $<
Expand All @@ -85,7 +83,7 @@ else
endif

gui.o: gui.c gui.h version.h
$(CC) -Os -c $< -DLLVL=2 $(CWRN) $(CDEF)
$(CC) $(CFLAGS) -Os -c $< -DLLVL=2

#---------------------------------------------------------------------------------#
# Catalogs
Expand Down
4 changes: 2 additions & 2 deletions build/Makefile.axrt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LDFLAGS = -specs=/usr/lib/x86_64-linux-gnu/axrt.specs
CGEN = -O0 -std=gnu99 -DAMIGA
CINC = -I /usr/include/axrt -I . -I $(VPATH)
CDEF = -D_DEFAULT_SOURCE -D_GNU_SOURCE -D__AMIGADATE__="\"($(DATE))\"" $(CEXT)
CFLAGS = $(CINC) $(CGEN) $(CDEF) -D__AROS__ -g -O0 -I/usr/include/axrt
CFLAGS = $(CINC) $(CGEN) $(CDEF) -D__AROS__ -D__AXRT__ -g -O0 -I/usr/include/axrt

$(EXE): $(OBJ) parser.o lexer.o $(STARTUP_OBJ) /usr/lib/x86_64-linux-gnu/axrt.ld
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
Expand All @@ -21,7 +21,7 @@ parser.o: parser.c
$(CC) $(CINC) $(CDEF) $(CGEN) -c $< -DYYERROR_VERBOSE

lexer.o: lexer.c
$(CC) $(CINC) $(CDEF) $(CGEN) -c $<
$(CC) $(CINC) $(CDEF) $(CGEN) -D__AXRT__ -c $<

parser.c: parser.y
$(YACC) $(YFLAGS) -d $< -o $@
Expand Down
24 changes: 24 additions & 0 deletions build/axrt.script
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
; Using a custom screen doesn't seem to work. Uncomment to test.
;(effect "center_left" 'horizontal' 1 254) (effect "center_left" 'horizontal' 1 255) ; "","e 36:1:254 36:1:255 1",""

; Silly experiment, smooth progress
(procedure progress start stop delay
(
(set i start)
(while (<= i stop)
(set i (+ i 1))
(set j delay)
(while (> j 0)
(set j (- j 1))
(complete i)
)
)
)
)

(progress 0 25 2000)
(message "Hello AxRT world!")

(progress 25 75 2000)
(message ("File:%s" (askfile (default "No file") (prompt "Pick a file") (help "Nope, no help"))))

(progress 75 100 2000)
10 changes: 10 additions & 0 deletions build/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3412,8 +3412,18 @@ int main(int argc, char **argv)
// Assume failure.
int ret = -1;

#ifdef __AXRT__
(void) argc;
(void) argv;

// Temp AxRT workaround until argument handling in AxRT is implemented.
char *argv_[] = {"Installer", "axrt.script", NULL};

if(arg_init(2, argv_))
#else
// Initialize the argument handling.
if(arg_init(argc, argv))
#endif
{
yyscan_t lexer;

Expand Down
2 changes: 1 addition & 1 deletion dist/InstallerLG installer
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; $VER: InstallerLG 0.1.0-alpha.47
; $VER: InstallerLG 0.1.0-alpha.48
; Install script for InstallerLG

(set #app-bin "Installer")
Expand Down
5 changes: 5 additions & 0 deletions dist/InstallerLG.guide
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ Italian translations.
@{B}The complete changelog@{UB}
@{B}-----------------------------------------------------------------------@{UB}

@{B}0.1.0-alpha.48 (2020-NOT-YET)@{UB}
- Everything is now 64-bit clean and runs on AxRT.
- Fixed NOLOG and NOPRETEND commandline arguments.
- ?

@{B}0.1.0-alpha.47 (2020-05-17)@{UB}
- (askstring) and (asknumber) accept missing default in sloppy mode.
- (startup) chomps redundant (command) linefeed.
Expand Down
2 changes: 1 addition & 1 deletion dist/aminet/InstallerLG.readme
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Uploader: [email protected] (Ola S
Type: util/sys
Architecture: __ARCH__
Requires: MUI 3.8
Version: 0.1.0-alpha.47
Version: 0.1.0-alpha.48
Distribution: Aminet

InstallerLG
Expand Down
24 changes: 20 additions & 4 deletions src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,25 @@ static bool arg_post(void)
//------------------------------------------------------------------------------
static bool arg_cli(int argc, char **argv)
{
#if defined(AMIGA)
// Temp AxRT workaround until argument handling in AxRT is implemented.
#if defined(AMIGA) && !defined(__AXRT__)
// Not used on Amiga.
(void) argc;
(void) argv;

// Hack to get around ReadArgs overwriting dir names. Should be fixed.
char *old = args[ARG_OLDDIR], *home = args[ARG_HOMEDIR];
args[ARG_HOMEDIR] = args[ARG_OLDDIR] = NULL;

// Use the builtin commandline parser.
struct RDArgs *rda = (struct RDArgs *) ReadArgs(tr(S_ARGS), (IPTR *) args,
struct RDArgs *rda = (struct RDArgs *) ReadArgs(tr(S_ARGS), (LONG *) args,
NULL);
// Copy booleans and restore dir names. See above.
args[ARG_NOPRETEND] = args[ARG_HOMEDIR];
args[ARG_NOLOG] = args[ARG_OLDDIR];
args[ARG_HOMEDIR] = home;
args[ARG_OLDDIR] = old;

if(!rda)
{
// Invalid or missing arguments.
Expand Down Expand Up @@ -238,8 +249,13 @@ bool arg_init(int argc, char **argv)
// Invoked from CLI or WB.
bool init = argc ? arg_cli(argc, argv) : arg_wb(argv);

// Go to script working directory and return.
return init && args[ARG_HOMEDIR] && !chdir(args[ARG_HOMEDIR]);
// Go to script working directory and return. Temp AxRT workaround until
// argument handling in AxRT is implemented.
return init && args[ARG_HOMEDIR]
#ifndef __AXRT__
&& !chdir(args[ARG_HOMEDIR])
#endif
;
}

//------------------------------------------------------------------------------
Expand Down
15 changes: 11 additions & 4 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ inp_t gui_copyfiles_start(const char *msg, const char *hlp, pnode_p lst, bool cn
(void)cnf;
(void)bck;

printf("Starting file copy %s.\n", msg);
if(msg) {
printf("Starting file copy %s.\n", msg);
}

return G_TRUE;
}
Expand All @@ -365,7 +367,9 @@ inp_t gui_copyfiles_setcur(const char *cur, bool nga, bool bck)
(void)nga;
(void)bck;

printf("Copying files Cur:%s.\n", cur);
if(cur) {
printf("Copying files Cur:%s.\n", cur);
}

return G_TRUE;
}
Expand Down Expand Up @@ -401,7 +405,10 @@ inp_t gui_confirm(const char *msg, const char *hlp, bool bck)
void gui_error(int line, const char *type, const char *info)
{
printf("Error of type %s on line %d.", type, line);
printf("Error info: %s", info);

if(info) {
printf("Error info: %s", info);
}
}

void gui_effect(int eff, int cl1, int cl2)
Expand All @@ -418,7 +425,7 @@ inp_t gui_closemedia(int mid)

inp_t gui_setmedia(int mid, int act, const char *par)
{
printf("Set media with mid %d, act %d and par %s", mid, act, par);
printf("Set media with mid %d, act %d and par %s", mid, act, par ? par : "NONE");

return G_TRUE;
}
Expand Down
5 changes: 1 addition & 4 deletions src/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,8 @@ entry_p n_onerror(entry_p contxt)
// Zero or more arguments. No options.
C_SANE(0, NULL);

// Global context where the user defined procedures are found.
entry_p con = global(contxt);

// Make sure that '@onerror' exists. On out of memory it might be missing.
entry_p *err = con->symbols;
entry_p *err = global(contxt)->symbols;

while(exists(*err))
{
Expand Down
23 changes: 6 additions & 17 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2389,7 +2389,7 @@ entry_p n_delete(entry_p contxt)
#if defined(AMIGA) && !defined(LG_TEST)
int wild = ParsePatternNoCase(file, buf_raw(), buf_len());
#else
int wild = get_num(contxt, "@wild");
int wild = get_num(contxt, "@alfa");
#endif

// 0 == no pattern, 1 == pattern, -1 == buffer overflow.
Expand Down Expand Up @@ -2566,6 +2566,7 @@ entry_p n_foreach(entry_p contxt)
#else
cur->type = h_exists(name);
cur->name = DBG_ALLOC(strdup(name));
err = get_num(contxt, "@alfa") == LG_TRUE;
#endif

// Empty name indicates a PANIC if the locking failed.
Expand Down Expand Up @@ -2721,39 +2722,27 @@ entry_p n_makeassign(entry_p contxt)
}
}
#else
res = LG_TRUE;
res = get_num(contxt, "@beta");
#endif

// Log the outcome.
h_log(contxt,
// Clang scan-build dead code true positive.
#ifndef __clang_analyzer__
res ? tr(S_ACRT) :
#endif
tr(S_ACRE), asn, dst);
h_log(contxt, res ? tr(S_ACRT) : tr(S_ACRE), asn, dst);
}
else
{
#if defined(AMIGA) && !defined(LG_TEST)
// Remove assign.
res = AssignLock(str(C_ARG(1)), (BPTR) NULL) ? LG_TRUE : LG_FALSE;
#else
res = LG_FAKE;
res = get_num(contxt, "@gamma");
#endif

// Log the outcome.
h_log(contxt,
// Clang scan-build dead code true positive.
#ifndef __clang_analyzer__
res ? tr(S_ADEL) :
#endif
tr(S_ADLE), asn);
h_log(contxt, res ? tr(S_ADEL) : tr(S_ADLE), asn);
}

// Clang scan-build dead code true positive.
#ifndef __clang_analyzer__
if(!res)
#endif
{
// Could not create / rm assign / get lock.
ERR(ERR_ASSIGN, str(C_ARG(1)));
Expand Down
Loading

0 comments on commit fdf2467

Please sign in to comment.