From 1f1741cdfb275f3a9c781d320453e291e3985c9c Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 10 Nov 2016 16:30:41 -0500 Subject: [PATCH] added comments to edit.h and cleaned up warnings in exec.c --- inc/edit.h | 49 +++++++++++++++++++++++++------------------------ libedit/exec.c | 7 ++----- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/inc/edit.h b/inc/edit.h index 169a0aa..06e5a38 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -16,35 +16,36 @@ char* fdgets(int fd); /* Buffer management functions *****************************************************************************/ typedef struct Log { - struct Log* next; - bool locked; - bool insert; + struct Log* next; /* pointer to next operation in the stack */ + bool locked; /* whether new operations can be coalesced or not */ + bool insert; /* whether this operation was an insert or delete */ union { struct { - size_t beg; - size_t end; + size_t beg; /* offset in the file where insertion started */ + size_t end; /* offset in the file where insertion ended */ } ins; struct { - size_t off; - size_t len; - Rune* runes; + size_t off; /* offset in the file where the deletion occurred */ + size_t len; /* number of runes deleted */ + Rune* runes; /* array of runes containing deleted content */ } del; } data; } Log; typedef struct buf { - char* path; /* the path to the open file */ - int charset; /* the character set of the buffer */ - int crlf; /* tracks whether the file uses dos style line endings */ - bool locked; /* tracks current mode */ - bool modified; /* tracks whether the buffer has been modified */ - size_t bufsize; /* size of the buffer in runes */ - Rune* bufstart; /* start of the data buffer */ - Rune* bufend; /* end of the data buffer */ - Rune* gapstart; /* start of the gap */ - Rune* gapend; /* end of the gap */ - Log* undo; /* undo list */ - Log* redo; /* redo list */ + char* path; /* the path to the open file */ + int charset; /* the character set of the buffer */ + int crlf; /* tracks whether the file uses dos style line endings */ + bool locked; /* tracks current mode */ + bool modified; /* tracks whether the buffer has been modified */ + size_t bufsize; /* size of the buffer in runes */ + Rune* bufstart; /* start of the data buffer */ + Rune* bufend; /* end of the data buffer */ + Rune* gapstart; /* start of the gap */ + Rune* gapend; /* end of the gap */ + Log* undo; /* undo list */ + Log* redo; /* redo list */ + bool expand_tabs; /* tracks current mode */ } Buf; typedef struct { @@ -173,10 +174,10 @@ UGlyph* screen_getglyph(unsigned row, unsigned col, unsigned* scrwidth); /* Command Executions *****************************************************************************/ typedef struct { - int pid; - int in; - int out; - int err; + int pid; /* process id of the child process */ + int in; /* file descriptor for the child process's standard input */ + int out; /* file descriptor for the child process's standard output */ + int err; /* file descriptor for the child process's standard error */ } Process; int execute(char** cmd, Process* proc); diff --git a/libedit/exec.c b/libedit/exec.c index e90bfda..8f1b6c0 100644 --- a/libedit/exec.c +++ b/libedit/exec.c @@ -1,12 +1,9 @@ +#define _POSIX_C_SOURCE 200809L #include #include #include - -#define _POSIX_C_SOURCE 200809L #include -#include -#include -#include +#include #define PIPE_READ 0 #define PIPE_WRITE 1 -- 2.51.0