aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.indent.pro632
-rw-r--r--contrib/find_typedefs.py95
2 files changed, 727 insertions, 0 deletions
diff --git a/.indent.pro b/.indent.pro
new file mode 100644
index 000000000..29c9900c3
--- /dev/null
+++ b/.indent.pro
@@ -0,0 +1,632 @@
1//GNU (default) style:
2//
3//-nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
4//-ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
5//-saw -nsc -nsob
6//
7// -------
8// int foo;
9// char *bar;
10// bar = strdup ("whe-e-e");
11// -------
12// int foo;
13// char *bar;
14//
15// bar = strdup ("whe-e-e");
16// -------
17// Broken in indent-2.2.10
18--blank-lines-after-declarations
19//--no-blank-lines-after-declarations
20//
21// -------
22// int foo (...) {
23// ...
24// }
25// void bar (...) {
26// ...
27// }
28// -------
29// int foo (...) {
30// ...
31// }
32//
33// void bar (...) {
34// ...
35// }
36// -------
37--blank-lines-after-procedures
38//
39// -------
40// /*
41// blah
42// */
43// -------
44// /*
45// * blah
46// */
47// -------
48// WARNING: tends to turn commented-out code chunks into star-walled comment blocks
49--start-left-side-of-comments
50//
51// -------
52// if (foo) { bar }
53// -------
54// if (foo)
55// {
56// bar
57// }
58// -------
59--braces-after-if-line
60//
61// -------
62// if (foo)
63// {
64// bar
65// } else {
66// baz
67// }
68// -------
69// if (foo)
70// {
71// bar
72// }
73// else
74// {
75// baz
76// }
77// -------
78--dont-cuddle-else
79//
80// -------
81// do
82// {
83// foo
84// }
85// while (bar)
86// -------
87// do
88// {
89// foo
90// } while (bar)
91// -------
92--dont-cuddle-do-while
93//
94// -------
95// switch (foo)
96// {
97// case bar:
98// baz
99// }
100// -------
101// switch (foo)
102// {
103// case bar:
104// baz
105// }
106// -------
107--case-indentation0
108//
109// -------
110// switch (foo)
111// {
112// case bar:
113// {
114// baz
115// }
116// }
117// -------
118// switch (foo)
119// {
120// case bar:
121// {
122// baz
123// }
124// }
125// -------
126// Yes, it looks wrong. However, braces inside cases should not be used like this anyway.
127--case-brace-indentation0
128//
129// -------
130// for (i = 0; foobar(i); i++);
131// -------
132// for (i = 0; foobar(i); i++) ;
133// -------
134--space-special-semicolon
135//
136// -------
137// foo(bar)
138// -------
139// foo (bar)
140// -------
141--space-after-procedure-calls
142//
143// -------
144// (int *)foo;
145// (my_custom_type_that_was_not_passed_with_T_argument_see_below *)bar;
146// -------
147// (int *) foo;
148// (my_custom_type_that_was_not_passed_with_T_argument_see_below *)bar;
149// -------
150--space-after-cast
151//
152// -------
153// sizeof(foobar)
154// -------
155// sizeof (foobar)
156// -------
157-bs
158//
159// -------
160// for(foo;bar;baz)
161// -------
162// for (foo;bar;baz)
163// -------
164--space-after-for
165//
166// -------
167// if(foo)
168// -------
169// if (foo)
170// -------
171--space-after-if
172//
173// -------
174// while(foo)
175// -------
176// while (foo)
177// -------
178--space-after-while
179//
180// -------
181// if ( foo ( a > b ) | ( bar ( baz ) ) )
182// -------
183// if (foo (a > b) | (bar (baz)))
184// -------
185--no-space-after-parentheses
186//
187// -------
188// int a;
189// char b;
190// -------
191// int a;
192// char b;
193// -------
194--declaration-indentation0
195//
196// -------
197// int a,
198// b,
199// c;
200// -------
201// int a, b, c;
202// -------
203--no-blank-lines-after-commas
204//
205// -------
206// int foo (int bar, char *baz, long wheee, intptr_t zool);
207// -------
208// int foo (
209// int bar,
210// char *baz,
211// long wheee,
212// intptr_t zool);
213// -------
214--break-function-decl-args
215//
216// -------
217// int foo (
218// int bar,
219// char *baz,
220// long wheee,
221// intptr_t zool
222// );
223// -------
224// int foo (
225// int bar,
226// char *baz,
227// long wheee,
228// intptr_t zool);
229// -------
230--dont-break-function-decl-args-end
231//
232// -------
233// int foo (bar);
234// -------
235// int
236// foo (bar);
237// -------
238--procnames-start-lines
239//
240// -------
241// struct foo { int a; };
242// -------
243// struct foo
244// {
245// int a;
246// };
247// -------
248--braces-after-struct-decl-line
249//
250// -------
251// int foo (bar) {
252// baz
253// }
254// -------
255// int foo (bar)
256// {
257// baz
258// }
259// -------
260--braces-after-func-def-line
261//
262// -------
263// if (foo)
264// {
265// while (bar)
266// {
267// baz;
268// }
269// }
270// -------
271// if (foo)
272// {
273// while (bar)
274// {
275// baz;
276// }
277// }
278// -------
279--indent-level2
280//
281// -------
282// if (foo)
283// {
284// bar;
285// }
286// -------
287// if (foo)
288// {
289// bar;
290// }
291// -------
292--brace-indent0
293//
294// -------
295// boom = foo (bar) - baz +
296// whee (zool);
297// rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha,
298// stereo);
299// -------
300// boom = foo (bar) - baz +
301// whee (zool);
302// rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha,
303// stereo);
304// -------
305--continuation-indentation4
306//
307// -------
308// rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha,
309// stereo);
310// -------
311// rules = power (mono, mwahahahahahahahaahahahahahahahahahahhahahahahaha,
312// stereo);
313// -------
314--continue-at-parentheses
315//--dont-line-up-parentheses
316//
317// -------
318// while ((((i < 2 &&
319// k > 0) || p == 0) &&
320// q == 1) ||
321// n = 0)
322// -------
323// while ((((i < 2 &&
324// k > 0) || p == 0) &&
325// q == 1) ||
326// n = 0)
327// -------
328--paren-indentation2
329//
330// -------
331// char *
332// create_world (x, y, scale)
333// int x;
334// int y;
335// float scale;
336// {
337// ...
338// }
339// -------
340// char *
341// create_world (x, y, scale)
342// int x;
343// int y;
344// float scale;
345// {
346// ...
347// }
348// -------
349--parameter-indentation2
350//
351// -------
352// if (longlonglonglonglonglonglong
353// <tab character>short)
354// -------
355// if (longlonglonglonglonglonglong
356// short)
357// -------
358--no-tabs
359//
360// -------
361// #if WINDOWS
362// #if ZOOL
363// #define WHEE GNUNET_NO
364// #else
365// #define WHEE GNUNET_YES
366// #endif
367// #endif
368// -------
369// #if WINDOWS
370// # if ZOOL
371// # define WHEE GNUNET_NO
372// # else
373// # define WHEE GNUNET_YES
374// # endif
375// #endif
376// -------
377--preprocessor-indentation0
378//
379// -------
380// int foo (bar)
381// {
382// if (c)
383// goto end;
384// if (a > 0)
385// {
386// begin:
387// a = 0;
388// if (b != 0)
389// goto begin;
390// }
391// end:
392// return 0;
393// }
394// -------
395// int foo (bar)
396// {
397// if (c)
398// goto end;
399// if (a > 0)
400// {
401// begin:
402// a = 0;
403// if (b != 0)
404// goto begin;
405// }
406// end:
407// return 0;
408// }
409// -------
410--indent-label0
411//
412// -------
413// line-longer-than-80-chars /* some comment, not counted */
414// -------
415// 80-chars-long-line /* some comment, not counted */
416// rest-of-the-line
417// -------
418--line-length80
419//
420// -------
421// /* comment-line-longer-than-80-chars */
422// -------
423// /* 80-chars-long-comment-line
424// rest-of-the-line */
425// -------
426--comment-line-length80
427//
428// -------
429// if (mask
430// && ((mask[0] == '\0')
431// || (mask[1] == '\0'
432// && ((mask[0] == '0') || (mask[0] == '*')))))
433// -------
434// if (mask &&
435// ((mask[0] == '\0') ||
436// (mask[1] == '\0' &&
437// ((mask[0] == '0') || (mask[0] == '*')))))
438// -------
439--break-after-boolean-operator
440//
441// -------
442// if (mask
443// && ((mask[0] == '\0')
444// || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))
445// -------
446// if (mask /* this newline is preserved, override it with --ignore-newlines */
447// && ((mask[0] == '\0')
448// || (mask[1] == '\0' &&
449// ((mask[0] == '0') || (mask[0] == '*')))))
450// -------
451// For now just keep ignoring. After everything settles down, we might want to start putting custom newlines where it is appropriate
452--honour-newlines
453//--ignore-newlines
454//
455//
456//
457// Also add a list of typedefed types here, like this:
458// -T <typedefedtype1>
459// -T <typedefedtype2>
460// for this:
461// typedef int typedefedtype1;
462// typedef char *typedefedtype2;
463// The following is obtained by running a Python script i wrote on src subdir:
464-T GNUNET_MysqlDataProcessor
465-T GNUNET_DHT_MessageReceivedHandler
466-T DHTLOG_MESSAGE_TYPES
467-T GNUNET_MysqlDataProcessor
468-T GNUNET_DV_MessageReceivedHandler
469-T p2p_dv_MESSAGE_NeighborInfo
470-T p2p_dv_MESSAGE_Data
471-T p2p_dv_MESSAGE_Disconnect
472-T GNUNET_FS_QueueStart
473-T GNUNET_FS_QueueStop
474-T SuspendSignalFunction
475-T GNUNET_FS_TEST_UriContinuation
476-T GNUNET_FS_TreeBlockProcessor
477-T GNUNET_FS_TreeProgressCallback
478-T GSF_ConnectedPeerIterator
479-T GSF_GetMessageCallback
480-T GSF_PeerReserveCallback
481-T GSF_PendingRequestReplyHandler
482-T GSF_PendingRequestIterator
483-T GSF_LocalLookupContinuation
484-T GNUNET_ARM_Callback
485-T GNUNET_TRANSPORT_ATS_AllocationNotification
486-T GNUNET_ATS_AddressSuggestionCallback
487-T GNUNET_BLOCK_GetKeyFunction
488-T GNUNET_CHAT_JoinCallback
489-T GNUNET_CHAT_MessageCallback
490-T GNUNET_CHAT_MemberListCallback
491-T GNUNET_CHAT_MessageConfirmation
492-T GNUNET_CHAT_RoomIterator
493-T GNUNET_CLIENT_MessageHandler
494-T GNUNET_CLIENT_ShutdownTask
495-T GNUNET_FileNameCallback
496-T GNUNET_CONFIGURATION_Iterator
497-T GNUNET_CONFIGURATION_Section_Iterator
498-T GNUNET_CONNECTION_AccessCheck
499-T GNUNET_CONNECTION_Receiver
500-T GNUNET_CONNECTION_TransmitReadyNotify
501-T GNUNET_HashCodeIterator
502-T GNUNET_CONTAINER_HashMapIterator
503-T GNUNET_CONTAINER_HeapCostType
504-T GNUNET_CONTAINER_HeapIterator
505-T GNUNET_CORE_ConnectEventHandler
506-T GNUNET_CORE_PeerStatusEventHandler
507-T GNUNET_CORE_DisconnectEventHandler
508-T GNUNET_CORE_MessageCallback
509-T GNUNET_CORE_StartupCallback
510-T GNUNET_CORE_ControlContinuation
511-T GNUNET_CORE_PeerConfigurationInfoCallback
512-T GNUNET_CRYPTO_HashCompletedCallback
513-T GNUNET_DATACACHE_Iterator
514-T GNUNET_DATACACHE_DeleteNotifyCallback
515-T DiskUtilizationChange
516-T PluginDatumProcessor
517-T PluginGetRandom
518-T GNUNET_DATASTORE_ContinuationWithStatus
519-T GNUNET_DATASTORE_DatumProcessor
520-T GNUNET_DHT_GetIterator
521-T GNUNET_DHT_FindPeerProcessor
522-T GNUNET_DHT_ReplyProcessor
523-T GNUNET_DISK_DirectoryIteratorCallback
524-T GNUNET_FRAGMENT_MessageProcessor
525-T GNUNET_DEFRAGMENT_AckProcessor
526-T GNUNET_FS_KeywordIterator
527-T GNUNET_FS_ProgressCallback
528-T GNUNET_FS_FileInformationProcessor
529-T GNUNET_FS_DataReader
530-T GNUNET_FS_FileProcessor
531-T GNUNET_FS_DirectoryScanner
532-T GNUNET_FS_PublishContinuation
533-T GNUNET_FS_IndexedFileProcessor
534-T GNUNET_FS_NamespaceInfoProcessor
535-T GNUNET_FS_IdentifierProcessor
536-T GNUNET_FS_DirectoryEntryProcessor
537-T GNUNET_HELLO_GenerateAddressListCallback
538-T GNUNET_HELLO_AddressIterator
539-T GNUNET_MESH_MessageCallback
540-T GNUNET_MESH_TunnelEndHandler
541-T GNUNET_MESH_ApplicationType
542-T GNUNET_MESH_TunnelDisconnectHandler
543-T GNUNET_MESH_TunnelConnectHandler
544-T GNUNET_MESH_MessageCallback
545-T GNUNET_MESH_TunnelEndHandler
546-T GNUNET_MESH_ApplicationType
547-T GNUNET_MESH_TunnelDisconnectHandler
548-T GNUNET_MESH_TunnelConnectHandler
549-T GNUNET_NAT_AddressCallback
550-T GNUNET_NAT_ReversalCallback
551-T GNUNET_NAT_TestCallback
552-T GNUNET_NSE_Callback
553-T GNUNET_OS_NetworkInterfaceProcessor
554-T GNUNET_OS_LineProcessor
555-T GNUNET_PEERINFO_Processor
556-T GNUNET_PEER_Id
557-T GNUNET_PLUGIN_Callback
558-T GNUNET_PROGRAM_Main
559-T GNUNET_PSEUDONYM_Iterator
560-T GNUNET_RESOLVER_AddressCallback
561-T GNUNET_RESOLVER_HostnameCallback
562-T GNUNET_SCHEDULER_TaskIdentifier
563-T GNUNET_SCHEDULER_Task
564-T GNUNET_SCHEDULER_select
565-T GNUNET_SERVER_MessageCallback
566-T GNUNET_SERVER_DisconnectCallback
567-T GNUNET_SERVER_MessageTokenizerCallback
568-T GNUNET_SERVICE_Main
569-T GNUNET_SIGNAL_Handler
570-T GNUNET_STATISTICS_Iterator
571-T GNUNET_STATISTICS_Callback
572-T GNUNET_TESTING_NotifyHostkeyCreated
573-T GNUNET_TESTING_NotifyDaemonRunning
574-T GNUNET_TESTING_NotifyCompletion
575-T GNUNET_TESTING_NotifyConnections
576-T GNUNET_TESTING_NotifyConnection
577-T GNUNET_TESTING_NotifyTopology
578-T GNUNET_TESTING_STATISTICS_Iterator
579-T GNUNET_TRANSPORT_SessionEnd
580-T GNUNET_TRANSPORT_AddressNotification
581-T GNUNET_TRANSPORT_TransmitContinuation
582-T GNUNET_TRANSPORT_TransmitFunction
583-T GNUNET_TRANSPORT_DisconnectFunction
584-T GNUNET_TRANSPORT_AddressStringCallback
585-T GNUNET_TRANSPORT_AddressPrettyPrinter
586-T GNUNET_TRANSPORT_CheckAddress
587-T GNUNET_TRANSPORT_AddressToString
588-T GNUNET_TRANSPORT_ReceiveCallback
589-T GNUNET_TRANSPORT_NotifyConnect
590-T GNUNET_TRANSPORT_NotifyDisconnect
591-T GNUNET_TRANSPORT_AddressLookUpCallback
592-T GNUNET_TRANSPORT_HelloUpdateCallback
593-T GNUNET_TRANSPORT_BlacklistCallback
594-T sa_family_t
595-T SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
596-T PLIBC_SEARCH__compar_fn_t
597-T _win_comparison_fn_t
598-T PLIBC_SEARCH_ACTION
599-T PLIBC_SEARCH_VISIT
600-T PLIBC_SEARCH__action_fn_t
601-T PLIBC_SEARCH__free_fn_t
602-T MESH_TunnelNumber
603-T TransmissionContinuation
604-T GNUNET_TESTING_ConnectionProcessor
605-T SetupContinuation
606-T glp_prob
607-T glp_iocp
608-T glp_smcp
609-T GNUNET_TRANSPORT_ATS_AddressNotification
610-T GNUNET_TRANSPORT_ATS_ResultCallback
611-T GST_BlacklistTestContinuation
612-T GST_HelloCallback
613-T GST_NeighbourSendContinuation
614-T GST_NeighbourIterator
615-T GST_ValidationAddressCallback
616-T u32
617-T u16
618-T u8
619-T __le32
620-T EmailAddress
621-T SMTPMessage
622-T GNUNET_TRANSPORT_TESTING_connect_cb
623-T ieee80211_mgt_beacon_t
624-T ieee80211_mgt_auth_t
625-T u64
626-T u32
627-T u16
628-T u8
629-T uLong
630-T uLong
631-T KBlock_secret_key
632-T MyNSGetExecutablePathProto
diff --git a/contrib/find_typedefs.py b/contrib/find_typedefs.py
new file mode 100644
index 000000000..d6db597da
--- /dev/null
+++ b/contrib/find_typedefs.py
@@ -0,0 +1,95 @@
1from __future__ import print_function
2import os
3import re
4import sys
5
6debug = False
7
8def get_td_from_function_signature (line, file, num):
9 left_paren = line.find ('(')
10 if left_paren > 0:
11 left_paren += 1
12 line = line[left_paren:]
13 right_paren = line.find (')')
14 if right_paren > 0 and right_paren > left_paren and line[right_paren:].find ('(') >= 0:
15 fname = line[:right_paren]
16 fname = fname.lstrip (' ').lstrip ('*').lstrip (' ').rstrip (' ')
17 if len (fname) > 0:
18 if debug:
19 print ("from {0}:{1}".format (file, num))
20 print ("-T {0}".format (fname))
21
22def get_td_from_simple_type (line, file, num):
23 line = line.rstrip (' ').rstrip ('\t').rstrip (' ').rstrip ('\t')
24 right_space = line.rfind (' ')
25 right_tab = line.rfind ('\t')
26 sep = right_tab if right_tab > right_space else right_space
27 sep += 1
28 tname = line[sep:]
29 tname = tname.lstrip ('*')
30 if len (tname) > 0:
31 if debug:
32 print ("from {0}:{1}".format (file, num))
33 print ("-T {0}".format (tname))
34
35def find_typedefs (file):
36 with open (file, 'rb') as f:
37 td = False
38 td_struct = False
39 td_level = 0
40 td_line = []
41 data = f.read ()
42 for i, l in enumerate (data.splitlines (False)):
43 # Don't try to be too smart: only count lines that begin with 'typedef '
44 l = l.rstrip (' ').rstrip ('\t')
45 if len (l) == 0:
46 continue
47 if not td:
48 if l[:8] != 'typedef ':
49 continue
50 else:
51 td = True
52 if l[8:].lstrip (' ').lstrip ('\t')[:6] == 'struct':
53 td_struct = True
54 if td_struct:
55 leftcbrace = l.find ('{')
56 if leftcbrace >= 0:
57 if td_level == 0:
58 td_line.append (l[:leftcbrace])
59 l = l[leftcbrace + 1:]
60 td_level += 1
61 rightcbrace = l.rfind ('}')
62 if rightcbrace >= 0:
63 td_level -= 1
64 if td_level == 0:
65 td_line.append (l[rightcbrace + 1:])
66 else:
67 td_line.append (l)
68 if len (l) > 0 and l[-1] == ';' and (not td_struct or td_level == 0):
69 td_line = ' '.join (td_line)
70 td_line = td_line[:-1]
71 if len (td_line) > 0:
72 if td_line[-1] == ')':
73 get_td_from_function_signature (td_line, file, i)
74 else:
75 get_td_from_simple_type (td_line, file, i)
76 td_line = []
77 td = False
78 td_struct = False
79 td_level = 0
80
81
82def scan_dir (d):
83 for dirpath, dirs, files in os.walk (d):
84 for f in files:
85 if re.match (r'(?!lt_).+\.(c|cc|h)$', f):
86 file = os.path.join (dirpath, f)
87 find_typedefs (file)
88
89
90if __name__ == '__main__':
91 if len (sys.argv[1:]) == 0:
92 arg = os.getcwd ()
93 else:
94 arg = sys.argv[1]
95 scan_dir (arg) \ No newline at end of file