]> git.mdlowis.com Git - projs/tide.git/commitdiff
enabled more warnings and fixed them all. Suppressed unused variable warnings in...
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 10 Dec 2018 19:42:35 +0000 (14:42 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 10 Dec 2018 19:42:35 +0000 (14:42 -0500)
14 files changed:
bin/c+
bin/c-
bin/lang
config.h
config.mk
inc/edit.h
src/edit.c
src/fetch.c
src/lib/buf.c
src/lib/view.c
src/lib/x11.c
src/pick.c
src/registrar.c
src/tide.c

diff --git a/bin/c+ b/bin/c+
index fa235713efc7e4cca2806783d805789285dcc7c1..f50e5d4eecf436721289ee361a3afb3beda0c115 100755 (executable)
--- a/bin/c+
+++ b/bin/c+
@@ -1,5 +1,6 @@
 #!/bin/sh
 case "$(lang "$file")" in
-    C) sed 's/^/\/\//g' "$@" ;;
+    C|JavaScript)
+        sed 's/^/\/\//g' "$@" ;;
     *) sed 's/^/#/g' "$@" ;;
 esac
diff --git a/bin/c- b/bin/c-
index 93107ad98116fde4f0cc2e6e280a0ae13f02e66e..e1f6991bde12b15a1412eb8e6b4369116a2ea269 100755 (executable)
--- a/bin/c-
+++ b/bin/c-
@@ -1,5 +1,6 @@
 #!/bin/sh
 case "$(lang "$file")" in
-    C) sed 's/^\/\///g' "$@" ;;
+    C|JavaScript)
+        sed 's/^\/\///g' "$@" ;;
     *) sed 's/^#//g' "$@" ;;
 esac
index 8c1806fdabe4713f2a27f390128ba5e459570fd9..7da04072b9b048d195d1bb662a31a85bf5a7691f 100755 (executable)
--- a/bin/lang
+++ b/bin/lang
@@ -5,5 +5,6 @@ case "$1" in
     *.ml) echo "ML" ;;
     *.py) echo "Python" ;;
     *.rb) echo "Ruby" ;;
+    *.js) echo "JavaScript" ;;
     *)    echo "Text" ;;
 esac
index 643559cbdd8e2c240e3c9512698fed455016818e..bb36a1edbca4092354339a7ee4bd96c7ff04acaf 100644 (file)
--- a/config.h
+++ b/config.h
@@ -1,3 +1,6 @@
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-variable"
+
 enum { Off = 0, On = 1 };
 
 enum { /* Color Names */
@@ -84,17 +87,9 @@ static int Palette[ClrCount] = {
 #endif
 
 Rule* BuiltinRules[] = {
-    (Rule[]){ /* Look up .c or .h files in Code/ */
-        { ISSET, "EDITOR", NULL },
-        { MATCHES, "data", "\\.[ch]$" },
-        { ISDIR, "Code", NULL },
-        { EXEC, "[[ $(find Code -type f -name '*$data') ]]", NULL },
-        { LAUNCH, "find Code -type f -name '*$data' | xargs -r $EDITOR", NULL },
-        { COMPLETE, NULL, NULL }
-    },
     (Rule[]){ /* Match URLS and open them with the browser */
         { ISSET, "BROWSER", NULL },
-        { MATCHES, "data", "^(https?|ftp):/*.*" }, */
+        { MATCHES, "data", "^(https?|ftp)://.*" },
         { LAUNCH, "$BROWSER $0", NULL },
         { COMPLETE, NULL, NULL }
     },
@@ -116,7 +111,15 @@ Rule* BuiltinRules[] = {
         { ISSET, "EDITOR", NULL },
         { ISFILE, "tags", NULL },
         { EXEC, "grep -q '^$data\\s\\+' tags", NULL },
-        { LAUNCH, "picktag fetch tags '$data' | xargs -r tide", NULL },
+        { LAUNCH, "picktag fetch tags '$data' | xargs -r edit", NULL },
+        { COMPLETE, NULL, NULL }
+    },
+    (Rule[]){ /* Look up .c or .h files in Code/ */
+        { ISSET, "EDITOR", NULL },
+        { MATCHES, "data", "\\.[ch]$" },
+        { ISDIR, "Code", NULL },
+        { EXEC, "[[ $(find Code -type f -name '*$data') ]]", NULL },
+        { LAUNCH, "find Code -type f -name '*$data' | xargs -r $EDITOR", NULL },
         { COMPLETE, NULL, NULL }
     },
     (Rule[]){ /* If it's an existing directory, open it with system default */
@@ -125,4 +128,8 @@ Rule* BuiltinRules[] = {
         { COMPLETE, NULL, NULL }
     },
 };
+
 #endif
+
+#pragma GCC diagnostic pop
+
index 0d4b9afcb7603a6385b572ef2de91f80f72b4fb4..835c8f51222bd1ac8a55bee4ec92a95900242d7a 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -19,7 +19,7 @@ INCS += -I/usr/include/freetype2
 # Compiler Setup
 CC = cc
 CFLAGS  = -g --std=c99 -MMD $(INCS)
-CFLAGS += -Wall -Werror
+CFLAGS += -Wall -Wextra
 CFLAGS += -Wno-unused-function
 
 # Linker Setup
index 8a6121e424d0ff231916c868bcb44d72446eef65..027a1ad55399d797e8d1569675acba31072b9622 100644 (file)
@@ -120,7 +120,7 @@ void view_init(View* view, char* file);
 void view_reload(View* view);
 size_t view_limitrows(View* view, size_t maxrows);
 void view_resize(View* view, size_t width, size_t nrows);
-void view_update(View* view, size_t* csrx, size_t* csry);
+void view_update(View* view);
 Row* view_getrow(View* view, size_t row);
 void view_byrune(View* view, int move, bool extsel);
 void view_byword(View* view, int move, bool extsel);
index 52648beafbed81b14ab5de5540c484fe515ad33e..4b776a222d49a16d48cc7f1656c6dd214b7fb887 100644 (file)
@@ -49,6 +49,7 @@ void edit_file(XConf* x, Window registrar, char* path, char* addr) {
 }
 
 void xclientmsg(XConf* x, XEvent* e) {
+    (void)x, (void)e;
     puts("clientmsg");
 }
 
index 37405c00b48e192f9d8e9553d106b9e8ae4a3240..817dde21f2df47f7a306e3c41c381201925f352d 100644 (file)
@@ -124,6 +124,7 @@ bool var_unset(char* var) {
 }
 
 bool find_file(char* file) {
+    (void)file;
     return false;
 }
 
@@ -182,7 +183,7 @@ void usage(char* pname) {
 int main(int argc, char** argv) {
     if (argc != 2) usage(argv[0]);
     setenv("data", argv[1], 1);
-    for (int i = 0; i < nelem(BuiltinRules); i++) {
+    for (unsigned int i = 0; i < nelem(BuiltinRules); i++) {
         Rule* rule = BuiltinRules[i];
         for (; rule->type != COMPLETE; rule++) {
             //printf("%d '%s' '%s'\n", rule->type, rule->arg1, rule->arg2);
index f5928edcce6b53e26595673ddd5d2ef2e4c133c9..1bbb7a23f4acba98b1473061dec74f9968da62fe 100644 (file)
@@ -248,6 +248,8 @@ static void dumplog(Buf* buf) {
     printf("Redo:\n");
     for (Log* log = buf->redo; log; log = log->next)
         printf("    (%d) %lu-%lu '%s'\n", log->transid, log->beg, log->end, log->data);
+#else
+    (void)buf;
 #endif
 }
 
@@ -473,7 +475,7 @@ static void selblock(Buf* buf, Rune first, Rune last) {
 }
 
 static int bytes_match(Buf* buf, size_t mbeg, size_t mend, char* str) {
-    for (; *str; str++, mbeg++) {
+    for (; *str && mbeg < mend; str++, mbeg++) {
         int cmp = *str - getb(buf, mbeg);
         if (cmp != 0) return cmp;
     }
index 254387577b4a950fad7e877ca63d83a0dee20b92..0348c0a1b6c113c0a17ff1e8c93c9625eebc8e1f 100644 (file)
@@ -165,7 +165,7 @@ void view_resize(View* view, size_t width, size_t nrows) {
     resize(view, width, nrows, off);
 }
 
-void view_update(View* view, size_t* csrx, size_t* csry) {
+void view_update(View* view) {
     /* refill the view contents to make sure updates are visible */
     size_t off = view->rows[view->index]->off;
     clear_rows(view, view->index);
index c5a20b9f573dfcb4ff02e15690b49429057fbc13..f9f740790e3d1777f40f9b40973e5c6515472aa5 100644 (file)
@@ -96,7 +96,7 @@ static void get_position(WinRegion id, int x, int y, size_t* row, size_t* col) {
     int starty = (id == EDIT ? Divider+3 : 0);
     int startx = ScrollWidth+3;
     int maxy = (id == EDIT
-        ? (Divider + (win_view(EDIT)->nrows * X.font->height))
+        ? (Divider + (int)(win_view(EDIT)->nrows * X.font->height))
         : Divider - 4
     );
     x = (x < 0 ? 0 : (x > X.width ? X.width : x));
@@ -106,7 +106,7 @@ static void get_position(WinRegion id, int x, int y, size_t* row, size_t* col) {
 }
 
 static struct XSel* selfetch(Atom atom) {
-    for (int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
+    for (unsigned int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
         if (atom == Selections[i].atom)
             return &Selections[i];
     return NULL;
@@ -308,7 +308,7 @@ static void draw_rect(int color, int x, int y, int width, int height) {
     XftColorFree(X.display, X.visual, X.colormap, &clr);
 }
 
-static void draw_statbox(drawcsr* csr) {
+static void draw_statbox(void) {
     draw_rect(VerBdr, ScrollWidth, 0, 1, X.height/4);
     switch (win_view(EDIT)->buffer.status) {
         case NORMAL:   draw_rect(TagsBg, 0, 0, ScrollWidth, X.height/4); break;
@@ -335,11 +335,10 @@ static bool draw_csr(View* view, size_t fheight, int x, int y, bool csrdrawn) {
 
 static void draw_view(View* view, XftFont* font, size_t nrows, drawcsr* csr, int bg, int fg, int sel) {
     size_t fheight = font->height;
-    size_t csrx = SIZE_MAX, csry = SIZE_MAX;
     bool csr_drawn = false;
     /* draw the view to the window */
     view_resize(view, (csr->w - csr->x), nrows);
-    view_update(view, &csrx, &csry);
+    view_update(view);
     draw_rect(bg, csr->x, csr->y, csr->w, ((nrows + 1) * fheight) + 9);
     for (size_t i = 0; i < nrows; i++) {
         Row* row = view_getrow(view, i + view->index);
@@ -359,7 +358,7 @@ static void draw_view(View* view, XftFont* font, size_t nrows, drawcsr* csr, int
             x += row->cols[i].width;
         }
         XftColor fgc;
-        xftcolor(&fgc, EditFg);
+        xftcolor(&fgc, fg);
         XftDrawGlyphSpec(X.xft, &fgc, font, specs, row->len);
         XftColorFree(X.display, X.visual, X.colormap, &fgc);
     }
@@ -404,7 +403,7 @@ static void xkeypress(XEvent* e) {
     if (key == RUNE_ERR) return;
     KeyBtnState = e->xkey.state;
     int mods = KeyBtnState & (ModCtrl|ModShift|ModAlt);
-    uint32_t mkey = tolower(key);
+    int32_t mkey = tolower(key);
     for (KeyBinding* bind = Keys; bind && bind->key; bind++) {
         bool match   = (mkey == bind->key);
         bool exact   = (bind->mods == mods);
@@ -508,7 +507,7 @@ static void xselrequest(XEvent* e) {
 }
 
 static void xclientmsg(XEvent* e) {
-    if (e->xclient.data.l[0] == XInternAtom(X.display, "WM_DELETE_WINDOW", False))
+    if ((Atom)(e->xclient.data.l[0]) == XInternAtom(X.display, "WM_DELETE_WINDOW", False))
         win_quit();
     else if (e->xclient.message_type == XInternAtom(X.display, "GOTO", False))
         view_setln(win_view(EDIT), e->xclient.data.l[0]);
@@ -538,6 +537,7 @@ static void (*EventHandlers[LASTEvent])(XEvent*) = {
 };
 
 static void xupdate(Job* job) {
+    (void)job;
     int nevents;
     /* process events from the queue */
     XEventsQueued(X.display, QueuedAfterFlush);
@@ -555,7 +555,7 @@ static void xupdate(Job* job) {
     /* draw the regions to the window */
     drawcsr csr = { .w = X.width, .h = X.height };
     csr.x += ScrollWidth + 1;
-    draw_statbox(&csr);
+    draw_statbox();
     draw_view(&Regions[TAGS], X.tagfont, tagrows, &csr, TagsBg, TagsFg, TagsSel);
     draw_hrule(&csr);
     draw_view(&Regions[EDIT], X.font, editrows, &csr, EditBg, EditFg, EditSel);
@@ -587,7 +587,7 @@ void win_init(KeyBinding* bindings) {
     X.tagfont = X.font;
     x11_window("unnamed");
     /* initialize selection atoms */
-    for (int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
+    for (unsigned int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
         Selections[i].atom = XInternAtom(X.display, Selections[i].name, 0);
     SelTarget = XInternAtom(X.display, "UTF8_STRING", 0);
     if (SelTarget == None)
@@ -626,7 +626,7 @@ void win_prop_set(char* xname, char* ename, char* value) {
 }
 
 void win_update(int ms) {
-    job_poll(Timeout);
+    job_poll(ms);
     xupdate(NULL);
 }
 
index 44445cdc7668255d071f58971e5a1f05d86d5fb4..c7f78e21355d51fa663c042f79da9a844d611a3b 100644 (file)
@@ -92,7 +92,7 @@ bool match(char *string, size_t offset, size_t *start, size_t *end) {
 }
 
 void score(void) {
-    for (int i = 0; i < vec_size(&Choices); i++) {
+    for (unsigned int i = 0; i < vec_size(&Choices); i++) {
         Choice* choice = (Choice*)vec_at(&Choices, i);
         float qlen = (float)QueryIdx;
         if (match(choice->string, 0, &choice->match_start, &choice->match_end)) {
@@ -108,9 +108,11 @@ void score(void) {
 }
 
 static void xkeypress(XConf* x, XEvent* e) {
+    (void)x, (void)e;
 }
 
 static void xbtnpress(XConf* x, XEvent* e) {
+    (void)x, (void)e;
 }
 
 static void xresize(XConf* x, XEvent* e) {
@@ -158,7 +160,7 @@ void filter(void) {
     }
 }
 
-int main(int argc, char** argv) {
+int main(void) {
     load_choices();
     if (vec_size(&Choices) > 1)
         filter();
index c67abcac0156ce14a9974738cae792ce308ef563..c74f30ee87748749c16a955d8b1eb327e63caa1f 100644 (file)
@@ -81,19 +81,21 @@ void win_open(XConf* x, char* wdir, char* path, char* addr) {
 }
 
 void selclear(XConf* x, XEvent* e) {
+    (void)x, (void)e;
     exit(0);
 }
 
 void clientmsg(XConf* x, XEvent* e) {
     if (XA_REGISTRAR != e->xclient.message_type)
         return;
-    if (XA_ADD == e->xclient.data.l[0])
+    if (XA_ADD == (Atom)(e->xclient.data.l[0]))
         win_add(x, e->xclient.window);
-    else if (XA_DEL == e->xclient.data.l[0])
+    else if (XA_DEL == (Atom)(e->xclient.data.l[0]))
         win_del(e->xclient.window);
 }
 
 void propnotify(XConf* x, XEvent* e) {
+    (void)e;
     Atom type;
     int format;
     unsigned long datalen, nleft;
@@ -113,7 +115,7 @@ void propnotify(XConf* x, XEvent* e) {
     }
 }
 
-int main(int argc, char** argv) {
+int main(void) {
     XConf x = {0};
     x11_init(&x);
     x11_mkwin(&x, 1, 1, PropertyChangeMask);
index 1dc67232050e66405a597d57a28f21f09e906041..ab665290ec1be9a4234b0e379e60ddb5da1d5d2e 100644 (file)
@@ -87,10 +87,12 @@ void exec(char* cmd) {
 /* Keyboard and Tag Handlers
  ******************************************************************************/
 static void select_line(char* arg) {
+    (void)arg;
     buf_selln(win_buf(FOCUSED));
 }
 
 static void join_lines(char* arg) {
+    (void)arg;
     View* view = win_view(FOCUSED);
     buf_logstart(win_buf(FOCUSED));
     view_eol(view, false);
@@ -104,6 +106,7 @@ static void join_lines(char* arg) {
 }
 
 static void delete(char* arg) {
+    (void)arg;
     bool byword = win_keymodsset(ModCtrl);
     view_delete(win_view(FOCUSED), RIGHT, byword);
 }
@@ -124,6 +127,7 @@ void cut(char* arg) {
 }
 
 void paste(char* arg) {
+    (void)arg;
     assert(win_sel_get(CLIPBOARD, onpaste));
 }
 
@@ -142,10 +146,12 @@ static void del_to(void (*tofn)(View*, bool)) {
 }
 
 static void del_to_bol(char* arg) {
+    (void)arg;
     del_to(view_bol);
 }
 
 static void del_to_eol(char* arg) {
+    (void)arg;
     del_to(view_eol);
 }
 
@@ -156,14 +162,17 @@ static void del_to_bow(char* arg) {
 }
 
 static void backspace(char* arg) {
+    (void)arg;
     view_delete(win_view(FOCUSED), LEFT, win_keymodsset(ModCtrl));
 }
 
 static void cursor_bol(char* arg) {
+    (void)arg;
     view_bol(win_view(FOCUSED), false);
 }
 
 static void cursor_eol(char* arg) {
+    (void)arg;
     view_eol(win_view(FOCUSED), false);
 }
 
@@ -192,54 +201,67 @@ static void cursor_home_end(
 }
 
 static void cursor_home(char* arg) {
+    (void)arg;
     cursor_home_end(view_bof, view_bol);
 }
 
 static void cursor_end(char* arg) {
+    (void)arg;
     cursor_home_end(view_eof, view_eol);
 }
 
 static void cursor_up(char* arg) {
+    (void)arg;
     cursor_mvupdn(UP);
 }
 
 static void cursor_dn(char* arg) {
+    (void)arg;
     cursor_mvupdn(DOWN);
 }
 
 static void cursor_left(char* arg) {
+    (void)arg;
     cursor_mvlr(LEFT);
 }
 
 static void cursor_right(char* arg) {
+    (void)arg;
     cursor_mvlr(RIGHT);
 }
 
 static void page_up(char* arg) {
+    (void)arg;
     view_scrollpage(win_view(FOCUSED), UP);
 }
 
 static void page_dn(char* arg) {
+    (void)arg;
     view_scrollpage(win_view(FOCUSED), DOWN);
 }
 
 static void select_prev(char* arg) {
+    (void)arg;
     view_selprev(win_view(FOCUSED));
 }
 
 static void change_focus(char* arg) {
+    (void)arg;
     win_togglefocus();
 }
 
 static void undo(char* arg) {
+    (void)arg;
     view_undo(win_view(FOCUSED));
 }
 
 static void redo(char* arg) {
+    (void)arg;
     view_redo(win_view(FOCUSED));
 }
 
 static void quit(char* arg) {
+    (void)arg;
     win_quit();
 }
 
@@ -264,14 +286,17 @@ static void get(char* arg) {
 }
 
 static void tag_undo(char* arg) {
+    (void)arg;
     view_undo(win_view(EDIT));
 }
 
 static void tag_redo(char* arg) {
+    (void)arg;
     view_redo(win_view(EDIT));
 }
 
 static void search(char* arg) {
+    (void)arg;
     char* str;
     SearchDir *= (win_keymodsset(ModShift) ? UP : DOWN);
     if (win_keymodsset(ModAlt) && SearchTerm)
@@ -285,6 +310,7 @@ static void search(char* arg) {
 }
 
 static void execute(char* arg) {
+    (void)arg;
     char* str = view_getcmd(win_view(FOCUSED));
     if (str) exec(str);
     free(str);
@@ -296,6 +322,7 @@ static void find(char* arg) {
 }
 
 static void open_file(char* arg) {
+    (void)arg;
     cmd_exec(CMD_PICKFILE);
 }
 
@@ -304,10 +331,12 @@ static void pick_symbol(char* symbol) {
 }
 
 static void pick_ctag(char* arg) {
+    (void)arg;
     pick_symbol(NULL);
 }
 
 static void complete(char* arg) {
+    (void)arg;
     View* view = win_view(FOCUSED);
     view_selectobj(view, risword);
     cmd_execwitharg(CMD_COMPLETE, view_getstr(view));
@@ -326,22 +355,26 @@ static void jump_to(char* arg) {
 }
 
 static void goto_ctag(char* arg) {
+    (void)arg;
     char* str = view_getctx(win_view(FOCUSED));
     jump_to(str);
     free(str);
 }
 
 static void tabs(char* arg) {
+    (void)arg;
     ExpandTabs = !ExpandTabs;
     win_title(NULL); // force an update of title
 }
 
 static void indent(char* arg) {
+    (void)arg;
     CopyIndent = !CopyIndent;
     win_title(NULL); // force an update of title
 }
 
 static void eol_mode(char* arg) {
+    (void)arg;
     DosLineFeed = !DosLineFeed;
     win_title(NULL);
     View* view = win_view(EDIT);
@@ -352,10 +385,12 @@ static void eol_mode(char* arg) {
 }
 
 static void new_win(char* arg) {
+    (void)arg;
     cmd_exec(CMD_TIDE);
 }
 
 static void newline(char* arg) {
+    (void)arg;
     View* view = win_view(FOCUSED);
     if (win_keymodsset(ModShift)) {
         view_byline(view, UP, false);
@@ -366,6 +401,7 @@ static void newline(char* arg) {
 }
 
 static void highlight(char* arg) {
+    (void)arg;
     view_selctx(win_view(FOCUSED));
 }
 
@@ -447,7 +483,7 @@ static KeyBinding Bindings[] = {
     { .mods = ModOneOrMore, .key = '\n',       .fn = newline      },
     { .mods = ModCtrl,      .key = ' ',        .fn = complete     },
 
-    { 0, 0, 0 }
+    { 0, 0, 0, 0 }
 };
 
 static void usage(void) {