Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
74af4bf
First drop of lldump, a database dumping tool. Currently handles key…
memmerto Jan 20, 2019
75c9b10
Update .gitignore for lldump
memmerto Jan 20, 2019
15fc07e
Add --with-32bit and --with-64bit options to configure (gcc only)
memmerto Jan 2, 2019
b7473b5
Add help text to xref dump; add support for 32-bit and 64-bit keyfiles
memmerto Mar 10, 2019
0c472c4
First drop of lldump, a database dumping tool. Currently handles key…
memmerto Jan 20, 2019
3b92ad2
Update .gitignore for lldump
memmerto Jan 20, 2019
2178663
Add help text to xref dump; add support for 32-bit and 64-bit keyfiles
memmerto Mar 10, 2019
4f6deb2
First drop of lldump, a database dumping tool. Currently handles key…
memmerto Jan 20, 2019
4100e7c
Fix formatting in 64-bit keyfile dump
memmerto Mar 10, 2019
eb56389
Merge branch 'lldump' of github.com:MarcNo/lifelines into lldump
memmerto Mar 10, 2019
4604719
Sigh. Undo my 64-bit mods for keyfile since keyfiles don't change in…
memmerto Mar 10, 2019
d24a9f0
Refine keyfile dump
memmerto Mar 16, 2019
04d728e
Update KEYFILE1, KEYFILE2 and DELETESET dumpers to show file offsets
memmerto Mar 16, 2019
3041698
Remove incorrect 64-bit portability comment
memmerto Mar 16, 2019
c0b8252
Revert INT/INT32 data type changes (for now)
memmerto Mar 16, 2019
442ed5d
Fix offset calculations in dumpxrefs/dumpxrecs
memmerto Mar 16, 2019
6a1a64c
lldump: Dump master index and first block
memmerto Mar 17, 2019
c594225
Add scripting and config to use SonarQube C/C++ scanner
memmerto Apr 27, 2019
e59b709
Fix two errors found using cppcheck
memmerto Apr 27, 2019
1a8b26e
Merge pull request #334 from MarcNo/sonarqube
memmerto Apr 28, 2019
9431229
Update sonar.sh
memmerto Apr 28, 2019
bf18f90
Some clean-up and warning fixes
Apr 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# must be unique in a given SonarQube instance
sonar.projectKey=LifeLines:LATEST

# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=LifeLines
sonar.projectVersion=LATEST

# Path is relative to the sonar-project.properties file.
#sonar.sources=src/arch,src/btree,src/gedlib,src/interp,src/liflines,src/stdlib,src/tools,src/ui
sonar.sources=src
34 changes: 34 additions & 0 deletions build/sonar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# NOTE: This script assumes that:
# - the sonarqube server is running on the default port
# - the C/C++ module has been installed in SonciQube
# - the sonar-scanner is installed and in $PATH

# Check for configuration file
if [ ! -f sonar-project.properties ]
then
echo "ERROR: Could not find sonarqube properties file!"
exit
fi

# Get and unzip build wrapper
wget http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip

# Build with build wrapper
(cd ..; build/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir build/sonar_build_wrapper_output make clean all)

# Run analysis
# NOTE: This assumes that:
# - the sonarqube server is running on the default port
# - the sonar-scanner is installed and in $PATH
(cd ..; sonar-scanner -Dproject.settings=build/sonar-project.properties -Dsonar.cfamily.build-wrapper-output=build/sonar_build_wrapper_output)

# Remove build wrapper and scanner files
rm -rf sonar_build_wrapper_output
rm -rf ../.scannerwork

# Remove build wrapper
rm -rf build-wrapper-linux-x86
rm -f build-wrapper-linux-x86.zip
33 changes: 33 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,39 @@ case $host in
;;
esac

dnl Specify bit width if requrested
AC_ARG_WITH(32bit,
[ --with-32bit Build in 32-bit mode ],
[build_32bit=$withval],
[build_32bit=no])

AC_ARG_WITH(64bit,
[ --with-64bit Build in 64-bit mode ],
[build_64bit=$withval],
[build_64bit=no])

if test "$build_32bit" = "yes"
then
if test "${ac_cv_prog_gcc}" = "yes"; then
CFLAGS="${CFLAGS} -m32"
LDFLAGS="${LDFLAGS} -m32"
else
echo "The use of --with-32bit is only supported when using gcc!"
exit
fi
fi

if test "$build_64bit" = "yes"
then
if test "${ac_cv_prog_gcc}" = "yes"; then
CFLAGS="${CFLAGS} -m64"
LDFLAGS="${LDFLAGS} -m64"
else
echo "The use of --with-64bit is only supported when using gcc!"
exit
fi
fi

dnl **************************************************************
dnl Handle Docs Target
dnl **************************************************************
Expand Down
5 changes: 4 additions & 1 deletion src/gedlib/charmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ static XNODE create_xnode(XNODE, INT, STRING);
static BOOLEAN init_map_from_str(STRING str, CNSTRING mapname, TRANTABLE * ptt, ZSTR zerr);
static void maperror(CNSTRING errmsg);
static void remove_xnodes(XNODE);
#ifdef DEBUG
static void show_xnode(XNODE node);
static void show_xnodes(INT indent, XNODE node);
#endif
static XNODE step_xnode(XNODE, INT);
static INT translate_match(TRANTABLE tt, CNSTRING in, CNSTRING * out);

Expand Down Expand Up @@ -607,7 +609,6 @@ show_trantable (TRANTABLE tt)
}
}
}
#endif /* DEBUG */

/*===============================================
* show_xnodes -- DEBUG routine that shows XNODEs
Expand Down Expand Up @@ -638,6 +639,8 @@ show_xnode (XNODE node)
} else
llwprintf("\n");
}
#endif /* DEBUG */

/*===================================================
* custom_translatez -- Translate string via custom translation table
* zstr: [I/O] string to be translated (in-place)
Expand Down
2 changes: 0 additions & 2 deletions src/gedlib/dblist.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ INT
get_dblist (STRING path, LIST * dblist, LIST * dbdesclist)
{
STRING dirs=0;
INT ndirs=0;
STRING p=0;
ASSERT(!(*dblist));
ASSERT(!(*dbdesclist));
Expand All @@ -51,7 +50,6 @@ get_dblist (STRING path, LIST * dblist, LIST * dbdesclist)
return 0;
dirs = (STRING)stdalloc(strlen(path)+2);
/* find directories in dirs & delimit with zeros */
ndirs = chop_path(path, dirs);
/* now process each directory */
for (p=dirs; *p; p+=strlen(p)+1) {
add_dbs_to_list(*dblist, *dbdesclist, p);
Expand Down
2 changes: 1 addition & 1 deletion src/gedlib/indiseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ indi_to_families (NODE indi, BOOLEAN fams)
{
INT temp = atoi(indi_to_key(spouse) + 1);
if (temp && temp != mykeynum)
spkeynum = temp;
spkeynum = temp; //TODO is this right? this loop doesn't do anything
}
ENDFAMSPOUSES
append_indiseq_ival(seq, fkey, NULL, mykeynum, TRUE, FALSE);
Expand Down
54 changes: 51 additions & 3 deletions src/gedlib/xreffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ extern BTREE BTR;
* and other keys in file; remaining words are keys, in respective
* order, for the records; first in each group is next unused key;
* rest are keys of deleted records
* nixrefs==1 means there are no deleted INDI keys
* nixrefs==2 means there is one deleted INDI key (ixrefs[1])
* n==1 means there are no deleted INDI keys
* n==2 means there is one deleted INDI key (ixrefs[1])
*=================================================================*/
/*
In memory, data is kept in a DELETESET
Expand Down Expand Up @@ -86,7 +86,6 @@ struct deleteset_s
};
typedef struct deleteset_s *DELETESET;


/*********************************************
* local function prototypes
*********************************************/
Expand All @@ -98,6 +97,7 @@ static BOOLEAN addsxref_impl(INT key, DUPS dups);
static BOOLEAN addexref_impl(INT key, DUPS dups);
static BOOLEAN addxref_impl(CNSTRING key, DUPS dups);
static BOOLEAN addxxref_impl(INT key, DUPS dups);
static void dumpxrecs(STRING type, DELETESET set, INT *offset);
static INT find_slot(INT keynum, DELETESET set);
static void freexref(DELETESET set);
static DELETESET get_deleteset_from_type(char ctype);
Expand Down Expand Up @@ -365,6 +365,54 @@ writexrefs (void)
fflush(xreffp);
return TRUE;
}
/*================================
* dumpxrefs -- Print xrefs to stdout
* storage order: IFESX
*==============================*/
void
dumpxrefs (void)
{
INT offset = 0;

printf("NOTE: n is always the number of deleted keys PLUS ONE.\n");
printf("NOTE: Each entry indicates the next available key value.\n\n");

/* Dump "n" values */
printf("0x%02x: I n: 0x%08x (%d)\n", offset, irecs.n, irecs.n);
offset += sizeof(irecs.n);
printf("0x%02x: F n: 0x%08x (%d)\n", offset, frecs.n, frecs.n);
offset += sizeof(frecs.n);
printf("0x%02x: E n: 0x%08x (%d)\n", offset, erecs.n, erecs.n);
offset += sizeof(erecs.n);
printf("0x%02x: S n: 0x%08x (%d)\n", offset, srecs.n, srecs.n);
offset += sizeof(srecs.n);
printf("0x%02x: X n: 0x%08x (%d)\n", offset, xrecs.n, xrecs.n);
offset += sizeof(xrecs.n);

/* Dump "recs" values */
dumpxrecs("I", &irecs, &offset);
dumpxrecs("F", &frecs, &offset);
dumpxrecs("E", &erecs, &offset);
dumpxrecs("S", &srecs, &offset);
dumpxrecs("X", &xrecs, &offset);

/* Dump size */
printf("0x%02x: EOF (0x%02x)\n", offset, offset);
}
/*================================
* dumpxrecs -- Print DELETESET to stdout
*==============================*/
static void
dumpxrecs (STRING type, DELETESET set, INT *offset)
{
INT i;

for (i=0; i<set->n; i++)
{
printf("0x%02x: %s[%02d]: 0x%08x (%d)\n", *offset, type, i, (set->recs)[i], (set->recs)[i]);
*offset += sizeof((set->recs)[i]);
}
}
/*=====================================
* find_slot -- Find slot at which to add key
*===================================*/
Expand Down
1 change: 1 addition & 0 deletions src/hdrs/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ add it to any database that does not yet have it.
*/
typedef struct {
char name[18]; /* KF_NAME */
char pad[2]; /* matches padding added by compiler */
INT magic; /* KF_MAGIC */ /* byte alignment check */
INT version; /* KF_VER */
} KEYFILE2;
Expand Down
1 change: 1 addition & 0 deletions src/hdrs/gedcom.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ BOOLEAN create_database(STRING dbused, INT *lldberr);
NODE create_node(STRING, STRING, STRING, NODE);
NODE create_temp_node(STRING, STRING, STRING, NODE);
void delete_metarec(STRING key);
void dumpxrefs(void);
BOOLEAN edit_mapping(INT);
BOOLEAN edit_valtab_from_db(STRING, TABLE*, INT sep, STRING, STRING (*validator)(TABLE tab, void * param), void *param);
BOOLEAN equal_tree(NODE, NODE);
Expand Down
2 changes: 1 addition & 1 deletion src/interp/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ llrpt_alpha (PNODE node, SYMTAB stab, BOOLEAN *eflg)
i = pvalue_to_int(val);
delete_pvalue_ptr(&val);
if (i < 1 || i > 26)
sprintf(scratch, "XX");
sprintf(scratch, "_");
else
sprintf(scratch, "%c", 'a' + i - 1);
return create_pvalue_from_string(scratch);
Expand Down
2 changes: 1 addition & 1 deletion src/interp/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ lextok (PACTX pactx, YYSTYPE * lvalp, INT c, INT t)
p = tokbuf;
while (TRUE) {
while ((c = inchar(pactx)) != EOF && c != '"' && c != '\\') {
if (p-tokbuf > sizeof(tokbuf)/sizeof(tokbuf[0]) - 3) {
if (p-tokbuf > (int)(sizeof(tokbuf)/sizeof(tokbuf[0]) - 3)) {
/* Overflowing tokbuf buffer */
/* TODO: (Perry, 2006-06-30) I don't know how to fail gracefully from here inside parser */
char msg[512];
Expand Down
12 changes: 3 additions & 9 deletions src/liflines/browse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ static void
save_nkey_list (STRING key, struct hist * histp)
{
FILE * fp=0;
INT next, prev, count, temp;
INT next, count, temp;
size_t rtn;

count = get_hist_count(histp);
Expand All @@ -1649,15 +1649,13 @@ save_nkey_list (STRING key, struct hist * histp)
rtn = fwrite(&count, 4, 1, fp); ASSERT(rtn==1);
rtn = fwrite(&count, 4, 1, fp); ASSERT(rtn==1);

prev = -1;
next = histp->start;
while (1) {
/* write type & number, 4 bytes each */
temp = histp->list[next].ntype;
rtn = fwrite(&temp, 4, 1, fp); ASSERT(rtn==1);
temp = histp->list[next].keynum;
rtn = fwrite(&temp, 4, 1, fp); ASSERT(rtn==1);
prev = next;
next = (next+1) % histp->size;
if (next == histp->past_end)
break; /* finished them all */
Expand All @@ -1684,7 +1682,7 @@ static void
history_record (RECORD rec, struct hist * histp)
{
NKEY nkey = nkey_zero();
INT prev, next, i;
INT next, i;
INT count = get_hist_count(histp);
INT protect = getlloptint("HistoryBounceSuppress", 0);
if (!histp->size) return;
Expand All @@ -1704,13 +1702,11 @@ history_record (RECORD rec, struct hist * histp)
if (protect>count)
protect=count;
/* traverse from most recent back (bounce suppression) */
prev = -1;
next = (histp->past_end-1);
if (next < 0) next += histp->size;
for (i=0; i<protect; ++i) {
if (nkey_eq(&nkey, &histp->list[next]))
return;
prev = next;
if (--next < 0) next += histp->size;
}
/* it is a new one so add it to circular list */
Expand Down Expand Up @@ -1828,13 +1824,12 @@ static INDISEQ
get_history_list (struct hist * histp)
{
INDISEQ seq=0;
INT next, prev;
INT next;
if (!histp->size || histp->start==-1) {
return NULL;
}
/* add all items of history to seq */
seq = create_indiseq_null();
prev = -1;
next = histp->start;
while (1) {
NODE node=0;
Expand All @@ -1843,7 +1838,6 @@ get_history_list (struct hist * histp)
STRING key = node_to_key(node);
append_indiseq_null(seq, key, NULL, TRUE, FALSE);
}
prev = next;
next = (next+1) % histp->size;
if (next == histp->past_end)
break; /* finished them all */
Expand Down
5 changes: 4 additions & 1 deletion src/liflines/cscurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ mvccwprintw (WINDOW *wp, int y, int x, ...)
{
va_list args;
char * fmt;
int ret;
va_start(args, x);
wmove(wp, y, x);
fmt = va_arg(args, char *);
return vccwprintw(wp, fmt, args);
ret = vccwprintw(wp, fmt, args);
va_end(args);
return ret;
}
/*============================
* vccwprintw -- vwprintw with codeset convert from internal to GUI
Expand Down
2 changes: 0 additions & 2 deletions src/liflines/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,10 @@ static void
restore_record (NODE node, INT type, INT num)
{
STRING old, new, str, key;
char scratch[10];

if (!node) return;
ASSERT(old = nxref(node));
new = translate_key(rmvat(old));
sprintf(scratch, "%6ld", num);
switch (type) {
case INDI_REC: break;
case FAM_REC: break;
Expand Down
3 changes: 1 addition & 2 deletions src/liflines/llexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ main (int argc, char **argv)
LIST exprogs=NULL;
TABLE exargs=NULL;
STRING progout=NULL;
BOOLEAN graphical=TRUE;
STRING configfile=0;
STRING crashlog=NULL;
int i=0;
Expand Down Expand Up @@ -256,7 +255,7 @@ main (int argc, char **argv)
progout = optarg;
break;
case 'z': /* nongraphical box */
graphical = FALSE;
// graphical = FALSE;
break;
case 'C': /* specify config file */
configfile = optarg;
Expand Down
2 changes: 1 addition & 1 deletion src/stdlib/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ clear_generic (GENERIC *gen)
case GENERIC_INT: break;
case GENERIC_FLOAT:
stdfree(gen->data.fval);
gen->data.fval = 0;
gen->data.fval = 0; // TODO fall through OK??
case GENERIC_STRING:
stdfree(gen->data.sval);
gen->data.sval = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/stdlib/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ print_version (CNSTRING program)
printf("%s (lifelines) %s\n", program, get_lifelines_version(48));
printf("\n");

printf(_("Copyright (C) 1991-2018 Thomas T. Wetmore IV and contributors."));
printf(_("Copyright (C) 1991-2019 Thomas T. Wetmore IV and contributors."));
printf("\n");
printf(_("This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."));
Expand Down
1 change: 1 addition & 0 deletions src/tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Makefile.in
.deps
btedit
dbverify
lldump
lltest
Loading