Skip to content

Commit 4b1e83c

Browse files
authored
Merge pull request #2108 from luismarques/patch-1
Minor fixes for ctod.dd merged-on-behalf-of: H. S. Teoh <quickfur@users.noreply.github.com>
2 parents d6bbf61 + b6b0a93 commit 4b1e83c

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ctod.dd

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ $(P
244244
$(CCODE
245245
#define ARRAY_LENGTH 17
246246
int array[ARRAY_LENGTH];
247-
for (i = 0; i &lt; ARRAY_LENGTH; i++)
247+
for (size_t i = 0; i &lt; ARRAY_LENGTH; i++)
248248
func(array[i]);
249249
)
250250

251251
or:
252252

253253
$(CCODE
254254
int array[17];
255-
for (i = 0; i &lt; sizeof(array) / sizeof(array[0]); i++)
255+
for (size_t i = 0; i &lt; sizeof(array) / sizeof(array[0]); i++)
256256
func(array[i]);
257257
)
258258

@@ -666,11 +666,11 @@ struct ABC
666666
align (1) int x; // x is byte aligned
667667
align (4)
668668
{
669-
... // declarations in {} are dword aligned
669+
... // declarations in {} are 32-bit aligned
670670
}
671-
align (2): // switch to word alignment from here on
671+
align (2): // switch to 16-bit alignment from here on
672672

673-
int y; // y is word aligned
673+
int y; // y is 16-bit aligned
674674
}
675675
----------------------------
676676

@@ -856,7 +856,7 @@ $(H2 $(LNAME2 arrayinit2, Array Initializations))
856856

857857
$(H4 The C Way)
858858

859-
C initializes array by positional dependence. C99 fixes the issue:
859+
C initializes arrays by positional dependence. C99 fixes the issue:
860860
$(CCODE
861861
int a[3] = { 3,2,1 };
862862
int a[3] = { [2]=1, [0]=3, [1]=2 }; /* C99 designated initializer */
@@ -889,7 +889,8 @@ enum color { black, red, green }
889889
int[3] c = [ black:3, green:2, red:5 ];
890890
----------------------------
891891

892-
Nested array initializations must be explicit:
892+
Nested array initializations must be explicit and consistent with the
893+
array types:
893894

894895
----------------------------
895896
int[2][3] b = [ [2,3], [6,5], [3,4] ];
@@ -902,7 +903,8 @@ $(H2 $(LNAME2 stringlit, Escaped String Literals))
902903

903904
$(H4 The C Way)
904905

905-
C has problems with the DOS file system because a \ is an escape in a string. To specifiy file c:\root\file.c:
906+
C has problems with the DOS file system because a \ is an escape in a string.
907+
To specifiy the file c:\root\file.c you would use:
906908
$(CCODE
907909
char file[] = "c:\\root\\file.c";
908910
)
@@ -918,7 +920,7 @@ char quoteString[] = "\"[^\\\\]*(\\\\.[^\\\\]*)*\"";
918920
$(H4 The D Way)
919921

920922
D has both C-style string literals which can use escaping,
921-
and WYSIWYG (what you see is what you get) raw strings
923+
and WYSIWYG (what you see is what you get) raw strings,
922924
usable with the `$(BACKTICK)foo$(BACKTICK)` and `r"bar"` syntax:
923925

924926
----------------------------
@@ -951,15 +953,15 @@ $(CCODE
951953
#include &lt;tchar.h&gt;
952954
tchar string[] = TEXT("hello");
953955
)
954-
Furthermore, in praxis `wchar_t` is not usable in portable code as its size
956+
Furthermore, in practice `wchar_t` is not usable in portable code as its size
955957
is implementation dependent. On POSIX conforming machines it generally
956-
represents an UTF-32 codeunit, on Windows an UTF-16 codeunit. C11 introduced
958+
represents an UTF-32 codeunit, on Windows an UTF-16 code unit. C11 introduced
957959
C++11 types char16_t and char32_t to overcome this issue.
958960

959961
$(H4 The D Way)
960962

961963
The type of a string is determined by semantic analysis, so there is no need
962-
to wrap strings in a macro call. Alternatively if type inference is used the
964+
to wrap strings in a macro call. Alternatively, if type inference is used, the
963965
string can have a `c`, `w` or `d` suffix, representing UTF-8,
964966
UTF-16 and UTF-32 encoding, respectively. If no suffix is used the type is
965967
inferred to be a UTF-8 string:
@@ -1098,7 +1100,7 @@ if (h != Handle.init)
10981100
...
10991101
-----------------------------
11001102

1101-
There's only one name to remember: $(D Handle).
1103+
Now there's only one name to remember: $(D Handle).
11021104

11031105
<hr>$(COMMENT ============================================ )
11041106
$(H2 $(LNAME2 structcmp, Comparing structs))

0 commit comments

Comments
 (0)