Skip to content

Commit b3b76ca

Browse files
Tyler WhitneyTyler Whitney
authored andcommitted
acrolinx fixes
1 parent 0320164 commit b3b76ca

4 files changed

Lines changed: 42 additions & 42 deletions

File tree

docs/c-runtime-library/reference/strtok-strtok-l-wcstok-wcstok-l-mbstok-mbstok-l.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Set of delimiter characters.
6565
Locale to use.
6666

6767
*context*<br/>
68-
Points to memory used to store the internal state of the parser so that the parser can continue from where it left off during subsequent calls.
68+
Points to memory used to store the internal state of the parser so that the parser can continue from where it left off the next time you call **wcstok**.
6969

7070
## Return Value
7171

docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,29 @@ For more information, see [Format Specifications](../../c-runtime-library/format
108108

109109
## Return Value
110110

111-
The **vsnprintf** function returns the number of characters written, not counting the terminating null character. If the buffer size specified by *count* is not sufficiently large to contain the output specified by *format* and *argptr*, the return value of **vsnprintf** is the number of characters that would be written, not counting the null character, if *count* were sufficiently large. If the return value is greater than *count* - 1, the output has been truncated. A return value of -1 indicates that an encoding error has occurred.
111+
The **vsnprintf** function returns the number of characters that are written, not counting the terminating null character. If the buffer size specified by *count* isn't sufficiently large to contain the output specified by *format* and *argptr*, the return value of **vsnprintf** is the number of characters that would be written, not counting the null character, if *count* were sufficiently large. If the return value is greater than *count* - 1, the output has been truncated. A return value of -1 indicates that an encoding error has occurred.
112112

113-
Both **_vsnprintf** and **_vsnwprintf** functions return the number of characters written if the number of characters to write is less than or equal to *count*; if the number of characters to write is greater than *count*, these functions return -1 indicating that output has been truncated.
113+
Both **_vsnprintf** and **_vsnwprintf** functions return the number of characters written if the number of characters to write is less than or equal to *count*. If the number of characters to write is greater than *count*, these functions return -1 indicating that output has been truncated.
114114

115-
The value returned by all these functions does not include the terminating null, whether one is written or not.
115+
The value returned by all these functions doesn't include the terminating null, whether one is written or not.
116116

117-
- If *count* is zero and *buffer* is **NULL**, the value returned is the number of characters the functions would write, not including any terminating null. You can use this result to allocate sufficient buffer space for the string and its terminating null, and then call the function again to fill the buffer.
118-
- If *count* is zero but *buffer* is not **NULL**, nothing is written and the function returns `-1`.
119-
- If *format* is **NULL**, or if *buffer* is **NULL** and *count* is not equal to zero, these functions invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1 and set **errno** to **EINVAL**.
117+
- If *count* is zero and *buffer* is **NULL**, the value returned is the number of characters the functions would write. The value does not take into account a terminating **NULL**. You can use this result to allocate sufficient buffer space for the string and its terminating null, and then call the function again to fill the buffer.
118+
- If *count* is zero but *buffer* isn't **NULL**, nothing is written and the function returns `-1`.
119+
- If *format* is **NULL**, or if *buffer* is **NULL** and *count* isn't equal to zero, these functions invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1 and set **errno** to **EINVAL**.
120120

121121
## Remarks
122122

123-
Each of these functions takes a pointer to an argument list, then formats the data, and writes up to *count* characters to the memory pointed to by *buffer*. The **vsnprintf** function always writes a null terminator, even if it truncates the output. When using **_vsnprintf** and **_vsnwprintf**, the buffer will be null-terminated only if there is room at the end (that is, if the number of characters to write is less than *count*).
123+
Each of these functions takes a pointer to an argument list, then formats the data, and writes up to *count* characters to the memory pointed to by *buffer*. The **vsnprintf** function always writes a null terminator, even if it truncates the output. When using **_vsnprintf** and **_vsnwprintf**, the buffer will be null-terminated only if there's room at the end (that is, if the number of characters to write is less than *count*).
124124

125125
> [!IMPORTANT]
126-
> To prevent certain kinds of security risks, ensure that *format* is not a user-defined string. For more information, see [Avoiding Buffer Overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
126+
> To prevent certain kinds of security risks, ensure that *format* isn't a user-defined string. For more information, see [Avoiding Buffer Overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
127127
128128
> [!NOTE]
129-
> To ensure that there is room for the terminating null when calling **_vsnprintf**, **_vsnprintf_l**, **_vsnwprintf** and **_vsnwprintf_l**, be sure that *count* is strictly less than the buffer length and initialize the buffer to null prior to calling the function.
129+
> To ensure that there's room for the terminating null when calling **_vsnprintf**, **_vsnprintf_l**, **_vsnwprintf** and **_vsnwprintf_l**, be sure that *count* is strictly less than the buffer length and initialize the buffer to null prior to calling the function.
130130
>
131131
> Because **vsnprintf** always writes the terminating null, the *count* parameter may be equal to the size of the buffer.
132132
133-
Beginning with the UCRT in Visual Studio 2015 and Windows 10, **vsnprintf** is no longer identical to **_vsnprintf**. The **vsnprintf** function complies with the C99 standard; **_vnsprintf** is retained for backward compatibility with older Visual Studio code.
133+
Beginning with the UCRT in Visual Studio 2015 and Windows 10, **vsnprintf** is no longer identical to **_vsnprintf**. The **vsnprintf** function complies with the C99 standard; **_vnsprintf** is kept for backward compatibility with older Visual Studio code.
134134

135135
The versions of these functions with the **_l** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
136136

docs/mfc/reference/cmultidoctemplate-class.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ An MDI application can support more than one type of document, and documents of
4141

4242
The application uses the document template(s) when the user creates a new document. If the application supports more than one type of document, then the framework gets the names of the supported document types from the document templates and displays them in a list in the File New dialog box. Once the user has selected a document type, the application creates a document class object, a frame window object, and a view object and attaches them to each other.
4343

44-
You do not need to call any member functions of `CMultiDocTemplate` except the constructor. The framework handles `CMultiDocTemplate` objects internally.
44+
You don't need to call any member functions of `CMultiDocTemplate` except the constructor. The framework handles `CMultiDocTemplate` objects internally.
4545

4646
For more information on `CMultiDocTemplate`, see [Document Templates and the Document/View Creation Process](../../mfc/document-templates-and-the-document-view-creation-process.md).
4747

@@ -76,7 +76,7 @@ CMultiDocTemplate(
7676
*nIDResource*<br/>
7777
Specifies the ID of the resources used with the document type. This may include menu, icon, accelerator table, and string resources.
7878

79-
The string resource consists of up to seven substrings separated by the '\n' character (the '\n' character is needed as a place holder if a substring is not included; however, trailing '\n' characters are not necessary); these substrings describe the document type. For information on the substrings, see [CDocTemplate::GetDocString](../../mfc/reference/cdoctemplate-class.md#getdocstring). This string resource is found in the application's resource file. For example:
79+
The string resource consists of up to seven substrings separated by the '\n' character (the '\n' character is needed as a place holder if a substring isn't included; however, trailing '\n' characters aren't necessary); these substrings describe the document type. For information on the substrings, see [CDocTemplate::GetDocString](../../mfc/reference/cdoctemplate-class.md#getdocstring). This string resource is found in the application's resource file. For example:
8080

8181
```RC
8282
// MYCALC.RC
@@ -86,7 +86,7 @@ BEGIN
8686
END
8787
```
8888

89-
Note that the string begins with a '\n' character; this is because the first substring is not used for MDI applications and so is not included. You can edit this string using the string editor; the entire string appears as a single entry in the String Editor, not as seven separate entries.
89+
The string begins with a '\n' character because the first substring isn't used for MDI applications and so isn't included. You can edit this string using the string editor; the entire string appears as a single entry in the String Editor, not as seven separate entries.
9090

9191
For more information about these resource types, see [Resource Editors](../../windows/resource-editors.md).
9292

docs/safeint/safeint-class.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,26 @@ The `SafeInt` class protects against integer overflow in mathematical operations
157157

158158
The `SafeInt` class checks whether an arithmetic overflow occurs or whether the code tries to divide by zero. In both cases, the class calls the error handler to warn the program of the potential problem.
159159

160-
This class also lets you compare two different types of integers as long as they are `SafeInt` objects. Typically, when you perform a comparison, you must first convert the numbers to be the same type. Casting one number to another type often requires checks to make sure that there is no loss of data.
160+
This class also lets you compare two different types of integers as long as they are `SafeInt` objects. Typically, when you do a comparison, you must first convert the numbers to be the same type. Casting one number to another type often requires checks to make sure that there is no loss of data.
161161

162162
The Operators table in this topic lists the mathematical and comparison operators supported by the `SafeInt` class. Most mathematical operators return a `SafeInt` object of type `T`.
163163

164164
Comparison operations between a `SafeInt` and an integral type can be performed in either direction. For example, both `SafeInt<int>(x) < y` and `y> SafeInt<int>(x)` are valid and will return the same result.
165165

166-
Many binary operators do not support using two different `SafeInt` types. One example of this is the `&` operator. `SafeInt<T, E> & int` is supported, but `SafeInt<T, E> & SafeInt<U, E>` is not. In the latter example, the compiler does not know what type of parameter to return. One solution to this problem is to cast the second parameter back to the base type. By using the same parameters, this can be done with `SafeInt<T, E> & (U)SafeInt<U, E>`.
166+
Many binary operators don't support using two different `SafeInt` types. One example of this is the `&` operator. `SafeInt<T, E> & int` is supported, but `SafeInt<T, E> & SafeInt<U, E>` isn't. In the latter example, the compiler does not know what type of parameter to return. One solution to this problem is to cast the second parameter back to the base type. By using the same parameters, this can be done with `SafeInt<T, E> & (U)SafeInt<U, E>`.
167167

168168
> [!NOTE]
169-
> For any bitwise operations, the two different parameters should be the same size. If the sizes differ, the compiler will throw an [ASSERT](../mfc/reference/diagnostic-services.md#assert) exception. The results of this operation cannot be guaranteed to be accurate. To resolve this issue, cast the smaller parameter until it is the same size as the larger parameter.
169+
> For any bitwise operations, the two different parameters should be the same size. If the sizes differ, the compiler will throw an [ASSERT](../mfc/reference/diagnostic-services.md#assert) exception. The results of this operation can't be guaranteed to be accurate. To resolve this issue, cast the smaller parameter until it's the same size as the larger parameter.
170170
171171
For the shift operators, shifting more bits than exist for the template type will throw an ASSERT exception. This will have no effect in release mode. Mixing two types of SafeInt parameters is possible for the shift operators because the return type is the same as the original type. The number on the right side of the operator only indicates the number of bits to shift.
172172

173-
When you perform a logical comparison with a SafeInt object, the comparison is strictly arithmetic. For example, consider these expressions:
173+
When you do a logical comparison with a SafeInt object, the comparison is strictly arithmetic. For example, consider these expressions:
174174

175175
- `SafeInt<uint>((uint)~0) > -1`
176176

177177
- `((uint)~0) > -1`
178178

179-
The first statement resolves to **true**, but the second statement resolves to `false`. The bitwise negation of 0 is 0xFFFFFFFF. In the second statement, the default comparison operator compares 0xFFFFFFFF to 0xFFFFFFFF and considers them to be equal. The comparison operator for the `SafeInt` class realizes that the second parameter is negative whereas the first parameter is unsigned. Therefore, although the bit representation is identical, the `SafeInt` logical operator realizes that the unsigned integer is larger than -1.
179+
The first statement resolves to **true**, but the second statement resolves to `false`. The bitwise negation of 0 is 0xFFFFFFFF. In the second statement, the default comparison operator compares 0xFFFFFFFF to 0xFFFFFFFF and considers them to be equal. The comparison operator for the `SafeInt` class realizes that the second parameter is negative but the first parameter is unsigned. So, although the bit representation is identical, the `SafeInt` logical operator realizes that the unsigned integer is larger than -1.
180180

181181
Be careful when you use the `SafeInt` class together with the `?:` ternary operator. Consider the following line of code.
182182

@@ -206,7 +206,7 @@ Int x = flag ? (int) SafeInt<unsigned int>(y) : -1;
206206
There are two options to customize the error policy. The first option is to set the parameter `E` when you create a `SafeInt`. Use this option when you want to change the error handling policy for just one `SafeInt`. The other option is to define _SAFEINT_DEFAULT_ERROR_POLICY to be your customized error-handling class before you include the `SafeInt` library. Use this option when you want to change the default error handling policy for all instances of the `SafeInt` class in your code.
207207

208208
> [!NOTE]
209-
> A customized class that handles errors from the SafeInt library should not return control to the code that called the error handler. After the error handler is called, the result of the `SafeInt` operation cannot be trusted.
209+
> A customized class that handles errors from the SafeInt library should not return control to the code that called the error handler. After the error handler is called, the result of the `SafeInt` operation can't be trusted.
210210
211211
## Inheritance Hierarchy
212212

@@ -217,9 +217,25 @@ There are two options to customize the error policy. The first option is to set
217217
**Header:** SafeInt.hpp
218218
> [!NOTE]
219219
> The latest version of this library is located at [https://github.com/dcleblanc/SafeInt](https://github.com/dcleblanc/SafeInt). Clone the library and include SafeInt.hpp to use the SafeInt library.
220-
> Prefer this github repo to <safeint.h>. It is a modern version of <safeint.h> that includes a small number of bug fixes, uses modern features of C++ resulting in more efficient code, and is portable to any platform using gcc, clang, or Intel compilers.
220+
> Prefer this github repo to <safeint.h>. it's a modern version of <safeint.h> that includes a small number of bug fixes, uses modern features of C++ resulting in more efficient code, and is portable to any platform using gcc, clang, or Intel compilers.
221221
222-
**Namespace:** msl::utilities
222+
### Example
223+
224+
```c
225+
#include "SafeInt.hpp" // set path to your clone of the SafeInt GitHub repo (https://github.com/dcleblanc/SafeInt)
226+
227+
int main()
228+
{
229+
int divisor = 3;
230+
int dividend = 6;
231+
int result;
232+
233+
bool success = SafeDivide(dividend, divisor, result); // result = 2
234+
success = SafeDivide(dividend, 0, result); // expect fail. result isn't modified.
235+
}
236+
```
237+
238+
**Namespace:** none
223239

224240
## <a name="safeint"></a> SafeInt::SafeInt
225241

@@ -251,28 +267,12 @@ SafeInt (const U& i)
251267
[in] A `SafeInt` of type U. The new `SafeInt` object will have the same value as *u*, but will be of type T.
252268
253269
`U`
254-
The type of data stored in the `SafeInt`. This can be either a Boolean, character, or integer type. If it is an integer type, it can be signed or unsigned and be between 8 and 64 bits.
255-
256-
### Example
257-
258-
```c
259-
#include "SafeInt.hpp" // set path to your clone of the SafeInt GitHub repo (https://github.com/dcleblanc/SafeInt)
260-
261-
int main()
262-
{
263-
int divisor = 3;
264-
int dividend = 6;
265-
int result;
266-
267-
bool success = SafeDivide(dividend, divisor, result); // result = 2
268-
success = SafeDivide(dividend, 0, result); // expect fail. result is not modified.
269-
}
270-
```
270+
The type of data stored in the `SafeInt`. This can be either a Boolean, character, or integer type. If it's an integer type, it can be signed or unsigned and be between 8 and 64 bits.
271271
272272
### Remarks
273273
274-
The input parameter for the constructor, *i* or *u*, must be a Boolean, character, or integer type. If it is another type of parameter, the `SafeInt` class calls [static_assert](../cpp/static-assert.md) to indicate an invalid input parameter.
274+
The input parameter for the constructor, *i* or *u*, must be a Boolean, character, or integer type. If it's another type of parameter, the `SafeInt` class calls [static_assert](../cpp/static-assert.md) to indicate an invalid input parameter.
275275
276-
The constructors that use the template type `U` automatically convert the input parameter to the type specified by `T`. The `SafeInt` class converts the data without any loss of data. It reports to the error handler `E` if it cannot convert the data to type `T` without data loss.
276+
The constructors that use the template type `U` automatically convert the input parameter to the type specified by `T`. The `SafeInt` class converts the data without any loss of data. It reports to the error handler `E` if it can't convert the data to type `T` without data loss.
277277
278-
If you create a `SafeInt` from a Boolean parameter, you need to initialize the value immediately. You cannot construct a `SafeInt` using the code `SafeInt<bool> sb;`. This will generate a compile error.
278+
If you create a `SafeInt` from a Boolean parameter, you need to initialize the value immediately. You can't construct a `SafeInt` using the code `SafeInt<bool> sb;`. This will generate a compile error.

0 commit comments

Comments
 (0)