https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2b3fd31bc55ddb2185a64…
commit 2b3fd31bc55ddb2185a64c33bf2dd8b753de44e2
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat May 5 01:36:19 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat May 5 01:37:30 2018 +0200
[CONUTILS] Use the currently active console codepage to output text to files. If you want to output UTF-8 run "chcp 65001" before.
CORE-12122
---
sdk/lib/conutils/outstream.c | 34 +++++++++++++++++++---------------
sdk/lib/conutils/stream.c | 20 +++++++++-----------
sdk/lib/conutils/stream.h | 14 ++++----------
sdk/lib/conutils/stream_private.h | 2 +-
4 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/sdk/lib/conutils/outstream.c b/sdk/lib/conutils/outstream.c
index a36a5ddaa2..645452f3ef 100644
--- a/sdk/lib/conutils/outstream.c
+++ b/sdk/lib/conutils/outstream.c
@@ -103,7 +103,7 @@ ConWrite(
// if (IsConsoleHandle(Stream->hHandle))
if (Stream->IsConsole)
{
- // TODO: Check if (ConStream->Mode == WideText or UTF16Text) ??
+ // TODO: Check if (Stream->Mode == WideText or UTF16Text) ??
/*
* This code is inspired from _cputws, in particular from the fact that,
@@ -136,15 +136,15 @@ ConWrite(
*
* Implementation NOTE:
* MultiByteToWideChar (resp. WideCharToMultiByte) are equivalent to
- * OemToCharBuffW (resp. CharToOemBuffW), but the latters uselessly
- * depend on user32.dll, while MultiByteToWideChar and WideCharToMultiByte
- * only need kernel32.dll.
+ * OemToCharBuffW (resp. CharToOemBuffW), but these latter functions
+ * uselessly depend on user32.dll, while MultiByteToWideChar and
+ * WideCharToMultiByte only need kernel32.dll.
*/
if ((Stream->Mode == WideText) || (Stream->Mode == UTF16Text))
{
#ifndef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
- /* Convert from the current process/thread's codepage to UTF-16 */
- WCHAR *buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
+ /* Convert from the current process/thread's code page to UTF-16 */
+ PWCHAR buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
if (!buffer)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -200,18 +200,22 @@ ConWrite(
}
else if ((Stream->Mode == UTF8Text) || (Stream->Mode == AnsiText))
{
- CHAR *buffer;
+ UINT CodePage;
+ PCHAR buffer;
/*
- * Resolve the codepage cache if it was not assigned yet
- * (only if the stream is in ANSI mode; in UTF8 mode the
- * codepage was already set to CP_UTF8).
+ * Resolve the current code page if it has not been assigned yet
+ * (we do this only if the stream is in ANSI mode; in UTF8 mode
+ * the code page is always set to CP_UTF8). Otherwise use the
+ * current stream's code page.
*/
if (/*(Stream->Mode == AnsiText) &&*/ (Stream->CodePage == INVALID_CP))
- Stream->CodePage = GetConsoleOutputCP(); // CP_ACP, CP_OEMCP
+ CodePage = GetConsoleOutputCP(); // CP_ACP, CP_OEMCP
+ else
+ CodePage = Stream->CodePage;
#ifdef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
- /* Convert from UTF-16 to either UTF-8 or ANSI, using stream codepage */
+ /* Convert from UTF-16 to either UTF-8 or ANSI, using the stream code page */
// NOTE: MB_LEN_MAX defined either in limits.h or in stdlib.h .
buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * MB_LEN_MAX);
if (!buffer)
@@ -219,14 +223,14 @@ ConWrite(
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
- len = WideCharToMultiByte(Stream->CodePage, 0,
+ len = WideCharToMultiByte(CodePage, 0,
szStr, len, buffer, len * MB_LEN_MAX,
NULL, NULL);
szStr = (PVOID)buffer;
#else
/*
- * Convert from the current process/thread's codepage to either
- * UTF-8 or ANSI, using stream codepage.
+ * Convert from the current process/thread's code page to either
+ * UTF-8 or ANSI, using the stream code page.
* We need to perform a double conversion, by going through UTF-16.
*/
// TODO!
diff --git a/sdk/lib/conutils/stream.c b/sdk/lib/conutils/stream.c
index 0b137ea2f7..7246453df4 100644
--- a/sdk/lib/conutils/stream.c
+++ b/sdk/lib/conutils/stream.c
@@ -73,9 +73,6 @@ static int ConToCRTMode[] =
_O_U16TEXT, // UTF16Text (UTF16 without BOM; translated)
_O_U8TEXT, // UTF8Text (UTF8 without BOM; translated)
};
-#endif
-
-#ifdef USE_CRT
/*
* See http://archives.miloush.net/michkap/archive/2008/03/18/8306597.html
@@ -83,7 +80,7 @@ static int ConToCRTMode[] =
* for more details.
*/
-// NOTE: May the translated mode be cached somehow?
+// NOTE1: May the translated mode be cached somehow?
// NOTE2: We may also call IsConsoleHandle to directly set the mode to
// _O_U16TEXT if it's ok??
// NOTE3: _setmode returns the previous mode, or -1 if failure.
@@ -99,16 +96,17 @@ do { \
#else /* defined(USE_CRT) */
/*
- * We set Stream->CodePage to INVALID_CP (= -1) to signal that the codepage
+ * We set Stream->CodePage to INVALID_CP (== -1) to signal that the code page
* is either not assigned (if the mode is Binary, WideText, or UTF16Text), or
- * is not cached yet (if the mode is AnsiText). In this latter case the cache
- * is resolved inside ConWrite. Finally, if the mode is UTF8Text, the codepage
- * cache is set to CP_UTF8.
- * The codepage cache can be reset by an explicit call to CON_STREAM_SET_MODE
+ * is not cached (if the mode is AnsiText). In this latter case the code page
+ * is resolved inside ConWrite. Finally, if the mode is UTF8Text, the code page
+ * cache is always set to CP_UTF8.
+ * The code page cache can be reset by an explicit call to CON_STREAM_SET_MODE
* (i.e. by calling ConStreamSetMode, or by reinitializing the stream with
* ConStreamInit(Ex)).
*
- * NOTE: the magic value could not be '0' since it is reserved for CP_ACP.
+ * NOTE: the reserved values are: 0 (CP_ACP), 1 (CP_OEMCP), 2 (CP_MACCP),
+ * 3 (CP_THREAD_ACP), 42 (CP_SYMBOL), 65000 (CP_UTF7) and 65001 (CP_UTF8).
*/
#define CON_STREAM_SET_MODE(Stream, Mode, CacheCodePage) \
do { \
@@ -229,7 +227,7 @@ ConStreamSetCacheCodePage(
return FALSE;
/*
- * Keep the original stream mode but set the correct file codepage
+ * Keep the original stream mode but set the correct file code page
* (will be reset only if Mode == AnsiText).
*/
Mode = Stream->Mode;
diff --git a/sdk/lib/conutils/stream.h b/sdk/lib/conutils/stream.h
index 8a2746af5c..031ae56d30 100644
--- a/sdk/lib/conutils/stream.h
+++ b/sdk/lib/conutils/stream.h
@@ -113,20 +113,14 @@ do { \
} while(0)
#endif /* defined(USE_CRT) */
-#ifdef _UNICODE
/*
- * Use UTF8 by default for file output, because this mode is back-compatible
- * with ANSI, and it displays nice on terminals that support UTF8 by default
- * (not many terminals support UTF16 on the contrary).
+ * Use ANSI by default for file output, with no cached code page.
+ * Note that setting the stream mode to AnsiText and the code page value
+ * to CP_UTF8 sets the stream to UTF8 mode, and has the same effect as if
+ * the stream mode UTF8Text had been specified instead.
*/
-#define ConInitStdStreams() \
- ConInitStdStreamsAndMode(UTF8Text, INVALID_CP)
- /* Note that here the cache code page is unused */
-#else
-/* Use ANSI by default for file output */
#define ConInitStdStreams() \
ConInitStdStreamsAndMode(AnsiText, INVALID_CP)
-#endif /* defined(_UNICODE) */
/* Stream translation modes */
BOOL
diff --git a/sdk/lib/conutils/stream_private.h b/sdk/lib/conutils/stream_private.h
index 6b801dfb23..181cf77fc3 100644
--- a/sdk/lib/conutils/stream_private.h
+++ b/sdk/lib/conutils/stream_private.h
@@ -46,7 +46,7 @@ typedef struct _CON_STREAM
* when 'hHandle' refers to a file or a pipe.
*/
CON_STREAM_MODE Mode;
- UINT CodePage; // Used to convert UTF-16 text to some ANSI codepage.
+ UINT CodePage; // Used to convert UTF-16 text to some ANSI code page.
#endif /* defined(USE_CRT) */
} CON_STREAM, *PCON_STREAM;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b893124a20b8024a26d79…
commit b893124a20b8024a26d794a4d1867845ca3493e4
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Fri May 4 06:03:41 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Fri May 4 08:08:45 2018 +0200
[NTFS] Fix 2 Clang-Cl warnings about CurrentKey->IndexEntry->Flags
"warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]"
CORE-14306
---
drivers/filesystems/ntfs/btree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/filesystems/ntfs/btree.c b/drivers/filesystems/ntfs/btree.c
index 35a6eb6cd0..a702e25b33 100644
--- a/drivers/filesystems/ntfs/btree.c
+++ b/drivers/filesystems/ntfs/btree.c
@@ -1257,7 +1257,7 @@ UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
}
// Is the Index Entry large enough to store the VCN?
- if (!CurrentKey->IndexEntry->Flags & NTFS_INDEX_ENTRY_NODE)
+ if (!BooleanFlagOn(CurrentKey->IndexEntry->Flags, NTFS_INDEX_ENTRY_NODE))
{
// Allocate memory for the larger index entry
PINDEX_ENTRY_ATTRIBUTE NewEntry = ExAllocatePoolWithTag(NonPagedPool,
@@ -1357,7 +1357,7 @@ UpdateIndexNode(PDEVICE_EXTENSION DeviceExt,
}
// Is the Index Entry large enough to store the VCN?
- if (!CurrentKey->IndexEntry->Flags & NTFS_INDEX_ENTRY_NODE)
+ if (!BooleanFlagOn(CurrentKey->IndexEntry->Flags, NTFS_INDEX_ENTRY_NODE))
{
// Allocate memory for the larger index entry
PINDEX_ENTRY_ATTRIBUTE NewEntry = ExAllocatePoolWithTag(NonPagedPool,
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65e29b4b1f3ba0360c2fb…
commit 65e29b4b1f3ba0360c2fb30b5c3a38d1ffb784e2
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Wed May 2 23:30:10 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed May 2 23:33:45 2018 +0200
[NTOSKRNL] Optimize a bit deferred writes.
In the lazy writer run, first post items that are queued for this.
Only then, start executing deferred writes if any.
If there were any, reschedule immediately a lazy writer run, to keep
Cc warm and to make it unqueue write faster in case of high IOs situation.
To make second lazy writer run happen faster, we keep our state active to
use short delay (1s) instead of standard idle (3s).
---
ntoskrnl/cc/lazywrite.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/ntoskrnl/cc/lazywrite.c b/ntoskrnl/cc/lazywrite.c
index ddb7bc42c3..8cb5adb2e7 100644
--- a/ntoskrnl/cc/lazywrite.c
+++ b/ntoskrnl/cc/lazywrite.c
@@ -152,12 +152,6 @@ CcLazyWriteScan(VOID)
DPRINT("Lazy writer done (%d)\n", Count);
}
- /* If we have deferred writes, try them now! */
- if (!IsListEmpty(&CcDeferredWrites))
- {
- CcPostDeferredWrites();
- }
-
/* Post items that were due for end of run */
while (!IsListEmpty(&ToPost))
{
@@ -166,10 +160,22 @@ CcLazyWriteScan(VOID)
CcPostWorkQueue(WorkItem, &CcRegularWorkQueue);
}
- /* We're no longer active */
- OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
- LazyWriter.ScanActive = FALSE;
- KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
+ /* If we have deferred writes, try them now! */
+ if (!IsListEmpty(&CcDeferredWrites))
+ {
+ CcPostDeferredWrites();
+ /* Reschedule immediately a lazy writer run
+ * Keep us active to have short idle delay
+ */
+ CcScheduleLazyWriteScan(FALSE);
+ }
+ else
+ {
+ /* We're no longer active */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
+ LazyWriter.ScanActive = FALSE;
+ KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
+ }
}
VOID CcScheduleLazyWriteScan(