]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed build errors due to use of non-forward declared symbols
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 17 Sep 2018 20:10:38 +0000 (16:10 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 17 Sep 2018 20:10:38 +0000 (16:10 -0400)
lib/buf.c

index efeda373b75c7add085bcde601ec313c2b41bdaf..fe740ced33c5a2dba613225f3f537cda579d050d 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -16,6 +16,39 @@ static size_t pagealign(size_t sz) {
     return sz;
 }
 
+static void buf_resize(Buf* buf, size_t sz) {
+    /* allocate the new buffer and gap */
+    Buf copy = *buf;
+    copy.bufsize  = sz;
+    copy.bufstart = (char*)malloc(copy.bufsize);
+    copy.bufend   = copy.bufstart + copy.bufsize;
+    copy.gapstart = copy.bufstart;
+    copy.gapend   = copy.bufend;
+    /* copy the data from the old buffer to the new one */
+    for (char* curr = buf->bufstart; curr < buf->gapstart; curr++)
+        *(copy.gapstart++) = *(curr);
+    for (char* curr = buf->gapend; curr < buf->bufend; curr++)
+        *(copy.gapstart++) = *(curr);
+    /* free the buffer and commit the changes */
+    free(buf->bufstart);
+    memcpy(buf, &copy, sizeof(Buf));
+}
+
+static void buf_syncgap(Buf* buf, size_t off) {
+    assert(off <= buf_end(buf));
+    /* If the buffer is full, resize it before syncing */
+    if (0 == (buf->gapend - buf->gapstart))
+        buf_resize(buf, buf->bufsize << 1);
+    /* Move the gap to the desired offset */
+    char* newpos = (buf->bufstart + off);
+    if (newpos < buf->gapstart)
+        while (newpos < buf->gapstart)
+            *(--buf->gapend) = *(--buf->gapstart);
+    else
+        while (newpos > buf->gapstart)
+            *(buf->gapstart++) = *(buf->gapend++);
+}
+
 static char getb(Buf* buf, size_t off) {
     if (off >= buf_end(buf)) return '\n'; // TODO: get rid of this hack
     size_t bsz = (buf->gapstart - buf->bufstart);
@@ -89,7 +122,7 @@ void buf_load(Buf* buf, char* path) {
     buf->status  = NORMAL;
     buf->modtime = (uint64_t)sb.st_mtime;
     buf_logclear(buf);
-    
+
     /* use the EOL style of the first line to determine EOL style */
     DosLineFeed = (getb(buf, buf_eol(buf, 0)) == '\r');
 }
@@ -125,39 +158,6 @@ int buf_save(Buf* buf, char* path) {
     return buf->status;
 }
 
-static void buf_resize(Buf* buf, size_t sz) {
-    /* allocate the new buffer and gap */
-    Buf copy = *buf;
-    copy.bufsize  = sz;
-    copy.bufstart = (char*)malloc(copy.bufsize);
-    copy.bufend   = copy.bufstart + copy.bufsize;
-    copy.gapstart = copy.bufstart;
-    copy.gapend   = copy.bufend;
-    /* copy the data from the old buffer to the new one */
-    for (char* curr = buf->bufstart; curr < buf->gapstart; curr++)
-        *(copy.gapstart++) = *(curr);
-    for (char* curr = buf->gapend; curr < buf->bufend; curr++)
-        *(copy.gapstart++) = *(curr);
-    /* free the buffer and commit the changes */
-    free(buf->bufstart);
-    memcpy(buf, &copy, sizeof(Buf));
-}
-
-static void buf_syncgap(Buf* buf, size_t off) {
-    assert(off <= buf_end(buf));
-    /* If the buffer is full, resize it before syncing */
-    if (0 == (buf->gapend - buf->gapstart))
-        buf_resize(buf, buf->bufsize << 1);
-    /* Move the gap to the desired offset */
-    char* newpos = (buf->bufstart + off);
-    if (newpos < buf->gapstart)
-        while (newpos < buf->gapstart)
-            *(--buf->gapend) = *(--buf->gapstart);
-    else
-        while (newpos > buf->gapstart)
-            *(buf->gapstart++) = *(buf->gapend++);
-}
-
 static Sel buf_getsel(Buf* buf) {
     size_t temp;
     Sel sel = buf->selection;