Author: avg
Date: Mon Apr 12 21:05:36 2010
New Revision: 206505
URL: http://svn.freebsd.org/changeset/base/206505

Log:
  MFC r205989: indent(1): new option, -ta, to treat all *_t identifiers as
  types

Modified:
  stable/7/usr.bin/indent/args.c
  stable/7/usr.bin/indent/indent.1
  stable/7/usr.bin/indent/indent_globs.h
  stable/7/usr.bin/indent/lexi.c
Directory Properties:
  stable/7/usr.bin/indent/   (props changed)

Modified: stable/7/usr.bin/indent/args.c
==============================================================================
--- stable/7/usr.bin/indent/args.c      Mon Apr 12 21:04:35 2010        
(r206504)
+++ stable/7/usr.bin/indent/args.c      Mon Apr 12 21:05:36 2010        
(r206505)
@@ -157,6 +157,7 @@ struct pro {
     {"sc", PRO_BOOL, true, ON, &star_comment_cont},
     {"sob", PRO_BOOL, false, ON, &swallow_optional_blanklines},
     {"st", PRO_SPECIAL, 0, STDIN, 0},
+    {"ta", PRO_BOOL, false, ON, &auto_typedefs},
     {"troff", PRO_BOOL, false, ON, &troff},
     {"ut", PRO_BOOL, true, ON, &use_tabs},
     {"v", PRO_BOOL, false, ON, &verbose},

Modified: stable/7/usr.bin/indent/indent.1
==============================================================================
--- stable/7/usr.bin/indent/indent.1    Mon Apr 12 21:04:35 2010        
(r206504)
+++ stable/7/usr.bin/indent/indent.1    Mon Apr 12 21:05:36 2010        
(r206505)
@@ -80,6 +80,7 @@
 .Op Fl sob | Fl nsob
 .Ek
 .Op Fl \&st
+.Op Fl \&ta
 .Op Fl troff
 .Op Fl ut | Fl nut
 .Op Fl v | Fl \&nv
@@ -377,6 +378,9 @@ Default:
 Causes
 .Nm
 to take its input from stdin and put its output to stdout.
+.It Fl ta
+Automatically add all identifiers ending in "_t" to the list
+of type keywords.
 .It Fl T Ns Ar typename
 Adds
 .Ar typename

Modified: stable/7/usr.bin/indent/indent_globs.h
==============================================================================
--- stable/7/usr.bin/indent/indent_globs.h      Mon Apr 12 21:04:35 2010        
(r206504)
+++ stable/7/usr.bin/indent/indent_globs.h      Mon Apr 12 21:05:36 2010        
(r206505)
@@ -204,6 +204,8 @@ int     function_brace_split;       /* split f
                                         * brace onto separate lines */
 int        use_tabs;                   /* set true to use tabs for spacing,
                                         * false uses all spaces */
+int        auto_typedefs;              /* set true to recognize identifiers
+                                        * ending in "_t" like typedefs */
 
 /* -troff font state information */
 

Modified: stable/7/usr.bin/indent/lexi.c
==============================================================================
--- stable/7/usr.bin/indent/lexi.c      Mon Apr 12 21:04:35 2010        
(r206504)
+++ stable/7/usr.bin/indent/lexi.c      Mon Apr 12 21:05:36 2010        
(r206505)
@@ -249,6 +249,17 @@ lexi(void)
        last_code = ident;      /* Remember that this is the code we will
                                 * return */
 
+       if (auto_typedefs) {
+           const char *q = s_token;
+           /* Check if we have an "_t" in the end */
+           if (q[0] && q[1] &&
+               (strcmp(q + strlen(q) - 2, "_t") == 0)) {
+               ps.its_a_keyword = true;
+               ps.last_u_d = true;
+               goto found_auto_typedef;
+           }
+       }
+
        /*
         * This loop will check if the token is a keyword.
         */
@@ -285,6 +296,7 @@ lexi(void)
                /* FALLTHROUGH */
 
            case 4:             /* one of the declaration keywords */
+           found_auto_typedef:
                if (ps.p_l_follow) {
                    ps.cast_mask |= (1 << ps.p_l_follow) & ~ps.sizeof_mask;
                    break;      /* inside parens: cast, param list or sizeof */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to