HTStyle 0.11 → 0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/htstyle.gemspec +1 -1
- data/lib/htstyle.rb +3 -2
- data/lib/version.rb +1 -1
- data/spec/example_output.c +63 -63
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c5cb0251745e1f858523629322ff0b55c2c7564
|
4
|
+
data.tar.gz: 46286cea55f179570edb3b53a7d39f246f60cec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf73eabf35cd7e68d33008532857b7114eaa0fceb3ebf81b51d8a7b3d3ed631da6c6e6b62970c49934096463ba66bb05f19d9c433eb7feeab8ba3f4d9708ca37
|
7
|
+
data.tar.gz: 89dd83cae6b2a87ccebdfc9d9715ef2511ff46be3a4e3fe15534bec6e97e4adf17997a2ebc6d2c9750703bc25046cf2d577391fc2c275303de60ca071b3c3dff
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
##HTStyle
|
2
|
-
Now that everyone looks up to
|
2
|
+
Now that everyone looks up to Hacking Team, you probably want to implement their coding style.
|
3
3
|
|
4
4
|
This application can re-indent you rexisting codebase to match the awesome style.
|
5
5
|
|
6
|
+
###Install
|
7
|
+
This is now a published gem.
|
8
|
+
|
9
|
+
gem install HTStyle
|
10
|
+
|
6
11
|
###Usage
|
7
12
|
|
8
13
|
./htstyle < input.c > output.c
|
data/htstyle.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = HTStyle::VERSION
|
8
8
|
spec.authors = ["Technion"]
|
9
9
|
spec.email = ["technion@lolware.net"]
|
10
|
-
spec.summary = %q{Implements
|
10
|
+
spec.summary = %q{Implements Hacking Team code style}
|
11
11
|
spec.description = %q{Implements Hack Team code style}
|
12
12
|
spec.homepage = "https://github.com/technion/htstyle"
|
13
13
|
spec.license = "BSD"
|
data/lib/htstyle.rb
CHANGED
@@ -6,8 +6,9 @@ module HTStyle
|
|
6
6
|
accum = 0
|
7
7
|
handle.each_line do |line|
|
8
8
|
line.lstrip!
|
9
|
-
|
10
|
-
accum
|
9
|
+
line.chomp!
|
10
|
+
accum += 4 if line[-1] == '{'
|
11
|
+
accum -= 4 if line[-1] == '}'
|
11
12
|
white = 80 - line.length - accum
|
12
13
|
white = 0 if white < 0
|
13
14
|
puts " " * white + line
|
data/lib/version.rb
CHANGED
data/spec/example_output.c
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
/* Example socket code - find a free port
|
2
|
+
* technion@lolware.net
|
3
|
+
* 10/2/2015
|
4
|
+
* Example only - not production tested
|
5
|
+
*/
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <sys/socket.h>
|
8
|
+
#include <arpa/inet.h>
|
9
|
+
#include <string.h>
|
10
|
+
#ifndef S_SPLINT_S
|
11
|
+
#include <unistd.h>
|
12
|
+
#endif
|
13
|
+
#include <stdlib.h>
|
14
|
+
#include <errno.h>
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
#define STARTPORT 8081 /* Start port range to check for a free port */
|
17
|
+
#define ENDPOINT 8090
|
18
18
|
|
19
|
-
|
19
|
+
static uint16_t bind_open_port(int sock);
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
int main()
|
22
|
+
{
|
23
|
+
int sock;
|
24
|
+
uint16_t port;
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
/* Generic socket creation, ipv4, TCP */
|
27
|
+
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
28
|
+
if (sock < 0) {
|
29
|
+
perror("Failed to create socket");
|
30
|
+
exit(EXIT_FAILURE);
|
31
|
+
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
port = bind_open_port(sock);
|
34
|
+
printf("Successfully bound to socket %d\n", port);
|
35
|
+
(void)close(sock);
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
return 0;
|
38
|
+
}
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
/* Cycles from STARTPORT to ENDPORT, looking for a port that is
|
41
|
+
* available for bind().
|
42
|
+
* int sock: Valid socket
|
43
|
+
* Returns: port number, or 0 for error
|
44
|
+
*/
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
static uint16_t bind_open_port(int sock)
|
47
|
+
{
|
48
|
+
struct sockaddr_in servAddr;
|
49
|
+
uint16_t port;
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
51
|
+
for(port = STARTPORT; port <= ENDPOINT; port++) {
|
52
|
+
memset(&servAddr, 0, sizeof(servAddr));
|
53
|
+
servAddr.sin_family = AF_INET;
|
54
|
+
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
55
|
+
servAddr.sin_port = htons(port);
|
56
|
+
if (bind(sock, (struct sockaddr *) &servAddr,
|
57
|
+
(socklen_t)sizeof(servAddr)) == 0) {
|
58
|
+
/* Successful bind */
|
59
|
+
return port;
|
60
|
+
}
|
61
|
+
/* Error condition on bind() */
|
62
|
+
if(errno == EADDRINUSE) {
|
63
|
+
/* This is the "port in use" error, try for another port */
|
64
|
+
printf("Port %d is in use\n", port);
|
65
|
+
continue;
|
66
|
+
}
|
67
|
+
/* Reaching here indicates a different error */
|
68
|
+
perror("Failed to bind");
|
69
|
+
}
|
70
|
+
printf("Unable to find a valid port");
|
71
|
+
return 0;
|
72
72
|
|
73
|
-
|
73
|
+
}
|
74
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HTStyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Technion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,7 @@ rubyforge_project:
|
|
83
83
|
rubygems_version: 2.4.6
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
|
-
summary: Implements
|
86
|
+
summary: Implements Hacking Team code style
|
87
87
|
test_files:
|
88
88
|
- spec/example_output.c
|
89
89
|
- spec/htstyle_spec.rb
|