Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 9657a9fb9d53a2e3ac76be2d61f19e24cde213cb Author: Raniconduh <clagv.randomgames@gmail.com> Date: Wed Jan 26 12:00:29 2022 +0000 fix header guards and off-by-one error in check_config() attempt fix for config file lines beginning with '=' diff --git a/include/commands.h b/include/commands.h index e0afbae..9002050 100644 --- a/include/commands.h +++ b/include/commands.h @@ -15 +15 @@ -#ifndef COMMANDS_H -#define COMMANDS_H +#ifndef _COMMANDS_H +#define _COMMANDS_H    void ext_open(char *);  long search_file(long, char *); @@ -144 +144 @@ extern bool cutting;  extern char * cut_start_dir;  extern char ** cuts;   -#endif /* COMMANDS_H */ +#endif /* _COMMANDS_H */ diff --git a/include/dir.h b/include/dir.h index fce97f8..f079f56 100644 --- a/include/dir.h +++ b/include/dir.h @@ -15 +15 @@ -#ifndef DIR_H -#define DIR_H +#ifndef _DIR_H +#define _DIR_H    #include <stdbool.h>  #include <time.h> @@ -744 +744 @@ extern char * cwd;    extern bool permission_denied;   -#endif /* DIR_H */ +#endif /* _DIR_H */ diff --git a/include/icons.h b/include/icons.h index 76568ae..b87e5d5 100644 --- a/include/icons.h +++ b/include/icons.h @@ -15 +15 @@ -#ifndef ICONS_H -#define ICONS_H +#ifndef _ICONS_H +#define _ICONS_H    #include "type.h"   @@ -2314 +2314 @@ int icmp(const void * a, const void * b) {   return strcmp(*(const char **)a, ((const struct icon_pair*)b)->ext);  }   -#endif /* ICONS_H */ +#endif /* _ICONS_H */ diff --git a/include/io.h b/include/io.h index 58ab5a5..7ff743f 100644 --- a/include/io.h +++ b/include/io.h @@ -15 +15 @@ -#ifndef IO_H -#define IO_H +#ifndef _IO_H +#define _IO_H    #include <stdbool.h>  #include <stdio.h> @@ -414 +414 @@ extern bool print_path;  extern int stdout_back;  extern size_t n_marked_files;   -#endif /* IO_H */ +#endif /* _IO_H */ diff --git a/include/main.h b/include/main.h index 567c3d3..a3ea612 100644 --- a/include/main.h +++ b/include/main.h @@ -15 +15 @@ -#ifndef MAIN_H -#define MAIN_H +#ifndef _MAIN_H +#define _MAIN_H    #define LAST_F (n_dir_entries > ((unsigned)LINES - 6) ? ((unsigned)LINES - 6) : n_dir_entries)   @@ -74 +74 @@  void help(void);  void handle_winch(int);   -#endif /* MAIN_H */ +#endif /*_MAIN_H */ diff --git a/include/opts.h b/include/opts.h index 36dc151..8d04b34 100644 --- a/include/opts.h +++ b/include/opts.h @@ -15 +15 @@ -#ifndef OPTS_H -#define OPTS_H +#ifndef _OPTS_H +#define _OPTS_H    #include <stdbool.h>   @@ -184 +184 @@ void create_config(void);  void read_config(void);  void terminate_opts(void);   -#endif +#endif /* _OPTS_H */ diff --git a/include/type.h b/include/type.h index 2bc531b..5cf5f9c 100644 --- a/include/type.h +++ b/include/type.h @@ -15 +15 @@ -#ifndef TYPE_H -#define TYPE_H +#ifndef _TYPE_H +#define _TYPE_H    #include "dir.h"   @@ -144 +144 @@ void lowers(char *);  enum mime_type_t get_mime(char *);  char * get_icon(struct dir_entry_t *);   -#endif /* TYPE_H */ +#endif /* _TYPE_H */ diff --git a/src/opts.c b/src/opts.c index a44af60..7352459 100644 --- a/src/opts.c +++ b/src/opts.c @@ -327 +327 @@ bool check_config(void) {   cfg_path = malloc(strlen(home) + 9 + csc_len);   sprintf(cfg_path, "%s/.config", home);   } else { - cfg_path = malloc(strlen(xdg_config) + 1 + csc_len); + cfg_path = malloc(strlen(xdg_config) + 2 + csc_len);   strcpy(cfg_path, xdg_config);   }   @@ -1078 +1078 @@ void read_config(void) {     // add null terminator to var   char * val = strchr(var, '='); - while (isspace(val[n - 1])) n--; - val[n] = 0; + while (val + n > line && isspace(val[--n])); + val[n + 1] = 0;   val++;     // remove trailing white space after '='