this is needed for correctness because the preprocessor is just
doing text replacement.
This is the correct way:
#define MUL(x, y) ((x) * (y))
MUL(1+2, 3-4) -> ((1+2) * (3-4)) # not: (1+2 * 3-4)
I didn't put parens around all arg usages for readability.
Some stuff (like index) is not expected to be an expression.
Also, when a arg is only used in another macro or function call,
no parens are needed either.
I reviewed the code: no harm was done (yet) due to this fault.
Thanks to @rciorba who found this.
(cherry picked from commit a3cecf599f)
(cherry picked from commit 981a936f47)
filenames like ..foobar are valid, so, to detect stuff in upper dirs,
we need to include the path separator and check if it starts with '../'.
(cherry picked from commit 60e9249100)
due to block buffering (in borg, pipes, sshd, ssh) partial lines might
be received. for plain text, this causes cosmetic issues.
the code now makes sure handle_remote_line() only gets called with a
complete line (which is terminated by any universal newline char, a
pure \r seems to be needed for remote progress displays).
it also fixes a yet undiscovered partial utf-8-sequence decoding issue
that might occur for the same reason.
(cherry picked from commit f2b48cd5c8)
refactor: make a generally usable function
fix: remove support code for ancient pyinstaller
the "else" branch was needed for pyinstaller < 20160820 because it did
not have the LD_LIBRARY_PATH_ORIG env var, so we just killed LDLP
because we had no better way.
but with borg tests running under fakeroot, this is troublesome as
fakeroot uses this also and can't find its library without it.
so, just remove it, we do not need to support old pyinstaller.
(cherry picked from commit 5dd16672c0)
Buffer: delete support for multiple threads
Thread-local objects are a fairly complex footgun, so avoid them in
the first place. When a Compressor uses a Buffer (for example),
just create multiple Compressor instances for each thread, owned by
each thread. Minimize multiple ownership of objects across
threads if at all possible!
(cherry picked from commit f7ed5d7220)
Integer division is slow, and this improves the speed of all operations on the hashmap.
Benchmarked this patch on the rciorba/master-bench branch:
9e5d61e03c/results.html
(cherry picked from commit 12e0f55991)
a user was (rightfully) complaining that borg does a whole lot of
writing to .cache and was also quite inefficient because that took
rather long and occurred too frequently.
this was caused by big indexes/caches and the relatively high default
checkpoint frequency (every 300s) in 1.0.
we already have increased that value to 1800s in master (which soon will
be 1.1), so this changeset just does the same for 1.0.x.
Split up parsing and filtering for --keep-within
Fixes#2610
Parse --keep-within argument early, via new method within_range passed
to argparse type=, so that better error messages can be given.
Also swallows ValueError stacktrace per the comment in the old code that
including it wasn't desirable.
With the argument specified as unsigned char *, Cython emits
code in the Python wrapper to convert string-like objects to
unsigned char* (essentially PyBytes_AS_STRING).
Because the len(data) call is performed on a cdef'd string-ish type,
Cython emits a strlen() call, on the result of PyBytes_AS_STRING.
This is not correct, since embedded null bytes are entirely possible.
Incidentally, the code generated by Cython was also not correct,
since the Clang Static Analyzer found a path of execution where
passing arguments in a weird way from Python resulted in strlen(NULL).
Formulated like this, Cython emits essentially:
c_buzhash(
PyBytes_AS_STRING(data),
PyObject_Length(data),
...
)
which is correct.
(cherry picked from commit faf2d0b537)