瀏覽代碼

Untypedef struct item

Adds clarity. Typedefs for structs are definitely a discussion matter,
but there's no reason to hide a simple data-structure behind a
meaningless typedef.
master
FRIGN 8 年之前
committed by Hiltjo Posthuma
父節點
當前提交
10fd4f275f
共有 1 個文件被更改,包括 9 次插入10 次删除
  1. +9
    -10
      dmenu.c

+ 9
- 10
dmenu.c 查看文件

@@ -28,14 +28,13 @@
/* enums */ /* enums */
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */


typedef struct Item Item;
struct Item {
struct item {
char *text; char *text;
Item *left, *right;
struct item *left, *right;
bool out; bool out;
}; };


static void appenditem(Item *, Item **, Item **);
static void appenditem(struct item *, struct item **, struct item **);
static void calcoffsets(void); static void calcoffsets(void);
static char *cistrstr(const char *, const char *); static char *cistrstr(const char *, const char *);
static void cleanup(void); static void cleanup(void);
@@ -56,9 +55,9 @@ static int bh, mw, mh;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
static int inputw, promptw; static int inputw, promptw;
static size_t cursor; static size_t cursor;
static Item *items = NULL;
static Item *matches, *matchend;
static Item *prev, *curr, *next, *sel;
static struct item *items = NULL;
static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel;
static int mon = -1, screen; static int mon = -1, screen;


static Atom clip, utf8; static Atom clip, utf8;
@@ -75,7 +74,7 @@ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr; static char *(*fstrstr)(const char *, const char *) = strstr;


static void static void
appenditem(Item *item, Item **list, Item **last)
appenditem(struct item *item, struct item **list, struct item **last)
{ {
if (*last) if (*last)
(*last)->right = item; (*last)->right = item;
@@ -135,7 +134,7 @@ static void
drawmenu(void) drawmenu(void)
{ {
int curpos; int curpos;
Item *item;
struct item *item;
int x = 0, y = 0, h = bh, w; int x = 0, y = 0, h = bh, w;


drw_setscheme(drw, &scheme[SchemeNorm]); drw_setscheme(drw, &scheme[SchemeNorm]);
@@ -408,7 +407,7 @@ match(void)
char buf[sizeof text], *s; char buf[sizeof text], *s;
int i, tokc = 0; int i, tokc = 0;
size_t len; size_t len;
Item *item, *lprefix, *lsubstr, *prefixend, *substrend;
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;


strcpy(buf, text); strcpy(buf, text);
/* separate input text into tokens to be matched individually */ /* separate input text into tokens to be matched individually */


Loading…
取消
儲存