Skip to content
Snippets Groups Projects
Commit 70f439d9 authored by Christian Göttsche's avatar Christian Göttsche Committed by Yorhel
Browse files

Enforce const correctness on strings

(cherry picked from commit 9801f46ece0ca2525f02d71464efc42296dddcb5)
parent 39709aa6
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0, show_items = 0, show_mtime = 0; static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0, show_items = 0, show_mtime = 0;
static char *message = NULL; static const char *message = NULL;
...@@ -256,7 +256,7 @@ static void browse_draw_item(struct dir *n, int row) { ...@@ -256,7 +256,7 @@ static void browse_draw_item(struct dir *n, int row) {
void browse_draw() { void browse_draw() {
struct dir *t; struct dir *t;
char *tmp; const char *tmp;
int selected = 0, i; int selected = 0, i;
erase(); erase();
......
...@@ -181,7 +181,7 @@ static void draw_error(char *cur, char *msg) { ...@@ -181,7 +181,7 @@ static void draw_error(char *cur, char *msg) {
void dir_draw() { void dir_draw() {
float f; float f;
char *unit; const char *unit;
switch(dir_ui) { switch(dir_ui) {
case 0: case 0:
......
...@@ -33,7 +33,7 @@ int page, start; ...@@ -33,7 +33,7 @@ int page, start;
#define KEYS 19 #define KEYS 19
char *keys[KEYS*2] = { const char *keys[KEYS*2] = {
/*|----key----| |----------------description----------------|*/ /*|----key----| |----------------description----------------|*/
"up, k", "Move cursor up", "up, k", "Move cursor up",
"down, j", "Move cursor down", "down, j", "Move cursor down",
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <sys/wait.h> #include <sys/wait.h>
void shell_draw() { void shell_draw() {
char *full_path; const char *full_path;
int res; int res;
/* suspend ncurses mode */ /* suspend ncurses mode */
...@@ -52,7 +52,7 @@ void shell_draw() { ...@@ -52,7 +52,7 @@ void shell_draw() {
"Press any key to continue.", "Press any key to continue.",
full_path, res); full_path, res);
} else { } else {
char *shell = getenv("NCDU_SHELL"); const char *shell = getenv("NCDU_SHELL");
if (shell == NULL) { if (shell == NULL) {
shell = getenv("SHELL"); shell = getenv("SHELL");
if (shell == NULL) if (shell == NULL)
......
...@@ -62,7 +62,7 @@ char *cropstr(const char *from, int s) { ...@@ -62,7 +62,7 @@ char *cropstr(const char *from, int s) {
} }
float formatsize(int64_t from, char **unit) { float formatsize(int64_t from, const char **unit) {
float r = from; float r = from;
if (si) { if (si) {
if(r < 1000.0f) { *unit = " B"; } if(r < 1000.0f) { *unit = " B"; }
...@@ -87,7 +87,7 @@ float formatsize(int64_t from, char **unit) { ...@@ -87,7 +87,7 @@ float formatsize(int64_t from, char **unit) {
void printsize(enum ui_coltype t, int64_t from) { void printsize(enum ui_coltype t, int64_t from) {
char *unit; const char *unit;
float r = formatsize(from, &unit); float r = formatsize(from, &unit);
uic_set(t == UIC_HD ? UIC_NUM_HD : t == UIC_SEL ? UIC_NUM_SEL : UIC_NUM); uic_set(t == UIC_HD ? UIC_NUM_HD : t == UIC_SEL ? UIC_NUM_SEL : UIC_NUM);
printw("%5.1f", r); printw("%5.1f", r);
...@@ -218,7 +218,7 @@ void nccreate(int height, int width, const char *title) { ...@@ -218,7 +218,7 @@ void nccreate(int height, int width, const char *title) {
} }
void ncprint(int r, int c, char *fmt, ...) { void ncprint(int r, int c, const char *fmt, ...) {
va_list arg; va_list arg;
va_start(arg, fmt); va_start(arg, fmt);
move(subwinr+r, subwinc+c); move(subwinr+r, subwinc+c);
...@@ -227,7 +227,7 @@ void ncprint(int r, int c, char *fmt, ...) { ...@@ -227,7 +227,7 @@ void ncprint(int r, int c, char *fmt, ...) {
} }
void nctab(int c, int sel, int num, char *str) { void nctab(int c, int sel, int num, const char *str) {
uic_set(sel ? UIC_KEY_HD : UIC_KEY); uic_set(sel ? UIC_KEY_HD : UIC_KEY);
ncprint(0, c, "%d", num); ncprint(0, c, "%d", num);
uic_set(sel ? UIC_HD : UIC_DEFAULT); uic_set(sel ? UIC_HD : UIC_DEFAULT);
...@@ -355,7 +355,7 @@ void freedir(struct dir *dr) { ...@@ -355,7 +355,7 @@ void freedir(struct dir *dr) {
} }
char *getpath(struct dir *cur) { const char *getpath(struct dir *cur) {
static char *dat; static char *dat;
static int datl = 0; static int datl = 0;
struct dir *d, **list; struct dir *d, **list;
......
...@@ -106,10 +106,10 @@ int ncresize(int, int); ...@@ -106,10 +106,10 @@ int ncresize(int, int);
void nccreate(int, int, const char *); void nccreate(int, int, const char *);
/* printf something somewhere in the last created window */ /* printf something somewhere in the last created window */
void ncprint(int, int, char *, ...); void ncprint(int, int, const char *, ...);
/* Add a "tab" to a window */ /* Add a "tab" to a window */
void nctab(int, int, int, char *); void nctab(int, int, int, const char *);
/* same as the w* functions of ncurses, with a color */ /* same as the w* functions of ncurses, with a color */
#define ncaddstr(r, c, s) mvaddstr(subwinr+(r), subwinc+(c), s) #define ncaddstr(r, c, s) mvaddstr(subwinr+(r), subwinc+(c), s)
...@@ -129,7 +129,7 @@ void nctab(int, int, int, char *); ...@@ -129,7 +129,7 @@ void nctab(int, int, int, char *);
char *cropstr(const char *, int); char *cropstr(const char *, int);
/* Converts the given size in bytes into a float (0 <= f < 1000) and a unit string */ /* Converts the given size in bytes into a float (0 <= f < 1000) and a unit string */
float formatsize(int64_t, char **); float formatsize(int64_t, const char **);
/* print size in the form of xxx.x XB */ /* print size in the form of xxx.x XB */
void printsize(enum ui_coltype, int64_t); void printsize(enum ui_coltype, int64_t);
...@@ -148,7 +148,7 @@ void freedir(struct dir *); ...@@ -148,7 +148,7 @@ void freedir(struct dir *);
/* generates full path from a dir item, /* generates full path from a dir item,
returned pointer will be overwritten with a subsequent call */ returned pointer will be overwritten with a subsequent call */
char *getpath(struct dir *); const char *getpath(struct dir *);
/* returns the root element of the given dir struct */ /* returns the root element of the given dir struct */
struct dir *getroot(struct dir *); struct dir *getroot(struct dir *);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment