2
0

Fix ./build's targets interpretation & other improvements.

This commit is contained in:
Maarten Billemont
2017-09-01 11:16:09 -04:00
parent 9a5e9ced31
commit 060ce61030
7 changed files with 15 additions and 18 deletions

View File

@@ -197,7 +197,9 @@ use_mpw_xml() {
### BUILD TARGETS
for target in "${targets_all[@]}"; do
if [[ ${targets:-$targets_default} == 'all' || " $target " = *" ${targets:-$targets_default} "* ]]; then
echo "target: $target in ' $targets '."
if [[ ${targets:-$targets_default} == 'all' || " ${targets:-$targets_default} " = *" $target "* ]]; then
echo
echo "Building target: $target..."
( "$target" "$@" )

View File

@@ -213,7 +213,7 @@ bool mpw_mkdirs(const char *filePath) {
}
/** Read until EOF from the given file descriptor.
* @return A newly allocated string or NULL the read buffer couldn't be allocated. */
* @return A newly allocated string or NULL if the read buffer couldn't be allocated or an error occurred. */
char *mpw_read_fd(int fd) {
char *buf = NULL;
@@ -222,13 +222,13 @@ char *mpw_read_fd(int fd) {
while ((mpw_realloc( &buf, &bufSize, blockSize )) &&
((readSize = read( fd, buf + bufOffset, blockSize )) > 0));
if (readSize == ERR)
dbg( "While reading: %s\n", strerror( errno ) );
mpw_free( &buf, bufSize );
return buf;
}
/** Read the file contents of a given file.
* @return A newly allocated string or NULL the read buffer couldn't be allocated. */
* @return A newly allocated string or NULL if the read buffer couldn't be allocated. */
char *mpw_read_file(FILE *file) {
if (!file)

View File

@@ -203,14 +203,9 @@ int main(const int argc, char *const argv[]) {
return EX_DATAERR;
}
if ((!masterPassword || !strlen( masterPassword )) && masterPasswordFDArg) {
FILE *masterPasswordFile = fdopen( atoi( masterPasswordFDArg ), "r" );
if (!masterPasswordFile)
wrn( "Error opening master password FD %s: %s\n", masterPasswordFDArg, strerror( errno ) );
else {
masterPassword = mpw_read_file( masterPasswordFile );
if (ferror( masterPasswordFile ))
wrn( "Error reading master password from %s: %d\n", masterPasswordFDArg, ferror( masterPasswordFile ) );
}
masterPassword = mpw_read_fd( atoi( masterPasswordFDArg ) );
if (!masterPassword && errno)
wrn( "Error reading master password from FD %s: %s\n", masterPasswordFDArg, strerror( errno ) );
}
if ((!masterPassword || !strlen( masterPassword )) && masterPasswordArg)
masterPassword = strdup( masterPasswordArg );