[patch] typedefs and identifiers with leading underscores

123 <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
There is no reason to have a name for structs when we just want to
typedef them. BTW identifiers that begin with underscore are reserved.
Attached patch fixes all typedefs.

_______________________________________________
Dillo-dev mailing list
[email protected]
http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
typedefs.diff (text/plain, 7.7 KB)
diff -r 6d07beeb3d51 dlib/dlib.h
--- a/dlib/dlib.h	Mon May 28 21:40:15 2012 +0200
+++ b/dlib/dlib.h	Sat Jun 02 14:18:18 2012 +0400
@@ -99,7 +99,7 @@
  */
 #define Dstr_char_t    char
 
-typedef struct _dstr {
+typedef struct {
    int sz;          /* allocated size (private) */
    int len;
    Dstr_char_t *str;
@@ -128,13 +128,11 @@
 /*
  *-- dList --------------------------------------------------------------------
  */
-struct Dlist_ {
+typedef struct {
    int sz;          /* allocated size (private) */
    int len;
    void **list;
-};
-
-typedef struct Dlist_ Dlist;
+} Dlist;
 
 /* dCompareFunc:
  * Return: 0 if parameters are equal (for dList_find_custom).
diff -r 6d07beeb3d51 src/bitvec.h
--- a/src/bitvec.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/bitvec.h	Sat Jun 02 14:18:18 2012 +0400
@@ -6,12 +6,10 @@
 #define BVEC_TYPE uchar_t
 #define BVEC_SIZE sizeof(BVEC_TYPE)
 
-typedef struct _bitvec bitvec_t;
-
-struct _bitvec {
+typedef struct {
    BVEC_TYPE *vec;
    int len;       /* number of bits [1 based] */
-};
+} bitvec_t;
 
 
 /*
diff -r 6d07beeb3d51 src/bw.h
--- a/src/bw.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/bw.h	Sat Jun 02 14:18:18 2012 +0400
@@ -10,13 +10,8 @@
 #define BW_Img             (2)  /* Image URLs */
 #define BW_Force           (4)  /* Stop connection too */
 
-
-typedef struct _BrowserWindow BrowserWindow;
-
-
 /* browser_window contains the specific data for a single window */
-struct _BrowserWindow
-{
+typedef struct {
    /* Pointer to the UI object this bw belongs to */
    void *ui;
 
@@ -61,7 +56,7 @@
    /* HTML-bugs detected at parse time */
    int num_page_bugs;
    Dstr *page_bugs;
-};
+} BrowserWindow;
 
 
 #ifdef __cplusplus
diff -r 6d07beeb3d51 src/cache.h
--- a/src/cache.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/cache.h	Sat Jun 02 14:18:18 2012 +0400
@@ -34,16 +34,17 @@
 #define CA_HugeFile     0x1000  /* URL content is too big */
 #define CA_IsEmpty      0x2000  /* True until a byte of content arrives */
 
+typedef struct CacheClient CacheClient_t;
+
 /*
  * Callback type for cache clients
  */
-typedef struct _CacheClient CacheClient_t;
 typedef void (*CA_Callback_t)(int Op, CacheClient_t *Client);
 
 /*
  * Data structure for cache clients.
  */
-struct _CacheClient {
+struct CacheClient {
    int Key;                 /* Primary Key for this client */
    const DilloUrl *Url;     /* Pointer to a cache entry Url */
    int Version;             /* Dicache version of this Url (0 if not used) */
diff -r 6d07beeb3d51 src/chain.h
--- a/src/chain.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/chain.h	Sat Jun 02 14:18:18 2012 +0400
@@ -29,14 +29,13 @@
 #define FWD 1
 #define BCK 2
 
+typedef struct ChainLink ChainLink;
 
-typedef struct _ChainLink ChainLink;
-typedef struct _DataBuf DataBuf;
 typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info,
                                 void *Data1, void *Data2);
 
 /* This is the main data structure for CCC nodes */
-struct _ChainLink {
+struct ChainLink {
    void *LocalKey;
 
    int Flags;
@@ -51,12 +50,11 @@
 };
 
 /* A convenience data structure for passing data chunks between nodes */
-struct _DataBuf {
+typedef struct {
    char *Buf;
    int Size;
    int Code;
-};
-
+} DataBuf;
 
 
 /*
diff -r 6d07beeb3d51 src/decode.h
--- a/src/decode.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/decode.h	Sat Jun 02 14:18:18 2012 +0400
@@ -7,9 +7,9 @@
 extern "C" {
 #endif /* __cplusplus */
 
-typedef struct _Decode    Decode;
+typedef struct Decode Decode;
 
-struct _Decode {
+struct Decode {
    char *buffer;
    Dstr *leftover;
    void *state;
diff -r 6d07beeb3d51 src/dicache.h
--- a/src/dicache.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/dicache.h	Sat Jun 02 14:18:18 2012 +0400
@@ -24,9 +24,9 @@
    DIC_Abort       /* Image transfer aborted */
 } DicEntryState;
 
-typedef struct _DICacheEntry DICacheEntry;
+typedef struct DICacheEntry DICacheEntry;
 
-struct _DICacheEntry {
+struct DICacheEntry {
    DilloUrl *url;          /* Image URL for this entry */
    uint_t width, height;   /* As taken from image data */
    DilloImgType type;      /* Image type */
diff -r 6d07beeb3d51 src/html_common.hh
--- a/src/html_common.hh	Mon May 28 21:40:15 2012 +0200
+++ b/src/html_common.hh	Sat Jun 02 14:18:18 2012 +0400
@@ -39,8 +39,6 @@
  * Typedefs
  */
 
-typedef struct _DilloHtmlImage   DilloHtmlImage;
-typedef struct _DilloHtmlState   DilloHtmlState;
 
 typedef enum {
    DT_NONE,
@@ -94,12 +92,12 @@
  * Data Structures
  */
 
-struct _DilloHtmlImage {
+typedef struct {
    DilloUrl *url;
    DilloImage *image;
-};
+} DilloHtmlImage;
 
-struct _DilloHtmlState {
+typedef struct {
    DilloHtmlParseMode parse_mode;
    DilloHtmlTableMode table_mode;
    DilloHtmlTableBorderMode table_border_mode;
@@ -120,7 +118,7 @@
       have to be "handed over" (see Html_add_indented and
       Html_eventually_pop_dw). */
    bool hand_over_break;
-};
+} DilloHtmlState;
 
 /*
  * Classes
diff -r 6d07beeb3d51 src/jpeg.c
--- a/src/jpeg.c	Mon May 28 21:40:15 2012 +0200
+++ b/src/jpeg.c	Sat Jun 02 14:18:18 2012 +0400
@@ -57,9 +57,9 @@
    struct jpeg_error_mgr pub;    /* "public" fields */
    jmp_buf setjmp_buffer;        /* for return to caller */
 };
-typedef struct my_error_mgr * my_error_ptr;
+typedef struct my_error_mgr *my_error_ptr;
 
-typedef struct DilloJpeg {
+typedef struct {
    DilloImage *Image;
    DilloUrl *url;
    int version;
diff -r 6d07beeb3d51 src/klist.h
--- a/src/klist.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/klist.h	Sat Jun 02 14:18:18 2012 +0400
@@ -8,19 +8,16 @@
 extern "C" {
 #endif /* __cplusplus */
 
-typedef struct _KlistNode KlistNode_t;
-typedef struct _Klist Klist_t;
-
-struct _KlistNode {
+typedef struct {
    int Key;        /* primary key */
    void *Data;     /* data reference */
-};
+} KlistNode_t;
 
-struct _Klist {
+typedef struct {
    Dlist *List;
    int Clean;      /* check flag */
    int Counter;    /* counter (for making keys) */
-};
+} Klist_t;
 
 
 /*
diff -r 6d07beeb3d51 src/misc.c
--- a/src/misc.c	Mon May 28 21:40:15 2012 +0200
+++ b/src/misc.c	Sat Jun 02 14:18:18 2012 +0400
@@ -97,7 +97,7 @@
 }
 
 /* TODO: could use dStr ADT! */
-typedef struct ContentType_ {
+typedef struct {
    const char *str;
    int len;
 } ContentType_t;
diff -r 6d07beeb3d51 src/prefs.h
--- a/src/prefs.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/prefs.h	Sat Jun 02 14:18:18 2012 +0400
@@ -29,9 +29,7 @@
 enum {PREFS_FILTER_ALLOW_ALL,
       PREFS_FILTER_SAME_DOMAIN};
 
-typedef struct _DilloPrefs DilloPrefs;
-
-struct _DilloPrefs {
+typedef struct {
    int width;
    int height;
    int xpos;
@@ -93,7 +91,7 @@
    bool_t show_msg;
    bool_t show_extra_warnings;
    bool_t middle_click_drags_page;
-};
+} DilloPrefs; 
 
 /* Global Data */
 extern DilloPrefs prefs;
diff -r 6d07beeb3d51 src/prefsparser.cc
--- a/src/prefsparser.cc	Mon May 28 21:40:15 2012 +0200
+++ b/src/prefsparser.cc	Sat Jun 02 14:18:18 2012 +0400
@@ -33,7 +33,7 @@
    PREFS_PANEL_SIZE
 } PrefType_t;
 
-typedef struct SymNode_ {
+typedef struct {
    const char *name;
    void *pref;
    PrefType_t type;
diff -r 6d07beeb3d51 src/url.h
--- a/src/url.h	Mon May 28 21:40:15 2012 +0200
+++ b/src/url.h	Sat Jun 02 14:18:18 2012 +0400
@@ -83,14 +83,11 @@
 #define URL_ILLEGAL_CHARS(u)        URL_ILLEGAL_CHARS_(u)
 #define URL_ILLEGAL_CHARS_SPC(u)    URL_ILLEGAL_CHARS_SPC_(u)
 
-
-typedef struct _DilloUrl DilloUrl;
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-struct _DilloUrl {
+typedef struct DilloUrl {
    Dstr  *url_string;
    const char *buffer;
    const char *scheme;            /**/
@@ -106,7 +103,7 @@
    int ismap_url_len;             /* Used by server side image maps */
    int illegal_chars;             /* number of illegal chars */
    int illegal_chars_spc;         /* number of illegal space chars */
-};
+} DilloUrl;
 
 
 DilloUrl* a_Url_new(const char *url_str, const char *base_url);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.