Skip to content

Commit 48aec46

Browse files
committed
format {foo} => { foo }
modified: format.rb modified: ../ch03/README.md modified: ../ch04/README.md modified: ../ch05/README.md modified: ../ch05/ex5_14.cpp modified: ../ch05/ex5_17.cpp modified: ../ch06/README.md modified: ../ch06/ex6_23.cpp modified: ../ch07/README.md modified: ../ch07/ex7_11.h modified: ../ch07/ex7_12.h modified: ../ch07/ex7_15.h modified: ../ch07/ex7_21.h modified: ../ch07/ex7_22.h modified: ../ch07/ex7_23.h modified: ../ch07/ex7_24.h modified: ../ch07/ex7_26.h modified: ../ch07/ex7_27.h modified: ../ch07/ex7_32.h modified: ../ch07/ex7_50.h modified: ../ch09/README.md modified: ../ch09/ex9_41.cpp modified: ../ch09/ex9_47_1.cpp modified: ../ch09/ex9_47_2.cpp modified: ../ch09/ex9_52.cpp modified: ../ch10/README.md modified: ../ch10/ex10_05.cpp modified: ../ch10/ex10_12.cpp modified: ../ch10/ex10_17.cpp modified: ../ch10/ex10_22.cpp modified: ../ch10/ex10_27.cpp modified: ../ch10/ex10_28.cpp modified: ../ch10/ex10_32.cpp modified: ../ch11/README.md modified: ../ch11/ex11_12_13.cpp modified: ../ch11/ex11_20.cpp modified: ../ch11/ex11_27_28_29_30.cpp modified: ../ch11/ex11_31.cpp modified: ../ch11/ex11_32.cpp modified: ../ch11/ex11_8.cpp modified: ../ch12/README.md modified: ../ch12/ex12_02_TEST.cpp modified: ../ch12/ex12_06.cpp modified: ../ch12/ex12_15.cpp modified: ../ch12/ex12_17_18.cpp modified: ../ch12/ex12_19.h modified: ../ch12/ex12_22.h modified: ../ch12/ex12_23.cpp modified: ../ch12/ex12_24.cpp modified: ../ch12/ex12_27_30.cpp modified: ../ch12/ex12_27_30.h modified: ../ch12/ex12_28.cpp modified: ../ch12/ex12_32.cpp modified: ../ch12/ex12_32.h modified: ../ch12/ex12_33.cpp modified: ../ch12/ex12_33.h modified: ../ch13/README.md modified: ../ch13/ex13_13.cpp modified: ../ch13/ex13_26.h modified: ../ch13/ex13_28.h modified: ../ch13/ex13_34_36_37.h modified: ../ch13/ex13_39.h modified: ../ch13/ex13_40.h modified: ../ch13/ex13_42_StrVec.h modified: ../ch13/ex13_42_TextQuery.h modified: ../ch13/ex13_44_47.h modified: ../ch13/ex13_49_Message.h modified: ../ch13/ex13_49_StrVec.h modified: ../ch13/ex13_49_String.h modified: ../ch14/ex14_02.h modified: ../ch14/ex14_07.h modified: ../ch14/ex14_16_StrBlob.h modified: ../ch14/ex14_16_StrVec.h modified: ../ch14/ex14_16_String.h modified: ../ch14/ex14_18_StrBlob.h modified: ../ch14/ex14_18_StrVec.h modified: ../ch14/ex14_18_StrVecMain.cpp modified: ../ch14/ex14_18_String.h modified: ../ch14/ex14_22.h modified: ../ch14/ex14_23.h modified: ../ch14/ex14_24.cpp modified: ../ch14/ex14_24.h modified: ../ch14/ex14_26_StrBlob.h modified: ../ch14/ex14_26_StrVec.h modified: ../ch14/ex14_26_String.h modified: ../ch14/ex14_27_28_StrBlob.h modified: ../ch14/ex14_30_StrBlob.h modified: ../ch14/ex14_32.cpp modified: ../ch14/ex14_32.h modified: ../ch14/ex14_37.cpp modified: ../ch14/ex14_38_39.cpp modified: ../ch14/ex14_40.cpp modified: ../ch14/ex14_42.cpp modified: ../ch14/ex14_44.cpp modified: ../ch14/ex14_45.h modified: ../ch14/ex14_49.cpp modified: ../ch14/ex14_49.h modified: ../ch15/ex15.23.cpp modified: ../ch15/ex15.26/bulk_quote.h modified: ../ch15/ex15.27/bulk_quote.h modified: ../ch15/ex15.28.29/bulk_quote.h modified: ../ch15/ex15.30/basket.h modified: ../ch15/ex15.30/bulk_quote.h modified: ../ch15/ex15.30/quote.h modified: ../ch15/ex15.31.32.33.cpp modified: ../ch15/ex15.42_b/andquery.h modified: ../ch15/ex15.42_b/binaryquery.h modified: ../ch15/ex15.42_b/notquery.h modified: ../ch15/ex15.42_b/orquery.h modified: ../ch15/ex15.42_b/query.h modified: ../ch15/ex15.42_b/queryresult.h modified: ../ch15/ex15.42_b/wordquery.h modified: ../ch15/ex15.42_c/andquery.h modified: ../ch15/ex15.42_c/binaryquery.h modified: ../ch15/ex15.42_c/notquery.h modified: ../ch15/ex15.42_c/orquery.h modified: ../ch15/ex15.42_c/query.h modified: ../ch15/ex15.42_c/queryresult.h modified: ../ch15/ex15.42_c/wordquery.h modified: ../ch16/ex16.1.2.3/main.cpp modified: ../ch16/ex16.12.13/Blob.h modified: ../ch16/ex16.16/main.cpp modified: ../ch16/ex16.16/vec.h modified: ../ch16/ex16.24/Blob.h modified: ../ch16/ex16.24/main.cpp modified: ../ch16/ex16.28/shared_pointer.hpp modified: ../ch16/ex16.28/unique_pointer.h modified: ../ch16/ex16.29/Blob.h modified: ../ch16/ex16.29/shared_pointer.h modified: ../ch16/ex16.29/unique_pointer.h modified: ../ch16/ex16.40/main.cpp modified: ../ch16/ex16.58.59/strvec.h modified: ../ch16/ex16.58.59/vec.h modified: ../ch16/ex16.6/main.cpp modified: ../ch16/ex16.60.61/main.cpp modified: ../ch16/ex16.7.8/main.cpp modified: ../ch17/ex17_10.cpp modified: ../ch17/ex17_11_12_13.cpp modified: ../ch17/ex17_19_20.cpp modified: ../ch17/ex17_21.cpp modified: ../ch17/ex17_23.cpp modified: ../ch17/ex17_33.cpp modified: ../ch17/ex17_4_5_6_7_8.cpp modified: ../ch17/ex17_4_5_6_7_8_SalesData.h modified: ../ch18/ex18.1.2.3.cpp
1 parent cd1940c commit 48aec46

File tree

145 files changed

+296
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+296
-281
lines changed

.tools/format.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,30 @@ def for_commas
2020
end
2121
end
2222
end
23-
23+
24+
def for_curly_brackets
25+
count = 0
26+
each_line do |line|
27+
begin
28+
if line.match /{.*}/
29+
puts (count += 1).to_s; puts line
30+
line.gsub! /{(\S)/, '{ \1'
31+
line.gsub! /(\S)}/, '\1 }'
32+
end
33+
rescue Exception => e
34+
puts e.message + ", ignored."
35+
end
36+
end
37+
end
38+
2439
private
2540
def each_line
2641
@handlers.each do |h|
2742
h.on_each_line { |line| yield line }
28-
end
43+
end
2944
end
3045
end
3146

3247
format = Format.new ARGV[0], [ "cpp", "h", "hpp", "md" ]
3348
format.for_commas
34-
49+
format.for_curly_brackets

ch03/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This code was dereferencing and printing the first item stored in `s`. Since `s`
3939
>Is the following range for legal? If so, what is the type of c?
4040
```cpp
4141
const string s = "Keep out!";
42-
for (auto &c : s){/*... */}
42+
for (auto &c : s){ /*... */ }
4343
```
4444
4545
Depending on the code within for loop body. For example:
@@ -66,10 +66,10 @@ vectors? What are the values of the elements?
6666
vector<int> v1; // size:0, no values.
6767
vector<int> v2(10); // size:10, value:0
6868
vector<int> v3(10, 42); // size:10, value:42
69-
vector<int> v4{10}; // size:1, value:10
70-
vector<int> v5{10, 42}; // size:2, value:10, 42
71-
vector<string> v6{10}; // size:10, value:""
72-
vector<string> v7{10, "hi"}; // size:10, value:"hi"
69+
vector<int> v4{ 10 }; // size:1, value:10
70+
vector<int> v5{ 10, 42 }; // size:2, value:10, 42
71+
vector<string> v6{ 10 }; // size:10, value:""
72+
vector<string> v7{ 10, "hi" }; // size:10, value:"hi"
7373
```
7474
7575
##[Exercise 3.14](ex3_14.cpp)
@@ -161,7 +161,7 @@ p1 += p2 - p1;
161161
##Exercise 3.37
162162
>What does the following program do?
163163
```cpp
164-
const char ca[] = {'h', 'e', 'l', 'l', 'o'};
164+
const char ca[] = { 'h', 'e', 'l', 'l', 'o' };
165165
const char *cp = ca;
166166
while (*cp) {
167167
cout << *cp << endl;

ch04/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ reference: [Usage of the Built-in Comma Operator](http://stackoverflow.com/quest
294294
>Explain the following loop.
295295
```cpp
296296
constexpr int size = 5;
297-
int ia[size] = {1, 2, 3, 4, 5};
297+
int ia[size] = { 1, 2, 3, 4, 5 };
298298
for (int *ptr = ia, ix = 0;
299299
ix != size && ptr != ia+size;
300300
++ix, ++ptr) { /* ... */ }

ch05/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ while (iter != s.end()) { /* . . . */ }
6161
```cpp
6262
//corrrected as:
6363
bool status;
64-
while ((status = find(word))) {/* ... */}
65-
if (!status) {/* ... */}
64+
while ((status = find(word))) { /* ... */ }
65+
if (!status) { /* ... */ }
6666
```
6767

6868
##[Exercise 5.5](ex5_5.cpp)

ch05/ex5_14.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main()
1111
{
1212
if (str == prestr) ++count;
1313
else count = 0;
14-
if (count > max_duplicated.second) max_duplicated = {prestr, count};
14+
if (count > max_duplicated.second) max_duplicated = { prestr, count };
1515
}
1616

1717
if (max_duplicated.first.empty()) cout << "There's no duplicated string." << endl;

ch05/ex5_17.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ using std::cout; using std::endl; using std::vector;
55

66
int main()
77
{
8-
vector<int> vec1{0, 1, 1, 2};
9-
vector<int> vec2{0, 1, 1, 2, 3, 5, 8};
8+
vector<int> vec1{ 0, 1, 1, 2 };
9+
vector<int> vec2{ 0, 1, 1, 2, 3, 5, 8 };
1010

1111
auto size = vec1.size() < vec2.size() ? vec1.size() : vec2.size();
1212
for (decltype(vec1.size()) i = 0; i != size; ++i) {

ch06/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int divide(int a, int b) { return b != 0 ? a / b : 0; }
410410
411411
## Exercise 6.56
412412
```cpp
413-
std::vector<decltype(func) *> vec{add, subtract, multiply, divide};
413+
std::vector<decltype(func) *> vec{ add, subtract, multiply, divide };
414414
for (auto f : vec)
415415
std::cout << f(2, 2) << std::endl;
416416
```

ch06/ex6_23.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void print(int (&arr)[2])
3535

3636
int main()
3737
{
38-
int i = 0, j[2] = {0, 1};
38+
int i = 0, j[2] = { 0, 1 };
3939
char ch[5] = "pezy";
4040

4141
print(ch);

ch07/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ the condition of the `if` statement would read two Sales_data object at one time
3131
## [Exercise 7.13](ex7_13.cpp)
3232
## Exercise 7.14
3333
```cpp
34-
Sales_data() : units_sold(0) , revenue(0){}
34+
Sales_data() : units_sold(0) , revenue(0){ }
3535
```
3636
3737
## [Exercise 7.15](ex7_15.h)
@@ -122,7 +122,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXX
122122
- less scope for misreading
123123
- can use the member function parameter which name is same as the member name.
124124

125-
void setAddr(const std::string &addr) {this->addr = addr;}
125+
void setAddr(const std::string &addr) { this->addr = addr; }
126126

127127
**Cons**
128128

ch07/ex7_11.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
struct Sales_data {
1515
Sales_data() = default;
16-
Sales_data(const std::string &s):bookNo(s) {}
17-
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
16+
Sales_data(const std::string &s):bookNo(s) { }
17+
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
1818
Sales_data(std::istream &is);
1919

2020
std::string isbn() const { return bookNo; };

0 commit comments

Comments
 (0)