]> git.armaanb.net Git - st.git/commitdiff
Reduce visibility wherever possible
authorDevin J. Pohly <djpohly@gmail.com>
Sat, 24 Feb 2018 22:32:20 +0000 (16:32 -0600)
committerDevin J. Pohly <djpohly@gmail.com>
Mon, 26 Feb 2018 03:56:26 +0000 (21:56 -0600)
When possible, declare functions/variables static and move struct
definitions out of headers.  In order to allow utf8decode to become
internal, use codepoint for DECSCUSR extension directly.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
st.c
st.h
win.h
x.c

diff --git a/st.c b/st.c
index ce32cc0d3fe645ae1d19098e6b1a72d3d12febd0..f46aab61c0329a11c652bbb574f9a71525dfc994 100644 (file)
--- a/st.c
+++ b/st.c
@@ -36,6 +36,7 @@
 
 /* Arbitrary sizes */
 #define UTF_INVALID   0xFFFD
+#define UTF_SIZ       4
 #define ESC_BUF_SIZ   (128*UTF_SIZ)
 #define ESC_ARG_SIZ   16
 #define STR_BUF_SIZ   ESC_BUF_SIZ
@@ -95,6 +96,31 @@ enum escape_state {
        ESC_DCS        =128,
 };
 
+typedef struct {
+       Glyph attr; /* current char attributes */
+       int x;
+       int y;
+       char state;
+} TCursor;
+
+typedef struct {
+       int mode;
+       int type;
+       int snap;
+       /*
+        * Selection variables:
+        * nb – normalized coordinates of the beginning of the selection
+        * ne – normalized coordinates of the end of the selection
+        * ob – original coordinates of the beginning of the selection
+        * oe – original coordinates of the end of the selection
+        */
+       struct {
+               int x, y;
+       } nb, ne, ob, oe;
+
+       int alt;
+} Selection;
+
 /* Internal representation of the screen */
 typedef struct {
        int row;      /* nb row */
@@ -187,15 +213,18 @@ static void tstrsequence(uchar);
 
 static void drawregion(int, int, int, int);
 
+static void selnormalize(void);
 static void selscroll(int, int);
 static void selsnap(int *, int *, int);
 
+static size_t utf8decode(const char *, Rune *, size_t);
 static Rune utf8decodebyte(char, size_t *);
 static char utf8encodebyte(Rune, size_t);
-static char *utf8strchr(char *s, Rune u);
+static char *utf8strchr(char *, Rune);
 static size_t utf8validate(Rune *, size_t);
 
 static char *base64dec(const char *);
+static char base64dec_getc(const char **);
 
 static ssize_t xwrite(int, const char *, size_t);
 
diff --git a/st.h b/st.h
index 0a7472ba8d702dabc5fa94ad3e2c4d953b6c296a..1015fc6bdd0d1505288651e433db96c5ad21445b 100644 (file)
--- a/st.h
+++ b/st.h
@@ -1,8 +1,5 @@
 /* See LICENSE for license details. */
 
-/* Arbitrary sizes */
-#define UTF_SIZ       4
-
 /* macros */
 #define MIN(a, b)              ((a) < (b) ? (a) : (b))
 #define MAX(a, b)              ((a) < (b) ? (b) : (a))
@@ -69,41 +66,6 @@ typedef struct {
 
 typedef Glyph *Line;
 
-typedef struct {
-       Glyph attr; /* current char attributes */
-       int x;
-       int y;
-       char state;
-} TCursor;
-
-/* Purely graphic info */
-typedef struct {
-       int tw, th; /* tty width and height */
-       int w, h; /* window width and height */
-       int ch; /* char height */
-       int cw; /* char width  */
-       int mode; /* window state/mode flags */
-       int cursor; /* cursor style */
-} TermWindow;
-
-typedef struct {
-       int mode;
-       int type;
-       int snap;
-       /*
-        * Selection variables:
-        * nb – normalized coordinates of the beginning of the selection
-        * ne – normalized coordinates of the end of the selection
-        * ob – original coordinates of the beginning of the selection
-        * oe – original coordinates of the end of the selection
-        */
-       struct {
-               int x, y;
-       } nb, ne, ob, oe;
-
-       int alt;
-} Selection;
-
 typedef union {
        int i;
        uint ui;
@@ -137,11 +99,9 @@ void selclear(void);
 void selinit(void);
 void selstart(int, int, int);
 void selextend(int, int, int, int);
-void selnormalize(void);
 int selected(int, int);
 char *getsel(void);
 
-size_t utf8decode(const char *, Rune *, size_t);
 size_t utf8encode(Rune, char *);
 
 void *xmalloc(size_t);
diff --git a/win.h b/win.h
index 7a866fdfa9864e954780364cd89d2a2bce77758c..31f327d61cf9746d07a6c4676de08e79819d39c1 100644 (file)
--- a/win.h
+++ b/win.h
@@ -27,7 +27,6 @@ void xbell(void);
 void xclipcopy(void);
 void xdrawcursor(int, int, Glyph, int, int, Glyph);
 void xdrawline(Line, int, int, int);
-void xhints(void);
 void xfinishdraw(void);
 void xloadcols(void);
 int xsetcolorname(int, const char *);
diff --git a/x.c b/x.c
index 970d6dd8816750f9d66075d68163a7be59bfdf90..f7b05285508d458a5e23be643881d6f4a9c3af02 100644 (file)
--- a/x.c
+++ b/x.c
@@ -75,6 +75,15 @@ typedef XftColor Color;
 typedef XftGlyphFontSpec GlyphFontSpec;
 
 /* Purely graphic info */
+typedef struct {
+       int tw, th; /* tty width and height */
+       int w, h; /* window width and height */
+       int ch; /* char height */
+       int cw; /* char width  */
+       int mode; /* window state/mode flags */
+       int cursor; /* cursor style */
+} TermWindow;
+
 typedef struct {
        Display *dpy;
        Colormap cmap;
@@ -133,6 +142,8 @@ static int xgeommasktogravity(int);
 static void xinit(int, int);
 static void cresize(int, int);
 static void xresize(int, int);
+static void xhints(void);
+static int xloadcolor(int, const char *, Color *);
 static int xloadfont(Font *, FcPattern *);
 static void xloadfonts(char *, double);
 static void xunloadfont(Font *);
@@ -1430,8 +1441,8 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
        /* draw the new one */
        if (IS_SET(MODE_FOCUSED)) {
                switch (win.cursor) {
-               case 7: /* st extension: snowman */
-                       utf8decode("☃", &g.u, UTF_SIZ);
+               case 7: /* st extension: snowman (U+2603) */
+                       g.u = 0x2603;
                case 0: /* Blinking Block */
                case 1: /* Blinking Block (Default) */
                case 2: /* Steady Block */