bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/11] Automatically include 'size_t', 'wchar_t' and 'ptrdiff_t'


From: Tim Hentenaar
Subject: [PATCH 06/11] Automatically include 'size_t', 'wchar_t' and 'ptrdiff_t' as a rw_decl tokens, since they're guaranteed to be available in ANSI C.
Date: Mon, 15 Jun 2015 21:52:57 +0200

---
 ChangeLog    |  2 ++
 src/indent.c | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f5ad166..1f797ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
        * Add an option (-slc/--single-line-conditionals) to allow
          conditionals and their inner statement to be on the same line if
          they're not braced. This should fix GNU bug #42357.
+       * Added a small patch to add size_t, wchar_t and ptrdiff_t to
+         user_specials automatically.
 
 2014-04-07  Andrew Shadura  <address@hidden>
        * Don't add extra 'const' keyword to C++ programs (closes Debian bugs
diff --git a/src/indent.c b/src/indent.c
index 8e49264..087b3ce 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1040,6 +1040,7 @@ int main(
     int     argc,
     char ** argv)
 {
+    char *tmp;
     char *profile_pathname = 0;
     BOOLEAN using_stdin = false;
     exit_values_ty exit_status;
@@ -1065,6 +1066,21 @@ int main(
     }
 #endif
 
+    /* 'size_t', 'wchar_t' and 'ptrdiff_t' are guarenteed to be
+     * available in ANSI C.
+     *
+     * I'm malloc'ing this in the hopes that it will be freed
+     * along with the rest of the user_specials array in
+     * lexi.c (assuming that it actually is.)
+     */
+    tmp = (char *)xmalloc(25);
+    memcpy(tmp, "size_t", 7);
+    addkey(tmp, rw_decl);
+    memcpy(tmp + 7, "wchar_t", 8);
+    addkey(tmp + 7, rw_decl);
+    memcpy(tmp + 15, "ptrdiff_t", 10);
+    addkey(tmp + 15, rw_decl);
+
     init_parser ();
     initialize_backups ();
     exit_status = total_success;
-- 
2.3.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]