22 Commits

Author SHA1 Message Date
Benedikt Heine
9591af02a8 Retrieve user's home from passwd entry as fallback
For weird reasons, the HOME-variable might not always be set. So we
should fallback on something more reliable.

Fixes #693
2020-03-10 16:29:20 +01:00
Benedikt Heine
8a46b88da9 Use g_strcmp0 for string comparisons
g_strcmp0 handles NULL values correctly. This allows to omit NULL
pointer checks, which would be otherwise crucial.
2019-01-07 17:56:00 +01:00
Benedikt Heine
8579b3ed6b Add assertion macro to return values
Just recently, I started using g_return_val_if_fail as a brief assertion
checker. It'll also exit the function with a specified return value.

But actually this introduces some weird behavior. It's configurable by
environment variables and it'll print out a log message, if the
expression didn't validate properly. But some of these assertions are
actually ment to be silent.

Using a simple macro makes it simple to structure the assertions and its
return values in a block at the start of a function or anywhere else.
2019-01-07 15:30:42 +01:00
Benedikt Heine
ed341dfca3 Add S2US macro 2018-11-15 15:17:48 +01:00
Benedikt Heine
2d2a9c893c Add doxygen docs for markup and utils files 2018-11-11 17:27:11 +01:00
Benedikt Heine
d8d457f500 Remove string_replace()
string_replace_at does almost the same and string_replace is only used
once, where additionally string_replace_at would be the better choice.
2018-11-11 15:18:56 +01:00
Nikos Tsipinakis
f12f1094ed
Merge pull request #550 from bebehei/misc
Misc patches
2018-10-10 17:59:30 +03:00
Benedikt Heine
bb02897bc8 Introduce STR_EQ and STRN_EQ macros 2018-10-09 10:08:17 +02:00
Benedikt Heine
778a6857d8 Move clean_value function to utils.c
This is a typical string manipulation function an has no necessity to
stay in option_parser.
2018-10-08 18:27:11 +02:00
Benedikt Heine
1f4cd4bd15 Use STR_(EMPTY|FULL) for string emptyness checks 2018-10-08 17:38:00 +02:00
Benedikt Heine
ac4a0becd2 Count monotonic time with Linux specific clocks
On Linux, CLOCK_MONOTONIC has got a bug. It does not count
onwards during sleep, albeit required by POSIX. This behavior
is reasoned with the requirement for poll().
Also the GLib people are sticking to this behavior in their
g_get_monotonic_time() function.

So we have to use a drop in replacement, which respects CLOCK_BOOTTIME
on Linux, as this is the clock, what would be CLOCK_MONOTONIC on POSIX
systems.
2018-03-20 14:17:03 +01:00
Benedikt Heine
020a90e521 Replace die method with appropriate critical log 2018-02-02 17:29:04 +01:00
Benedikt Heine
fc4f0a4238 Refactor arguments into one line
Parameters should not cover an area. All arguments should be on a single
line (either horizontally or vertically).
2017-11-25 01:32:06 +01:00
Edward Betts
5f87039946 correct spelling mistake 2017-10-10 23:41:08 +01:00
Benedikt Heine
5d46cd700c Add option_get_time functions 2017-10-07 17:46:24 +02:00
Benedikt Heine
ab9bf55892 Prevent replacement of format strings in message
To replace all occuring format strings inside the msg, replace_all had
been used previously. This leads to buggy behavior, if a format string
occurs in the replaced text, as the format string will get replaced
again under certain conditions.

Introducing a pointer, which skips the already replaced parts, will
prevent doubly replacing format strings from content.

Fixes #322
2017-09-07 15:25:14 +02:00
Benedikt Heine
759aa518d5 Refactor star scheme of pointers
To achieve a consistent scheme, all stars of the
pointers should be on the side of the variable and
not on the side of the type.

wrong: char* a
wrong: char * a
good:  char *a

This commit is generated by the following sed command
with manual fixes of all false positives.

find src \( -name '*.c' -or -name '*.h' \) -print0
| xargs -0 -n1 sed -i
's/\([a-zA-Z]\+[-_a-zA-Z0-9]*\)\s*\*\s\+
\([a-zA-Z]\+[-_a-zA-Z0-9]*\)/\1 *\2/g'
2017-09-06 23:14:25 +02:00
Benedikt Heine
8e3a7586d1 replace ~/ in script paths 2017-08-15 23:35:02 +02:00
Nikos Tsipinakis
3f5257f285 Remove unused function string_to_argv 2017-02-05 13:05:52 +02:00
Nikos Tsipinakis
964688699e Use include guards consistently
* Don't mix pragma guards and include guards, prefer classic include
  guards since apparently pragma guards are not a standard yet.
* Use the DUNST_FILE_H naming convention for all include guards.
2017-01-29 15:32:36 +02:00
Nikos Tsipinakis
756dee58c7 Remove unused function 2016-11-22 17:55:28 +02:00
Nikos Tsipinakis
2df2e7d06c Move dunst source files to src/ 2016-11-19 11:54:03 +02:00