Remove all unused includes with include-what-you-use (fixes #11)

This commit is contained in:
Aaron Fischer 2018-10-25 12:17:28 +02:00
parent 9679b5b7a4
commit 7dccd70e38
13 changed files with 78 additions and 127 deletions

View file

@ -12,8 +12,9 @@ CFLAGS = -Wall \
-std=c99 -std=c99
SRC=$(wildcard *.c) SRC=$(wildcard *.c)
fn: $(SRC)
$(CC) -o $@ $^ $(CFLAGS)
clean: clean:
rm -f fn rm -f fn
fn: $(SRC)
$(CC) -o $@ $^ $(CFLAGS)

View file

@ -2,25 +2,19 @@
#define _BSD_SOURCE #define _BSD_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#include <ctype.h> #include <errno.h> // for errno
#include <errno.h> #include <fcntl.h> // for open, O_CREAT, O_RDWR
#include <fcntl.h> #include <stdio.h> // for NULL, fclose, fopen, FILE
#include <stdio.h> #include <stdlib.h> // for free
#include <string.h> #include <string.h> // for strdup, strerror
#include <stdarg.h> #include <unistd.h> // for close, ftruncate, ssize_t
#include <stdlib.h> #include <termios.h> // for termios
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "file.h" #include "file.h"
#include "hl.h" #include "fn.h" // for editorSetStatusMessage, E, editorConfig, edito...
#include "terminal.h" #include "hl.h" // for editorSelectSyntaxHighlight
#include "row.h" #include "row.h" // for editorRowsToString
#include "terminal.h" // for die
void editorOpen(char *filename) { void editorOpen(char *filename) {
free(E.filename); free(E.filename);

View file

@ -2,28 +2,15 @@
#define _BSD_SOURCE #define _BSD_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#include <ctype.h> #include <signal.h> // for signal, SIGWINCH
#include <errno.h> #include <stdio.h> // for NULL
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h" #include "fn.h"
#include "terminal.h" #include "file.h" // for editorOpen
#include "output.h" #include "input.h" // for editorProcessKeypress
#include "row.h" #include "output.h" // for editorRefreshScreen, editorSetStatusMessage
#include "hl.h" #include "terminal.h" // for die, setWindowSize, enableRawMode
#include "search.h"
#include "file.h"
#include "input.h"
// TODO: Put this somewhere else? // TODO: Put this somewhere else?
void windowResizeCallback(int signum); void windowResizeCallback(int signum);

View file

@ -1,6 +1,9 @@
#ifndef _FN_H #ifndef _FN_H
#define _FN_H #define _FN_H
#include <bits/types/time_t.h> // for time_t
#include <termios.h> // for termios
#define FN_VERSION "0.2" #define FN_VERSION "0.2"
#define FN_TAB_STOP 4 #define FN_TAB_STOP 4
#define FN_QUIT_TIMES 2 #define FN_QUIT_TIMES 2

View file

@ -1,19 +1,11 @@
#include <ctype.h> #include <ctype.h> // for isdigit, isspace
#include <errno.h> #include <stdio.h> // for NULL
#include <fcntl.h> #include <stdlib.h> // for realloc
#include <stdio.h> #include <string.h> // for memset, strlen, strncmp, strchr, strcmp, strrchr
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "hl.h" #include "hl.h"
#include "fn.h" // for erow, E, editorConfig, editorSyntax, editorHighl...
char *C_HL_extensions[] = { ".c", ".h", ".cpp", NULL }; char *C_HL_extensions[] = { ".c", ".h", ".cpp", NULL };
char *C_HL_keywords[] = { char *C_HL_keywords[] = {

View file

@ -1,6 +1,9 @@
#ifndef _HL_H #ifndef _HL_H
#define _HL_H #define _HL_H
#include "fn.h" // for erow
int is_separator(int c); int is_separator(int c);
void editorUpdateSyntax(erow *row); void editorUpdateSyntax(erow *row);
int editorSyntaxToColor(int hl); int editorSyntaxToColor(int hl);

View file

@ -1,24 +1,14 @@
#include <ctype.h> #include <ctype.h> // for iscntrl
#include <errno.h> #include <stdio.h> // for NULL
#include <fcntl.h> #include <stdlib.h> // for exit, free
#include <stdio.h> #include <unistd.h> // for STDOUT_FILENO
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "row.h"
#include "terminal.h"
#include "input.h" #include "input.h"
#include "output.h" #include "file.h" // for editorSave
#include "file.h" #include "fn.h" // for E, editorConfig, erow, CTRL_KEY, editorKey::AR...
#include "search.h" #include "output.h" // for editorSetStatusMessage, editorDelChar, editorI...
#include "search.h" // for editorFind
#include "terminal.h" // for editorReadKey
char *editorPrompt(char *prompt, void (*callback)(char *, int)) { char *editorPrompt(char *prompt, void (*callback)(char *, int)) {

View file

@ -1,21 +1,15 @@
#include <ctype.h> #include <ctype.h> // for iscntrl
#include <errno.h> #include <stdarg.h> // for va_list
#include <fcntl.h> #include <stdio.h> // for snprintf, vsnprintf, NULL
#include <stdio.h> #include <string.h> // for strlen
#include <stdarg.h> #include <time.h> // for time
#include <stdlib.h> #include <unistd.h> // for STDOUT_FILENO
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "row.h"
#include "hl.h"
#include "output.h" #include "output.h"
#include "fn.h" // for E, editorConfig, erow, FN_VERSION, abuf, editorH...
#include "hl.h" // for editorSyntaxToColor
#include "row.h" // for abAppend, abFree, editorDelRow, editorRowCxToRx
void editorScroll() { void editorScroll() {
E.rx = 0; E.rx = 0;

View file

@ -1,6 +1,8 @@
#ifndef _OUTPUT_H #ifndef _OUTPUT_H
#define _OUTPUT_H #define _OUTPUT_H
struct abuf;
void editorScroll(); void editorScroll();
void editorDrawRows(struct abuf *ab); void editorDrawRows(struct abuf *ab);

View file

@ -1,20 +1,11 @@
#include <ctype.h> #include <stdio.h> // for NULL
#include <errno.h> #include <stdlib.h> // for free, realloc, malloc
#include <fcntl.h> #include <string.h> // for memmove, memcpy
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "hl.h"
#include "row.h" #include "row.h"
#include "fn.h" // for erow, E, editorConfig, FN_TAB_STOP, abuf
#include "hl.h" // for editorUpdateSyntax
void abAppend(struct abuf *ab, const char *s, int len) { void abAppend(struct abuf *ab, const char *s, int len) {
char *new = realloc(ab->b, ab->len + len); char *new = realloc(ab->b, ab->len + len);

View file

@ -1,8 +1,13 @@
#ifndef _ROW_H #ifndef _ROW_H
#define _ROW_H #define _ROW_H
#include <stddef.h> // for NULL
#include "fn.h" // for erow
#define ABUF_INIT {NULL, 0} #define ABUF_INIT {NULL, 0}
void abAppend(struct abuf *ab, const char *s, int len); void abAppend(struct abuf *ab, const char *s, int len);
void abFree(struct abuf *ab); void abFree(struct abuf *ab);

View file

@ -1,20 +1,10 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "fn.h"
#include "search.h" #include "search.h"
#include "row.h" #include <stdio.h> // for NULL
#include <stdlib.h> // for free, malloc
#include <string.h> // for memcpy, memset, strlen, strstr
#include "fn.h" // for E, editorConfig, erow, editorPrompt, editorHighl...
#include "row.h" // for editorRowRxToCx
void editorFindCallback(char *query, int key) { void editorFindCallback(char *query, int key) {
static int last_match = -1; static int last_match = -1;

View file

@ -1,13 +1,12 @@
#include <stdio.h> #include <errno.h> // for EAGAIN, errno
#include <errno.h> #include <stdio.h> // for perror, sscanf
#include <stdlib.h> #include <stdlib.h> // for atexit, exit
#include <termios.h> #include <sys/ioctl.h> // for winsize, ioctl, TIOCGWINSZ
#include <sys/ioctl.h> #include <termios.h> // for termios, tcsetattr, tcgetattr, TCSAFLUSH, cc_t
#include <unistd.h> #include <unistd.h> // for STDIN_FILENO, STDOUT_FILENO
#include <time.h>
#include "fn.h"
#include "terminal.h" #include "terminal.h"
#include "fn.h" // for E, editorConfig, editorKey::END_KEY, editorKe...
void die(const char *s) { void die(const char *s) {
write(STDOUT_FILENO, "\x1b[2J", 4); write(STDOUT_FILENO, "\x1b[2J", 4);