22 Commits

Author SHA1 Message Date
Benedikt Heine
bd8fd8b1d2 Improve whitespace handling 2017-11-25 01:38:28 +01:00
Benedikt Heine
01197584ae Do not extra check g_free for null 2017-10-11 01:19:58 +02:00
Benedikt Heine
be3636c679 Remove _GNU_SOURCE macro
After some research, the _GNU_SOURCE does not affect any function call
anymore. To avoid future failures on other systems not using glibc,
_GNU_SOURCE gets removed.
2017-10-08 02:32:37 +02:00
Benedikt Heine
5d46cd700c Add option_get_time functions 2017-10-07 17:46:24 +02:00
Benedikt Heine
41defb7c85 Break overlong argument lists 2017-09-25 02:26:11 +02:00
Benedikt Heine
554c873808 Mark constant strings as const
It's hard to trace back, which methods in option parser require freeing
the result and which prohibit it. Marking all non-freeable values as
const lets this problem solve the compiler.
2017-09-25 02:26:11 +02:00
Benedikt Heine
530eaaf5ed Rename double to int 2017-09-19 13:26:30 +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
Luke Shumaker
bf01932471 option_parser: Fix inconsistent Warning message.
Usually, it's "Warning: invalid config file at line %d", but in one case
there's a colon after "line".
2017-02-25 21:27:49 -05:00
Nikos Tsipinakis
37628f3dc4 Print errors to stderr
A lot of error reporting used a simple `printf` call which by default
prints to stdout. This was changed so that all error reporting is done
by an `fprintf(stderr, ...)` call.
2017-02-20 17:48:11 +02:00
Nikos Tsipinakis
92e83a939f Remove a few more leftover memory allocation checks
According to the glib memory allocation documentation, if any memory
allocation calls fail the application will be terminated so there is no
need to check if the call succeeded.
2017-02-20 17:25:59 +02:00
John Chen
656846900a Fix missing * in option_parser.c 2017-02-14 00:45:02 +08:00
John Chen
17e2929ee7 Change malloc and related functions to glib ones.
* malloc  -> g_malloc
* realloc -> g_realloc
* free    -> g_free
* strdup  -> g_strdup
* strndup -> g_strndup
2017-02-14 00:44:53 +08:00
John Chen
7037afb2bc Fix include. Add empty lines between include layers. 2017-02-14 00:39:04 +08:00
Nikos Tsipinakis
956f91f6a4 Fix issue with loading config files with lines bigger than BUFSIZ
To load each line of the configuration file we were previously using a
simple buffer of length BUFSIZ. BUFSIZ is a macro provided by glibc as
the 'recommended length for a buffer'. But since one of our users
encountered a situation where really long config lines were necessary
it's time to change that behaviour.

This commit changes the line reading from using fgets with a character
limit of BUFSIZ to simply using getline.

We initialize the buffer pointer to NULL since getline will
automatically allocate a big enough buffer for us if it's passed a NULL
pointer. After that we pass the same buffer pointer again since,
according to the getline manpage, getline will also call realloc on the
buffer if necessary. Which means the only thing we have to do is call
free() at the end of the parsing process.

Fixes #294
2017-02-11 18:00:11 +02:00
Nikos Tsipinakis
42a641c728 Take allow_markup into account if markup is not set
Preserve backwards compatibility for now, this might be removed for the
3.0 release later on.
2017-02-08 20:55:48 +02:00
Nikos Tsipinakis
a788770a0f Add the ability to call load_settings more than once
free_ini() didn't properly reset `section_count` and `sections` which
caused a segfault if load_ini_file was called multiple times in the same
run.
2017-01-29 15:32:36 +02:00
Luke Shumaker
2c93c7a277 Use the appropriate string search functions instead of strstr everywhere.
This mostly means using strchr, but I also found:
  option_parser.c:load_ini_file:
    - replace multiple calls to strstr with strpbrk
  notification.c:notification_init:
    - replace string_replace in a while loop with a single call to
      string_replace_char

redo string replace all
2016-12-17 17:00:43 -03:00
Nikos Tsipinakis
187d3f9ab9 Invalid boolean values should fall back to the default
Previously, an invalid value was always false
2016-12-15 19:13:08 +02:00
Nikos Tsipinakis
bae745b1fd Don't use ini_get_int to get doubles
option_get_double used ini_get_int to retrieve values from the config
file, changed it to use ini_get_double so that decimal accuracy isn't
lost.
2016-12-03 19:16:32 +02:00
Nikos Tsipinakis
2df2e7d06c Move dunst source files to src/ 2016-11-19 11:54:03 +02:00